* blk-cgroup cleanups
@ 2022-09-21 18:04 Christoph Hellwig
2022-09-21 18:04 ` [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue Christoph Hellwig
` (18 more replies)
0 siblings, 19 replies; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
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(-)
^ permalink raw reply [flat|nested] 41+ messages in thread
* [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:00 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg Christoph Hellwig
` (17 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
When blk_throtl_init fails, we need to call blk_ioprio_exit. Switch to
proper goto based unwinding to fix this.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 869af9d72bcf8..3a88f8c011d27 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
2022-09-21 18:04 ` [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:03 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances Christoph Hellwig
` (16 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Just open code it in the only caller and drop the unused !BLK_CGROUP
stub.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 3 +--
block/blk-cgroup.h | 13 -------------
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 3a88f8c011d27..4180de4cbb3e1 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index d2724d1dd7c9b..c1fb00a1dfc03 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -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; }
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
2022-09-21 18:04 ` [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue Christoph Hellwig
2022-09-21 18:04 ` [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:17 ` Andreas Herrmann
2022-09-26 20:56 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions Christoph Hellwig
` (15 subsequent siblings)
18 siblings, 2 replies; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Use blkg_lookup instead of open coding it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 6 +++---
block/blk-cgroup.h | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4180de4cbb3e1..b9a1dcee5a244 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);
}
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index c1fb00a1dfc03..30396cad50e9a 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (2 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 14:15 ` Andreas Herrmann
2022-09-26 20:58 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 05/17] blk-cgroup: remove blkg_lookup_check Christoph Hellwig
` (14 subsequent siblings)
18 siblings, 2 replies; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Add 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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 38 +++++++++++++++-----------------------
block/blk-cgroup.h | 39 ++++++++++++---------------------------
2 files changed, 27 insertions(+), 50 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index b9a1dcee5a244..d1216760d0255 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
}
/**
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 30396cad50e9a..91b7ae0773be6 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -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;
}
/**
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 05/17] blk-cgroup: remove blkg_lookup_check
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (3 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 14:16 ` Andreas Herrmann
2022-09-26 21:18 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue Christoph Hellwig
` (13 subsequent siblings)
18 siblings, 2 replies; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
The 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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 36 ++++++++++--------------------------
1 file changed, 10 insertions(+), 26 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index d1216760d0255..1306112d76486 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (4 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 05/17] blk-cgroup: remove blkg_lookup_check Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:34 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit Christoph Hellwig
` (12 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass 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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 25 +++++--------------------
block/blk-cgroup.h | 8 ++++----
block/genhd.c | 5 +++--
3 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 1306112d76486..4ca6933a7c3f5 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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)
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 91b7ae0773be6..aa2b286bc825f 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -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,
diff --git a/block/genhd.c b/block/genhd.c
index d36fabf0abc1f..f1af045fac2fe 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (5 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:38 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init Christoph Hellwig
` (11 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_ioprio_init and blk_ioprio_exit as part of moving
the blk-cgroup infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 4 ++--
block/blk-ioprio.c | 8 ++++----
block/blk-ioprio.h | 8 ++++----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4ca6933a7c3f5..89974fd0db3da 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c
index c00060a02c6ef..8bb6b8eba4cee 100644
--- a/block/blk-ioprio.c
+++ b/block/blk-ioprio.c
@@ -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)
diff --git a/block/blk-ioprio.h b/block/blk-ioprio.h
index 5a1eb550e178c..b6afb8e80de05 100644
--- a/block/blk-ioprio.h
+++ b/block/blk-ioprio.h
@@ -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)
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (6 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:40 ` Andreas Herrmann
2022-09-27 1:19 ` Jens Axboe
2022-09-21 18:04 ` [PATCH 09/17] blk-iocost: simplify ioc_name Christoph Hellwig
` (10 subsequent siblings)
18 siblings, 2 replies; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_iolatency_init as part of moving the blk-cgroup
infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 2 +-
block/blk-iolatency.c | 3 ++-
block/blk.h | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 89974fd0db3da..82a117ff54de5 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index e285152345a20..c6f61fe88b875 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -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;
diff --git a/block/blk.h b/block/blk.h
index d7142c4d2fefb..361db83147c6f 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -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
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 09/17] blk-iocost: simplify ioc_name
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (7 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 12:10 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init Christoph Hellwig
` (9 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Just directly dereference the disk name instead of going through multiple
hoops to find the same value.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-iocost.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 7936e5f5821c7..cba9d3ad58e16 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -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)
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (8 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 09/17] blk-iocost: simplify ioc_name Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 12:11 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 11/17] blk-iocost: cleanup ioc_qos_write Christoph Hellwig
` (8 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_iocost_init as part of moving the blk-cgroup
infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-iocost.c | 7 ++++---
block/blk.h | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index cba9d3ad58e16..1e7bf0d353227 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -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));
diff --git a/block/blk.h b/block/blk.h
index 361db83147c6f..8d5c7a6f52a66 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -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
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 11/17] blk-iocost: cleanup ioc_qos_write
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (9 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 12:11 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit Christoph Hellwig
` (7 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Use a local disk variable instead of retrieving the disk and
request_queue over and over by various means.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-iocost.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 1e7bf0d353227..b8e5f550aa5be 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -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;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (10 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 11/17] blk-iocost: cleanup ioc_qos_write Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-23 6:38 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue Christoph Hellwig
` (6 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_throtl_init and blk_throtl_exit as part of moving
the blk-cgroup infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 6 +++---
block/blk-throttle.c | 7 +++++--
block/blk-throttle.h | 8 ++++----
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 82a117ff54de5..3dfd78f1312db 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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)
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 55f2d985cfbbd..9ca8ae0ae6683 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -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);
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
index 66b4292b1b92a..f75852a4e5337 100644
--- a/block/blk-throttle.h
+++ b/block/blk-throttle.h
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (11 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-23 6:39 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios Christoph Hellwig
` (5 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_throtl_register_queue as part of moving the
blk-cgroup infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-sysfs.c | 2 +-
block/blk-throttle.c | 3 ++-
block/blk-throttle.h | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e1f009aba6fd2..e71b3b43927c0 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -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);
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 9ca8ae0ae6683..a9709d4af6f39 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -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;
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
index f75852a4e5337..7e217e613aee2 100644
--- a/block/blk-throttle.h
+++ b/block/blk-throttle.h
@@ -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)
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (12 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-23 6:42 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all Christoph Hellwig
` (4 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blk_throtl_cancel_bios as part of moving the
blk-cgroup infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-throttle.c | 3 ++-
block/blk-throttle.h | 4 ++--
block/genhd.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index a9709d4af6f39..8c683d5050483 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -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;
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
index 7e217e613aee2..143991fd13228 100644
--- a/block/blk-throttle.h
+++ b/block/blk-throttle.h
@@ -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);
diff --git a/block/genhd.c b/block/genhd.c
index f1af045fac2fe..d6a21803a57e2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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();
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (13 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios Christoph Hellwig
@ 2022-09-21 18:04 ` Christoph Hellwig
2022-09-22 13:42 ` Andreas Herrmann
2022-09-21 18:05 ` [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle Christoph Hellwig
` (3 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:04 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass the gendisk to blkg_destroy_all as part of moving the blk-cgroup
infrastructure to be gendisk based.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 3dfd78f1312db..c2d5ca2eb92e5 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (14 preceding siblings ...)
2022-09-21 18:04 ` [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all Christoph Hellwig
@ 2022-09-21 18:05 ` Christoph Hellwig
2022-09-22 14:21 ` Andreas Herrmann
2022-09-21 18:05 ` [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers Christoph Hellwig
` (2 subsequent siblings)
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:05 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Pass 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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
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(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index c2d5ca2eb92e5..fc82057db9629 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index b8e5f550aa5be..b0899ab214c41 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -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);
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index c6f61fe88b875..571fa95aafe96 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -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
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 9f40dbc65f82c..dd5841a42c331 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -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;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 1fdccd2f1422e..82e62007881db 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -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;
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (15 preceding siblings ...)
2022-09-21 18:05 ` [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle Christoph Hellwig
@ 2022-09-21 18:05 ` Christoph Hellwig
2022-09-23 7:03 ` Andreas Herrmann
2022-09-26 21:26 ` blk-cgroup cleanups Tejun Heo
2022-09-27 1:19 ` Jens Axboe
18 siblings, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2022-09-21 18:05 UTC (permalink / raw)
To: Tejun Heo, Jens Axboe; +Cc: linux-block
Prepare for storing the blkcg information in the gendisk instead of
the request_queue.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-cgroup.c | 56 +++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index fc82057db9629..94af5f3f3620b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH 09/17] blk-iocost: simplify ioc_name
2022-09-21 18:04 ` [PATCH 09/17] blk-iocost: simplify ioc_name Christoph Hellwig
@ 2022-09-22 12:10 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 12:10 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:53PM +0200, Christoph Hellwig wrote:
> Just directly dereference the disk name instead of going through multiple
> hoops to find the same value.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-iocost.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 7936e5f5821c7..cba9d3ad58e16 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -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)
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init
2022-09-21 18:04 ` [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init Christoph Hellwig
@ 2022-09-22 12:11 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 12:11 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:54PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_iocost_init as part of moving the blk-cgroup
> infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-iocost.c | 7 ++++---
> block/blk.h | 2 +-
> 2 files changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index cba9d3ad58e16..1e7bf0d353227 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -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));
> diff --git a/block/blk.h b/block/blk.h
> index 361db83147c6f..8d5c7a6f52a66 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -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
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 11/17] blk-iocost: cleanup ioc_qos_write
2022-09-21 18:04 ` [PATCH 11/17] blk-iocost: cleanup ioc_qos_write Christoph Hellwig
@ 2022-09-22 12:11 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 12:11 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:55PM +0200, Christoph Hellwig wrote:
> Use a local disk variable instead of retrieving the disk and
> request_queue over and over by various means.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-iocost.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 1e7bf0d353227..b8e5f550aa5be 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -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;
> }
>
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue
2022-09-21 18:04 ` [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue Christoph Hellwig
@ 2022-09-22 13:00 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:00 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:45PM +0200, Christoph Hellwig wrote:
> When blk_throtl_init fails, we need to call blk_ioprio_exit. Switch to
> proper goto based unwinding to fix this.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 869af9d72bcf8..3a88f8c011d27 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg
2022-09-21 18:04 ` [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg Christoph Hellwig
@ 2022-09-22 13:03 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:03 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:46PM +0200, Christoph Hellwig wrote:
> Just open code it in the only caller and drop the unused !BLK_CGROUP
> stub.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 3 +--
> block/blk-cgroup.h | 13 -------------
> 2 files changed, 1 insertion(+), 15 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 3a88f8c011d27..4180de4cbb3e1 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
> index d2724d1dd7c9b..c1fb00a1dfc03 100644
> --- a/block/blk-cgroup.h
> +++ b/block/blk-cgroup.h
> @@ -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; }
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances
2022-09-21 18:04 ` [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances Christoph Hellwig
@ 2022-09-22 13:17 ` Andreas Herrmann
2022-09-26 20:56 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:17 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:47PM +0200, Christoph Hellwig wrote:
> Use blkg_lookup instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 6 +++---
> block/blk-cgroup.h | 8 ++++----
> 2 files changed, 7 insertions(+), 7 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 4180de4cbb3e1..b9a1dcee5a244 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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);
> }
> diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
> index c1fb00a1dfc03..30396cad50e9a 100644
> --- a/block/blk-cgroup.h
> +++ b/block/blk-cgroup.h
> @@ -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);
>
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue
2022-09-21 18:04 ` [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue Christoph Hellwig
@ 2022-09-22 13:34 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:34 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:50PM +0200, Christoph Hellwig wrote:
> Pass 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 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:
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -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
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 1306112d76486..4ca6933a7c3f5 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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)
> diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
> index 91b7ae0773be6..aa2b286bc825f 100644
> --- a/block/blk-cgroup.h
> +++ b/block/blk-cgroup.h
> @@ -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,
> diff --git a/block/genhd.c b/block/genhd.c
> index d36fabf0abc1f..f1af045fac2fe 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit
2022-09-21 18:04 ` [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit Christoph Hellwig
@ 2022-09-22 13:38 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:38 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:51PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_ioprio_init and blk_ioprio_exit as part of moving
> the blk-cgroup infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 4 ++--
> block/blk-ioprio.c | 8 ++++----
> block/blk-ioprio.h | 8 ++++----
> 3 files changed, 10 insertions(+), 10 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 4ca6933a7c3f5..89974fd0db3da 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c
> index c00060a02c6ef..8bb6b8eba4cee 100644
> --- a/block/blk-ioprio.c
> +++ b/block/blk-ioprio.c
> @@ -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)
> diff --git a/block/blk-ioprio.h b/block/blk-ioprio.h
> index 5a1eb550e178c..b6afb8e80de05 100644
> --- a/block/blk-ioprio.h
> +++ b/block/blk-ioprio.h
> @@ -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)
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
2022-09-21 18:04 ` [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init Christoph Hellwig
@ 2022-09-22 13:40 ` Andreas Herrmann
2022-09-27 1:19 ` Jens Axboe
1 sibling, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:40 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:52PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_iolatency_init as part of moving the blk-cgroup
> infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 2 +-
> block/blk-iolatency.c | 3 ++-
> block/blk.h | 4 ++--
> 3 files changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 89974fd0db3da..82a117ff54de5 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
>
> diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
> index e285152345a20..c6f61fe88b875 100644
> --- a/block/blk-iolatency.c
> +++ b/block/blk-iolatency.c
> @@ -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;
> diff --git a/block/blk.h b/block/blk.h
> index d7142c4d2fefb..361db83147c6f 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -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
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all
2022-09-21 18:04 ` [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all Christoph Hellwig
@ 2022-09-22 13:42 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 13:42 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:59PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blkg_destroy_all as part of moving the blk-cgroup
> infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 3dfd78f1312db..c2d5ca2eb92e5 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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);
> }
>
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions
2022-09-21 18:04 ` [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions Christoph Hellwig
@ 2022-09-22 14:15 ` Andreas Herrmann
2022-09-26 20:58 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 14:15 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:48PM +0200, Christoph Hellwig wrote:
> Add 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
s/generated/generate/
> open code the hint update in the two callers that care.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 38 +++++++++++++++-----------------------
> block/blk-cgroup.h | 39 ++++++++++++---------------------------
> 2 files changed, 27 insertions(+), 50 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index b9a1dcee5a244..d1216760d0255 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> }
>
> /**
> diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
> index 30396cad50e9a..91b7ae0773be6 100644
> --- a/block/blk-cgroup.h
> +++ b/block/blk-cgroup.h
> @@ -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;
> }
>
> /**
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 05/17] blk-cgroup: remove blkg_lookup_check
2022-09-21 18:04 ` [PATCH 05/17] blk-cgroup: remove blkg_lookup_check Christoph Hellwig
@ 2022-09-22 14:16 ` Andreas Herrmann
2022-09-26 21:18 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 14:16 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:49PM +0200, Christoph Hellwig wrote:
> The 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 36 ++++++++++--------------------------
> 1 file changed, 10 insertions(+), 26 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index d1216760d0255..1306112d76486 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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);
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle
2022-09-21 18:05 ` [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle Christoph Hellwig
@ 2022-09-22 14:21 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-22 14:21 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:05:00PM +0200, Christoph Hellwig wrote:
> Pass 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 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(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index c2d5ca2eb92e5..fc82057db9629 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
>
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index b8e5f550aa5be..b0899ab214c41 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -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);
> diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
> index c6f61fe88b875..571fa95aafe96 100644
> --- a/block/blk-iolatency.c
> +++ b/block/blk-iolatency.c
> @@ -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
> diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
> index 9f40dbc65f82c..dd5841a42c331 100644
> --- a/include/linux/blk-cgroup.h
> +++ b/include/linux/blk-cgroup.h
> @@ -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;
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 1fdccd2f1422e..82e62007881db 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -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;
> }
> }
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit
2022-09-21 18:04 ` [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit Christoph Hellwig
@ 2022-09-23 6:38 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-23 6:38 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:56PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_throtl_init and blk_throtl_exit as part of moving
> the blk-cgroup infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 6 +++---
> block/blk-throttle.c | 7 +++++--
> block/blk-throttle.h | 8 ++++----
> 3 files changed, 12 insertions(+), 9 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 82a117ff54de5..3dfd78f1312db 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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)
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 55f2d985cfbbd..9ca8ae0ae6683 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -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);
> diff --git a/block/blk-throttle.h b/block/blk-throttle.h
> index 66b4292b1b92a..f75852a4e5337 100644
> --- a/block/blk-throttle.h
> +++ b/block/blk-throttle.h
> @@ -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);
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue
2022-09-21 18:04 ` [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue Christoph Hellwig
@ 2022-09-23 6:39 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-23 6:39 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:57PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_throtl_register_queue as part of moving the
> blk-cgroup infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-sysfs.c | 2 +-
> block/blk-throttle.c | 3 ++-
> block/blk-throttle.h | 4 ++--
> 3 files changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index e1f009aba6fd2..e71b3b43927c0 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -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);
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 9ca8ae0ae6683..a9709d4af6f39 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -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;
>
> diff --git a/block/blk-throttle.h b/block/blk-throttle.h
> index f75852a4e5337..7e217e613aee2 100644
> --- a/block/blk-throttle.h
> +++ b/block/blk-throttle.h
> @@ -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)
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios
2022-09-21 18:04 ` [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios Christoph Hellwig
@ 2022-09-23 6:42 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-23 6:42 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:58PM +0200, Christoph Hellwig wrote:
> Pass the gendisk to blk_throtl_cancel_bios as part of moving the
> blk-cgroup infrastructure to be gendisk based.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-throttle.c | 3 ++-
> block/blk-throttle.h | 4 ++--
> block/genhd.c | 2 +-
> 3 files changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index a9709d4af6f39..8c683d5050483 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -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;
>
> diff --git a/block/blk-throttle.h b/block/blk-throttle.h
> index 7e217e613aee2..143991fd13228 100644
> --- a/block/blk-throttle.h
> +++ b/block/blk-throttle.h
> @@ -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);
> diff --git a/block/genhd.c b/block/genhd.c
> index f1af045fac2fe..d6a21803a57e2 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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();
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers
2022-09-21 18:05 ` [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers Christoph Hellwig
@ 2022-09-23 7:03 ` Andreas Herrmann
0 siblings, 0 replies; 41+ messages in thread
From: Andreas Herrmann @ 2022-09-23 7:03 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Tejun Heo, Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:05:01PM +0200, Christoph Hellwig wrote:
> Prepare for storing the blkcg information in the gendisk instead of
> the request_queue.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 56 +++++++++++++++++++++++-----------------------
> 1 file changed, 28 insertions(+), 28 deletions(-)
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index fc82057db9629..94af5f3f3620b 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> --
> 2.30.2
>
--
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)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances
2022-09-21 18:04 ` [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances Christoph Hellwig
2022-09-22 13:17 ` Andreas Herrmann
@ 2022-09-26 20:56 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Tejun Heo @ 2022-09-26 20:56 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:47PM +0200, Christoph Hellwig wrote:
> Use blkg_lookup instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
For patches 1-3:
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions
2022-09-21 18:04 ` [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions Christoph Hellwig
2022-09-22 14:15 ` Andreas Herrmann
@ 2022-09-26 20:58 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Tejun Heo @ 2022-09-26 20:58 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block
On Wed, Sep 21, 2022 at 08:04:48PM +0200, Christoph Hellwig wrote:
> Add 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 05/17] blk-cgroup: remove blkg_lookup_check
2022-09-21 18:04 ` [PATCH 05/17] blk-cgroup: remove blkg_lookup_check Christoph Hellwig
2022-09-22 14:16 ` Andreas Herrmann
@ 2022-09-26 21:18 ` Tejun Heo
1 sibling, 0 replies; 41+ messages in thread
From: Tejun Heo @ 2022-09-26 21:18 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block
Hello,
On Wed, Sep 21, 2022 at 08:04:49PM +0200, Christoph Hellwig wrote:
> The 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
but please look below.
> /**
> * 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);
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.
--
tejun
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: blk-cgroup cleanups
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (16 preceding siblings ...)
2022-09-21 18:05 ` [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers Christoph Hellwig
@ 2022-09-26 21:26 ` Tejun Heo
2022-09-27 1:19 ` Jens Axboe
18 siblings, 0 replies; 41+ messages in thread
From: Tejun Heo @ 2022-09-26 21:26 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block
Hello,
On Wed, Sep 21, 2022 at 08:04:44PM +0200, Christoph Hellwig wrote:
> 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,
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init
2022-09-21 18:04 ` [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init Christoph Hellwig
2022-09-22 13:40 ` Andreas Herrmann
@ 2022-09-27 1:19 ` Jens Axboe
1 sibling, 0 replies; 41+ messages in thread
From: Jens Axboe @ 2022-09-27 1:19 UTC (permalink / raw)
To: Christoph Hellwig, Tejun Heo; +Cc: linux-block
> diff --git a/block/blk.h b/block/blk.h
> index d7142c4d2fefb..361db83147c6f 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -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.
--
Jens Axboe
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: blk-cgroup cleanups
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
` (17 preceding siblings ...)
2022-09-26 21:26 ` blk-cgroup cleanups Tejun Heo
@ 2022-09-27 1:19 ` Jens Axboe
18 siblings, 0 replies; 41+ messages in thread
From: Jens Axboe @ 2022-09-27 1:19 UTC (permalink / raw)
To: Tejun Heo, Christoph Hellwig; +Cc: linux-block
On Wed, 21 Sep 2022 20:04:44 +0200, Christoph Hellwig wrote:
> 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(-)
>
> [...]
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: 99e603874366be1115b40ecbc0e25847186d84ea
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2022-09-27 1:19 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 18:04 blk-cgroup cleanups Christoph Hellwig
2022-09-21 18:04 ` [PATCH 01/17] blk-cgroup: fix error unwinding in blkcg_init_queue Christoph Hellwig
2022-09-22 13:00 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 02/17] blk-cgroup: remove blk_queue_root_blkg Christoph Hellwig
2022-09-22 13:03 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 03/17] blk-cgroup: remove open coded blkg_lookup instances Christoph Hellwig
2022-09-22 13:17 ` Andreas Herrmann
2022-09-26 20:56 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 04/17] blk-cgroup: cleanup the blkg_lookup family of functions Christoph Hellwig
2022-09-22 14:15 ` Andreas Herrmann
2022-09-26 20:58 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 05/17] blk-cgroup: remove blkg_lookup_check Christoph Hellwig
2022-09-22 14:16 ` Andreas Herrmann
2022-09-26 21:18 ` Tejun Heo
2022-09-21 18:04 ` [PATCH 06/17] blk-cgroup: pass a gendisk to blkcg_init_queue and blkcg_exit_queue Christoph Hellwig
2022-09-22 13:34 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 07/17] blk-ioprio: pass a gendisk to blk_ioprio_init and blk_ioprio_exit Christoph Hellwig
2022-09-22 13:38 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 08/17] blk-iolatency: pass a gendisk to blk_iolatency_init Christoph Hellwig
2022-09-22 13:40 ` Andreas Herrmann
2022-09-27 1:19 ` Jens Axboe
2022-09-21 18:04 ` [PATCH 09/17] blk-iocost: simplify ioc_name Christoph Hellwig
2022-09-22 12:10 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 10/17] blk-iocost: pass a gendisk to blk_iocost_init Christoph Hellwig
2022-09-22 12:11 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 11/17] blk-iocost: cleanup ioc_qos_write Christoph Hellwig
2022-09-22 12:11 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 12/17] blk-throttle: pass a gendisk to blk_throtl_init and blk_throtl_exit Christoph Hellwig
2022-09-23 6:38 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 13/17] blk-throttle: pass a gendisk to blk_throtl_register_queue Christoph Hellwig
2022-09-23 6:39 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 14/17] blk-throttle: pass a gendisk to blk_throtl_cancel_bios Christoph Hellwig
2022-09-23 6:42 ` Andreas Herrmann
2022-09-21 18:04 ` [PATCH 15/17] blk-cgroup: pass a gendisk to blkg_destroy_all Christoph Hellwig
2022-09-22 13:42 ` Andreas Herrmann
2022-09-21 18:05 ` [PATCH 16/17] blk-cgroup: pass a gendisk to blkcg_schedule_throttle Christoph Hellwig
2022-09-22 14:21 ` Andreas Herrmann
2022-09-21 18:05 ` [PATCH 17/17] blk-cgroup: pass a gendisk to the blkg allocation helpers Christoph Hellwig
2022-09-23 7:03 ` Andreas Herrmann
2022-09-26 21:26 ` blk-cgroup cleanups Tejun Heo
2022-09-27 1:19 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).