Message ID | 20180809145338.6160-2-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Ensure that a request queue is dissociated from the cgroup controller | expand |
Hello, On Thu, Aug 09, 2018 at 07:53:36AM -0700, Bart Van Assche wrote: > +/** > + * blkg_lookup - look up blkg for the specified request queue > + * @q: request_queue of interest > + * > + * Lookup blkg for @q at the root level. See also blkg_lookup(). > + */ > +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) > +{ > + struct blkcg_gq *blkg; > + > + rcu_read_lock(); > + blkg = blkg_lookup(&blkcg_root, q); > + rcu_read_unlock(); > + > + return blkg; > +} So, root blkg is always available as long as the request_queue is alive. Sth like the following would be simpler? static inline struct blkcg_gq *blk_queue_root_blkg(struct request_queue *q) { return q->root_blkg; }
On Thu, 2018-08-09 at 12:56 -0700, Tejun Heo wrote: > Hello, > > On Thu, Aug 09, 2018 at 07:53:36AM -0700, Bart Van Assche wrote: > > +/** > > + * blkg_lookup - look up blkg for the specified request queue > > + * @q: request_queue of interest > > + * > > + * Lookup blkg for @q at the root level. See also blkg_lookup(). > > + */ > > +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) > > +{ > > + struct blkcg_gq *blkg; > > + > > + rcu_read_lock(); > > + blkg = blkg_lookup(&blkcg_root, q); > > + rcu_read_unlock(); > > + > > + return blkg; > > +} > > So, root blkg is always available as long as the request_queue is > alive. Sth like the following would be simpler? > > static inline struct blkcg_gq *blk_queue_root_blkg(struct request_queue *q) > { > return q->root_blkg; > } That would not only be simpler, it would also avoid that blk_queue_root_blkg() returns NULL if bypass mode is enabled and the request queue is still associated with the block cgroup controller. How do you want to proceed with this change? Bart.
On 8/9/18 2:17 PM, Bart Van Assche wrote: > On Thu, 2018-08-09 at 12:56 -0700, Tejun Heo wrote: >> Hello, >> >> On Thu, Aug 09, 2018 at 07:53:36AM -0700, Bart Van Assche wrote: >>> +/** >>> + * blkg_lookup - look up blkg for the specified request queue >>> + * @q: request_queue of interest >>> + * >>> + * Lookup blkg for @q at the root level. See also blkg_lookup(). >>> + */ >>> +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) >>> +{ >>> + struct blkcg_gq *blkg; >>> + >>> + rcu_read_lock(); >>> + blkg = blkg_lookup(&blkcg_root, q); >>> + rcu_read_unlock(); >>> + >>> + return blkg; >>> +} >> >> So, root blkg is always available as long as the request_queue is >> alive. Sth like the following would be simpler? >> >> static inline struct blkcg_gq *blk_queue_root_blkg(struct request_queue *q) >> { >> return q->root_blkg; >> } > > That would not only be simpler, it would also avoid that blk_queue_root_blkg() > returns NULL if bypass mode is enabled and the request queue is still associated > with the block cgroup controller. How do you want to proceed with this change? Do a followup patch?
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index f7b910768306..1361cfc9b878 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -341,6 +341,23 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, return __blkg_lookup(blkcg, q, false); } +/** + * blkg_lookup - look up blkg for the specified request queue + * @q: request_queue of interest + * + * Lookup blkg for @q at the root level. See also blkg_lookup(). + */ +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) +{ + struct blkcg_gq *blkg; + + rcu_read_lock(); + blkg = blkg_lookup(&blkcg_root, q); + rcu_read_unlock(); + + return blkg; +} + /** * blkg_to_pdata - get policy private data * @blkg: blkg of interest @@ -864,6 +881,7 @@ static inline bool blk_cgroup_congested(void) { return false; } static inline void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay) { } static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; } +static inline struct blkcg_gq *blkg_root_lookup(struct request_queue *q) { return NULL; } static inline int blkcg_init_queue(struct request_queue *q) { return 0; } static inline void blkcg_drain_queue(struct request_queue *q) { } static inline void blkcg_exit_queue(struct request_queue *q) { }
This new function will be used in a later patch to verify whether a queue has been dissociated from the cgroup controller before being released. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Tejun Heo <tj@kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: <stable@vger.kernel.org> --- include/linux/blk-cgroup.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)