Skip to content

Commit 0f200d6

Browse files
authored
Merge pull request #227 from KCSesh/cherry-into-3.1.x
Prepare 3.1.2 Release in 3.1.x
2 parents 8d02857 + c903a82 commit 0f200d6

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v3.1.2 (2024-10-30)
2+
3+
## OS Changes
4+
* Add kernel-6.1 patch to fix io statistics for cgroup v1 ([#225])
5+
6+
[#225]: https://github.com/bottlerocket-os/bottlerocket-core-kit/pull/225
7+
18
# v3.1.1 (2024-10-24)
29

310
## OS Changes

Twoliter.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
schema-version = 1
2-
release-version = "3.1.1"
2+
release-version = "3.1.2"
33

44
[vendor.bottlerocket]
55
registry = "public.ecr.aws/bottlerocket"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From 4c5b35e202a3dd2c0d0bf0715c695ef3cc6d902e Mon Sep 17 00:00:00 2001
2+
From: Jinke Han <[email protected]>
3+
Date: Mon, 8 May 2023 01:06:31 +0800
4+
Subject: [PATCH] blk-throttle: Fix io statistics for cgroup v1
5+
6+
After commit f382fb0bcef4 ("block: remove legacy IO schedulers"),
7+
blkio.throttle.io_serviced and blkio.throttle.io_service_bytes become
8+
the only stable io stats interface of cgroup v1, and these statistics
9+
are done in the blk-throttle code. But the current code only counts the
10+
bios that are actually throttled. When the user does not add the throttle
11+
limit, the io stats for cgroup v1 has nothing. I fix it according to the
12+
statistical method of v2, and made it count all ios accurately.
13+
14+
Fixes: a7b36ee6ba29 ("block: move blk-throtl fast path inline")
15+
Tested-by: Andrea Righi <[email protected]>
16+
Signed-off-by: Jinke Han <[email protected]>
17+
Acked-by: Muchun Song <[email protected]>
18+
Acked-by: Tejun Heo <[email protected]>
19+
Link: https://lore.kernel.org/r/[email protected]
20+
Signed-off-by: Jens Axboe <[email protected]>
21+
[bcressey:
22+
- backport to 6.1
23+
- adjust context in blk_cgroup_bio_start
24+
- avoid changes from 3b8cc629 ("blk-cgroup: Optimize blkcg_rstat_flush()")]
25+
Signed-off-by: Ben Cressey <[email protected]>
26+
---
27+
block/blk-cgroup.c | 6 ++++--
28+
block/blk-throttle.c | 6 ------
29+
block/blk-throttle.h | 9 +++++++++
30+
3 files changed, 13 insertions(+), 8 deletions(-)
31+
32+
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
33+
index 1b7fd1fc2f33..435432c4a62e 100644
34+
--- a/block/blk-cgroup.c
35+
+++ b/block/blk-cgroup.c
36+
@@ -1969,6 +1969,9 @@ void blk_cgroup_bio_start(struct bio *bio)
37+
struct blkg_iostat_set *bis;
38+
unsigned long flags;
39+
40+
+ if (!cgroup_subsys_on_dfl(io_cgrp_subsys))
41+
+ return;
42+
+
43+
cpu = get_cpu();
44+
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
45+
flags = u64_stats_update_begin_irqsave(&bis->sync);
46+
@@ -1984,8 +1987,7 @@ void blk_cgroup_bio_start(struct bio *bio)
47+
bis->cur.ios[rwd]++;
48+
49+
u64_stats_update_end_irqrestore(&bis->sync, flags);
50+
- if (cgroup_subsys_on_dfl(io_cgrp_subsys))
51+
- cgroup_rstat_updated(bio->bi_blkg->blkcg->css.cgroup, cpu);
52+
+ cgroup_rstat_updated(bio->bi_blkg->blkcg->css.cgroup, cpu);
53+
put_cpu();
54+
}
55+
56+
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
57+
index 62a3f62316df..ab847abe30b0 100644
58+
--- a/block/blk-throttle.c
59+
+++ b/block/blk-throttle.c
60+
@@ -2176,12 +2176,6 @@ bool __blk_throtl_bio(struct bio *bio)
61+
62+
rcu_read_lock();
63+
64+
- if (!cgroup_subsys_on_dfl(io_cgrp_subsys)) {
65+
- blkg_rwstat_add(&tg->stat_bytes, bio->bi_opf,
66+
- bio->bi_iter.bi_size);
67+
- blkg_rwstat_add(&tg->stat_ios, bio->bi_opf, 1);
68+
- }
69+
-
70+
spin_lock_irq(&q->queue_lock);
71+
72+
throtl_update_latency_buckets(td);
73+
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
74+
index ef4b7a4de987..d1ccbfe9f797 100644
75+
--- a/block/blk-throttle.h
76+
+++ b/block/blk-throttle.h
77+
@@ -185,6 +185,15 @@ static inline bool blk_should_throtl(struct bio *bio)
78+
struct throtl_grp *tg = blkg_to_tg(bio->bi_blkg);
79+
int rw = bio_data_dir(bio);
80+
81+
+ if (!cgroup_subsys_on_dfl(io_cgrp_subsys)) {
82+
+ if (!bio_flagged(bio, BIO_CGROUP_ACCT)) {
83+
+ bio_set_flag(bio, BIO_CGROUP_ACCT);
84+
+ blkg_rwstat_add(&tg->stat_bytes, bio->bi_opf,
85+
+ bio->bi_iter.bi_size);
86+
+ }
87+
+ blkg_rwstat_add(&tg->stat_ios, bio->bi_opf, 1);
88+
+ }
89+
+
90+
/* iops limit is always counted */
91+
if (tg->has_rules_iops[rw])
92+
return true;
93+
--
94+
2.45.1
95+

packages/kernel-6.1/kernel-6.1.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Patch1004: 1004-af_unix-increase-default-max_dgram_qlen-to-512.patch
3636
# options for nvidia are instead included through DRM_SIMPLE
3737
Patch1005: 1005-Revert-Revert-drm-fb_helper-improve-CONFIG_FB-depend.patch
3838

39+
# Fix cgroup v1 I/O statistics in blk-throttle to count all I/Os, not just throttled ones, aligning with cgroup v2 methods.
40+
Patch1100: 1100-blk-throttle-Fix-io-statistics-for-cgroup-v1.patch
41+
3942
BuildRequires: bc
4043
BuildRequires: elfutils-devel
4144
BuildRequires: hostname

0 commit comments

Comments
 (0)