Message ID | 95356f4da3de009464a06c314bf79db672be6adf.1507138530.git.shli@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello, Shaohua. On Wed, Oct 04, 2017 at 10:41:19AM -0700, Shaohua Li wrote: > From: Shaohua Li <shli@fb.com> > > Currently we record block css info in bio but not in request. Normally > we can get a request's css from its bio, but in some situations, we > can't access request's bio, for example, after blk_update_request. Add > the css to request, so we can access css through the life cycle of a > request. Each request comes from cgroup specific request_list, so given a request, its blkcg membership can is accessible through request->rl->blkg->blkcg Thanks.
On Wed, Oct 04, 2017 at 10:51:49AM -0700, Tejun Heo wrote: > Hello, Shaohua. > > On Wed, Oct 04, 2017 at 10:41:19AM -0700, Shaohua Li wrote: > > From: Shaohua Li <shli@fb.com> > > > > Currently we record block css info in bio but not in request. Normally > > we can get a request's css from its bio, but in some situations, we > > can't access request's bio, for example, after blk_update_request. Add > > the css to request, so we can access css through the life cycle of a > > request. > > Each request comes from cgroup specific request_list, so given a > request, its blkcg membership can is accessible through > > request->rl->blkg->blkcg Nice. Seems only used for legacy queue though. Thanks, Shaohua
On Wed, Oct 04, 2017 at 11:02:46AM -0700, Shaohua Li wrote: > > Each request comes from cgroup specific request_list, so given a > > request, its blkcg membership can is accessible through > > > > request->rl->blkg->blkcg > > Nice. Seems only used for legacy queue though. Ah, you're right. rl isn't used for mq at all, so yeah, we probably should propagate the association through rq. Thanks.
diff --git a/block/blk-core.c b/block/blk-core.c index adb064a..07f8f7e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1551,6 +1551,11 @@ void __blk_put_request(struct request_queue *q, struct request *req) return; } +#ifdef CONFIG_BLK_CGROUP + if (req->css) + css_put(req->css); +#endif + lockdep_assert_held(q->queue_lock); blk_pm_put_request(req); @@ -3094,6 +3099,13 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq, rq->rq_flags |= RQF_QUIET; if (bio->bi_disk) rq->rq_disk = bio->bi_disk; +#ifdef CONFIG_BLK_CGROUP + rq->css = NULL; + if (bio->bi_css) { + rq->css = bio->bi_css; + css_get(rq->css); + } +#endif } #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 02fa42d..cdd3aeb 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -208,6 +208,7 @@ struct request { struct request_list *rl; /* rl this rq is alloced from */ unsigned long long start_time_ns; unsigned long long io_start_time_ns; /* when passed to hardware */ + struct cgroup_subsys_state *css; #endif /* Number of scatter-gather DMA addr+len pairs after * physical address coalescing is performed.