Skip to content

Commit 89ed6c9

Browse files
Xiu Jianfengaxboe
authored andcommitted
blk-cgroup: move congestion_count to struct blkcg
The congestion_count was introduced into the struct cgroup by commit d09d8df ("blkcg: add generic throttling mechanism"), but since it is closely related to the blkio subsys, it is not appropriate to put it in the struct cgroup, so let's move it to struct blkcg. There should be no functional changes because blkcg is per cgroup. Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20240716133058.3491350-1-xiujianfeng@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 72d04bd commit 89ed6c9

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

block/blk-cgroup.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,12 +2182,13 @@ void blk_cgroup_bio_start(struct bio *bio)
21822182

21832183
bool blk_cgroup_congested(void)
21842184
{
2185-
struct cgroup_subsys_state *css;
2185+
struct blkcg *blkcg;
21862186
bool ret = false;
21872187

21882188
rcu_read_lock();
2189-
for (css = blkcg_css(); css; css = css->parent) {
2190-
if (atomic_read(&css->cgroup->congestion_count)) {
2189+
for (blkcg = css_to_blkcg(blkcg_css()); blkcg;
2190+
blkcg = blkcg_parent(blkcg)) {
2191+
if (atomic_read(&blkcg->congestion_count)) {
21912192
ret = true;
21922193
break;
21932194
}

block/blk-cgroup.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ struct blkcg {
9595
struct cgroup_subsys_state css;
9696
spinlock_t lock;
9797
refcount_t online_pin;
98+
/* If there is block congestion on this cgroup. */
99+
atomic_t congestion_count;
98100

99101
struct radix_tree_root blkg_tree;
100102
struct blkcg_gq __rcu *blkg_hint;
@@ -374,7 +376,7 @@ static inline void blkcg_use_delay(struct blkcg_gq *blkg)
374376
if (WARN_ON_ONCE(atomic_read(&blkg->use_delay) < 0))
375377
return;
376378
if (atomic_add_return(1, &blkg->use_delay) == 1)
377-
atomic_inc(&blkg->blkcg->css.cgroup->congestion_count);
379+
atomic_inc(&blkg->blkcg->congestion_count);
378380
}
379381

380382
static inline int blkcg_unuse_delay(struct blkcg_gq *blkg)
@@ -399,7 +401,7 @@ static inline int blkcg_unuse_delay(struct blkcg_gq *blkg)
399401
if (old == 0)
400402
return 0;
401403
if (old == 1)
402-
atomic_dec(&blkg->blkcg->css.cgroup->congestion_count);
404+
atomic_dec(&blkg->blkcg->congestion_count);
403405
return 1;
404406
}
405407

@@ -418,7 +420,7 @@ static inline void blkcg_set_delay(struct blkcg_gq *blkg, u64 delay)
418420

419421
/* We only want 1 person setting the congestion count for this blkg. */
420422
if (!old && atomic_try_cmpxchg(&blkg->use_delay, &old, -1))
421-
atomic_inc(&blkg->blkcg->css.cgroup->congestion_count);
423+
atomic_inc(&blkg->blkcg->congestion_count);
422424

423425
atomic64_set(&blkg->delay_nsec, delay);
424426
}
@@ -435,7 +437,7 @@ static inline void blkcg_clear_delay(struct blkcg_gq *blkg)
435437

436438
/* We only want 1 person clearing the congestion count for this blkg. */
437439
if (old && atomic_try_cmpxchg(&blkg->use_delay, &old, 0))
438-
atomic_dec(&blkg->blkcg->css.cgroup->congestion_count);
440+
atomic_dec(&blkg->blkcg->congestion_count);
439441
}
440442

441443
/**

include/linux/cgroup-defs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ struct cgroup {
534534
/* used to store eBPF programs */
535535
struct cgroup_bpf bpf;
536536

537-
/* If there is block congestion on this cgroup. */
538-
atomic_t congestion_count;
539-
540537
/* Used to store internal freezer state */
541538
struct cgroup_freezer_state freezer;
542539

0 commit comments

Comments
 (0)