Skip to content

Commit

Permalink
block: always attach cgroup info into bio
Browse files Browse the repository at this point in the history
blkcg_bio_issue_check() already gets blkcg for a BIO.
bio_associate_blkcg() uses a percpu refcounter, so it's a very cheap
operation. There is no point we don't attach the cgroup info into bio at
blkcg_bio_issue_check. This also makes blktrace outputs correct cgroup
info.

Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Shaohua Li <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
shligit authored and axboe committed Jul 29, 2017
1 parent ca1136c commit 007cc56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 1 addition & 6 deletions block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2104,14 +2104,9 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td)
static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio)
{
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
int ret;

ret = bio_associate_current(bio);
if (ret == 0 || ret == -EBUSY)
if (bio->bi_css)
bio->bi_cg_private = tg;
blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio));
#else
bio_associate_current(bio);
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions include/linux/blk-cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
rcu_read_lock();
blkcg = bio_blkcg(bio);

/* associate blkcg if bio hasn't attached one */
bio_associate_blkcg(bio, &blkcg->css);

blkg = blkg_lookup(blkcg, q);
if (unlikely(!blkg)) {
spin_lock_irq(q->queue_lock);
Expand Down

0 comments on commit 007cc56

Please sign in to comment.