Message ID | 1f9bf3d57d5fe644f433844354c9af1aedb8442a.1497549993.git.shli@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 15, 2017 at 11:17:17AM -0700, Shaohua Li wrote: > From: Shaohua Li <shli@fb.com> > > 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. > > Signed-off-by: Shaohua Li <shli@fb.com> Acked-by: Tejun Heo <tj@kernel.org> Thanks.
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index a7285bf..a6ebd2b 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -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 } diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 01b62e7..fe10b85 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -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);