blk-cgroup cleanups
Subsystems (4)
Hi Tejun and Jens,
this series has a bunch of blk-cgroup cleanups and preparation for preparing to make blk-cgroup gendisk based. Another series for the next merge window will follow for the real changes that include refcounting updates.
Diffstat:
block/blk-cgroup.c | 186 +++++++++++++++++---------------------------- block/blk-cgroup.h | 68 ++++------------ block/blk-iocost.c | 37 ++++---- block/blk-iolatency.c | 5 - block/blk-ioprio.c | 8 - block/blk-ioprio.h | 8 - block/blk-sysfs.c | 2 block/blk-throttle.c | 13 ++- block/blk-throttle.h | 16 +-- block/blk.h | 4 block/genhd.c | 7 - include/linux/blk-cgroup.h | 5 - mm/swapfile.c | 2 13 files changed, 148 insertions(+), 213 deletions(-)
PATCH 1/17 blk-cgroup: fix error unwinding in blkcg_init_queue
When blk_throtl_init fails, we need to call blk_ioprio_exit. Switch to proper goto based unwinding to fix this.
--- block/blk-cgroup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
block/blk-cgroup.c +7 -6
@@ -1297,17 +1297,18 @@ int blkcg_init_queue(struct request_queue *q) ret =blk_throtl_init (q);if (ret) - goto err_destroy_all; + goto err_ioprio_exit; ret =blk_iolatency_init (q); -if (ret) { -blk_throtl_exit (q); -blk_ioprio_exit (q); - goto err_destroy_all; - } +if (ret) + goto err_throtl_exit;return 0 ; +err_throtl_exit: +blk_throtl_exit (q); +err_ioprio_exit: +blk_ioprio_exit (q); err_destroy_all:blkg_destroy_all (q);return ret;
Signature · 1 line
2.30.2
Re: [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue
Quoted 7 lines · Christoph Hellwig
When
blk_throtl_initfails, we need to callblk_ioprio_exit. Switch to proper goto based unwinding to fix this.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
Quoted 32 lines
block/blk-cgroup.c +7
-6@@ -1297,17 +1297,18 @@ int blkcg_init_queue(struct request_queue *q) ret =blk_throtl_init (q);if (ret) - goto err_destroy_all; + goto err_ioprio_exit; ret =blk_iolatency_init (q); -if (ret) { -blk_throtl_exit (q); -blk_ioprio_exit (q); - goto err_destroy_all; - } +if (ret) + goto err_throtl_exit;return 0 ; +err_throtl_exit: +blk_throtl_exit (q); +err_ioprio_exit: +blk_ioprio_exit (q); err_destroy_all:blkg_destroy_all (q);return ret;Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 2/17 blk-cgroup: remove blk_queue_root_blkg
In reply to Christoph HellwigJust open code it in the only caller and drop the unused !BLK_CGROUP stub.
--- block/blk-cgroup.c | 3 +-- block/blk-cgroup.h | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-)
block/blk-cgroup.c +1 -2
@@ -915,8 +915,7 @@ static void blkcg_fill_root_iostats(void)class_dev_iter_init (&iter, &block_class,NULL , &disk_type);while ((dev =class_dev_iter_next (&iter))) {struct block_device *bdev =dev_to_bdev (dev); -struct blkcg_gq *blkg = -blk_queue_root_blkg (bdev_get_queue (bdev)); +struct blkcg_gq *blkg = bdev->bd_disk->queue->root_blkg;struct blkg_iostat tmp;int cpu;unsigned long flags;
block/blk-cgroup.h +0 -13
@@ -268,17 +268,6 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,return __blkg_lookup (blkcg, q, false); } -/** -* blk_queue_root_blkg - return blkg for the (blkcg_root, @q) pair -* @q: request_queue of interest -* -* Lookup blkg for @q at the root level. See also blkg_lookup(). -*/ -static inline struct blkcg_gq *blk_queue_root_blkg (struct request_queue *q) -{ -return q->root_blkg; -} -/** * blkg_to_pdata - get policy private data * @blkg: blkg of interest
@@ -507,8 +496,6 @@ struct blkcg { };static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg,void *key) {return NULL ; } -static inline struct blkcg_gq *blk_queue_root_blkg (struct request_queue *q) -{return NULL ; }static inline int blkcg_init_queue (struct request_queue *q) {return 0 ; }static inline void blkcg_exit_queue (struct request_queue *q) { }static inline int blkcg_policy_register (struct blkcg_policy *pol) {return 0 ; }
Signature · 1 line
2.30.2
Re: [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg
Quoted 8 lines · Christoph Hellwig
Just open code it in the only caller and drop the unused !BLK_CGROUP stub.
Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 3 +-- block/blk-cgroup.h | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-)
Quoted 48 lines
block/blk-cgroup.c +1
-2@@ -915,8 +915,7 @@ static void blkcg_fill_root_iostats(void)class_dev_iter_init (&iter, &block_class,NULL , &disk_type);while ((dev =class_dev_iter_next (&iter))) {struct block_device *bdev =dev_to_bdev (dev); -struct blkcg_gq *blkg = -blk_queue_root_blkg (bdev_get_queue (bdev)); +struct blkcg_gq *blkg = bdev->bd_disk->queue->root_blkg;struct blkg_iostat tmp;int cpu;unsigned long flags;block/blk-cgroup.h +0
-13@@ -268,17 +268,6 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,return __blkg_lookup (blkcg, q, false); } -/** -* blk_queue_root_blkg - return blkg for the (blkcg_root, @q) pair -* @q: request_queue of interest -* -* Lookup blkg for @q at the root level. See also blkg_lookup(). -*/ -static inline struct blkcg_gq *blk_queue_root_blkg (struct request_queue *q) -{ -return q->root_blkg; -} -/** * blkg_to_pdata - get policy private data * @blkg: blkg of interest @@ -507,8 +496,6 @@ struct blkcg { };static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg,void *key) {return NULL ; } -static inline struct blkcg_gq *blk_queue_root_blkg (struct request_queue *q) -{return NULL ; }static inline int blkcg_init_queue (struct request_queue *q) {return 0 ; }static inline void blkcg_exit_queue (struct request_queue *q) { }static inline int blkcg_policy_register (struct blkcg_policy *pol) {return 0 ; }Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 3/17 blk-cgroup: remove open coded blkg_lookup instances
In reply to Christoph HellwigUse blkg_lookup instead of open coding it.
--- block/blk-cgroup.c | 6 +++--- block/blk-cgroup.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
block/blk-cgroup.c +3 -3
@@ -324,7 +324,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* link parent */ if (blkcg_parent (blkcg)) { - blkg->parent =__blkg_lookup (blkcg_parent (blkcg), q, false); + blkg->parent =blkg_lookup (blkcg_parent (blkcg), q);if (WARN_ON_ONCE (!blkg->parent)) { ret = -ENODEV ; goto err_put_css;
@@ -412,7 +412,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,struct blkcg_gq *ret_blkg = q->root_blkg;while (parent) { - blkg =__blkg_lookup (parent, q, false); + blkg =blkg_lookup (parent, q);if (blkg) {/* remember closest blkg */ ret_blkg = blkg;
@@ -724,7 +724,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,struct blkcg_gq *new_blkg; parent =blkcg_parent (blkcg); -while (parent && !__blkg_lookup (parent, q, false)) { +while (parent && !blkg_lookup (parent, q)) { pos = parent; parent =blkcg_parent (parent); }
block/blk-cgroup.h +4 -4
@@ -362,8 +362,8 @@ static inline void blkg_put(struct blkcg_gq *blkg)*/ #define blkg_for_each_descendant_pre (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ - if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q, false))) + if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ + (p_blkg)->q)))/** * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
@@ -377,8 +377,8 @@ static inline void blkg_put(struct blkcg_gq *blkg)*/ #define blkg_for_each_descendant_post (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ - if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q, false))) + if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ + (p_blkg)->q)))bool __blkcg_punt_bio_submit (struct bio *bio);
Signature · 1 line
2.30.2
Re: [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances
Quoted 7 lines · Christoph Hellwig
Use
blkg_lookupinstead of open coding it.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 6 +++--- block/blk-cgroup.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
Quoted 60 lines
block/blk-cgroup.c +3
-3@@ -324,7 +324,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* link parent */ if (blkcg_parent (blkcg)) { - blkg->parent =__blkg_lookup (blkcg_parent (blkcg), q, false); + blkg->parent =blkg_lookup (blkcg_parent (blkcg), q);if (WARN_ON_ONCE (!blkg->parent)) { ret = -ENODEV ; goto err_put_css;@@ -412,7 +412,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,struct blkcg_gq *ret_blkg = q->root_blkg;while (parent) { - blkg =__blkg_lookup (parent, q, false); + blkg =blkg_lookup (parent, q);if (blkg) {/* remember closest blkg */ ret_blkg = blkg;@@ -724,7 +724,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,struct blkcg_gq *new_blkg; parent =blkcg_parent (blkcg); -while (parent && !__blkg_lookup (parent, q, false)) { +while (parent && !blkg_lookup (parent, q)) { pos = parent; parent =blkcg_parent (parent); }block/blk-cgroup.h +4
-4@@ -362,8 +362,8 @@ static inline void blkg_put(struct blkcg_gq *blkg)*/ #define blkg_for_each_descendant_pre (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ - if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q, false))) + if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ + (p_blkg)->q)))/** * blkg_for_each_descendant_post - post-order walk of a blkg's descendants @@ -377,8 +377,8 @@ static inline void blkg_put(struct blkcg_gq *blkg)*/ #define blkg_for_each_descendant_post (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ - if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q, false))) + if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ + (p_blkg)->q)))bool __blkcg_punt_bio_submit (struct bio *bio);Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
Re: [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Use
blkg_lookupinstead of open coding it.Signed-off-by Christoph Hellwig <[email protected]>
For patches 1-3:
Thanks.
Signature · 1 line
tejun
PATCH 4/17 blk-cgroup: cleanup the blkg_lookup family of functions
In reply to Christoph HellwigAdd a fully inlined blkg_lookup as the extra two checks aren't going to generated a lot more code vs the call to the slowpath routine, and open code the hint update in the two callers that care.
--- block/blk-cgroup.c | 38 +++++++++++++++----------------------- block/blk-cgroup.h | 39 ++++++++++++--------------------------- 2 files changed, 27 insertions(+), 50 deletions(-)
block/blk-cgroup.c +15 -23
@@ -263,29 +263,13 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,return NULL ; } -struct blkcg_gq *blkg_lookup_slowpath (struct blkcg *blkcg, -struct request_queue *q,bool update_hint) +static void blkg_update_hint (struct blkcg *blkcg,struct blkcg_gq *blkg) { -struct blkcg_gq *blkg; - -/* -* Hint didn't match. Look up from the radix tree. Note that the -* hint can only be updated under queue_lock as otherwise @blkg -* could have already been removed from blkg_tree. The caller is -* responsible for grabbing queue_lock if @update_hint. -*/ - blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); -if (blkg && blkg->q == q) { -if (update_hint) { -lockdep_assert_held (&q->queue_lock); -rcu_assign_pointer (blkcg->blkg_hint, blkg); - } -return blkg; - } +lockdep_assert_held (&blkg->q->queue_lock); -return NULL ; +if (blkcg != &blkcg_root && blkg !=rcu_dereference (blkcg->blkg_hint)) +rcu_assign_pointer (blkcg->blkg_hint, blkg); } -EXPORT_SYMBOL_GPL (blkg_lookup_slowpath);/* * If @new_blkg is %NULL, this function tries to allocate a new one as
@@ -397,9 +381,11 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,return blkg;spin_lock_irqsave (&q->queue_lock, flags); - blkg =__blkg_lookup (blkcg, q, true); -if (blkg) + blkg =blkg_lookup (blkcg, q); +if (blkg) { +blkg_update_hint (blkcg, blkg); goto found; + }/* * Create blkgs walking down from blkcg_root to @blkcg, so that all
@@ -621,12 +607,18 @@ static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,const struct blkcg_policy *pol, struct request_queue *q) { + struct blkcg_gq *blkg; +WARN_ON_ONCE (!rcu_read_lock_held ());lockdep_assert_held (&q->queue_lock);if (!blkcg_policy_enabled (q, pol))return ERR_PTR (-EOPNOTSUPP ); -return __blkg_lookup (blkcg, q, true/* update_hint */ ); + + blkg =blkg_lookup (blkcg, q); +if (blkg) +blkg_update_hint (blkcg, blkg); +return blkg; }/**
block/blk-cgroup.h +12 -27
@@ -178,8 +178,6 @@ struct blkcg_policy {extern struct blkcg blkcg_root;extern bool blkcg_debug_stats; -struct blkcg_gq *blkg_lookup_slowpath (struct blkcg *blkcg, -struct request_queue *q,bool update_hint);int blkcg_init_queue (struct request_queue *q);void blkcg_exit_queue (struct request_queue *q);
@@ -227,22 +225,21 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio) }/** -* __blkg_lookup - internal version of blkg_lookup() +* blkg_lookup - lookup blkg for the specified blkcg - q pair * @blkcg: blkcg of interest * @q: request_queue of interest -* @update_hint: whether to update lookup hint with the result or not * -* This is internal version and shouldn't be used by policy -* implementations. Looks up blkgs for the @blkcg - @q pair regardless of -* @q's bypass state. If @update_hint is %true, the caller should be -* holding @q->queue_lock and lookup hint is updated on success. +* Lookup blkg for the @blkcg - @q pair. + +* Must be called in a RCU critical section. */ -static inline struct blkcg_gq *__blkg_lookup (struct blkcg *blkcg, -struct request_queue *q, -bool update_hint) +static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg, +struct request_queue *q) {struct blkcg_gq *blkg; +WARN_ON_ONCE (!rcu_read_lock_held ()); +if (blkcg == &blkcg_root)return q->root_blkg;
@@ -250,22 +247,10 @@ static inline struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg,if (blkg && blkg->q == q)return blkg; -return blkg_lookup_slowpath (blkcg, q, update_hint); -} - -/** -* blkg_lookup - lookup blkg for the specified blkcg - q pair -* @blkcg: blkcg of interest -* @q: request_queue of interest -* -* Lookup blkg for the @blkcg - @q pair. This function should be called -* under RCU read lock. -*/ -static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg, -struct request_queue *q) -{ -WARN_ON_ONCE (!rcu_read_lock_held ()); -return __blkg_lookup (blkcg, q, false); + blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); +if (blkg && blkg->q != q) + blkg =NULL ; +return blkg; }/**
Signature · 1 line
2.30.2
Re: [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions
Quoted 2 lines · Christoph Hellwig
Add a fully inlined
blkg_lookupas the extra two checks aren't going to generated a lot more code vs the call to the slowpath routine, and
s/generated/generate/
Quoted 7 lines
open code the hint update in the two callers that care.
Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 38 +++++++++++++++----------------------- block/blk-cgroup.h | 39 ++++++++++++--------------------------- 2 files changed, 27 insertions(+), 50 deletions(-)
Quoted 146 lines
block/blk-cgroup.c +15
-23@@ -263,29 +263,13 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,return NULL ; } -struct blkcg_gq *blkg_lookup_slowpath (struct blkcg *blkcg, -struct request_queue *q,bool update_hint) +static void blkg_update_hint (struct blkcg *blkcg,struct blkcg_gq *blkg) { -struct blkcg_gq *blkg; - -/* -* Hint didn't match. Look up from the radix tree. Note that the -* hint can only be updated under queue_lock as otherwise @blkg -* could have already been removed from blkg_tree. The caller is -* responsible for grabbing queue_lock if @update_hint. -*/ - blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); -if (blkg && blkg->q == q) { -if (update_hint) { -lockdep_assert_held (&q->queue_lock); -rcu_assign_pointer (blkcg->blkg_hint, blkg); - } -return blkg; - } +lockdep_assert_held (&blkg->q->queue_lock); -return NULL ; +if (blkcg != &blkcg_root && blkg !=rcu_dereference (blkcg->blkg_hint)) +rcu_assign_pointer (blkcg->blkg_hint, blkg); } -EXPORT_SYMBOL_GPL (blkg_lookup_slowpath);/* * If @new_blkg is %NULL, this function tries to allocate a new one as @@ -397,9 +381,11 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,return blkg;spin_lock_irqsave (&q->queue_lock, flags); - blkg =__blkg_lookup (blkcg, q, true); -if (blkg) + blkg =blkg_lookup (blkcg, q); +if (blkg) { +blkg_update_hint (blkcg, blkg); goto found; + }/* * Create blkgs walking down from blkcg_root to @blkcg, so that all @@ -621,12 +607,18 @@ static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,const struct blkcg_policy *pol, struct request_queue *q) { + struct blkcg_gq *blkg; +WARN_ON_ONCE (!rcu_read_lock_held ());lockdep_assert_held (&q->queue_lock);if (!blkcg_policy_enabled (q, pol))return ERR_PTR (-EOPNOTSUPP ); -return __blkg_lookup (blkcg, q, true/* update_hint */ ); + + blkg =blkg_lookup (blkcg, q); +if (blkg) +blkg_update_hint (blkcg, blkg); +return blkg; }/** block/blk-cgroup.h +12
-27@@ -178,8 +178,6 @@ struct blkcg_policy {extern struct blkcg blkcg_root;extern bool blkcg_debug_stats; -struct blkcg_gq *blkg_lookup_slowpath (struct blkcg *blkcg, -struct request_queue *q,bool update_hint);int blkcg_init_queue (struct request_queue *q);void blkcg_exit_queue (struct request_queue *q);@@ -227,22 +225,21 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio) }/** -* __blkg_lookup - internal version of blkg_lookup() +* blkg_lookup - lookup blkg for the specified blkcg - q pair * @blkcg: blkcg of interest * @q: request_queue of interest -* @update_hint: whether to update lookup hint with the result or not * -* This is internal version and shouldn't be used by policy -* implementations. Looks up blkgs for the @blkcg - @q pair regardless of -* @q's bypass state. If @update_hint is %true, the caller should be -* holding @q->queue_lock and lookup hint is updated on success. +* Lookup blkg for the @blkcg - @q pair. + +* Must be called in a RCU critical section. */ -static inline struct blkcg_gq *__blkg_lookup (struct blkcg *blkcg, -struct request_queue *q, -bool update_hint) +static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg, +struct request_queue *q) {struct blkcg_gq *blkg; +WARN_ON_ONCE (!rcu_read_lock_held ()); +if (blkcg == &blkcg_root)return q->root_blkg;@@ -250,22 +247,10 @@ static inline struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg,if (blkg && blkg->q == q)return blkg; -return blkg_lookup_slowpath (blkcg, q, update_hint); -} - -/** -* blkg_lookup - lookup blkg for the specified blkcg - q pair -* @blkcg: blkcg of interest -* @q: request_queue of interest -* -* Lookup blkg for the @blkcg - @q pair. This function should be called -* under RCU read lock. -*/ -static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg, -struct request_queue *q) -{ -WARN_ON_ONCE (!rcu_read_lock_held ()); -return __blkg_lookup (blkcg, q, false); + blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); +if (blkg && blkg->q != q) + blkg =NULL ; +return blkg; }/** Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
Re: [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
Add a fully inlined
blkg_lookupas the extra two checks aren't going to generated a lot more code vs the call to the slowpath routine, and open code the hint update in the two callers that care.Signed-off-by Christoph Hellwig <[email protected]>
Thanks.
Signature · 1 line
tejun
PATCH 5/17 blk-cgroup: remove blkg_lookup_check
In reply to Christoph HellwigThe combinations of an error check with an ERR_PTR return and a lookup with a NULL return leads to ugly handling of the return values in the callers. Just open coding the check and the lookup is much simpler.
--- block/blk-cgroup.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
block/blk-cgroup.c +10 -26
@@ -602,25 +602,6 @@ u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v) }EXPORT_SYMBOL_GPL (__blkg_prfill_u64); -/* Performs queue bypass and policy enabled checks then looks up blkg. */ -static struct blkcg_gq *blkg_lookup_check (struct blkcg *blkcg, -const struct blkcg_policy *pol, -struct request_queue *q) -{ -struct blkcg_gq *blkg; - -WARN_ON_ONCE (!rcu_read_lock_held ()); -lockdep_assert_held (&q->queue_lock); - -if (!blkcg_policy_enabled (q, pol)) -return ERR_PTR (-EOPNOTSUPP ); - - blkg =blkg_lookup (blkcg, q); -if (blkg) -blkg_update_hint (blkcg, blkg); -return blkg; -} -/** * blkcg_conf_open_bdev - parse and open bdev for per-blkg config update * @inputp: input string pointer
@@ -697,14 +678,16 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (blkcg, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg); +if (!blkcg_policy_enabled (q, pol)) { + ret = -EOPNOTSUPP ; goto fail_unlock; } -if (blkg) + blkg =blkg_lookup (blkcg, q); +if (blkg) { +blkg_update_hint (blkcg, blkg); goto success; + }/* * Create blkgs walking down from blkcg_root to @blkcg, so that all
@@ -740,14 +723,15 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (pos, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg); +if (!blkcg_policy_enabled (q, pol)) {blkg_free (new_blkg); + ret = -EOPNOTSUPP ; goto fail_preloaded; } + blkg =blkg_lookup (pos, q);if (blkg) { +blkg_update_hint (pos, blkg);blkg_free (new_blkg); }else { blkg =blkg_create (pos, q, new_blkg);
Signature · 1 line
2.30.2
Re: [PATCH 05/17] blk-cgroup: remove blkg_lookup_check
Quoted 8 lines · Christoph Hellwig
The combinations of an error check with an
ERR_PTRreturn and a lookup with a NULL return leads to ugly handling of the return values in the callers. Just open coding the check and the lookup is much simpler.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
Quoted 73 lines
block/blk-cgroup.c +10
-26@@ -602,25 +602,6 @@ u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v) }EXPORT_SYMBOL_GPL (__blkg_prfill_u64); -/* Performs queue bypass and policy enabled checks then looks up blkg. */ -static struct blkcg_gq *blkg_lookup_check (struct blkcg *blkcg, -const struct blkcg_policy *pol, -struct request_queue *q) -{ -struct blkcg_gq *blkg; - -WARN_ON_ONCE (!rcu_read_lock_held ()); -lockdep_assert_held (&q->queue_lock); - -if (!blkcg_policy_enabled (q, pol)) -return ERR_PTR (-EOPNOTSUPP ); - - blkg =blkg_lookup (blkcg, q); -if (blkg) -blkg_update_hint (blkcg, blkg); -return blkg; -} -/** * blkcg_conf_open_bdev - parse and open bdev for per-blkg config update * @inputp: input string pointer @@ -697,14 +678,16 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (blkcg, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg); +if (!blkcg_policy_enabled (q, pol)) { + ret = -EOPNOTSUPP ; goto fail_unlock; } -if (blkg) + blkg =blkg_lookup (blkcg, q); +if (blkg) { +blkg_update_hint (blkcg, blkg); goto success; + }/* * Create blkgs walking down from blkcg_root to @blkcg, so that all @@ -740,14 +723,15 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (pos, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg); +if (!blkcg_policy_enabled (q, pol)) {blkg_free (new_blkg); + ret = -EOPNOTSUPP ; goto fail_preloaded; } + blkg =blkg_lookup (pos, q);if (blkg) { +blkg_update_hint (pos, blkg);blkg_free (new_blkg); }else { blkg =blkg_create (pos, q, new_blkg);Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
Re: [PATCH 05/17] blk-cgroup: remove blkg_lookup_check
In reply to Christoph HellwigHello,
Quoted 5 lines · Christoph Hellwig
The combinations of an error check with an
ERR_PTRreturn and a lookup with a NULL return leads to ugly handling of the return values in the callers. Just open coding the check and the lookup is much simpler.Signed-off-by Christoph Hellwig <[email protected]>
but please look below.
Quoted 31 lines
/**
*blkcg_conf_open_bdev- parse and open bdev for per-blkg config update
* @inputp: input string pointerblock/blk-cgroup.c +6
-7@@ -697,14 +678,16 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (blkcg, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg); +if (!blkcg_policy_enabled (q, pol)) { + ret = -EOPNOTSUPP ; goto fail_unlock; } -if (blkg) + blkg =blkg_lookup (blkcg, q); +if (blkg) { +blkg_update_hint (blkcg, blkg); goto success; + }/* * Create blkgs walking down from blkcg_root to @blkcg, so that all @@ -740,14 +723,15 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,rcu_read_lock ();spin_lock_irq (&q->queue_lock); - blkg =blkg_lookup_check (pos, pol, q); -if (IS_ERR (blkg)) { - ret =PTR_ERR (blkg);
block/blk-cgroup.c int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, · line 735
Quoted 10 lines
block/blk-cgroup.c +4
-0+if (!blkcg_policy_enabled (q, pol)) {blkg_free (new_blkg); + ret = -EOPNOTSUPP ; goto fail_preloaded; } + blkg =blkg_lookup (pos, q);if (blkg) { +blkg_update_hint (pos, blkg);blkg_free (new_blkg);
I don't think conf_prep needs to update the hint in the first place, so we can just do blkg_lookup()'s and drop the blkg_update_hint() calls.
Thanks.
Signature · 1 line
tejun
PATCH 6/17 blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue
In reply to Christoph HellwigPass the gendisk to blkcg_init_disk and blkcg_exit_disk as part of moving the blk-cgroup infrastructure to be gendisk based. Also remove the rather pointless kerneldoc comments for these internal functions with a single caller each.
--- block/blk-cgroup.c | 25 +++++-------------------- block/blk-cgroup.h | 8 ++++---- block/genhd.c | 5 +++-- 3 files changed, 12 insertions(+), 26 deletions(-)
block/blk-cgroup.c +5 -20
@@ -1230,18 +1230,9 @@ static int blkcg_css_online(struct cgroup_subsys_state *css)return 0 ; } -/** -* blkcg_init_queue - initialize blkcg part of request queue -* @q: request_queue to initialize -* -* Called from blk_alloc_queue(). Responsible for initializing blkcg -* part of new request_queue @q. -* -* RETURNS: -* 0 on success, -errno on failure. -*/ -int blkcg_init_queue (struct request_queue *q) +int blkcg_init_disk (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *new_blkg, *blkg;bool preloaded;int ret;
@@ -1294,16 +1285,10 @@ int blkcg_init_queue(struct request_queue *q)return PTR_ERR (blkg); } -/** -* blkcg_exit_queue - exit and release blkcg part of request_queue -* @q: request_queue being released -* -* Called from blk_exit_queue(). Responsible for exiting blkcg part. -*/ -void blkcg_exit_queue (struct request_queue *q) +void blkcg_exit_disk (struct gendisk *disk) { -blkg_destroy_all (q); -blk_throtl_exit (q); +blkg_destroy_all (disk->queue); +blk_throtl_exit (disk->queue); }static void blkcg_bind (struct cgroup_subsys_state *root_css)
block/blk-cgroup.h +4 -4
@@ -178,8 +178,8 @@ struct blkcg_policy {extern struct blkcg blkcg_root;extern bool blkcg_debug_stats; -int blkcg_init_queue (struct request_queue *q); -void blkcg_exit_queue (struct request_queue *q); +int blkcg_init_disk (struct gendisk *disk); +void blkcg_exit_disk (struct gendisk *disk);/* Blkio controller policy registration */ int blkcg_policy_register (struct blkcg_policy *pol);
@@ -481,8 +481,8 @@ struct blkcg { };static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg,void *key) {return NULL ; } -static inline int blkcg_init_queue (struct request_queue *q) {return 0 ; } -static inline void blkcg_exit_queue (struct request_queue *q) { } +static inline int blkcg_init_disk (struct gendisk *disk) {return 0 ; } +static inline void blkcg_exit_disk (struct gendisk *disk) { }static inline int blkcg_policy_register (struct blkcg_policy *pol) {return 0 ; }static inline void blkcg_policy_unregister (struct blkcg_policy *pol) { } static inline int blkcg_activate_policy(struct request_queue *q,
block/genhd.c +3 -2
@@ -1150,7 +1150,8 @@ static void disk_release(struct device *dev) !test_bit(GD_ADDED, &disk->state))blk_mq_exit_queue (disk->queue); -blkcg_exit_queue (disk->queue); +blkcg_exit_disk (disk); +bioset_exit (&disk->bio_split);disk_release_events (disk);
@@ -1363,7 +1364,7 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,if (xa_insert (&disk->part_tbl,0 , disk->part0,GFP_KERNEL )) goto out_destroy_part_tbl; -if (blkcg_init_queue (q)) +if (blkcg_init_disk (disk)) goto out_erase_part0;rand_initialize_disk (disk);
Signature · 1 line
2.30.2
Re: [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue
Quoted 11 lines · Christoph Hellwig
Pass the gendisk to
blkcg_init_diskandblkcg_exit_diskas part of moving the blk-cgroup infrastructure to be gendisk based. Also remove the rather pointless kerneldoc comments for these internal functions with a single caller each.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 25 +++++-------------------- block/blk-cgroup.h | 8 ++++---- block/genhd.c | 5 +++-- 3 files changed, 12 insertions(+), 26 deletions(-)
This creates a stale reference to blkcg_exit_queue() in comment of block/blk-core.c which needs to be adapted, I think:
block/blk-core.c +1 -1
@@ -223,7 +223,7 @@ const char *blk_status_to_str(blk_status_t status)* * This function does not cancel any asynchronous activity arising * out of elevator or throttling code. That would require elevator_exit() -* and blkcg_exit_queue() to be called with queue lock initialized. +* and blkcg_exit_disk() to be called with queue lock initialized. * */ void blk_sync_queue (struct request_queue *q)
--
Otherwise
Quoted 97 lines
block/blk-cgroup.c +5
-20@@ -1230,18 +1230,9 @@ static int blkcg_css_online(struct cgroup_subsys_state *css)return 0 ; } -/** -* blkcg_init_queue - initialize blkcg part of request queue -* @q: request_queue to initialize -* -* Called from blk_alloc_queue(). Responsible for initializing blkcg -* part of new request_queue @q. -* -* RETURNS: -* 0 on success, -errno on failure. -*/ -int blkcg_init_queue (struct request_queue *q) +int blkcg_init_disk (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *new_blkg, *blkg;bool preloaded;int ret;@@ -1294,16 +1285,10 @@ int blkcg_init_queue(struct request_queue *q)return PTR_ERR (blkg); } -/** -* blkcg_exit_queue - exit and release blkcg part of request_queue -* @q: request_queue being released -* -* Called from blk_exit_queue(). Responsible for exiting blkcg part. -*/ -void blkcg_exit_queue (struct request_queue *q) +void blkcg_exit_disk (struct gendisk *disk) { -blkg_destroy_all (q); -blk_throtl_exit (q); +blkg_destroy_all (disk->queue); +blk_throtl_exit (disk->queue); }static void blkcg_bind (struct cgroup_subsys_state *root_css)block/blk-cgroup.h +4
-4@@ -178,8 +178,8 @@ struct blkcg_policy {extern struct blkcg blkcg_root;extern bool blkcg_debug_stats; -int blkcg_init_queue (struct request_queue *q); -void blkcg_exit_queue (struct request_queue *q); +int blkcg_init_disk (struct gendisk *disk); +void blkcg_exit_disk (struct gendisk *disk);/* Blkio controller policy registration */ int blkcg_policy_register (struct blkcg_policy *pol);@@ -481,8 +481,8 @@ struct blkcg { };static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg,void *key) {return NULL ; } -static inline int blkcg_init_queue (struct request_queue *q) {return 0 ; } -static inline void blkcg_exit_queue (struct request_queue *q) { } +static inline int blkcg_init_disk (struct gendisk *disk) {return 0 ; } +static inline void blkcg_exit_disk (struct gendisk *disk) { }static inline int blkcg_policy_register (struct blkcg_policy *pol) {return 0 ; }static inline void blkcg_policy_unregister (struct blkcg_policy *pol) { } static inline int blkcg_activate_policy(struct request_queue *q,block/genhd.c +3
-2@@ -1150,7 +1150,8 @@ static void disk_release(struct device *dev) !test_bit(GD_ADDED, &disk->state))blk_mq_exit_queue (disk->queue); -blkcg_exit_queue (disk->queue); +blkcg_exit_disk (disk); +bioset_exit (&disk->bio_split);disk_release_events (disk);@@ -1363,7 +1364,7 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,if (xa_insert (&disk->part_tbl,0 , disk->part0,GFP_KERNEL )) goto out_destroy_part_tbl; -if (blkcg_init_queue (q)) +if (blkcg_init_disk (disk)) goto out_erase_part0;rand_initialize_disk (disk);Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 7/17 blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit
In reply to Christoph HellwigPass the gendisk to blk_ioprio_init and blk_ioprio_exit as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-cgroup.c | 4 ++-- block/blk-ioprio.c | 8 ++++---- block/blk-ioprio.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-)
block/blk-cgroup.c +2 -2
@@ -1257,7 +1257,7 @@ int blkcg_init_disk(struct gendisk *disk)if (preloaded)radix_tree_preload_end (); - ret =blk_ioprio_init (q); + ret =blk_ioprio_init (disk);if (ret) goto err_destroy_all;
@@ -1274,7 +1274,7 @@ int blkcg_init_disk(struct gendisk *disk) err_throtl_exit:blk_throtl_exit (q); err_ioprio_exit: -blk_ioprio_exit (q); +blk_ioprio_exit (disk); err_destroy_all:blkg_destroy_all (q);return ret;
block/blk-ioprio.c +4 -4
@@ -202,14 +202,14 @@ void blkcg_set_ioprio(struct bio *bio) bio->bi_ioprio = prio; } -void blk_ioprio_exit (struct request_queue *q) +void blk_ioprio_exit (struct gendisk *disk) { -blkcg_deactivate_policy (q, &ioprio_policy); +blkcg_deactivate_policy (disk->queue, &ioprio_policy); } -int blk_ioprio_init (struct request_queue *q) +int blk_ioprio_init (struct gendisk *disk) { -return blkcg_activate_policy (q, &ioprio_policy); +return blkcg_activate_policy (disk->queue, &ioprio_policy); }static int __init ioprio_init (void )
block/blk-ioprio.h +4 -4
@@ -9,15 +9,15 @@ struct request_queue;struct bio ;#ifdef CONFIG_BLK_CGROUP_IOPRIO -int blk_ioprio_init (struct request_queue *q); -void blk_ioprio_exit (struct request_queue *q); +int blk_ioprio_init (struct gendisk *disk); +void blk_ioprio_exit (struct gendisk *disk);void blkcg_set_ioprio (struct bio *bio);#else -static inline int blk_ioprio_init (struct request_queue *q) +static inline int blk_ioprio_init (struct gendisk *disk) {return 0 ; } -static inline void blk_ioprio_exit (struct request_queue *q) +static inline void blk_ioprio_exit (struct gendisk *disk) { }static inline void blkcg_set_ioprio (struct bio *bio)
Signature · 1 line
2.30.2
Re: [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit
Quoted 9 lines · Christoph Hellwig
Pass the gendisk to
blk_ioprio_initandblk_ioprio_exitas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 4 ++-- block/blk-ioprio.c | 8 ++++---- block/blk-ioprio.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-)
Quoted 72 lines
block/blk-cgroup.c +2
-2@@ -1257,7 +1257,7 @@ int blkcg_init_disk(struct gendisk *disk)if (preloaded)radix_tree_preload_end (); - ret =blk_ioprio_init (q); + ret =blk_ioprio_init (disk);if (ret) goto err_destroy_all;@@ -1274,7 +1274,7 @@ int blkcg_init_disk(struct gendisk *disk) err_throtl_exit:blk_throtl_exit (q); err_ioprio_exit: -blk_ioprio_exit (q); +blk_ioprio_exit (disk); err_destroy_all:blkg_destroy_all (q);return ret;block/blk-ioprio.c +4
-4@@ -202,14 +202,14 @@ void blkcg_set_ioprio(struct bio *bio) bio->bi_ioprio = prio; } -void blk_ioprio_exit (struct request_queue *q) +void blk_ioprio_exit (struct gendisk *disk) { -blkcg_deactivate_policy (q, &ioprio_policy); +blkcg_deactivate_policy (disk->queue, &ioprio_policy); } -int blk_ioprio_init (struct request_queue *q) +int blk_ioprio_init (struct gendisk *disk) { -return blkcg_activate_policy (q, &ioprio_policy); +return blkcg_activate_policy (disk->queue, &ioprio_policy); }static int __init ioprio_init (void )block/blk-ioprio.h +4
-4@@ -9,15 +9,15 @@ struct request_queue;struct bio ;#ifdef CONFIG_BLK_CGROUP_IOPRIO -int blk_ioprio_init (struct request_queue *q); -void blk_ioprio_exit (struct request_queue *q); +int blk_ioprio_init (struct gendisk *disk); +void blk_ioprio_exit (struct gendisk *disk);void blkcg_set_ioprio (struct bio *bio);#else -static inline int blk_ioprio_init (struct request_queue *q) +static inline int blk_ioprio_init (struct gendisk *disk) {return 0 ; } -static inline void blk_ioprio_exit (struct request_queue *q) +static inline void blk_ioprio_exit (struct gendisk *disk) { }static inline void blkcg_set_ioprio (struct bio *bio)Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 8/17 blk-iolatency: pass a gendisk to blk_iolatency_init
In reply to Christoph HellwigPass the gendisk to blk_iolatency_init as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-cgroup.c | 2 +- block/blk-iolatency.c | 3 ++- block/blk.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
block/blk-cgroup.c +1 -1
@@ -1265,7 +1265,7 @@ int blkcg_init_disk(struct gendisk *disk)if (ret) goto err_ioprio_exit; - ret =blk_iolatency_init (q); + ret =blk_iolatency_init (disk);if (ret) goto err_throtl_exit;
block/blk-iolatency.c +2 -1
@@ -756,8 +756,9 @@ static void blkiolatency_enable_work_fn(struct work_struct *work) } } -int blk_iolatency_init (struct request_queue *q) +int blk_iolatency_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blk_iolatency *blkiolat;struct rq_qos *rqos;int ret;
block/blk.h +2 -2
@@ -389,9 +389,9 @@ static inline struct bio *blk_queue_bounce(struct bio *bio, }#ifdef CONFIG_BLK_CGROUP_IOLATENCY -extern int blk_iolatency_init (struct request_queue *q); +int blk_iolatency_init (struct gendisk *disk);#else -static inline int blk_iolatency_init (struct request_queue *q) {return 0 ; } +static int blk_iolatency_init(struct gendisk *disk) { return 0 };#endif #ifdef CONFIG_BLK_DEV_ZONED
Signature · 1 line
2.30.2
Re: [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
Quoted 9 lines · Christoph Hellwig
Pass the gendisk to
blk_iolatency_initas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 2 +- block/blk-iolatency.c | 3 ++- block/blk.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
Quoted 47 lines
block/blk-cgroup.c +1
-1@@ -1265,7 +1265,7 @@ int blkcg_init_disk(struct gendisk *disk)if (ret) goto err_ioprio_exit; - ret =blk_iolatency_init (q); + ret =blk_iolatency_init (disk);if (ret) goto err_throtl_exit;block/blk-iolatency.c +2
-1@@ -756,8 +756,9 @@ static void blkiolatency_enable_work_fn(struct work_struct *work) } } -int blk_iolatency_init (struct request_queue *q) +int blk_iolatency_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blk_iolatency *blkiolat;struct rq_qos *rqos;int ret;block/blk.h +2
-2@@ -389,9 +389,9 @@ static inline struct bio *blk_queue_bounce(struct bio *bio, }#ifdef CONFIG_BLK_CGROUP_IOLATENCY -extern int blk_iolatency_init (struct request_queue *q); +int blk_iolatency_init (struct gendisk *disk);#else -static inline int blk_iolatency_init (struct request_queue *q) {return 0 ; } +static int blk_iolatency_init(struct gendisk *disk) { return 0 };#endif #ifdef CONFIG_BLK_DEV_ZONED Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
Jens Axboe
maintainerRe: [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
In reply to Christoph HellwigQuoted 5 lines
block/blk.h +0
-0
block/blk.h static inline struct bio *blk_queue_bounce(struct bio *bio, · line 395
Quoted 9 lines
block/blk.h +2
-2@@ -389,9 +389,9 @@ static inline struct bio *blk_queue_bounce(struct bio *bio, }#ifdef CONFIG_BLK_CGROUP_IOLATENCY -extern int blk_iolatency_init (struct request_queue *q); +int blk_iolatency_init (struct gendisk *disk);#else -static inline int blk_iolatency_init (struct request_queue *q) {return 0 ; } +static int blk_iolatency_init(struct gendisk *disk) { return 0 };#endif
This is missing both an 'inline' and a semicolon... I fixed it up while applying.
Signature · 1 line
Jens Axboe
PATCH 9/17 blk-iocost: simplify ioc_name
In reply to Christoph HellwigJust directly dereference the disk name instead of going through multiple hoops to find the same value.
--- block/blk-iocost.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
block/blk-iocost.c +5 -9
@@ -664,17 +664,13 @@ static struct ioc *q_to_ioc(struct request_queue *q)return rqos_to_ioc (rq_qos_id (q,RQ_QOS_COST )); } -static const char *q_name (struct request_queue *q) -{ -if (blk_queue_registered (q)) -return kobject_name (q->kobj.parent); -else -return "<unknown>" ; -} -static const char __maybe_unused *ioc_name (struct ioc *ioc) { -return q_name (ioc->rqos.q); +struct gendisk *disk = ioc->rqos.q->disk; + +if (!disk) +return "<unknown>" ; +return disk->disk_name; }static struct ioc_gq *pd_to_iocg (struct blkg_policy_data *pd)
Signature · 1 line
2.30.2
Re: [PATCH 09/17] blk-iocost: simplify ioc_name
Quoted 7 lines · Christoph Hellwig
Just directly dereference the disk name instead of going through multiple hoops to find the same value.
Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-iocost.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
Quoted 30 lines
block/blk-iocost.c +5
-9@@ -664,17 +664,13 @@ static struct ioc *q_to_ioc(struct request_queue *q)return rqos_to_ioc (rq_qos_id (q,RQ_QOS_COST )); } -static const char *q_name (struct request_queue *q) -{ -if (blk_queue_registered (q)) -return kobject_name (q->kobj.parent); -else -return "<unknown>" ; -} -static const char __maybe_unused *ioc_name (struct ioc *ioc) { -return q_name (ioc->rqos.q); +struct gendisk *disk = ioc->rqos.q->disk; + +if (!disk) +return "<unknown>" ; +return disk->disk_name; }static struct ioc_gq *pd_to_iocg (struct blkg_policy_data *pd)Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 10/17 blk-iocost: pass a gendisk to blk_iocost_init
In reply to Christoph HellwigPass the gendisk to blk_iocost_init as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-iocost.c | 7 ++++--- block/blk.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
block/blk-iocost.c +4 -3
@@ -2828,8 +2828,9 @@ static struct rq_qos_ops ioc_rqos_ops = { .exit = ioc_rqos_exit, }; -static int blk_iocost_init (struct request_queue *q) +static int blk_iocost_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct ioc *ioc;struct rq_qos *rqos;int i, cpu, ret;
@@ -3178,7 +3179,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, ioc =q_to_ioc (bdev_get_queue (bdev));if (!ioc) { - ret =blk_iocost_init (bdev_get_queue (bdev)); + ret =blk_iocost_init (bdev->bd_disk);if (ret) goto err; ioc =q_to_ioc (bdev_get_queue (bdev));
@@ -3345,7 +3346,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, ioc =q_to_ioc (bdev_get_queue (bdev));if (!ioc) { - ret =blk_iocost_init (bdev_get_queue (bdev)); + ret =blk_iocost_init (bdev->bd_disk);if (ret) goto err; ioc =q_to_ioc (bdev_get_queue (bdev));
block/blk.h +1 -1
@@ -391,7 +391,7 @@ static inline struct bio *blk_queue_bounce(struct bio *bio,#ifdef CONFIG_BLK_CGROUP_IOLATENCY int blk_iolatency_init (struct gendisk *disk);#else -static int blk_iolatency_init(struct gendisk *disk) { return 0 }; +static int blk_iolatency_init (struct gendisk *disk) {return 0 ; }#endif #ifdef CONFIG_BLK_DEV_ZONED
Signature · 1 line
2.30.2
Re: [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init
Quoted 8 lines · Christoph Hellwig
Pass the gendisk to
blk_iocost_initas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-iocost.c | 7 ++++--- block/blk.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
Quoted 49 lines
block/blk-iocost.c +4
-3@@ -2828,8 +2828,9 @@ static struct rq_qos_ops ioc_rqos_ops = { .exit = ioc_rqos_exit, }; -static int blk_iocost_init (struct request_queue *q) +static int blk_iocost_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct ioc *ioc;struct rq_qos *rqos;int i, cpu, ret;@@ -3178,7 +3179,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, ioc =q_to_ioc (bdev_get_queue (bdev));if (!ioc) { - ret =blk_iocost_init (bdev_get_queue (bdev)); + ret =blk_iocost_init (bdev->bd_disk);if (ret) goto err; ioc =q_to_ioc (bdev_get_queue (bdev));@@ -3345,7 +3346,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, ioc =q_to_ioc (bdev_get_queue (bdev));if (!ioc) { - ret =blk_iocost_init (bdev_get_queue (bdev)); + ret =blk_iocost_init (bdev->bd_disk);if (ret) goto err; ioc =q_to_ioc (bdev_get_queue (bdev));block/blk.h +1
-1@@ -391,7 +391,7 @@ static inline struct bio *blk_queue_bounce(struct bio *bio,#ifdef CONFIG_BLK_CGROUP_IOLATENCY int blk_iolatency_init (struct gendisk *disk);#else -static int blk_iolatency_init(struct gendisk *disk) { return 0 }; +static int blk_iolatency_init (struct gendisk *disk) {return 0 ; }#endif #ifdef CONFIG_BLK_DEV_ZONED Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 11/17 blk-iocost: cleanup ioc_qos_write
In reply to Christoph HellwigUse a local disk variable instead of retrieving the disk and request_queue over and over by various means.
--- block/blk-iocost.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
block/blk-iocost.c +8 -6
@@ -3167,6 +3167,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, size_t nbytes, loff_t off) {struct block_device *bdev; +struct gendisk *disk;struct ioc *ioc;u32 qos[NR_QOS_PARAMS ];bool enable, user;
@@ -3177,12 +3178,13 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,if (IS_ERR (bdev))return PTR_ERR (bdev); - ioc =q_to_ioc (bdev_get_queue (bdev)); + disk = bdev->bd_disk; + ioc =q_to_ioc (disk->queue);if (!ioc) { - ret =blk_iocost_init (bdev->bd_disk); + ret =blk_iocost_init (disk);if (ret) goto err; - ioc =q_to_ioc (bdev_get_queue (bdev)); + ioc =q_to_ioc (disk->queue); }spin_lock_irq (&ioc->lock);
@@ -3259,11 +3261,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,spin_lock_irq (&ioc->lock);if (enable) { -blk_stat_enable_accounting (ioc->rqos.q); -blk_queue_flag_set (QUEUE_FLAG_RQ_ALLOC_TIME , ioc->rqos.q); +blk_stat_enable_accounting (disk->queue); +blk_queue_flag_set (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = true; }else { -blk_queue_flag_clear (QUEUE_FLAG_RQ_ALLOC_TIME , ioc->rqos.q); +blk_queue_flag_clear (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = false; }
Signature · 1 line
2.30.2
Re: [PATCH 11/17] blk-iocost: cleanup ioc_qos_write
Quoted 7 lines · Christoph Hellwig
Use a local disk variable instead of retrieving the disk and
request_queueover and over by various means.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-iocost.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
Quoted 47 lines
block/blk-iocost.c +8
-6@@ -3167,6 +3167,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, size_t nbytes, loff_t off) {struct block_device *bdev; +struct gendisk *disk;struct ioc *ioc;u32 qos[NR_QOS_PARAMS ];bool enable, user;@@ -3177,12 +3178,13 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,if (IS_ERR (bdev))return PTR_ERR (bdev); - ioc =q_to_ioc (bdev_get_queue (bdev)); + disk = bdev->bd_disk; + ioc =q_to_ioc (disk->queue);if (!ioc) { - ret =blk_iocost_init (bdev->bd_disk); + ret =blk_iocost_init (disk);if (ret) goto err; - ioc =q_to_ioc (bdev_get_queue (bdev)); + ioc =q_to_ioc (disk->queue); }spin_lock_irq (&ioc->lock);@@ -3259,11 +3261,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,spin_lock_irq (&ioc->lock);if (enable) { -blk_stat_enable_accounting (ioc->rqos.q); -blk_queue_flag_set (QUEUE_FLAG_RQ_ALLOC_TIME , ioc->rqos.q); +blk_stat_enable_accounting (disk->queue); +blk_queue_flag_set (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = true; }else { -blk_queue_flag_clear (QUEUE_FLAG_RQ_ALLOC_TIME , ioc->rqos.q); +blk_queue_flag_clear (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = false; }Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 12/17 blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit
In reply to Christoph HellwigPass the gendisk to blk_throtl_init and blk_throtl_exit as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-cgroup.c | 6 +++--- block/blk-throttle.c | 7 +++++-- block/blk-throttle.h | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-)
block/blk-cgroup.c +3 -3
@@ -1261,7 +1261,7 @@ int blkcg_init_disk(struct gendisk *disk)if (ret) goto err_destroy_all; - ret =blk_throtl_init (q); + ret =blk_throtl_init (disk);if (ret) goto err_ioprio_exit;
@@ -1272,7 +1272,7 @@ int blkcg_init_disk(struct gendisk *disk)return 0 ; err_throtl_exit: -blk_throtl_exit (q); +blk_throtl_exit (disk); err_ioprio_exit:blk_ioprio_exit (disk); err_destroy_all:
@@ -1288,7 +1288,7 @@ int blkcg_init_disk(struct gendisk *disk)void blkcg_exit_disk (struct gendisk *disk) {blkg_destroy_all (disk->queue); -blk_throtl_exit (disk->queue); +blk_throtl_exit (disk); }static void blkcg_bind (struct cgroup_subsys_state *root_css)
block/blk-throttle.c +5 -2
@@ -2358,8 +2358,9 @@ void blk_throtl_bio_endio(struct bio *bio) }#endif -int blk_throtl_init (struct request_queue *q) +int blk_throtl_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct throtl_data *td;int ret;
@@ -2401,8 +2402,10 @@ int blk_throtl_init(struct request_queue *q)return ret; } -void blk_throtl_exit (struct request_queue *q) +void blk_throtl_exit (struct gendisk *disk) { +struct request_queue *q = disk->queue; +BUG_ON (!q->td);del_timer_sync (&q->td->service_queue.pending_timer);throtl_shutdown_wq (q);
block/blk-throttle.h +4 -4
@@ -168,14 +168,14 @@ static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)* Internal throttling interface */ #ifndef CONFIG_BLK_DEV_THROTTLING -static inline int blk_throtl_init (struct request_queue *q) {return 0 ; } -static inline void blk_throtl_exit (struct request_queue *q) { } +static inline int blk_throtl_init (struct gendisk *disk) {return 0 ; } +static inline void blk_throtl_exit (struct gendisk *disk) { }static inline void blk_throtl_register_queue (struct request_queue *q) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; }static inline void blk_throtl_cancel_bios (struct request_queue *q) { }#else /* CONFIG_BLK_DEV_THROTTLING */ -int blk_throtl_init (struct request_queue *q); -void blk_throtl_exit (struct request_queue *q); +int blk_throtl_init (struct gendisk *disk); +void blk_throtl_exit (struct gendisk *disk);void blk_throtl_register_queue (struct request_queue *q);bool __blk_throtl_bio (struct bio *bio);void blk_throtl_cancel_bios (struct request_queue *q);
Signature · 1 line
2.30.2
Re: [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit
Quoted 9 lines · Christoph Hellwig
Pass the gendisk to
blk_throtl_initandblk_throtl_exitas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 6 +++--- block/blk-throttle.c | 7 +++++-- block/blk-throttle.h | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-)
Quoted 84 lines
block/blk-cgroup.c +3
-3@@ -1261,7 +1261,7 @@ int blkcg_init_disk(struct gendisk *disk)if (ret) goto err_destroy_all; - ret =blk_throtl_init (q); + ret =blk_throtl_init (disk);if (ret) goto err_ioprio_exit;@@ -1272,7 +1272,7 @@ int blkcg_init_disk(struct gendisk *disk)return 0 ; err_throtl_exit: -blk_throtl_exit (q); +blk_throtl_exit (disk); err_ioprio_exit:blk_ioprio_exit (disk); err_destroy_all:@@ -1288,7 +1288,7 @@ int blkcg_init_disk(struct gendisk *disk)void blkcg_exit_disk (struct gendisk *disk) {blkg_destroy_all (disk->queue); -blk_throtl_exit (disk->queue); +blk_throtl_exit (disk); }static void blkcg_bind (struct cgroup_subsys_state *root_css)block/blk-throttle.c +5
-2@@ -2358,8 +2358,9 @@ void blk_throtl_bio_endio(struct bio *bio) }#endif -int blk_throtl_init (struct request_queue *q) +int blk_throtl_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct throtl_data *td;int ret;@@ -2401,8 +2402,10 @@ int blk_throtl_init(struct request_queue *q)return ret; } -void blk_throtl_exit (struct request_queue *q) +void blk_throtl_exit (struct gendisk *disk) { +struct request_queue *q = disk->queue; +BUG_ON (!q->td);del_timer_sync (&q->td->service_queue.pending_timer);throtl_shutdown_wq (q);block/blk-throttle.h +4
-4@@ -168,14 +168,14 @@ static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)* Internal throttling interface */ #ifndef CONFIG_BLK_DEV_THROTTLING -static inline int blk_throtl_init (struct request_queue *q) {return 0 ; } -static inline void blk_throtl_exit (struct request_queue *q) { } +static inline int blk_throtl_init (struct gendisk *disk) {return 0 ; } +static inline void blk_throtl_exit (struct gendisk *disk) { }static inline void blk_throtl_register_queue (struct request_queue *q) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; }static inline void blk_throtl_cancel_bios (struct request_queue *q) { }#else /* CONFIG_BLK_DEV_THROTTLING */ -int blk_throtl_init (struct request_queue *q); -void blk_throtl_exit (struct request_queue *q); +int blk_throtl_init (struct gendisk *disk); +void blk_throtl_exit (struct gendisk *disk);void blk_throtl_register_queue (struct request_queue *q);bool __blk_throtl_bio (struct bio *bio);void blk_throtl_cancel_bios (struct request_queue *q);Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 13/17 blk-throttle: pass a gendisk to blk_throtl_register_queue
In reply to Christoph HellwigPass the gendisk to blk_throtl_register_queue as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-sysfs.c | 2 +- block/blk-throttle.c | 3 ++- block/blk-throttle.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
block/blk-sysfs.c +1 -1
@@ -844,7 +844,7 @@ int blk_register_queue(struct gendisk *disk)blk_queue_flag_set (QUEUE_FLAG_REGISTERED , q);wbt_enable_default (q); -blk_throtl_register_queue (q); +blk_throtl_register (disk);/* Now everything is ready and send out KOBJ_ADD uevent */ kobject_uevent (&q->kobj,KOBJ_ADD );
block/blk-throttle.c +2 -1
@@ -2415,8 +2415,9 @@ void blk_throtl_exit(struct gendisk *disk)kfree (q->td); } -void blk_throtl_register_queue (struct request_queue *q) +void blk_throtl_register (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct throtl_data *td;int i;
block/blk-throttle.h +2 -2
@@ -170,13 +170,13 @@ static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)#ifndef CONFIG_BLK_DEV_THROTTLING static inline int blk_throtl_init (struct gendisk *disk) {return 0 ; }static inline void blk_throtl_exit (struct gendisk *disk) { } -static inline void blk_throtl_register_queue (struct request_queue *q) { } +static inline void blk_throtl_register (struct gendisk *disk) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; }static inline void blk_throtl_cancel_bios (struct request_queue *q) { }#else /* CONFIG_BLK_DEV_THROTTLING */ int blk_throtl_init (struct gendisk *disk);void blk_throtl_exit (struct gendisk *disk); -void blk_throtl_register_queue (struct request_queue *q); +void blk_throtl_register (struct gendisk *disk);bool __blk_throtl_bio (struct bio *bio);void blk_throtl_cancel_bios (struct request_queue *q);static inline bool blk_throtl_bio (struct bio *bio)
Signature · 1 line
2.30.2
Re: [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue
Quoted 9 lines · Christoph Hellwig
Pass the gendisk to
blk_throtl_register_queueas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-sysfs.c | 2 +- block/blk-throttle.c | 3 ++- block/blk-throttle.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
Quoted 51 lines
block/blk-sysfs.c +1
-1@@ -844,7 +844,7 @@ int blk_register_queue(struct gendisk *disk)blk_queue_flag_set (QUEUE_FLAG_REGISTERED , q);wbt_enable_default (q); -blk_throtl_register_queue (q); +blk_throtl_register (disk);/* Now everything is ready and send out KOBJ_ADD uevent */ kobject_uevent (&q->kobj,KOBJ_ADD );block/blk-throttle.c +2
-1@@ -2415,8 +2415,9 @@ void blk_throtl_exit(struct gendisk *disk)kfree (q->td); } -void blk_throtl_register_queue (struct request_queue *q) +void blk_throtl_register (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct throtl_data *td;int i;block/blk-throttle.h +2
-2@@ -170,13 +170,13 @@ static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)#ifndef CONFIG_BLK_DEV_THROTTLING static inline int blk_throtl_init (struct gendisk *disk) {return 0 ; }static inline void blk_throtl_exit (struct gendisk *disk) { } -static inline void blk_throtl_register_queue (struct request_queue *q) { } +static inline void blk_throtl_register (struct gendisk *disk) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; }static inline void blk_throtl_cancel_bios (struct request_queue *q) { }#else /* CONFIG_BLK_DEV_THROTTLING */ int blk_throtl_init (struct gendisk *disk);void blk_throtl_exit (struct gendisk *disk); -void blk_throtl_register_queue (struct request_queue *q); +void blk_throtl_register (struct gendisk *disk);bool __blk_throtl_bio (struct bio *bio);void blk_throtl_cancel_bios (struct request_queue *q);static inline bool blk_throtl_bio (struct bio *bio)Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 14/17 blk-throttle: pass a gendisk to blk_throtl_cancel_bios
In reply to Christoph HellwigPass the gendisk to blk_throtl_cancel_bios as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-throttle.c | 3 ++- block/blk-throttle.h | 4 ++-- block/genhd.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
block/blk-throttle.c +2 -1
@@ -1723,8 +1723,9 @@ struct blkcg_policy blkcg_policy_throtl = { .pd_free_fn = throtl_pd_free, }; -void blk_throtl_cancel_bios (struct request_queue *q) +void blk_throtl_cancel_bios (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct cgroup_subsys_state *pos_css;struct blkcg_gq *blkg;
block/blk-throttle.h +2 -2
@@ -172,13 +172,13 @@ static inline int blk_throtl_init(struct gendisk *disk) { return 0; }static inline void blk_throtl_exit (struct gendisk *disk) { }static inline void blk_throtl_register (struct gendisk *disk) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; } -static inline void blk_throtl_cancel_bios (struct request_queue *q) { } +static inline void blk_throtl_cancel_bios (struct gendisk *disk) { }#else /* CONFIG_BLK_DEV_THROTTLING */ int blk_throtl_init (struct gendisk *disk);void blk_throtl_exit (struct gendisk *disk);void blk_throtl_register (struct gendisk *disk);bool __blk_throtl_bio (struct bio *bio); -void blk_throtl_cancel_bios (struct request_queue *q); +void blk_throtl_cancel_bios (struct gendisk *disk);static inline bool blk_throtl_bio (struct bio *bio) {struct throtl_grp *tg =blkg_to_tg (bio->bi_blkg);
block/genhd.c +1 -1
@@ -626,7 +626,7 @@ void del_gendisk(struct gendisk *disk)pm_runtime_set_memalloc_noio (disk_to_dev (disk), false);device_del (disk_to_dev (disk)); -blk_throtl_cancel_bios (disk->queue); +blk_throtl_cancel_bios (disk);blk_sync_queue (q);blk_flush_integrity ();
Signature · 1 line
2.30.2
Re: [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios
Quoted 9 lines · Christoph Hellwig
Pass the gendisk to
blk_throtl_cancel_biosas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-throttle.c | 3 ++- block/blk-throttle.h | 4 ++-- block/genhd.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
Quoted 51 lines
block/blk-throttle.c +2
-1@@ -1723,8 +1723,9 @@ struct blkcg_policy blkcg_policy_throtl = { .pd_free_fn = throtl_pd_free, }; -void blk_throtl_cancel_bios (struct request_queue *q) +void blk_throtl_cancel_bios (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct cgroup_subsys_state *pos_css;struct blkcg_gq *blkg;block/blk-throttle.h +2
-2@@ -172,13 +172,13 @@ static inline int blk_throtl_init(struct gendisk *disk) { return 0; }static inline void blk_throtl_exit (struct gendisk *disk) { }static inline void blk_throtl_register (struct gendisk *disk) { }static inline bool blk_throtl_bio (struct bio *bio) {return false; } -static inline void blk_throtl_cancel_bios (struct request_queue *q) { } +static inline void blk_throtl_cancel_bios (struct gendisk *disk) { }#else /* CONFIG_BLK_DEV_THROTTLING */ int blk_throtl_init (struct gendisk *disk);void blk_throtl_exit (struct gendisk *disk);void blk_throtl_register (struct gendisk *disk);bool __blk_throtl_bio (struct bio *bio); -void blk_throtl_cancel_bios (struct request_queue *q); +void blk_throtl_cancel_bios (struct gendisk *disk);static inline bool blk_throtl_bio (struct bio *bio) {struct throtl_grp *tg =blkg_to_tg (bio->bi_blkg);block/genhd.c +1
-1@@ -626,7 +626,7 @@ void del_gendisk(struct gendisk *disk)pm_runtime_set_memalloc_noio (disk_to_dev (disk), false);device_del (disk_to_dev (disk)); -blk_throtl_cancel_bios (disk->queue); +blk_throtl_cancel_bios (disk);blk_sync_queue (q);blk_flush_integrity ();Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 15/17 blk-cgroup: pass a gendisk to blkg_destroy_all
In reply to Christoph HellwigPass the gendisk to blkg_destroy_all as part of moving the blk-cgroup infrastructure to be gendisk based.
--- block/blk-cgroup.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
block/blk-cgroup.c +4 -9
@@ -462,14 +462,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)percpu_ref_kill (&blkg->refcnt); } -/** -* blkg_destroy_all - destroy all blkgs associated with a request_queue -* @q: request_queue of interest -* -* Destroy all blkgs associated with @q. -*/ -static void blkg_destroy_all (struct request_queue *q) +static void blkg_destroy_all (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *blkg, *n;int count =BLKG_DESTROY_BATCH_SIZE ;
@@ -1276,7 +1271,7 @@ int blkcg_init_disk(struct gendisk *disk) err_ioprio_exit:blk_ioprio_exit (disk); err_destroy_all: -blkg_destroy_all (q); +blkg_destroy_all (disk);return ret; err_unlock:spin_unlock_irq (&q->queue_lock);
@@ -1287,7 +1282,7 @@ int blkcg_init_disk(struct gendisk *disk)void blkcg_exit_disk (struct gendisk *disk) { -blkg_destroy_all (disk->queue); +blkg_destroy_all (disk);blk_throtl_exit (disk); }
Signature · 1 line
2.30.2
Re: [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all
Quoted 7 lines · Christoph Hellwig
Pass the gendisk to
blkg_destroy_allas part of moving the blk-cgroup infrastructure to be gendisk based.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Quoted 42 lines
block/blk-cgroup.c +4
-9@@ -462,14 +462,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)percpu_ref_kill (&blkg->refcnt); } -/** -* blkg_destroy_all - destroy all blkgs associated with a request_queue -* @q: request_queue of interest -* -* Destroy all blkgs associated with @q. -*/ -static void blkg_destroy_all (struct request_queue *q) +static void blkg_destroy_all (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *blkg, *n;int count =BLKG_DESTROY_BATCH_SIZE ;@@ -1276,7 +1271,7 @@ int blkcg_init_disk(struct gendisk *disk) err_ioprio_exit:blk_ioprio_exit (disk); err_destroy_all: -blkg_destroy_all (q); +blkg_destroy_all (disk);return ret; err_unlock:spin_unlock_irq (&q->queue_lock);@@ -1287,7 +1282,7 @@ int blkcg_init_disk(struct gendisk *disk)void blkcg_exit_disk (struct gendisk *disk) { -blkg_destroy_all (disk->queue); +blkg_destroy_all (disk);blk_throtl_exit (disk); }Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 16/17 blk-cgroup: pass a gendisk to blkcg_schedule_throttle
In reply to Christoph HellwigPass the gendisk to blkcg_schedule_throttle as part of moving the blk-cgroup infrastructure to be gendisk based. Remove the unused !BLK_CGROUP stub while we're at it.
--- block/blk-cgroup.c | 8 +++++--- block/blk-iocost.c | 4 ++-- block/blk-iolatency.c | 2 +- include/linux/blk-cgroup.h | 5 ++--- mm/swapfile.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-)
block/blk-cgroup.c +5 -3
@@ -1792,13 +1792,13 @@ void blkcg_maybe_throttle_current(void)/** * blkcg_schedule_throttle - this task needs to check for throttling -* @q: the request queue IO was submitted on +* @gendisk: disk to throttle * @use_memdelay: do we charge this to memory delay for PSI * * This is called by the IO controller when we know there's delay accumulated * for the blkg for this task. We do not pass the blkg because there are places * we call this that may not have that information, the swapping code for -* instance will only have a request_queue at that point. This set's the +* instance will only have a block_device at that point. This set's the * notify_resume for the task to check and see if it requires throttling before * returning to user space. *
@@ -1807,8 +1807,10 @@ void blkcg_maybe_throttle_current(void)* throttle once. If the task needs to be throttled again it'll need to be * re-set at the next time we see the task. */ -void blkcg_schedule_throttle (struct request_queue *q,bool use_memdelay) +void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay) { +struct request_queue *q = disk->queue; +if (unlikely (current->flags &PF_KTHREAD ))return ;
block/blk-iocost.c +2 -2
@@ -2636,7 +2636,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)if (use_debt) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q, +blkcg_schedule_throttle (rqos->q->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP );iocg_unlock (iocg, ioc_locked, &flags);return ;
@@ -2737,7 +2737,7 @@ static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,if (likely (!list_empty (&iocg->active_list))) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q, +blkcg_schedule_throttle (rqos->q->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP ); }else {iocg_commit_bio (iocg, bio, abs_cost, cost);
block/blk-iolatency.c +1 -1
@@ -292,7 +292,7 @@ static void __blkcg_iolatency_throttle(struct rq_qos *rqos,unsigned use_delay =atomic_read (&lat_to_blkg (iolat)->use_delay);if (use_delay) -blkcg_schedule_throttle (rqos->q, use_memdelay); +blkcg_schedule_throttle (rqos->q->disk, use_memdelay);/* * To avoid priority inversions we want to just take a slot if we are
include/linux/blk-cgroup.h +2 -3
@@ -18,14 +18,14 @@struct bio ;struct cgroup_subsys_state ; -struct request_queue ; +struct gendisk ;#define FC_APPID_LEN 129#ifdef CONFIG_BLK_CGROUP extern struct cgroup_subsys_state *const blkcg_root_css; -void blkcg_schedule_throttle (struct request_queue *q,bool use_memdelay); +void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay);void blkcg_maybe_throttle_current (void );bool blk_cgroup_congested (void );void blkcg_pin_online (struct cgroup_subsys_state *blkcg_css);
@@ -39,7 +39,6 @@ struct cgroup_subsys_state *bio_blkcg_css(struct bio *bio);static inline void blkcg_maybe_throttle_current (void ) { }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 cgroup_subsys_state *bio_blkcg_css (struct bio *bio) {return NULL ;
mm/swapfile.c +1 -1
@@ -3655,7 +3655,7 @@ void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)plist_for_each_entry_safe (si, next, &swap_avail_heads[nid], avail_lists[nid]) {if (si->bdev) { -blkcg_schedule_throttle (bdev_get_queue (si->bdev), true); +blkcg_schedule_throttle (si->bdev->bd_disk, true);break ; } }
Signature · 1 line
2.30.2
Re: [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle
Quoted 4 lines · Christoph Hellwig
Pass the gendisk to
blkcg_schedule_throttleas part of moving the blk-cgroup infrastructure to be gendisk based. Remove the unused !BLK_CGROUP stub while we're at it.
Quoted 8 lines
Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 8 +++++--- block/blk-iocost.c | 4 ++-- block/blk-iolatency.c | 2 +- include/linux/blk-cgroup.h | 5 ++--- mm/swapfile.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-)
Quoted 112 lines
block/blk-cgroup.c +5
-3@@ -1792,13 +1792,13 @@ void blkcg_maybe_throttle_current(void)/** * blkcg_schedule_throttle - this task needs to check for throttling -* @q: the request queue IO was submitted on +* @gendisk: disk to throttle * @use_memdelay: do we charge this to memory delay for PSI * * This is called by the IO controller when we know there's delay accumulated * for the blkg for this task. We do not pass the blkg because there are places * we call this that may not have that information, the swapping code for -* instance will only have a request_queue at that point. This set's the +* instance will only have a block_device at that point. This set's the * notify_resume for the task to check and see if it requires throttling before * returning to user space. * @@ -1807,8 +1807,10 @@ void blkcg_maybe_throttle_current(void)* throttle once. If the task needs to be throttled again it'll need to be * re-set at the next time we see the task. */ -void blkcg_schedule_throttle (struct request_queue *q,bool use_memdelay) +void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay) { +struct request_queue *q = disk->queue; +if (unlikely (current->flags &PF_KTHREAD ))return ;block/blk-iocost.c +2
-2@@ -2636,7 +2636,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)if (use_debt) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q, +blkcg_schedule_throttle (rqos->q->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP );iocg_unlock (iocg, ioc_locked, &flags);return ;@@ -2737,7 +2737,7 @@ static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,if (likely (!list_empty (&iocg->active_list))) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q, +blkcg_schedule_throttle (rqos->q->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP ); }else {iocg_commit_bio (iocg, bio, abs_cost, cost);block/blk-iolatency.c +1
-1@@ -292,7 +292,7 @@ static void __blkcg_iolatency_throttle(struct rq_qos *rqos,unsigned use_delay =atomic_read (&lat_to_blkg (iolat)->use_delay);if (use_delay) -blkcg_schedule_throttle (rqos->q, use_memdelay); +blkcg_schedule_throttle (rqos->q->disk, use_memdelay);/* * To avoid priority inversions we want to just take a slot if we are include/linux/blk-cgroup.h +2
-3@@ -18,14 +18,14 @@struct bio ;struct cgroup_subsys_state ; -struct request_queue ; +struct gendisk ;#define FC_APPID_LEN 129#ifdef CONFIG_BLK_CGROUP extern struct cgroup_subsys_state *const blkcg_root_css; -void blkcg_schedule_throttle (struct request_queue *q,bool use_memdelay); +void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay);void blkcg_maybe_throttle_current (void );bool blk_cgroup_congested (void );void blkcg_pin_online (struct cgroup_subsys_state *blkcg_css);@@ -39,7 +39,6 @@ struct cgroup_subsys_state *bio_blkcg_css(struct bio *bio);static inline void blkcg_maybe_throttle_current (void ) { }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 cgroup_subsys_state *bio_blkcg_css (struct bio *bio) {return NULL ;mm/swapfile.c +1
-1@@ -3655,7 +3655,7 @@ void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)plist_for_each_entry_safe (si, next, &swap_avail_heads[nid], avail_lists[nid]) {if (si->bdev) { -blkcg_schedule_throttle (bdev_get_queue (si->bdev), true); +blkcg_schedule_throttle (si->bdev->bd_disk, true);break ; } }Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
PATCH 17/17 blk-cgroup: pass a gendisk to the blkg allocation helpers
In reply to Christoph HellwigPrepare for storing the blkcg information in the gendisk instead of the request_queue.
--- block/blk-cgroup.c | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-)
block/blk-cgroup.c +28 -28
@@ -202,19 +202,19 @@ static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)/** * blkg_alloc - allocate a blkg * @blkcg: block cgroup the new blkg is associated with -* @q: request_queue the new blkg is associated with +* @disk: gendisk the new blkg is associated with * @gfp_mask: allocation mask to use * * Allocate a new blkg assocating @blkcg and @q. */ -static struct blkcg_gq *blkg_alloc (struct blkcg *blkcg,struct request_queue *q, +static struct blkcg_gq *blkg_alloc (struct blkcg *blkcg,struct gendisk *disk,gfp_t gfp_mask) {struct blkcg_gq *blkg;int i, cpu;/* alloc and init base part */ - blkg =kzalloc_node (sizeof (*blkg), gfp_mask, q->node); + blkg =kzalloc_node (sizeof (*blkg), gfp_mask, disk->queue->node);if (!blkg)return NULL ;
@@ -225,10 +225,10 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,if (!blkg->iostat_cpu) goto err_free; -if (!blk_get_queue (q)) +if (!blk_get_queue (disk->queue)) goto err_free; - blkg->q = q; + blkg->q = disk->queue;INIT_LIST_HEAD (&blkg->q_node);spin_lock_init (&blkg->async_bio_lock);bio_list_init (&blkg->async_bios);
@@ -243,11 +243,11 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,struct blkcg_policy *pol = blkcg_policy[i];struct blkg_policy_data *pd; -if (!blkcg_policy_enabled (q, pol)) +if (!blkcg_policy_enabled (disk->queue, pol))continue ;/* alloc per-policy data and attach it to blkg */ - pd = pol->pd_alloc_fn (gfp_mask, q, blkcg); + pd = pol->pd_alloc_fn (gfp_mask, disk->queue, blkcg);if (!pd) goto err_free;
@@ -275,17 +275,16 @@ static void blkg_update_hint(struct blkcg *blkcg, struct blkcg_gq *blkg)* If @new_blkg is %NULL, this function tries to allocate a new one as * necessary using %GFP_NOWAIT. @new_blkg is always consumed on return. */ -static struct blkcg_gq *blkg_create (struct blkcg *blkcg, -struct request_queue *q, +static struct blkcg_gq *blkg_create (struct blkcg *blkcg,struct gendisk *disk,struct blkcg_gq *new_blkg) {struct blkcg_gq *blkg;int i, ret; -lockdep_assert_held (&q->queue_lock); +lockdep_assert_held (&disk->queue->queue_lock);/* request_queue is dying, do not create/recreate a blkg */ -if (blk_queue_dying (q)) { +if (blk_queue_dying (disk->queue)) { ret = -ENODEV ; goto err_free_blkg; }
@@ -298,7 +297,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* allocate */ if (!new_blkg) { - new_blkg =blkg_alloc (blkcg, q,GFP_NOWAIT | __GFP_NOWARN); + new_blkg =blkg_alloc (blkcg, disk,GFP_NOWAIT | __GFP_NOWARN);if (unlikely (!new_blkg)) { ret = -ENOMEM ; goto err_put_css;
@@ -308,7 +307,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* link parent */ if (blkcg_parent (blkcg)) { - blkg->parent =blkg_lookup (blkcg_parent (blkcg), q); + blkg->parent =blkg_lookup (blkcg_parent (blkcg), disk->queue);if (WARN_ON_ONCE (!blkg->parent)) { ret = -ENODEV ; goto err_put_css;
@@ -326,10 +325,10 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* insert */ spin_lock (&blkcg->lock); - ret =radix_tree_insert (&blkcg->blkg_tree, q->id, blkg); + ret =radix_tree_insert (&blkcg->blkg_tree, disk->queue->id, blkg);if (likely (!ret)) {hlist_add_head_rcu (&blkg->blkcg_node, &blkcg->blkg_list); -list_add (&blkg->q_node, &q->blkg_list); +list_add (&blkg->q_node, &disk->queue->blkg_list);for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];
@@ -358,19 +357,20 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/** * blkg_lookup_create - lookup blkg, try to create one if not there * @blkcg: blkcg of interest -* @q: request_queue of interest +* @disk: gendisk of interest * -* Lookup blkg for the @blkcg - @q pair. If it doesn't exist, try to +* Lookup blkg for the @blkcg - @disk pair. If it doesn't exist, try to * create one. blkg creation is performed recursively from blkcg_root such * that all non-root blkg's have access to the parent blkg. This function -* should be called under RCU read lock and takes @q->queue_lock. +* should be called under RCU read lock and takes @disk->queue->queue_lock. * * Returns the blkg or the closest blkg if blkg_create() fails as it walks * down from root. */ static struct blkcg_gq *blkg_lookup_create (struct blkcg *blkcg, -struct request_queue *q) +struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *blkg;unsigned long flags;
@@ -408,7 +408,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, parent =blkcg_parent (parent); } - blkg =blkg_create (pos, q,NULL ); + blkg =blkg_create (pos, disk,NULL );if (IS_ERR (blkg)) { blkg = ret_blkg;break ;
@@ -652,6 +652,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, __acquires(rcu) __acquires(&bdev->bd_queue->queue_lock) {struct block_device *bdev; +struct gendisk *disk;struct request_queue *q;struct blkcg_gq *blkg;int ret;
@@ -659,8 +660,8 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, bdev =blkcg_conf_open_bdev (&input);if (IS_ERR (bdev))return PTR_ERR (bdev); - - q =bdev_get_queue (bdev); + disk = bdev->bd_disk; + q = disk->queue;/* * blkcg_deactivate_policy() requires queue to be frozen, we can grab
@@ -703,7 +704,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,spin_unlock_irq (&q->queue_lock);rcu_read_unlock (); - new_blkg =blkg_alloc (pos, q,GFP_KERNEL ); + new_blkg =blkg_alloc (pos, disk,GFP_KERNEL );if (unlikely (!new_blkg)) { ret = -ENOMEM ; goto fail_exit_queue;
@@ -729,7 +730,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,blkg_update_hint (pos, blkg);blkg_free (new_blkg); }else { - blkg =blkg_create (pos, q, new_blkg); + blkg =blkg_create (pos, disk, new_blkg);if (IS_ERR (blkg)) { ret =PTR_ERR (blkg); goto fail_preloaded;
@@ -1234,7 +1235,7 @@ int blkcg_init_disk(struct gendisk *disk)INIT_LIST_HEAD (&q->blkg_list); - new_blkg =blkg_alloc (&blkcg_root, q,GFP_KERNEL ); + new_blkg =blkg_alloc (&blkcg_root, disk,GFP_KERNEL );if (!new_blkg)return -ENOMEM ;
@@ -1243,7 +1244,7 @@ int blkcg_init_disk(struct gendisk *disk)/* Make sure the root blkg exists. */ /* spin_lock_irq can serve as RCU read-side critical section. */ spin_lock_irq (&q->queue_lock); - blkg =blkg_create (&blkcg_root, q, new_blkg); + blkg =blkg_create (&blkcg_root, disk, new_blkg);if (IS_ERR (blkg)) goto err_unlock; q->root_blkg = blkg;
@@ -1860,8 +1861,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio,struct blkcg_gq *blkg, *ret_blkg =NULL ;rcu_read_lock (); - blkg =blkg_lookup_create (css_to_blkcg (css), -bdev_get_queue (bio->bi_bdev)); + blkg =blkg_lookup_create (css_to_blkcg (css), bio->bi_bdev->bd_disk);while (blkg) {if (blkg_tryget (blkg)) { ret_blkg = blkg;
Signature · 1 line
2.30.2
Re: [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers
Quoted 7 lines · Christoph Hellwig
Prepare for storing the blkcg information in the gendisk instead of the
request_queue.Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-cgroup.c | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-)
Quoted 208 lines
block/blk-cgroup.c +28
-28@@ -202,19 +202,19 @@ static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)/** * blkg_alloc - allocate a blkg * @blkcg: block cgroup the new blkg is associated with -* @q: request_queue the new blkg is associated with +* @disk: gendisk the new blkg is associated with * @gfp_mask: allocation mask to use * * Allocate a new blkg assocating @blkcg and @q. */ -static struct blkcg_gq *blkg_alloc (struct blkcg *blkcg,struct request_queue *q, +static struct blkcg_gq *blkg_alloc (struct blkcg *blkcg,struct gendisk *disk,gfp_t gfp_mask) {struct blkcg_gq *blkg;int i, cpu;/* alloc and init base part */ - blkg =kzalloc_node (sizeof (*blkg), gfp_mask, q->node); + blkg =kzalloc_node (sizeof (*blkg), gfp_mask, disk->queue->node);if (!blkg)return NULL ;@@ -225,10 +225,10 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,if (!blkg->iostat_cpu) goto err_free; -if (!blk_get_queue (q)) +if (!blk_get_queue (disk->queue)) goto err_free; - blkg->q = q; + blkg->q = disk->queue;INIT_LIST_HEAD (&blkg->q_node);spin_lock_init (&blkg->async_bio_lock);bio_list_init (&blkg->async_bios);@@ -243,11 +243,11 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,struct blkcg_policy *pol = blkcg_policy[i];struct blkg_policy_data *pd; -if (!blkcg_policy_enabled (q, pol)) +if (!blkcg_policy_enabled (disk->queue, pol))continue ;/* alloc per-policy data and attach it to blkg */ - pd = pol->pd_alloc_fn (gfp_mask, q, blkcg); + pd = pol->pd_alloc_fn (gfp_mask, disk->queue, blkcg);if (!pd) goto err_free;@@ -275,17 +275,16 @@ static void blkg_update_hint(struct blkcg *blkcg, struct blkcg_gq *blkg)* If @new_blkg is %NULL, this function tries to allocate a new one as * necessary using %GFP_NOWAIT. @new_blkg is always consumed on return. */ -static struct blkcg_gq *blkg_create (struct blkcg *blkcg, -struct request_queue *q, +static struct blkcg_gq *blkg_create (struct blkcg *blkcg,struct gendisk *disk,struct blkcg_gq *new_blkg) {struct blkcg_gq *blkg;int i, ret; -lockdep_assert_held (&q->queue_lock); +lockdep_assert_held (&disk->queue->queue_lock);/* request_queue is dying, do not create/recreate a blkg */ -if (blk_queue_dying (q)) { +if (blk_queue_dying (disk->queue)) { ret = -ENODEV ; goto err_free_blkg; }@@ -298,7 +297,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* allocate */ if (!new_blkg) { - new_blkg =blkg_alloc (blkcg, q,GFP_NOWAIT | __GFP_NOWARN); + new_blkg =blkg_alloc (blkcg, disk,GFP_NOWAIT | __GFP_NOWARN);if (unlikely (!new_blkg)) { ret = -ENOMEM ; goto err_put_css;@@ -308,7 +307,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* link parent */ if (blkcg_parent (blkcg)) { - blkg->parent =blkg_lookup (blkcg_parent (blkcg), q); + blkg->parent =blkg_lookup (blkcg_parent (blkcg), disk->queue);if (WARN_ON_ONCE (!blkg->parent)) { ret = -ENODEV ; goto err_put_css;@@ -326,10 +325,10 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/* insert */ spin_lock (&blkcg->lock); - ret =radix_tree_insert (&blkcg->blkg_tree, q->id, blkg); + ret =radix_tree_insert (&blkcg->blkg_tree, disk->queue->id, blkg);if (likely (!ret)) {hlist_add_head_rcu (&blkg->blkcg_node, &blkcg->blkg_list); -list_add (&blkg->q_node, &q->blkg_list); +list_add (&blkg->q_node, &disk->queue->blkg_list);for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];@@ -358,19 +357,20 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,/** * blkg_lookup_create - lookup blkg, try to create one if not there * @blkcg: blkcg of interest -* @q: request_queue of interest +* @disk: gendisk of interest * -* Lookup blkg for the @blkcg - @q pair. If it doesn't exist, try to +* Lookup blkg for the @blkcg - @disk pair. If it doesn't exist, try to * create one. blkg creation is performed recursively from blkcg_root such * that all non-root blkg's have access to the parent blkg. This function -* should be called under RCU read lock and takes @q->queue_lock. +* should be called under RCU read lock and takes @disk->queue->queue_lock. * * Returns the blkg or the closest blkg if blkg_create() fails as it walks * down from root. */ static struct blkcg_gq *blkg_lookup_create (struct blkcg *blkcg, -struct request_queue *q) +struct gendisk *disk) { +struct request_queue *q = disk->queue;struct blkcg_gq *blkg;unsigned long flags;@@ -408,7 +408,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, parent =blkcg_parent (parent); } - blkg =blkg_create (pos, q,NULL ); + blkg =blkg_create (pos, disk,NULL );if (IS_ERR (blkg)) { blkg = ret_blkg;break ;@@ -652,6 +652,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, __acquires(rcu) __acquires(&bdev->bd_queue->queue_lock) {struct block_device *bdev; +struct gendisk *disk;struct request_queue *q;struct blkcg_gq *blkg;int ret;@@ -659,8 +660,8 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, bdev =blkcg_conf_open_bdev (&input);if (IS_ERR (bdev))return PTR_ERR (bdev); - - q =bdev_get_queue (bdev); + disk = bdev->bd_disk; + q = disk->queue;/* * blkcg_deactivate_policy() requires queue to be frozen, we can grab @@ -703,7 +704,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,spin_unlock_irq (&q->queue_lock);rcu_read_unlock (); - new_blkg =blkg_alloc (pos, q,GFP_KERNEL ); + new_blkg =blkg_alloc (pos, disk,GFP_KERNEL );if (unlikely (!new_blkg)) { ret = -ENOMEM ; goto fail_exit_queue;@@ -729,7 +730,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,blkg_update_hint (pos, blkg);blkg_free (new_blkg); }else { - blkg =blkg_create (pos, q, new_blkg); + blkg =blkg_create (pos, disk, new_blkg);if (IS_ERR (blkg)) { ret =PTR_ERR (blkg); goto fail_preloaded;@@ -1234,7 +1235,7 @@ int blkcg_init_disk(struct gendisk *disk)INIT_LIST_HEAD (&q->blkg_list); - new_blkg =blkg_alloc (&blkcg_root, q,GFP_KERNEL ); + new_blkg =blkg_alloc (&blkcg_root, disk,GFP_KERNEL );if (!new_blkg)return -ENOMEM ;@@ -1243,7 +1244,7 @@ int blkcg_init_disk(struct gendisk *disk)/* Make sure the root blkg exists. */ /* spin_lock_irq can serve as RCU read-side critical section. */ spin_lock_irq (&q->queue_lock); - blkg =blkg_create (&blkcg_root, q, new_blkg); + blkg =blkg_create (&blkcg_root, disk, new_blkg);if (IS_ERR (blkg)) goto err_unlock; q->root_blkg = blkg;@@ -1860,8 +1861,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio,struct blkcg_gq *blkg, *ret_blkg =NULL ;rcu_read_lock (); - blkg =blkg_lookup_create (css_to_blkcg (css), -bdev_get_queue (bio->bi_bdev)); + blkg =blkg_lookup_create (css_to_blkcg (css), bio->bi_bdev->bd_disk);while (blkg) {if (blkg_tryget (blkg)) { ret_blkg = blkg;Signature · 1 line
2.30.2
Signature · 7 lines
Regards, Andreas SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)
Hello,
Quoted 6 lines · Christoph Hellwig
Hi Tejun and Jens,
this series has a bunch of blk-cgroup cleanups and preparation for preparing to make blk-cgroup gendisk based. Another series for the next merge window will follow for the real changes that include refcounting updates.
I only had a minor comment on patch 5 which can be addressed later. For the whole series,
Thanks.
Signature · 1 line
tejun
Quoted 21 lines · Christoph Hellwig
this series has a bunch of blk-cgroup cleanups and preparation for preparing to make blk-cgroup gendisk based. Another series for the next merge window will follow for the real changes that include refcounting updates.
Diffstat:
block/blk-cgroup.c | 186 +++++++++++++++++---------------------------- block/blk-cgroup.h | 68 ++++------------ block/blk-iocost.c | 37 ++++---- block/blk-iolatency.c | 5 - block/blk-ioprio.c | 8 - block/blk-ioprio.h | 8 - block/blk-sysfs.c | 2 block/blk-throttle.c | 13 ++- block/blk-throttle.h | 16 +-- block/blk.h | 4 block/genhd.c | 7 - include/linux/blk-cgroup.h | 5 - mm/swapfile.c | 2 13 files changed, 148 insertions(+), 213 deletions(-)
Quoted 1 line
[...]
Applied, thanks!
[01/17] blk-cgroup: fix error unwinding in blkcg_init_queue
commit: 33dc62796cb657a633050138a86253fb2a553713
[02/17] blk-cgroup: remove blk_queue_root_blkg
commit: 928f6f00a91ecbef6cb1fe59474831ceaf205290
[03/17] blk-cgroup: remove open coded blkg_lookup instances
commit: 79fcc5be93e5b17a2a5d36553f7a5c1ad9e953b6
[04/17] blk-cgroup: cleanup the blkg_lookup family of functions
commit: 4a69f325aa43847e0827fbfe4b3623307b0c9baa
[05/17] blk-cgroup: remove blkg_lookup_check
commit: f753526e327bc849c445c084d0f374e992038ae9
[06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue
commit: 9823538fb7efe66ce987a1e4c0e0f3dc882623c4
[07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit
commit: b0dde3f5d628f76f461fb650e2cebfac3460cff6
[08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
commit: 16fac1b5912b778a30d8863dbc928bef25c8d307
[09/17] blk-iocost: simplify ioc_name
commit: 9df3e65139b923dfe98f76b7057882c7afb2d3e4
[10/17] blk-iocost: pass a gendisk to blk_iocost_init
commit: 57b64554977e28ab84d33d298032872a8047a557
[11/17] blk-iocost: cleanup ioc_qos_write
commit: 3657647e33dff916a2d2d9df926d9bca3907d34f
[12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit
commit: e13793bae65919cd3e6a7827f8d30f4dbb8584ee
[13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue
commit: 5f6dc7522ac2e1701c92f20b9a1a664736787728
[14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios
commit: cad9266abcef586aa95f6f4095781e3e55473f2a
[15/17] blk-cgroup: pass a gendisk to blkg_destroy_all
commit: 00ad6991bbae116b7c83f68754edd6f4d5e65e01
[16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle
commit: de185b56e8a62822d4e1cdb3e068b38ca709aa47
[17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers
commit: 99e603874366be1115b40ecbc0e25847186d84eaBest regards,
Signature · 1 line
Jens Axboe