blk-mq: Reduce static requests memory footprint for shared sbitmap
Subsystems (4)
v3 cover blk-mq: Reduce static requests memory footprint for shared sbitmap
Currently a full set of static requests are allocated per hw queue per tagset when shared sbitmap is used.
However, only tagset->queue_depth number of requests may be active at any given time. As such, only tagset->queue_depth number of static requests are required.
The same goes for using an IO scheduler, which allocates a full set of static requests per hw queue per request queue.
This series changes shared sbitmap support by using a shared tags per tagset and request queue. Ming suggested something along those lines in v1 review. But we'll keep name "shared sbitmap" name as it is familiar. In using a shared tags, the static rqs also become shared, reducing the number of sets of static rqs, reducing memory usage.
Patch "blk-mq: Use shared tags for shared sbitmap support" is a bit big, and could potentially be broken down. But then maintaining ability to bisect becomes harder and each sub-patch would get more convoluted.
For megaraid sas driver on my 128-CPU arm64 system with 1x SATA disk, we save approx. 300MB(!) [370MB -> 60MB]
Baseline is v5.15-rc1
This resend is just a rebase, which applied cleanly.
Changes since v2:
- Make blk_mq_clear_rq_mapping() static again
- Various function renaming for conciseness and consistency
- Add/refactor alloc/free map and rqs function
- Drop the new blk_mq_ops init_request method in favour of passing an invalid HW queue index for shared sbitmap
- Add patch to not clear rq mapping for driver tags
- Remove blk_mq_init_bitmap_tags()
- Add some more RB tags (thanks!)
Changes since v1:
- Switch to use blk_mq_tags for shared sbitmap
- Add new blk_mq_ops init request callback
- Add some RB tags (thanks!)
John Garry (13):
blk-mq: Change rqs check in blk_mq_free_rqs()
block: Rename BLKDEV_MAX_RQ -> BLKDEV_DEFAULT_RQ
blk-mq: Relocate shared sbitmap resize in blk_mq_update_nr_requests()
blk-mq: Invert check in blk_mq_update_nr_requests()
blk-mq-sched: Rename blk_mq_sched_alloc_{tags -> map_and_rqs}()
blk-mq-sched: Rename blk_mq_sched_free_{requests -> rqs}()
blk-mq: Pass driver tags to blk_mq_clear_rq_mapping()
blk-mq: Don't clear driver tags own mapping
blk-mq: Add blk_mq_tag_update_sched_shared_sbitmap()
blk-mq: Add blk_mq_alloc_map_and_rqs()
blk-mq: Refactor and rename blk_mq_free_map_and_{requests->rqs}()
blk-mq: Use shared tags for shared sbitmap support
blk-mq: Stop using pointers for blk_mq_tags bitmap tags
block/bfq-iosched.c | 4 +- block/blk-core.c | 4 +- block/blk-mq-debugfs.c | 8 +- block/blk-mq-sched.c | 116 +++++++++++------------ block/blk-mq-sched.h | 4 +- block/blk-mq-tag.c | 125 +++++++++--------------- block/blk-mq-tag.h | 14 +-- block/blk-mq.c | 209 ++++++++++++++++++++++++----------------- block/blk-mq.h | 18 ++-- block/blk.h | 2 +- block/kyber-iosched.c | 4 +- block/mq-deadline.c | 2 +- drivers/block/rbd.c | 2 +- include/linux/blk-mq.h | 15 ++- include/linux/blkdev.h | 5 +- 15 files changed, 256 insertions(+), 276 deletions(-)
Signature · 1 line
2.26.2
PATCH RESEND v3 1/13 blk-mq: Change rqs check in blk_mq_free_rqs()
The original code in commit 24d2f90309b23 ("blk-mq: split out tag initialization, support shared tags") would check tags->rqs is non-NULL and then dereference tags->rqs[].
Then in commit 2af8cbe30531 ("blk-mq: split tag ->rqs[] into two"), we started to dereference tags->static_rqs[], but continued to check non-NULL tags->rqs.
Check tags->static_rqs as non-NULL instead, which is more logical.
--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
@@ -2340,7 +2340,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, {struct page *page; -if (tags->rqs && set->ops->exit_request) { +if (tags->static_rqs && set->ops->exit_request) {int i;for (i =0 ; i < tags->nr_tags; i++) {
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 01/13] blk-mq: Change rqs check in blk_mq_free_rqs()
Quoted 22 lines · John Garry
The original code in commit
24d2f90309b23("blk-mq: split out tag initialization, support shared tags") would checktags->rqsis non-NULL and then dereference tags->rqs[].Then in commit
2af8cbe30531("blk-mq: split tag ->rqs[] into two"), we started to dereference tags->static_rqs[], but continued to check non-NULLtags->rqs.Check
tags->static_rqsas non-NULL instead, which is more logical.Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-mq.c +0
-0
block/blk-mq.c void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, · line 2346
Quoted 8 lines
block/blk-mq.c +1
-1@@ -2340,7 +2340,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, {struct page *page; -if (tags->rqs && set->ops->exit_request) { +if (tags->static_rqs && set->ops->exit_request) {int i;for (i =0 ; i < tags->nr_tags; i++) {
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 2/13 block: Rename BLKDEV_MAX_RQ -> BLKDEV_DEFAULT_RQ
In reply to John GarryIt is a bit confusing that there is BLKDEV_MAX_RQ and MAX_SCHED_RQ, as the name BLKDEV_MAX_RQ would imply the max requests always, which it is not.
Rename to BLKDEV_MAX_RQ to BLKDEV_DEFAULT_RQ, matching it's usage - that being the default number of requests assigned when allocating a request queue.
--- block/blk-core.c | 2 +- block/blk-mq-sched.c | 2 +- block/blk-mq-sched.h | 2 +- drivers/block/rbd.c | 2 +- include/linux/blkdev.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
block/blk-core.c +1 -1
@@ -568,7 +568,7 @@ struct request_queue *blk_alloc_queue(int node_id)blk_queue_dma_alignment (q,511 );blk_set_default_limits (&q->limits); - q->nr_requests =BLKDEV_MAX_RQ ; + q->nr_requests =BLKDEV_DEFAULT_RQ ;return q;
block/blk-mq-sched.c +1 -1
@@ -606,7 +606,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)* Additionally, this is a per-hw queue depth. */ q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth, -BLKDEV_MAX_RQ ); +BLKDEV_DEFAULT_RQ );queue_for_each_hw_ctx (q, hctx, i) { ret =blk_mq_sched_alloc_tags (q, hctx, i);
block/blk-mq-sched.h +1 -1
@@ -5,7 +5,7 @@#include "blk-mq.h" #include "blk-mq-tag.h" -#define MAX_SCHED_RQ (16 * BLKDEV_MAX_RQ) +#define MAX_SCHED_RQ (16 * BLKDEV_DEFAULT_RQ)void blk_mq_sched_assign_ioc (struct request *rq);
drivers/block/rbd.c +1 -1
@@ -836,7 +836,7 @@ struct rbd_options {u32 alloc_hint_flags;/* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */ }; -#define RBD_QUEUE_DEPTH_DEFAULT BLKDEV_MAX_RQ +#define RBD_QUEUE_DEPTH_DEFAULT BLKDEV_DEFAULT_RQ#define RBD_ALLOC_SIZE_DEFAULT (64 * 1024)#define RBD_LOCK_TIMEOUT_DEFAULT 0/* no timeout */ #define RBD_READ_ONLY_DEFAULT false
include/linux/blkdev.h +1 -1
@@ -40,7 +40,7 @@ struct blk_stat_callback;struct blk_keyslot_manager ;#define BLKDEV_MIN_RQ 4 -#define BLKDEV_MAX_RQ 128/* Default maximum */ +#define BLKDEV_DEFAULT_RQ 128/* Must be consistent with blk_mq_poll_stats_bkt() */ #define BLK_MQ_POLL_STATS_BKTS 16
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 02/13] block: Rename BLKDEV_MAX_RQ -> BLKDEV_DEFAULT_RQ
Quoted 9 lines · John Garry
It is a bit confusing that there is
BLKDEV_MAX_RQandMAX_SCHED_RQ, as the nameBLKDEV_MAX_RQwould imply the max requests always, which it is not.Rename to
BLKDEV_MAX_RQtoBLKDEV_DEFAULT_RQ, matching it's usage - that being the default number of requests assigned when allocating a request queue.Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>
Quoted 8 lines
--- block/blk-core.c | 2 +- block/blk-mq-sched.c | 2 +- block/blk-mq-sched.h | 2 +- drivers/block/rbd.c | 2 +- include/linux/blkdev.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 3/13 blk-mq: Relocate shared sbitmap resize in blk_mq_update_nr_requests()
In reply to John GarryFor shared sbitmap, if the call to blk_mq_tag_update_depth() was successful for any hctx when hctx->sched_tags is not set, then it would be successful for all (due to nature in which blk_mq_tag_update_depth() fails).
As such, there is no need to call blk_mq_tag_resize_shared_sbitmap() for each hctx. So relocate the call until after the hctx iteration under the !q->elevator check, which is equivalent (to !hctx->sched_tags).
--- block/blk-mq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
block/blk-mq.c +7 -5
@@ -3616,8 +3616,6 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)if (!hctx->sched_tags) { ret =blk_mq_tag_update_depth (hctx, &hctx->tags, nr, false); -if (!ret &&blk_mq_is_sbitmap_shared (set->flags)) -blk_mq_tag_resize_shared_sbitmap (set, nr); }else { ret =blk_mq_tag_update_depth (hctx, &hctx->sched_tags, nr, true);
@@ -3635,9 +3633,13 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) }if (!ret) { q->nr_requests = nr; -if (q->elevator &&blk_mq_is_sbitmap_shared (set->flags)) -sbitmap_queue_resize (&q->sched_bitmap_tags, - nr - set->reserved_tags); +if (blk_mq_is_sbitmap_shared (set->flags)) { +if (q->elevator) +sbitmap_queue_resize (&q->sched_bitmap_tags, + nr - set->reserved_tags); +else +blk_mq_tag_resize_shared_sbitmap (set, nr); + } }blk_mq_unquiesce_queue (q);
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 03/13] blk-mq: Relocate shared sbitmap resize in blk_mq_update_nr_requests()
Quoted 9 lines · John Garry
For shared sbitmap, if the call to
blk_mq_tag_update_depth()was successful for any hctx whenhctx->sched_tagsis not set, then it would be successful for all (due to nature in whichblk_mq_tag_update_depth()fails).As such, there is no need to call
blk_mq_tag_resize_shared_sbitmap()for each hctx. So relocate the call until after the hctx iteration under the !q->elevator check, which is equivalent (to !hctx->sched_tags).
Quoted 6 lines
Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>--- block/blk-mq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 4/13 blk-mq: Invert check in blk_mq_update_nr_requests()
In reply to John GarryIt's easier to read:
if (x)
X; else Y;
over:
if (!x)
Y; else X;
No functional change intended.
--- block/blk-mq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
block/blk-mq.c +5 -5
@@ -3613,18 +3613,18 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)* If we're using an MQ scheduler, just update the scheduler * queue depth. This is similar to what the old code would do. */ -if (!hctx->sched_tags) { - ret =blk_mq_tag_update_depth (hctx, &hctx->tags, nr, - false); - }else { +if (hctx->sched_tags) { ret =blk_mq_tag_update_depth (hctx, &hctx->sched_tags, - nr, true); + nr, true);if (blk_mq_is_sbitmap_shared (set->flags)) { hctx->sched_tags->bitmap_tags = &q->sched_bitmap_tags; hctx->sched_tags->breserved_tags = &q->sched_breserved_tags; } + }else { + ret =blk_mq_tag_update_depth (hctx, &hctx->tags, nr, + false); }if (ret)break ;
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 04/13] blk-mq: Invert check in blk_mq_update_nr_requests()
Quoted 14 lines · John Garry
It's easier to read:
if (x)
X; else Y;over:
if (!x)
Y; else X;
Quoted 8 lines
No functional change intended.
Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>--- block/blk-mq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 5/13 blk-mq-sched: Rename blk_mq_sched_alloc_{tags -> map_and_rqs}()
In reply to John GarryFunction blk_mq_sched_alloc_tags() does same as __blk_mq_alloc_map_and_request(), so give a similar name to be consistent.
Similarly rename label err_free_tags -> err_free_map_and_rqs.
--- block/blk-mq-sched.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
block/blk-mq-sched.c +7 -7
@@ -515,9 +515,9 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,percpu_ref_put (&q->q_usage_counter); } -static int blk_mq_sched_alloc_tags (struct request_queue *q, -struct blk_mq_hw_ctx *hctx, -unsigned int hctx_idx) +static int blk_mq_sched_alloc_map_and_rqs (struct request_queue *q, +struct blk_mq_hw_ctx *hctx, +unsigned int hctx_idx) {struct blk_mq_tag_set *set = q->tag_set;int ret;
@@ -609,15 +609,15 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) BLKDEV_DEFAULT_RQ);queue_for_each_hw_ctx (q, hctx, i) { - ret =blk_mq_sched_alloc_tags (q, hctx, i); + ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i);if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; }if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { ret =blk_mq_init_sched_shared_sbitmap (q);if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; } ret = e->ops.init_sched (q, e);
@@ -645,8 +645,8 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) err_free_sbitmap:if (blk_mq_is_sbitmap_shared (q->tag_set->flags))blk_mq_exit_sched_shared_sbitmap (q); -err_free_tags:blk_mq_sched_free_requests (q); +err_free_map_and_rqs:blk_mq_sched_tags_teardown (q); q->elevator =NULL ;return ret;
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 05/13] blk-mq-sched: Rename blk_mq_sched_alloc_{tags -> map_and_rqs}()
Quoted 49 lines · John Garry
Function
blk_mq_sched_alloc_tags()does same as__blk_mq_alloc_map_and_request(), so give a similar name to be consistent.Similarly rename label
err_free_tags->err_free_map_and_rqs.Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>--- block/blk-mq-sched.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)block/blk-mq-sched.c +6
-6@@ -515,9 +515,9 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,percpu_ref_put (&q->q_usage_counter); } -static int blk_mq_sched_alloc_tags (struct request_queue *q, -struct blk_mq_hw_ctx *hctx, -unsigned int hctx_idx) +static int blk_mq_sched_alloc_map_and_rqs (struct request_queue *q, +struct blk_mq_hw_ctx *hctx, +unsigned int hctx_idx) {struct blk_mq_tag_set *set = q->tag_set;int ret;@@ -609,15 +609,15 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) BLKDEV_DEFAULT_RQ);queue_for_each_hw_ctx (q, hctx, i) { - ret =blk_mq_sched_alloc_tags (q, hctx, i); + ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i);if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; }if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { ret =blk_mq_init_sched_shared_sbitmap (q);if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; } ret = e->ops.init_sched (q, e);
block/blk-mq-sched.c int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) · line 652
Quoted 9 lines
block/blk-mq-sched.c +1
-1@@ -645,8 +645,8 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) err_free_sbitmap:if (blk_mq_is_sbitmap_shared (q->tag_set->flags))blk_mq_exit_sched_shared_sbitmap (q); -err_free_tags:blk_mq_sched_free_requests (q); +err_free_map_and_rqs:blk_mq_sched_tags_teardown (q); q->elevator =NULL ;return ret;
This is not only a rename, but it also moves the location of the label. Is that intended?
If so it needs some documentation why this is safe.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH RESEND v3 05/13] blk-mq-sched: Rename blk_mq_sched_alloc_{tags -> map_and_rqs}()
Quoted 31 lines
Quoted 31 lines
+static int blk_mq_sched_alloc_map_and_rqs(struct
request_queue*q, + structblk_mq_hw_ctx*hctx,
+ unsigned inthctx_idx)
{
structblk_mq_tag_set*set =q->tag_set;
int ret;block/blk-mq-sched.c +3
-3@@ -609,15 +609,15 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) BLKDEV_DEFAULT_RQ); queue_for_each_hw_ctx(q, hctx, i) { - ret = blk_mq_sched_alloc_tags(q, hctx, i); + ret = blk_mq_sched_alloc_map_and_rqs(q, hctx, i); if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; } if (blk_mq_is_sbitmap_shared(q->tag_set->flags)) { ret = blk_mq_init_sched_shared_sbitmap(q); if (ret) - goto err_free_tags; + goto err_free_map_and_rqs; } ret = e->ops.init_sched(q, e);@@ -645,8 +645,8 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
err_free_sbitmap:
if (blk_mq_is_sbitmap_shared(q->tag_set->flags))blk_mq_exit_sched_shared_sbitmap(q); -err_free_tags:
blk_mq_sched_free_requests(q);
Quoted 8 lines
Quoted 5 lines
+err_free_map_and_rqs:
blk_mq_sched_tags_teardown(q);
q->elevator= NULL;
return ret;This is not only a rename, but it also moves the location of the label. Is that intended?
If so it needs some documentation why this is safe.
Yeah, I think you're right.
The final code in the series looks correct, but this is a transient breakage.
I'll fix it.
Thanks,
John
PATCH RESEND v3 6/13 blk-mq-sched: Rename blk_mq_sched_free_{requests -> rqs}()
In reply to John GarryTo be more concise and consistent in naming, rename blk_mq_sched_free_requests() -> blk_mq_sched_free_rqs().
--- block/blk-core.c | 2 +- block/blk-mq-sched.c | 6 +++--- block/blk-mq-sched.h | 2 +- block/blk.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
block/blk-core.c +1 -1
@@ -406,7 +406,7 @@ void blk_cleanup_queue(struct request_queue *q)*/ mutex_lock (&q->sysfs_lock);if (q->elevator) -blk_mq_sched_free_requests (q); +blk_mq_sched_free_rqs (q);mutex_unlock (&q->sysfs_lock);percpu_ref_exit (&q->q_usage_counter);
block/blk-mq-sched.c +3 -3
@@ -631,7 +631,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) ret = e->ops.init_hctx (hctx, i);if (ret) { eq = q->elevator; -blk_mq_sched_free_requests (q); +blk_mq_sched_free_rqs (q);blk_mq_exit_sched (q, eq);kobject_put (&eq->kobj);return ret;
@@ -645,7 +645,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) err_free_sbitmap:if (blk_mq_is_sbitmap_shared (q->tag_set->flags))blk_mq_exit_sched_shared_sbitmap (q); -blk_mq_sched_free_requests (q); +blk_mq_sched_free_rqs (q); err_free_map_and_rqs:blk_mq_sched_tags_teardown (q); q->elevator =NULL ;
@@ -656,7 +656,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)* called in either blk_queue_cleanup or elevator_switch, tagset * is required for freeing requests */ -void blk_mq_sched_free_requests (struct request_queue *q) +void blk_mq_sched_free_rqs (struct request_queue *q) {struct blk_mq_hw_ctx *hctx;int i;
block/blk-mq-sched.h +1 -1
@@ -28,7 +28,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx);int blk_mq_init_sched (struct request_queue *q,struct elevator_type *e);void blk_mq_exit_sched (struct request_queue *q,struct elevator_queue *e); -void blk_mq_sched_free_requests (struct request_queue *q); +void blk_mq_sched_free_rqs (struct request_queue *q); static inline bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
block/blk.h +1 -1
@@ -200,7 +200,7 @@ static inline void elevator_exit(struct request_queue *q, {lockdep_assert_held (&q->sysfs_lock); -blk_mq_sched_free_requests (q); +blk_mq_sched_free_rqs (q);__elevator_exit (q, e); }
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 06/13] blk-mq-sched: Rename blk_mq_sched_free_{requests -> rqs}()
Quoted 11 lines · John Garry
To be more concise and consistent in naming, rename
blk_mq_sched_free_requests()->blk_mq_sched_free_rqs().Signed-off-by John Garry <[email protected]>--- block/blk-core.c | 2 +- block/blk-mq-sched.c | 6 +++--- block/blk-mq-sched.h | 2 +- block/blk.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 7/13 blk-mq: Pass driver tags to blk_mq_clear_rq_mapping()
In reply to John GarryFunction blk_mq_clear_rq_mapping() will be used for shared sbitmap tags in future, so pass a driver tags pointer instead of the tagset container and HW queue index.
--- block/blk-mq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
block/blk-mq.c +7 -5
@@ -2302,10 +2302,9 @@ static size_t order_to_size(unsigned int order) }/* called before freeing request pool in @tags */ -static void blk_mq_clear_rq_mapping (struct blk_mq_tag_set *set, -struct blk_mq_tags *tags,unsigned int hctx_idx) +static void blk_mq_clear_rq_mapping (struct blk_mq_tags *drv_tags, +struct blk_mq_tags *tags) { -struct blk_mq_tags *drv_tags = set->tags[hctx_idx];struct page *page;unsigned long flags;
@@ -2314,7 +2313,7 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,unsigned long end = start +order_to_size (page->private);int i; -for (i =0 ; i < set->queue_depth; i++) { +for (i =0 ; i < drv_tags->nr_tags; i++) {struct request *rq = drv_tags->rqs[i];unsigned long rq_addr = (unsigned long )rq;
@@ -2338,8 +2337,11 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,void blk_mq_free_rqs (struct blk_mq_tag_set *set,struct blk_mq_tags *tags,unsigned int hctx_idx) { +struct blk_mq_tags *drv_tags;struct page *page; + drv_tags = set->tags[hctx_idx]; +if (tags->static_rqs && set->ops->exit_request) {int i;
@@ -2353,7 +2355,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, } } -blk_mq_clear_rq_mapping (set, tags, hctx_idx); +blk_mq_clear_rq_mapping (drv_tags, tags);while (!list_empty (&tags->page_list)) { page = list_first_entry(&tags->page_list, struct page, lru);
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 07/13] blk-mq: Pass driver tags to blk_mq_clear_rq_mapping()
Quoted 9 lines · John Garry
Function
blk_mq_clear_rq_mapping()will be used for shared sbitmap tags in future, so pass a driver tags pointer instead of the tagset container and HW queue index.Signed-off-by John Garry <[email protected]>--- block/blk-mq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 8/13 blk-mq: Don't clear driver tags own mapping
In reply to John GarryFunction blk_mq_clear_rq_mapping() is required to clear the sched tags mappings in driver tags rqs[].
But there is no need for a driver tags to clear its own mapping, so skip clearing the mapping in this scenario.
--- block/blk-mq.c | 4 ++++ 1 file changed, 4 insertions(+)
block/blk-mq.c +4 -0
@@ -2308,6 +2308,10 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tags *drv_tags,struct page *page;unsigned long flags; +/* There is no need to clear a driver tags own mapping */ +if (drv_tags == tags) +return ; +list_for_each_entry (page, &tags->page_list, lru) {unsigned long start = (unsigned long )page_address (page);unsigned long end = start +order_to_size (page->private);
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 08/13] blk-mq: Don't clear driver tags own mapping
Quoted 17 lines · John Garry
Function
blk_mq_clear_rq_mapping()is required to clear the sched tags mappings in driver tags rqs[].But there is no need for a driver tags to clear its own mapping, so skip clearing the mapping in this scenario.
Signed-off-by John Garry <[email protected]>--- block/blk-mq.c | 4 ++++ 1 file changed, 4 insertions(+)block/blk-mq.c +0
-0
block/blk-mq.c static void blk_mq_clear_rq_mapping(struct blk_mq_tags *drv_tags, · line 2317
Quoted 10 lines
block/blk-mq.c +4
-0@@ -2308,6 +2308,10 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tags *drv_tags,struct page *page;unsigned long flags; +/* There is no need to clear a driver tags own mapping */ +if (drv_tags == tags) +return ; +list_for_each_entry (page, &tags->page_list, lru) {unsigned long start = (unsigned long )page_address (page);unsigned long end = start +order_to_size (page->private);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 9/13 blk-mq: Add blk_mq_tag_update_sched_shared_sbitmap()
In reply to John GarryPut the functionality to update the sched shared sbitmap size in a common function.
Since the same formula is always used to resize, and it can be got from the request queue argument, so just pass the request queue pointer.
--- block/blk-mq-sched.c | 3 +-- block/blk-mq-tag.c | 6 ++++++ block/blk-mq-tag.h | 1 + block/blk-mq.c | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-)
block/blk-mq-sched.c +1 -2
@@ -575,8 +575,7 @@ static int blk_mq_init_sched_shared_sbitmap(struct request_queue *queue) &queue->sched_breserved_tags; } -sbitmap_queue_resize (&queue->sched_bitmap_tags, - queue->nr_requests - set->reserved_tags); +blk_mq_tag_update_sched_shared_sbitmap (queue);return 0 ; }
block/blk-mq-tag.c +6 -0
@@ -634,6 +634,12 @@ void blk_mq_tag_resize_shared_sbitmap(struct blk_mq_tag_set *set, unsigned int ssbitmap_queue_resize (&set->__bitmap_tags, size - set->reserved_tags); } +void blk_mq_tag_update_sched_shared_sbitmap (struct request_queue *q) +{ +sbitmap_queue_resize (&q->sched_bitmap_tags, + q->nr_requests - q->tag_set->reserved_tags); +} +/** * blk_mq_unique_tag() - return a tag that is unique queue-wide * @rq: request for which to compute a unique tag
block/blk-mq-tag.h +1 -0
@@ -48,6 +48,7 @@ extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx, unsigned int depth, bool can_grow);extern void blk_mq_tag_resize_shared_sbitmap (struct blk_mq_tag_set *set,unsigned int size); +extern void blk_mq_tag_update_sched_shared_sbitmap (struct request_queue *q);extern void blk_mq_tag_wakeup_all (struct blk_mq_tags *tags,bool ); void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn,
block/blk-mq.c +1 -2
@@ -3641,8 +3641,7 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) q->nr_requests = nr;if (blk_mq_is_sbitmap_shared (set->flags)) {if (q->elevator) -sbitmap_queue_resize (&q->sched_bitmap_tags, - nr - set->reserved_tags); +blk_mq_tag_update_sched_shared_sbitmap (q);else blk_mq_tag_resize_shared_sbitmap (set, nr); }
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 09/13] blk-mq: Add blk_mq_tag_update_sched_shared_sbitmap()
Quoted 8 lines · John Garry
Put the functionality to update the sched shared sbitmap size in a common function.
Since the same formula is always used to resize, and it can be got from the request queue argument, so just pass the request queue pointer.
Signed-off-by John Garry <[email protected]>Reviewed-by Ming Lei <[email protected]>
Quoted 7 lines
--- block/blk-mq-sched.c | 3 +-- block/blk-mq-tag.c | 6 ++++++ block/blk-mq-tag.h | 1 + block/blk-mq.c | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-)Reviewed-by Hannes Reinecke <[email protected]>
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 10/13 blk-mq: Add blk_mq_alloc_map_and_rqs()
In reply to John GarryAdd a function to combine allocating tags and the associated requests, and factor out common patterns to use this new function.
Some functions only call blk_mq_alloc_map_and_rqs() now, but more functionality will be added later to those functions.
Also make blk_mq_alloc_rq_map() and blk_mq_alloc_rqs() static since they are only used in blk-mq.c, and finally rename some functions for conciseness and consistency with other function names:
- __blk_mq_alloc_map_and_{request -> rqs}()
- blk_mq_alloc_{map_and_requests -> set_map_and_rqs}()
--- block/blk-mq-sched.c | 15 +++-------- block/blk-mq-tag.c | 9 +------ block/blk-mq.c | 62 +++++++++++++++++++++++++------------------- block/blk-mq.h | 9 ++----- 4 files changed, 42 insertions(+), 53 deletions(-)
block/blk-mq-sched.c +3 -12
@@ -519,21 +519,12 @@ static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q, struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) { -struct blk_mq_tag_set *set = q->tag_set; -int ret; + hctx->sched_tags =blk_mq_alloc_map_and_rqs (q->tag_set, hctx_idx, + q->nr_requests); - hctx->sched_tags =blk_mq_alloc_rq_map (set, hctx_idx, q->nr_requests, - set->reserved_tags, set->flags);if (!hctx->sched_tags)return -ENOMEM ; - - ret =blk_mq_alloc_rqs (set, hctx->sched_tags, hctx_idx, q->nr_requests); -if (ret) { -blk_mq_free_rq_map (hctx->sched_tags, set->flags); - hctx->sched_tags =NULL ; - } - -return ret; +return 0 ; }/* called in queue's release handler, tagset has gone away */
block/blk-mq-tag.c +1 -8
@@ -592,7 +592,6 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,if (tdepth > tags->nr_tags) {struct blk_mq_tag_set *set = hctx->queue->tag_set;struct blk_mq_tags *new; -bool ret;if (!can_grow)return -EINVAL ;
@@ -604,15 +603,9 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,if (tdepth >MAX_SCHED_RQ )return -EINVAL ; - new =blk_mq_alloc_rq_map (set, hctx->queue_num, tdepth, - tags->nr_reserved_tags, set->flags); + new =blk_mq_alloc_map_and_rqs (set, hctx->queue_num, tdepth);if (!new)return -ENOMEM ; - ret =blk_mq_alloc_rqs (set, new, hctx->queue_num, tdepth); -if (ret) { -blk_mq_free_rq_map (new, set->flags); -return -ENOMEM ; - }blk_mq_free_rqs (set, *tagsptr, hctx->queue_num);blk_mq_free_rq_map (*tagsptr, set->flags);
block/blk-mq.c +36 -26
108 lines not on this page · raw message
block/blk-mq.h +2 -7
@@ -55,13 +55,8 @@ void blk_mq_put_rq_ref(struct request *rq);void blk_mq_free_rqs (struct blk_mq_tag_set *set,struct blk_mq_tags *tags,unsigned int hctx_idx);void blk_mq_free_rq_map (struct blk_mq_tags *tags,unsigned int flags); -struct blk_mq_tags *blk_mq_alloc_rq_map (struct blk_mq_tag_set *set, -unsigned int hctx_idx, -unsigned int nr_tags, -unsigned int reserved_tags, -unsigned int flags); -int blk_mq_alloc_rqs (struct blk_mq_tag_set *set,struct blk_mq_tags *tags, -unsigned int hctx_idx,unsigned int depth); +struct blk_mq_tags *blk_mq_alloc_map_and_rqs (struct blk_mq_tag_set *set, +unsigned int hctx_idx,unsigned int depth);/* * Internal helpers for request insertion into sw queues
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 10/13] blk-mq: Add blk_mq_alloc_map_and_rqs()
Quoted 14 lines · John Garry
Add a function to combine allocating tags and the associated requests, and factor out common patterns to use this new function.
Some functions only call
blk_mq_alloc_map_and_rqs()now, but more functionality will be added later to those functions.Also make
blk_mq_alloc_rq_map()andblk_mq_alloc_rqs()static since they are only used inblk-mq.c, and finally rename some functions for conciseness and consistency with other function names:
- __blk_mq_alloc_map_and_{request -> rqs}()
- blk_mq_alloc_{map_and_requests -> set_map_and_rqs}()Suggested-by Ming Lei <[email protected]>Signed-off-by John Garry <[email protected]>
Quoted 7 lines
--- block/blk-mq-sched.c | 15 +++-------- block/blk-mq-tag.c | 9 +------ block/blk-mq.c | 62 +++++++++++++++++++++++++------------------- block/blk-mq.h | 9 ++----- 4 files changed, 42 insertions(+), 53 deletions(-)Reviewed-by Hannes Reinecke <[email protected]>
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 11/13 blk-mq: Refactor and rename blk_mq_free_map_and_{requests->rqs}()
In reply to John GarryRefactor blk_mq_free_map_and_requests() such that it can be used at many sites at which the tag map and rqs are freed.
Also rename to blk_mq_free_map_and_rqs(), which is shorter and matches the alloc equivalent.
--- block/blk-mq-tag.c | 3 +-- block/blk-mq.c | 40 ++++++++++++++++++++++++---------------- block/blk-mq.h | 4 +++- 3 files changed, 28 insertions(+), 19 deletions(-)
block/blk-mq-tag.c +1 -2
@@ -607,8 +607,7 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,if (!new)return -ENOMEM ; -blk_mq_free_rqs (set, *tagsptr, hctx->queue_num); -blk_mq_free_rq_map (*tagsptr, set->flags); +blk_mq_free_map_and_rqs (set, *tagsptr, hctx->queue_num); *tagsptr = new; }else {/*
block/blk-mq.c +24 -16
@@ -2878,15 +2878,15 @@ static bool __blk_mq_alloc_map_and_rqs(struct blk_mq_tag_set *set,return set->tags[hctx_idx]; } -static void blk_mq_free_map_and_requests (struct blk_mq_tag_set *set, -unsigned int hctx_idx) +void blk_mq_free_map_and_rqs (struct blk_mq_tag_set *set, +struct blk_mq_tags *tags, +unsigned int hctx_idx) {unsigned int flags = set->flags; -if (set->tags && set->tags[hctx_idx]) { -blk_mq_free_rqs (set, set->tags[hctx_idx], hctx_idx); -blk_mq_free_rq_map (set->tags[hctx_idx], flags); - set->tags[hctx_idx] =NULL ; +if (tags) { +blk_mq_free_rqs (set, tags, hctx_idx); +blk_mq_free_rq_map (tags, flags); } }
@@ -2967,8 +2967,10 @@ static void blk_mq_map_swqueue(struct request_queue *q)* fallback in case of a new remap fails * allocation */ -if (i && set->tags[i]) -blk_mq_free_map_and_requests (set, i); +if (i && set->tags[i]) { +blk_mq_free_map_and_rqs (set, set->tags[i], i); + set->tags[i] =NULL ; + } hctx->tags =NULL ;continue ;
@@ -3264,8 +3266,8 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,struct blk_mq_hw_ctx *hctx = hctxs[j];if (hctx) { -if (hctx->tags) -blk_mq_free_map_and_requests (set, j); +blk_mq_free_map_and_rqs (set, set->tags[j], j); + set->tags[j] =NULL ;blk_mq_exit_hctx (q, set, hctx, j); hctxs[j] =NULL ; }
@@ -3361,8 +3363,10 @@ static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)return 0 ; out_unwind: -while (--i >=0 ) -blk_mq_free_map_and_requests (set, i); +while (--i >=0 ) { +blk_mq_free_map_and_rqs (set, set->tags[i], i); + set->tags[i] =NULL ; + }return -ENOMEM ; }
@@ -3557,8 +3561,10 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)return 0 ; out_free_mq_rq_maps: -for (i =0 ; i < set->nr_hw_queues; i++) -blk_mq_free_map_and_requests (set, i); +for (i =0 ; i < set->nr_hw_queues; i++) { +blk_mq_free_map_and_rqs (set, set->tags[i], i); + set->tags[i] =NULL ; + } out_free_mq_map:for (i =0 ; i < set->nr_maps; i++) {kfree (set->map[i].mq_map);
@@ -3590,8 +3596,10 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set) {int i, j; -for (i =0 ; i < set->nr_hw_queues; i++) -blk_mq_free_map_and_requests (set, i); +for (i =0 ; i < set->nr_hw_queues; i++) { +blk_mq_free_map_and_rqs (set, set->tags[i], i); + set->tags[i] =NULL ; + }if (blk_mq_is_sbitmap_shared (set->flags))blk_mq_exit_shared_sbitmap (set);
block/blk-mq.h +3 -1
@@ -57,7 +57,9 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,void blk_mq_free_rq_map (struct blk_mq_tags *tags,unsigned int flags);struct blk_mq_tags *blk_mq_alloc_map_and_rqs (struct blk_mq_tag_set *set,unsigned int hctx_idx,unsigned int depth); - +void blk_mq_free_map_and_rqs (struct blk_mq_tag_set *set, +struct blk_mq_tags *tags, +unsigned int hctx_idx);/* * Internal helpers for request insertion into sw queues */
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 11/13] blk-mq: Refactor and rename blk_mq_free_map_and_{requests->rqs}()
Quoted 6 lines · John Garry
Refactor
blk_mq_free_map_and_requests()such that it can be used at many sites at which the tag map and rqs are freed.Also rename to
blk_mq_free_map_and_rqs(), which is shorter and matches the alloc equivalent.
Quoted 8 lines
Suggested-by Ming Lei <[email protected]>Signed-off-by John Garry <[email protected]>--- block/blk-mq-tag.c | 3 +-- block/blk-mq.c | 40 ++++++++++++++++++++++++---------------- block/blk-mq.h | 4 +++- 3 files changed, 28 insertions(+), 19 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH RESEND v3 12/13 blk-mq: Use shared tags for shared sbitmap support
In reply to John GarryCurrently we use separate sbitmap pairs and active_queues atomic_t for shared sbitmap support.
However a full sets of static requests are used per HW queue, which is quite wasteful, considering that the total number of requests usable at any given time across all HW queues is limited by the shared sbitmap depth.
As such, it is considerably more memory efficient in the case of shared sbitmap to allocate a set of static rqs per tag set or request queue, and not per HW queue.
So replace the sbitmap pairs and active_queues atomic_t with a shared tags per tagset and request queue, which will hold a set of shared static rqs.
Since there is now no valid HW queue index to be passed to the blk_mq_ops .init and .exit_request callbacks, pass an invalid index token. This changes the semantics of the APIs, such that the callback would need to validate the HW queue index before using it. Currently no user of shared sbitmap actually uses the HW queue index (as would be expected).
Continue to use term "shared sbitmap" for now, as the meaning is known.
--- block/blk-mq-sched.c | 84 +++++++++++++++++++------------------- block/blk-mq-tag.c | 61 +++++++++------------------- block/blk-mq-tag.h | 6 +-- block/blk-mq.c | 92 ++++++++++++++++++++++++------------------ block/blk-mq.h | 5 ++- include/linux/blk-mq.h | 15 ++++--- include/linux/blkdev.h | 3 +- 7 files changed, 127 insertions(+), 139 deletions(-)
block/blk-mq-sched.c +42 -42
@@ -519,6 +519,11 @@ static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q,struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) { + if (blk_mq_is_sbitmap_shared(q->tag_set->flags)) { + hctx->sched_tags = q->shared_sbitmap_tags; +return 0 ; + } + hctx->sched_tags =blk_mq_alloc_map_and_rqs (q->tag_set, hctx_idx, q->nr_requests);
@@ -527,61 +532,54 @@ static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q,return 0 ; } +static void blk_mq_exit_sched_shared_sbitmap (struct request_queue *queue) +{ +blk_mq_free_rq_map (queue->shared_sbitmap_tags); + queue->shared_sbitmap_tags =NULL ; +} +/* called in queue's release handler, tagset has gone away */ -static void blk_mq_sched_tags_teardown (struct request_queue *q) +static void blk_mq_sched_tags_teardown (struct request_queue *q,unsigned int flags) {struct blk_mq_hw_ctx *hctx;int i;queue_for_each_hw_ctx (q, hctx, i) {if (hctx->sched_tags) { -blk_mq_free_rq_map (hctx->sched_tags, hctx->flags); +if (!blk_mq_is_sbitmap_shared (q->tag_set->flags)) +blk_mq_free_rq_map (hctx->sched_tags); hctx->sched_tags =NULL ; } } + +if (blk_mq_is_sbitmap_shared (flags)) +blk_mq_exit_sched_shared_sbitmap (q); }static int blk_mq_init_sched_shared_sbitmap (struct request_queue *queue) {struct blk_mq_tag_set *set = queue->tag_set; -int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags); -struct blk_mq_hw_ctx *hctx; -int ret, i;/* * Set initial depth at max so that we don't need to reallocate for * updating nr_requests. */ - ret =blk_mq_init_bitmaps (&queue->sched_bitmap_tags, - &queue->sched_breserved_tags, -MAX_SCHED_RQ , set->reserved_tags, - set->numa_node, alloc_policy); -if (ret) -return ret; - -queue_for_each_hw_ctx (queue, hctx, i) { - hctx->sched_tags->bitmap_tags = - &queue->sched_bitmap_tags; - hctx->sched_tags->breserved_tags = - &queue->sched_breserved_tags; - } + queue->shared_sbitmap_tags =blk_mq_alloc_map_and_rqs (set, +BLK_MQ_NO_HCTX_IDX , +MAX_SCHED_RQ ); +if (!queue->shared_sbitmap_tags) +return -ENOMEM ;blk_mq_tag_update_sched_shared_sbitmap (queue);return 0 ; } -static void blk_mq_exit_sched_shared_sbitmap (struct request_queue *queue) -{ -sbitmap_queue_free (&queue->sched_bitmap_tags); -sbitmap_queue_free (&queue->sched_breserved_tags); -} -int blk_mq_init_sched (struct request_queue *q,struct elevator_type *e) { +unsigned int i, flags = q->tag_set->flags;struct blk_mq_hw_ctx *hctx;struct elevator_queue *eq; -unsigned int i;int ret;if (!e) {
@@ -598,21 +596,21 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth,BLKDEV_DEFAULT_RQ ); -queue_for_each_hw_ctx (q, hctx, i) { - ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i); +if (blk_mq_is_sbitmap_shared (flags)) { + ret =blk_mq_init_sched_shared_sbitmap (q);if (ret) - goto err_free_map_and_rqs; +return ret; } -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { - ret =blk_mq_init_sched_shared_sbitmap (q); +queue_for_each_hw_ctx (q, hctx, i) { + ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i);if (ret) goto err_free_map_and_rqs; } ret = e->ops.init_sched (q, e);if (ret) - goto err_free_sbitmap; + goto err_free_map_and_rqs;blk_mq_debugfs_register_sched (q);
@@ -632,12 +630,10 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)return 0 ; -err_free_sbitmap: -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) -blk_mq_exit_sched_shared_sbitmap (q); -blk_mq_sched_free_rqs (q); err_free_map_and_rqs: -blk_mq_sched_tags_teardown (q); +blk_mq_sched_free_rqs (q); +blk_mq_sched_tags_teardown (q, flags); + q->elevator =NULL ;return ret; }
@@ -651,9 +647,15 @@ void blk_mq_sched_free_rqs(struct request_queue *q)struct blk_mq_hw_ctx *hctx;int i; -queue_for_each_hw_ctx (q, hctx, i) { -if (hctx->sched_tags) -blk_mq_free_rqs (q->tag_set, hctx->sched_tags, i); +if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { +blk_mq_free_rqs (q->tag_set, q->shared_sbitmap_tags, +BLK_MQ_NO_HCTX_IDX ); + }else { +queue_for_each_hw_ctx (q, hctx, i) { +if (hctx->sched_tags) +blk_mq_free_rqs (q->tag_set, + hctx->sched_tags, i); + } } }
@@ -674,8 +676,6 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)blk_mq_debugfs_unregister_sched (q);if (e->type->ops.exit_sched) e->type->ops.exit_sched (e); -blk_mq_sched_tags_teardown (q); -if (blk_mq_is_sbitmap_shared (flags)) -blk_mq_exit_sched_shared_sbitmap (q); +blk_mq_sched_tags_teardown (q, flags); q->elevator =NULL ; }
block/blk-mq-tag.c +20 -41
117 lines not on this page · raw message
block/blk-mq-tag.h +2 -4
@@ -30,16 +30,14 @@ struct blk_mq_tags {extern struct blk_mq_tags *blk_mq_init_tags (unsigned int nr_tags,unsigned int reserved_tags, -int node,unsigned int flags); -extern void blk_mq_free_tags (struct blk_mq_tags *tags,unsigned int flags); +int node,int alloc_policy); +extern void blk_mq_free_tags (struct blk_mq_tags *tags);extern int blk_mq_init_bitmaps (struct sbitmap_queue *bitmap_tags,struct sbitmap_queue *breserved_tags,unsigned int queue_depth,unsigned int reserved,int node,int alloc_policy); -extern int blk_mq_init_shared_sbitmap (struct blk_mq_tag_set *set); -extern void blk_mq_exit_shared_sbitmap (struct blk_mq_tag_set *set);extern unsigned int blk_mq_get_tag (struct blk_mq_alloc_data *data);extern void blk_mq_put_tag (struct blk_mq_tags *tags,struct blk_mq_ctx *ctx,unsigned int tag);
block/blk-mq.c +52 -40
220 lines not on this page · raw message
block/blk-mq.h +3 -2
@@ -54,7 +54,7 @@ void blk_mq_put_rq_ref(struct request *rq);*/ void blk_mq_free_rqs (struct blk_mq_tag_set *set,struct blk_mq_tags *tags,unsigned int hctx_idx); -void blk_mq_free_rq_map (struct blk_mq_tags *tags,unsigned int flags); +void blk_mq_free_rq_map (struct blk_mq_tags *tags);struct blk_mq_tags *blk_mq_alloc_map_and_rqs (struct blk_mq_tag_set *set,unsigned int hctx_idx,unsigned int depth); void blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,
@@ -331,10 +331,11 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,if (blk_mq_is_sbitmap_shared (hctx->flags)) {struct request_queue *q = hctx->queue;struct blk_mq_tag_set *set = q->tag_set; +struct blk_mq_tags *tags = set->shared_sbitmap_tags;if (!test_bit (QUEUE_FLAG_HCTX_ACTIVE , &q->queue_flags))return true; - users =atomic_read (&set->active_queues_shared_sbitmap); + users =atomic_read (&tags->active_queues); }else {if (!test_bit (BLK_MQ_S_TAG_ACTIVE , &hctx->state))return true;
include/linux/blk-mq.h +7 -8
@@ -232,13 +232,11 @@ enum hctx_type {* @flags: Zero or more BLK_MQ_F_* flags. * @driver_data: Pointer to data owned by the block driver that created this * tag set. -* @active_queues_shared_sbitmap: -* number of active request queues per tag set. -* @__bitmap_tags: A shared tags sbitmap, used over all hctx's -* @__breserved_tags: -* A shared reserved tags sbitmap, used over all hctx's * @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues * elements. +* @shared_sbitmap_tags: +* Shared sbitmap set of tags. Has @nr_hw_queues elements. If +* set, shared by all @tags. * @tag_list_lock: Serializes tag_list accesses. * @tag_list: List of the request queues that use this tag set. See also * request_queue.tag_set_list.
@@ -255,12 +253,11 @@ struct blk_mq_tag_set {unsigned int timeout;unsigned int flags;void *driver_data; -atomic_t active_queues_shared_sbitmap; -struct sbitmap_queue __bitmap_tags; -struct sbitmap_queue __breserved_tags;struct blk_mq_tags **tags; +struct blk_mq_tags *shared_sbitmap_tags; +struct mutex tag_list_lock;struct list_head tag_list; };
@@ -432,6 +429,8 @@ enum { ((policy & ((1 <<BLK_MQ_F_ALLOC_POLICY_BITS ) -1 )) \ << BLK_MQ_F_ALLOC_POLICY_START_BIT) +#define BLK_MQ_NO_HCTX_IDX (-1U) +struct gendisk *__blk_mq_alloc_disk (struct blk_mq_tag_set *set,void *queuedata,struct lock_class_key *lkclass);#define blk_mq_alloc_disk (set, queuedata) \
include/linux/blkdev.h +1 -2
@@ -459,8 +459,7 @@ struct request_queue {atomic_t nr_active_requests_shared_sbitmap; -struct sbitmap_queue sched_bitmap_tags; -struct sbitmap_queue sched_breserved_tags; +struct blk_mq_tags *shared_sbitmap_tags;struct list_head icq_list;#ifdef CONFIG_BLK_CGROUP
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 12/13] blk-mq: Use shared tags for shared sbitmap support
Quoted 100 lines · John Garry
Currently we use separate sbitmap pairs and
active_queuesatomic_tfor shared sbitmap support.However a full sets of static requests are used per HW queue, which is quite wasteful, considering that the total number of requests usable at any given time across all HW queues is limited by the shared sbitmap depth.
As such, it is considerably more memory efficient in the case of shared sbitmap to allocate a set of static rqs per tag set or request queue, and not per HW queue.
So replace the sbitmap pairs and
active_queuesatomic_twith a shared tags per tagset and request queue, which will hold a set of shared static rqs.Since there is now no valid HW queue index to be passed to the
blk_mq_ops.init and .exit_request callbacks, pass an invalid index token. This changes the semantics of the APIs, such that the callback would need to validate the HW queue index before using it. Currently no user of shared sbitmap actually uses the HW queue index (as would be expected).Continue to use term "shared sbitmap" for now, as the meaning is known.
Signed-off-by John Garry <[email protected]>--- block/blk-mq-sched.c | 84 +++++++++++++++++++------------------- block/blk-mq-tag.c | 61 +++++++++------------------- block/blk-mq-tag.h | 6 +-- block/blk-mq.c | 92 ++++++++++++++++++++++++------------------ block/blk-mq.h | 5 ++- include/linux/blk-mq.h | 15 ++++--- include/linux/blkdev.h | 3 +- 7 files changed, 127 insertions(+), 139 deletions(-)block/blk-mq-sched.c +17
-14@@ -519,6 +519,11 @@ static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q,struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) { + if (blk_mq_is_sbitmap_shared(q->tag_set->flags)) { + hctx->sched_tags = q->shared_sbitmap_tags; +return 0 ; + } + hctx->sched_tags =blk_mq_alloc_map_and_rqs (q->tag_set, hctx_idx, q->nr_requests);@@ -527,61 +532,54 @@ static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q,return 0 ; } +static void blk_mq_exit_sched_shared_sbitmap (struct request_queue *queue) +{ +blk_mq_free_rq_map (queue->shared_sbitmap_tags); + queue->shared_sbitmap_tags =NULL ; +} +/* called in queue's release handler, tagset has gone away */ -static void blk_mq_sched_tags_teardown (struct request_queue *q) +static void blk_mq_sched_tags_teardown (struct request_queue *q,unsigned int flags) {struct blk_mq_hw_ctx *hctx;int i;queue_for_each_hw_ctx (q, hctx, i) {if (hctx->sched_tags) { -blk_mq_free_rq_map (hctx->sched_tags, hctx->flags); +if (!blk_mq_is_sbitmap_shared (q->tag_set->flags)) +blk_mq_free_rq_map (hctx->sched_tags); hctx->sched_tags =NULL ; } } + +if (blk_mq_is_sbitmap_shared (flags)) +blk_mq_exit_sched_shared_sbitmap (q); }static int blk_mq_init_sched_shared_sbitmap (struct request_queue *queue) {struct blk_mq_tag_set *set = queue->tag_set; -int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags); -struct blk_mq_hw_ctx *hctx; -int ret, i;/* * Set initial depth at max so that we don't need to reallocate for * updating nr_requests. */ - ret =blk_mq_init_bitmaps (&queue->sched_bitmap_tags, - &queue->sched_breserved_tags, -MAX_SCHED_RQ , set->reserved_tags, - set->numa_node, alloc_policy); -if (ret) -return ret; - -queue_for_each_hw_ctx (queue, hctx, i) { - hctx->sched_tags->bitmap_tags =
block/blk-mq-sched.c static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q, · line 572
Quoted 10 lines
block/blk-mq-sched.c +5
-4- &queue->sched_bitmap_tags; - hctx->sched_tags->breserved_tags = - &queue->sched_breserved_tags; - } + queue->shared_sbitmap_tags =blk_mq_alloc_map_and_rqs (set, +BLK_MQ_NO_HCTX_IDX , +MAX_SCHED_RQ ); +if (!queue->shared_sbitmap_tags) +return -ENOMEM ;
Any particular reason why the 'shared_sbitmap_tags' pointer is added to the request queue and not the tagset? Everything else is located there, so I would have found it more logical
to add the 'shared_sbitmap_tags' pointer to the tagset, not the queue ...
Quoted 64 lines
block/blk-mq-sched.c +10
-18blk_mq_tag_update_sched_shared_sbitmap (queue);return 0 ; } -static void blk_mq_exit_sched_shared_sbitmap (struct request_queue *queue) -{ -sbitmap_queue_free (&queue->sched_bitmap_tags); -sbitmap_queue_free (&queue->sched_breserved_tags); -} -int blk_mq_init_sched (struct request_queue *q,struct elevator_type *e) { +unsigned int i, flags = q->tag_set->flags;struct blk_mq_hw_ctx *hctx;struct elevator_queue *eq; -unsigned int i;int ret;if (!e) {@@ -598,21 +596,21 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth,BLKDEV_DEFAULT_RQ ); -queue_for_each_hw_ctx (q, hctx, i) { - ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i); +if (blk_mq_is_sbitmap_shared (flags)) { + ret = blk_mq_init_sched_shared_sbitmap(q); > if (ret) - goto err_free_map_and_rqs; +return ret; } -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { - ret =blk_mq_init_sched_shared_sbitmap (q); +queue_for_each_hw_ctx (q, hctx, i) { + ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i);if (ret) goto err_free_map_and_rqs; } ret = e->ops.init_sched (q, e);if (ret) - goto err_free_sbitmap; + goto err_free_map_and_rqs;blk_mq_debugfs_register_sched (q);@@ -632,12 +630,10 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)return 0 ; -err_free_sbitmap: -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) -blk_mq_exit_sched_shared_sbitmap (q); -blk_mq_sched_free_rqs (q); err_free_map_and_rqs: -blk_mq_sched_tags_teardown (q); +blk_mq_sched_free_rqs (q); +blk_mq_sched_tags_teardown (q, flags); + q->elevator =NULL ;return ret; }
block/blk-mq-sched.c void blk_mq_sched_free_rqs(struct request_queue *q) · line 652
Quoted 9 lines
block/blk-mq-sched.c +3
-3@@ -651,9 +647,15 @@ void blk_mq_sched_free_rqs(struct request_queue *q)struct blk_mq_hw_ctx *hctx;int i; -queue_for_each_hw_ctx (q, hctx, i) { -if (hctx->sched_tags) -blk_mq_free_rqs (q->tag_set, hctx->sched_tags, i); +if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { +blk_mq_free_rqs (q->tag_set, q->shared_sbitmap_tags, +BLK_MQ_NO_HCTX_IDX );
'if (q->shared_sbitmap_tags)'
would be more obvious here ...
Quoted 187 lines
block/blk-mq-sched.c +7
-3+ }else { +queue_for_each_hw_ctx (q, hctx, i) { +if (hctx->sched_tags) +blk_mq_free_rqs (q->tag_set, + hctx->sched_tags, i); + } } }@@ -674,8 +676,6 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)blk_mq_debugfs_unregister_sched (q);if (e->type->ops.exit_sched) e->type->ops.exit_sched (e); -blk_mq_sched_tags_teardown (q); -if (blk_mq_is_sbitmap_shared (flags)) -blk_mq_exit_sched_shared_sbitmap (q); +blk_mq_sched_tags_teardown (q, flags); q->elevator =NULL ; }block/blk-mq-tag.c +20
-41@@ -27,10 +27,11 @@ bool __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)if (blk_mq_is_sbitmap_shared (hctx->flags)) {struct request_queue *q = hctx->queue;struct blk_mq_tag_set *set = q->tag_set; +struct blk_mq_tags *tags = set->shared_sbitmap_tags;if (!test_bit (QUEUE_FLAG_HCTX_ACTIVE , &q->queue_flags) && !test_and_set_bit (QUEUE_FLAG_HCTX_ACTIVE , &q->queue_flags)) -atomic_inc (&set->active_queues_shared_sbitmap); +atomic_inc (&tags->active_queues); }else {if (!test_bit (BLK_MQ_S_TAG_ACTIVE , &hctx->state) && !test_and_set_bit (BLK_MQ_S_TAG_ACTIVE , &hctx->state))@@ -61,10 +62,12 @@ void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)struct blk_mq_tag_set *set = q->tag_set;if (blk_mq_is_sbitmap_shared (hctx->flags)) { +struct blk_mq_tags *tags = set->shared_sbitmap_tags; +if (!test_and_clear_bit (QUEUE_FLAG_HCTX_ACTIVE , &q->queue_flags))return ; -atomic_dec (&set->active_queues_shared_sbitmap); +atomic_dec (&tags->active_queues); }else {if (!test_and_clear_bit (BLK_MQ_S_TAG_ACTIVE , &hctx->state))return ;@@ -510,38 +513,10 @@ static int blk_mq_init_bitmap_tags(struct blk_mq_tags *tags,return 0 ; } -int blk_mq_init_shared_sbitmap (struct blk_mq_tag_set *set) -{ -int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags); -int i, ret; - - ret =blk_mq_init_bitmaps (&set->__bitmap_tags, &set->__breserved_tags, - set->queue_depth, set->reserved_tags, - set->numa_node, alloc_policy); -if (ret) -return ret; - -for (i =0 ; i < set->nr_hw_queues; i++) { -struct blk_mq_tags *tags = set->tags[i]; - - tags->bitmap_tags = &set->__bitmap_tags; - tags->breserved_tags = &set->__breserved_tags; - } - -return 0 ; -} - -void blk_mq_exit_shared_sbitmap (struct blk_mq_tag_set *set) -{ -sbitmap_queue_free (&set->__bitmap_tags); -sbitmap_queue_free (&set->__breserved_tags); -} -struct blk_mq_tags *blk_mq_init_tags (unsigned int total_tags,unsigned int reserved_tags, -int node,unsigned int flags) +int node,int alloc_policy) { -int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (flags);struct blk_mq_tags *tags;if (total_tags >BLK_MQ_TAG_MAX ) {@@ -557,9 +532,6 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags, tags->nr_reserved_tags = reserved_tags;spin_lock_init (&tags->lock); -if (blk_mq_is_sbitmap_shared (flags)) -return tags; -if (blk_mq_init_bitmap_tags (tags, node, alloc_policy) <0 ) {kfree (tags);return NULL ;@@ -567,12 +539,10 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,return tags; } -void blk_mq_free_tags (struct blk_mq_tags *tags,unsigned int flags) +void blk_mq_free_tags (struct blk_mq_tags *tags) { -if (!blk_mq_is_sbitmap_shared (flags)) { -sbitmap_queue_free (tags->bitmap_tags); -sbitmap_queue_free (tags->breserved_tags); - } +sbitmap_queue_free (tags->bitmap_tags); +sbitmap_queue_free (tags->breserved_tags);kfree (tags); }@@ -603,6 +573,13 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,if (tdepth >MAX_SCHED_RQ )return -EINVAL ; +/* +* Only the sbitmap needs resizing since we allocated the max +* initially. +*/ +if (blk_mq_is_sbitmap_shared (set->flags)) +return 0 ; + new =blk_mq_alloc_map_and_rqs (set, hctx->queue_num, tdepth);if (!new)return -ENOMEM ;@@ -623,12 +600,14 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,void blk_mq_tag_resize_shared_sbitmap (struct blk_mq_tag_set *set,unsigned int size) { -sbitmap_queue_resize (&set->__bitmap_tags, size - set->reserved_tags); +struct blk_mq_tags *tags = set->shared_sbitmap_tags; + +sbitmap_queue_resize (&tags->__bitmap_tags, size - set->reserved_tags); }void blk_mq_tag_update_sched_shared_sbitmap (struct request_queue *q) { -sbitmap_queue_resize (&q->sched_bitmap_tags, +sbitmap_queue_resize (q->shared_sbitmap_tags->bitmap_tags, q->nr_requests - q->tag_set->reserved_tags); }block/blk-mq-tag.h +2
-4@@ -30,16 +30,14 @@ struct blk_mq_tags {extern struct blk_mq_tags *blk_mq_init_tags (unsigned int nr_tags,unsigned int reserved_tags, -int node,unsigned int flags); -extern void blk_mq_free_tags (struct blk_mq_tags *tags,unsigned int flags); +int node,int alloc_policy); +extern void blk_mq_free_tags (struct blk_mq_tags *tags);extern int blk_mq_init_bitmaps (struct sbitmap_queue *bitmap_tags,struct sbitmap_queue *breserved_tags,unsigned int queue_depth,unsigned int reserved,int node,int alloc_policy); -extern int blk_mq_init_shared_sbitmap (struct blk_mq_tag_set *set); -extern void blk_mq_exit_shared_sbitmap (struct blk_mq_tag_set *set);extern unsigned int blk_mq_get_tag (struct blk_mq_alloc_data *data);extern void blk_mq_put_tag (struct blk_mq_tags *tags,struct blk_mq_ctx *ctx,unsigned int tag);block/blk-mq.c +4
-1@@ -2344,7 +2344,10 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,struct blk_mq_tags *drv_tags;struct page *page; - drv_tags = set->tags[hctx_idx]; +if (blk_mq_is_sbitmap_shared (set->flags)) + drv_tags = set->shared_sbitmap_tags; +else + drv_tags = set->tags[hctx_idx];if (tags->static_rqs && set->ops->exit_request) {int i;
block/blk-mq.c void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, · line 2363
Quoted 7 lines
block/blk-mq.c +1
-0@@ -2354,6 +2357,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,if (!rq)continue ; + set->ops->exit_request (set, rq, hctx_idx); tags->static_rqs[i] =NULL ; }
Just adding a newline?
Quoted 293 lines
block/blk-mq.c +47
-39@@ -2373,21 +2377,20 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, } } -void blk_mq_free_rq_map (struct blk_mq_tags *tags,unsigned int flags) +void blk_mq_free_rq_map (struct blk_mq_tags *tags) {kfree (tags->rqs); tags->rqs =NULL ;kfree (tags->static_rqs); tags->static_rqs =NULL ; -blk_mq_free_tags (tags, flags); +blk_mq_free_tags (tags); }static struct blk_mq_tags *blk_mq_alloc_rq_map (struct blk_mq_tag_set *set,unsigned int hctx_idx,unsigned int nr_tags, -unsigned int reserved_tags, -unsigned int flags) +unsigned int reserved_tags) {struct blk_mq_tags *tags;int node;@@ -2396,7 +2399,8 @@ static struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,if (node ==NUMA_NO_NODE ) node = set->numa_node; - tags =blk_mq_init_tags (nr_tags, reserved_tags, node, flags); + tags =blk_mq_init_tags (nr_tags, reserved_tags, node, +BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags));if (!tags)return NULL ;@@ -2404,7 +2408,7 @@ static struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, node);if (!tags->rqs) { -blk_mq_free_tags (tags, flags); +blk_mq_free_tags (tags);return NULL ; }@@ -2413,7 +2417,7 @@ static struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, node);if (!tags->static_rqs) {kfree (tags->rqs); -blk_mq_free_tags (tags, flags); +blk_mq_free_tags (tags);return NULL ; }@@ -2855,14 +2859,13 @@ struct blk_mq_tags *blk_mq_alloc_map_and_rqs(struct blk_mq_tag_set *set,struct blk_mq_tags *tags;int ret; - tags =blk_mq_alloc_rq_map (set, hctx_idx, depth, set->reserved_tags, - set->flags); + tags =blk_mq_alloc_rq_map (set, hctx_idx, depth, set->reserved_tags);if (!tags)return NULL ; ret =blk_mq_alloc_rqs (set, tags, hctx_idx, depth);if (ret) { -blk_mq_free_rq_map (tags, set->flags); +blk_mq_free_rq_map (tags);return NULL ; }@@ -2872,6 +2875,12 @@ struct blk_mq_tags *blk_mq_alloc_map_and_rqs(struct blk_mq_tag_set *set,static bool __blk_mq_alloc_map_and_rqs (struct blk_mq_tag_set *set,int hctx_idx) { +if (blk_mq_is_sbitmap_shared (set->flags)) { + set->tags[hctx_idx] = set->shared_sbitmap_tags; + +return true; + } + set->tags[hctx_idx] =blk_mq_alloc_map_and_rqs (set, hctx_idx, set->queue_depth);@@ -2882,14 +2891,22 @@ void blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,struct blk_mq_tags *tags, unsigned int hctx_idx) { -unsigned int flags = set->flags; - if (tags) {blk_mq_free_rqs (set ,tags ,hctx_idx ); -blk_mq_free_rq_map (tags, flags); +blk_mq_free_rq_map (tags); } } +static void __blk_mq_free_map_and_rqs (struct blk_mq_tag_set *set, +struct blk_mq_tags *tags, +unsigned int hctx_idx) +{ +if (blk_mq_is_sbitmap_shared (set->flags)) +return ; + +blk_mq_free_map_and_rqs (set, tags, hctx_idx); +} +static void blk_mq_map_swqueue (struct request_queue *q) {unsigned int i, j, hctx_idx;@@ -2968,7 +2985,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)* allocation */ if (i && set->tags[i]) { -blk_mq_free_map_and_rqs (set, set->tags[i], i); +__blk_mq_free_map_and_rqs (set, set->tags[i], i); set->tags[i] =NULL ; }@@ -3266,7 +3283,7 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,struct blk_mq_hw_ctx *hctx = hctxs[j];if (hctx) { -blk_mq_free_map_and_rqs (set, set->tags[j], j); +__blk_mq_free_map_and_rqs (set, set->tags[j], j); set->tags[j] =NULL ;blk_mq_exit_hctx (q, set, hctx, j); hctxs[j] =NULL ;@@ -3354,6 +3371,14 @@ static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) {int i; +if (blk_mq_is_sbitmap_shared (set->flags)) { + set->shared_sbitmap_tags =blk_mq_alloc_map_and_rqs (set, +BLK_MQ_NO_HCTX_IDX , + set->queue_depth); +if (!set->shared_sbitmap_tags) +return -ENOMEM ; + } +for (i =0 ; i < set->nr_hw_queues; i++) {if (!__blk_mq_alloc_map_and_rqs (set, i)) goto out_unwind;@@ -3364,10 +3389,15 @@ static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) out_unwind:while (--i >=0 ) { -blk_mq_free_map_and_rqs (set, set->tags[i], i); +__blk_mq_free_map_and_rqs (set, set->tags[i], i); set->tags[i] =NULL ; } +if (blk_mq_is_sbitmap_shared (set->flags)) { +blk_mq_free_map_and_rqs (set, set->shared_sbitmap_tags, +BLK_MQ_NO_HCTX_IDX ); + } +return -ENOMEM ; }@@ -3546,25 +3576,11 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)if (ret) goto out_free_mq_map; -if (blk_mq_is_sbitmap_shared (set->flags)) { -atomic_set (&set->active_queues_shared_sbitmap,0 ); - -if (blk_mq_init_shared_sbitmap (set)) { - ret = -ENOMEM ; - goto out_free_mq_rq_maps; - } - } -mutex_init (&set->tag_list_lock);INIT_LIST_HEAD (&set->tag_list);return 0 ; -out_free_mq_rq_maps: -for (i =0 ; i < set->nr_hw_queues; i++) { -blk_mq_free_map_and_rqs (set, set->tags[i], i); - set->tags[i] =NULL ; - } out_free_mq_map:for (i =0 ; i < set->nr_maps; i++) {kfree (set->map[i].mq_map);@@ -3597,12 +3613,14 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)int i, j;for (i =0 ; i < set->nr_hw_queues; i++) { -blk_mq_free_map_and_rqs (set, set->tags[i], i); +__blk_mq_free_map_and_rqs (set, set->tags[i], i); set->tags[i] =NULL ; } -if (blk_mq_is_sbitmap_shared (set->flags)) -blk_mq_exit_shared_sbitmap (set); +if (blk_mq_is_sbitmap_shared (set->flags)) { +blk_mq_free_map_and_rqs (set, set->shared_sbitmap_tags, +BLK_MQ_NO_HCTX_IDX ); + }for (j =0 ; j < set->nr_maps; j++) {kfree (set->map[j].mq_map);@@ -3640,12 +3658,6 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)if (hctx->sched_tags) { ret =blk_mq_tag_update_depth (hctx, &hctx->sched_tags, nr, true); -if (blk_mq_is_sbitmap_shared (set->flags)) { - hctx->sched_tags->bitmap_tags = - &q->sched_bitmap_tags; - hctx->sched_tags->breserved_tags = - &q->sched_breserved_tags; - } }else { ret =blk_mq_tag_update_depth (hctx, &hctx->tags, nr, false);block/blk-mq.h +3
-2@@ -54,7 +54,7 @@ void blk_mq_put_rq_ref(struct request *rq);*/ void blk_mq_free_rqs (struct blk_mq_tag_set *set,struct blk_mq_tags *tags,unsigned int hctx_idx); -void blk_mq_free_rq_map (struct blk_mq_tags *tags,unsigned int flags); +void blk_mq_free_rq_map (struct blk_mq_tags *tags);struct blk_mq_tags *blk_mq_alloc_map_and_rqs (struct blk_mq_tag_set *set,unsigned int hctx_idx,unsigned int depth); void blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,@@ -331,10 +331,11 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,if (blk_mq_is_sbitmap_shared (hctx->flags)) {struct request_queue *q = hctx->queue;struct blk_mq_tag_set *set = q->tag_set; +struct blk_mq_tags *tags = set->shared_sbitmap_tags;if (!test_bit (QUEUE_FLAG_HCTX_ACTIVE , &q->queue_flags))return true; - users =atomic_read (&set->active_queues_shared_sbitmap); + users =atomic_read (&tags->active_queues); }else {if (!test_bit (BLK_MQ_S_TAG_ACTIVE , &hctx->state))return true;include/linux/blk-mq.h +7
-8@@ -232,13 +232,11 @@ enum hctx_type {* @flags: Zero or more BLK_MQ_F_* flags. * @driver_data: Pointer to data owned by the block driver that created this * tag set. -* @active_queues_shared_sbitmap: -* number of active request queues per tag set. -* @__bitmap_tags: A shared tags sbitmap, used over all hctx's -* @__breserved_tags: -* A shared reserved tags sbitmap, used over all hctx's * @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues * elements. +* @shared_sbitmap_tags: +* Shared sbitmap set of tags. Has @nr_hw_queues elements. If +* set, shared by all @tags. * @tag_list_lock: Serializes tag_list accesses. * @tag_list: List of the request queues that use this tag set. See also * request_queue.tag_set_list. @@ -255,12 +253,11 @@ struct blk_mq_tag_set {unsigned int timeout;unsigned int flags;void *driver_data; -atomic_t active_queues_shared_sbitmap; -struct sbitmap_queue __bitmap_tags; -struct sbitmap_queue __breserved_tags;struct blk_mq_tags **tags; +struct blk_mq_tags *shared_sbitmap_tags; +struct mutex tag_list_lock;struct list_head tag_list; };@@ -432,6 +429,8 @@ enum { ((policy & ((1 <<BLK_MQ_F_ALLOC_POLICY_BITS ) -1 )) \ << BLK_MQ_F_ALLOC_POLICY_START_BIT) +#define BLK_MQ_NO_HCTX_IDX (-1U) +struct gendisk *__blk_mq_alloc_disk (struct blk_mq_tag_set *set,void *queuedata,struct lock_class_key *lkclass);#define blk_mq_alloc_disk (set, queuedata) \include/linux/blkdev.h +0
-0
include/linux/blkdev.h struct request_queue { · line 465
Quoted 9 lines
include/linux/blkdev.h +1
-2@@ -459,8 +459,7 @@ struct request_queue {atomic_t nr_active_requests_shared_sbitmap; -struct sbitmap_queue sched_bitmap_tags; -struct sbitmap_queue sched_breserved_tags; +struct blk_mq_tags *shared_sbitmap_tags;struct list_head icq_list;#ifdef CONFIG_BLK_CGROUP
Why the double shared_sbitmap_tags pointer in struct request_queue and struct tag_set? To my knowledge there's a 1:1 relationship between request_queue and tag_set, so where's the point?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH RESEND v3 12/13] blk-mq: Use shared tags for shared sbitmap support
...
Quoted 27 lines
Quoted 27 lines
static int blk_mq_init_sched_shared_sbitmap(struct request_queue *queue) { struct blk_mq_tag_set *set = queue->tag_set;block/blk-mq-sched.c +3
-16-int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags); -struct blk_mq_hw_ctx *hctx; -int ret, i;/* * Set initial depth at max so that we don't need to reallocate for * updating nr_requests. */ - ret =blk_mq_init_bitmaps (&queue->sched_bitmap_tags, - &queue->sched_breserved_tags, -MAX_SCHED_RQ , set->reserved_tags, - set->numa_node, alloc_policy); -if (ret) -return ret; - -queue_for_each_hw_ctx (queue, hctx, i) { - hctx->sched_tags->bitmap_tags = - &queue->sched_bitmap_tags; - hctx->sched_tags->breserved_tags = - &queue->sched_breserved_tags; - } + queue->shared_sbitmap_tags =blk_mq_alloc_map_and_rqs (set, +BLK_MQ_NO_HCTX_IDX , +MAX_SCHED_RQ );
Quoted 9 lines
block/blk-mq-sched.c static int blk_mq_sched_alloc_map_and_rqs(struct request_queue *q, · line 571
Quoted 3 lines
block/blk-mq-sched.c +2
-0+if (!queue->shared_sbitmap_tags) +return -ENOMEM ;Any particular reason why the '
shared_sbitmap_tags' pointer is added to the request queue and not the tagset?
Everything else is located there, so I would have found it more logical to add the 'shared_sbitmap_tags' pointer to the tagset, not the queue ...
We already have it for both. Since commit d97e594c5166 ("blk-mq: Use request queue-wide tags for tagset-wide sbitmap"), we have a "shared sbitmap" per tagset and per request queue. If you check d97e594c5166 then it should explain the reason.
Quoted 76 lines
Quoted 64 lines
blk_mq_tag_update_sched_shared_sbitmap(queue); return 0; }block/blk-mq-sched.c +10
-18-static void blk_mq_exit_sched_shared_sbitmap (struct request_queue *queue) -{ -sbitmap_queue_free (&queue->sched_bitmap_tags); -sbitmap_queue_free (&queue->sched_breserved_tags); -} -int blk_mq_init_sched (struct request_queue *q,struct elevator_type *e) { +unsigned int i, flags = q->tag_set->flags;struct blk_mq_hw_ctx *hctx;struct elevator_queue *eq; -unsigned int i;int ret;if (!e) {@@ -598,21 +596,21 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth,BLKDEV_DEFAULT_RQ ); -queue_for_each_hw_ctx (q, hctx, i) { - ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i); +if (blk_mq_is_sbitmap_shared (flags)) { + ret = blk_mq_init_sched_shared_sbitmap(q); > if (ret) - goto err_free_map_and_rqs; +return ret; } -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { - ret =blk_mq_init_sched_shared_sbitmap (q); +queue_for_each_hw_ctx (q, hctx, i) { + ret =blk_mq_sched_alloc_map_and_rqs (q, hctx, i);if (ret) goto err_free_map_and_rqs; } ret = e->ops.init_sched (q, e);if (ret) - goto err_free_sbitmap; + goto err_free_map_and_rqs;blk_mq_debugfs_register_sched (q);@@ -632,12 +630,10 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)return 0 ; -err_free_sbitmap: -if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) -blk_mq_exit_sched_shared_sbitmap (q); -blk_mq_sched_free_rqs (q); err_free_map_and_rqs: -blk_mq_sched_tags_teardown (q); +blk_mq_sched_free_rqs (q); +blk_mq_sched_tags_teardown (q, flags); + q->elevator =NULL ;return ret; }block/blk-mq-sched.c void blk_mq_sched_free_rqs(struct request_queue *q) · line 652
Quoted 9 lines
block/blk-mq-sched.c +3
-3@@ -651,9 +647,15 @@ void blk_mq_sched_free_rqs(struct request_queue *q)struct blk_mq_hw_ctx *hctx;int i; -queue_for_each_hw_ctx (q, hctx, i) { -if (hctx->sched_tags) -blk_mq_free_rqs (q->tag_set, hctx->sched_tags, i); +if (blk_mq_is_sbitmap_shared (q->tag_set->flags)) { +blk_mq_free_rqs (q->tag_set, q->shared_sbitmap_tags, +BLK_MQ_NO_HCTX_IDX );'if (
q->shared_sbitmap_tags)'
Quoted 1 line
would be more obvious here ...
I suppose so. I am just doing it this way for consistency.
Quoted 10 lines
Quoted 10 lines
block/blk-mq-sched.c +6
-0+ }else { +queue_for_each_hw_ctx (q, hctx, i) { +if (hctx->sched_tags) +blk_mq_free_rqs (q->tag_set, + hctx->sched_tags, i); + } } }
...
Quoted 22 lines
Quoted 22 lines
};include/linux/blk-mq.h +2
-0@@ -432,6 +429,8 @@ enum { ((policy & ((1 <<BLK_MQ_F_ALLOC_POLICY_BITS ) -1 )) \ << BLK_MQ_F_ALLOC_POLICY_START_BIT) +#define BLK_MQ_NO_HCTX_IDX (-1U) +struct gendisk *__blk_mq_alloc_disk (struct blk_mq_tag_set *set,void *queuedata,struct lock_class_key *lkclass);#define blk_mq_alloc_disk (set, queuedata) \include/linux/blkdev.h +1
-2@@ -459,8 +459,7 @@ struct request_queue {atomic_t nr_active_requests_shared_sbitmap; -struct sbitmap_queue sched_bitmap_tags; -struct sbitmap_queue sched_breserved_tags; +struct blk_mq_tags *shared_sbitmap_tags;
Quoted 7 lines
include/linux/blkdev.h struct request_queue { · line 465
Quoted 3 lines
include/linux/blkdev.h +0
-0struct list_head icq_list;#ifdef CONFIG_BLK_CGROUP Why the double
shared_sbitmap_tagspointer in structrequest_queueand structtag_set? To my knowledge there's a 1:1 relationship betweenrequest_queueandtag_set, so where's the point?
As above, we also added a shared sbitmap per request queue.
The reason being that for "shared sbitmap" support, the request queue total depth should not grow for an increase in the number of HW queues.
Thanks,
John
PATCH RESEND v3 13/13 blk-mq: Stop using pointers for blk_mq_tags bitmap tags
In reply to John GarryNow that we use shared tags for shared sbitmap support, we don't require the tags sbitmap pointers, so drop them.
This essentially reverts commit 222a5ae03cdd ("blk-mq: Use pointers for blk_mq_tags bitmap tags").
Function blk_mq_init_bitmap_tags() is removed also, since it would be only a wrappper for blk_mq_init_bitmaps().
--- block/bfq-iosched.c | 4 +-- block/blk-mq-debugfs.c | 8 +++--- block/blk-mq-tag.c | 56 +++++++++++++++--------------------------- block/blk-mq-tag.h | 7 ++---- block/blk-mq.c | 8 +++--- block/kyber-iosched.c | 4 +-- block/mq-deadline.c | 2 +- 7 files changed, 35 insertions(+), 54 deletions(-)
block/bfq-iosched.c +2 -2
@@ -6894,8 +6894,8 @@ static void bfq_depth_updated(struct blk_mq_hw_ctx *hctx)struct blk_mq_tags *tags = hctx->sched_tags;unsigned int min_shallow; - min_shallow =bfq_update_depths (bfqd, tags->bitmap_tags); -sbitmap_queue_min_shallow_depth (tags->bitmap_tags, min_shallow); + min_shallow =bfq_update_depths (bfqd, &tags->bitmap_tags); +sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, min_shallow); }static int bfq_init_hctx (struct blk_mq_hw_ctx *hctx,unsigned int index)
block/blk-mq-debugfs.c +4 -4
@@ -452,11 +452,11 @@ static void blk_mq_debugfs_tags_show(struct seq_file *m, atomic_read(&tags->active_queues));seq_puts (m,"\nbitmap_tags:\n" ); -sbitmap_queue_show (tags->bitmap_tags, m); +sbitmap_queue_show (&tags->bitmap_tags, m);if (tags->nr_reserved_tags) {seq_puts (m,"\nbreserved_tags:\n" ); -sbitmap_queue_show (tags->breserved_tags, m); +sbitmap_queue_show (&tags->breserved_tags, m); } }
@@ -487,7 +487,7 @@ static int hctx_tags_bitmap_show(void *data, struct seq_file *m)if (res) goto out;if (hctx->tags) -sbitmap_bitmap_show (&hctx->tags->bitmap_tags->sb, m); +sbitmap_bitmap_show (&hctx->tags->bitmap_tags.sb, m);mutex_unlock (&q->sysfs_lock); out:
@@ -521,7 +521,7 @@ static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m)if (res) goto out;if (hctx->sched_tags) -sbitmap_bitmap_show (&hctx->sched_tags->bitmap_tags->sb, m); +sbitmap_bitmap_show (&hctx->sched_tags->bitmap_tags.sb, m);mutex_unlock (&q->sysfs_lock); out:
block/blk-mq-tag.c +20 -36
133 lines not on this page · raw message
block/blk-mq-tag.h +2 -5
@@ -11,11 +11,8 @@ struct blk_mq_tags {atomic_t active_queues; -struct sbitmap_queue *bitmap_tags; -struct sbitmap_queue *breserved_tags; - -struct sbitmap_queue __bitmap_tags; -struct sbitmap_queue __breserved_tags; +struct sbitmap_queue bitmap_tags; +struct sbitmap_queue breserved_tags;struct request **rqs;struct request **static_rqs;
block/blk-mq.c +4 -4
@@ -1062,14 +1062,14 @@ static inline unsigned int queued_to_index(unsigned int queued)static bool __blk_mq_get_driver_tag (struct request *rq) { -struct sbitmap_queue *bt = rq->mq_hctx->tags->bitmap_tags; +struct sbitmap_queue *bt = &rq->mq_hctx->tags->bitmap_tags;unsigned int tag_offset = rq->mq_hctx->tags->nr_reserved_tags;int tag;blk_mq_tag_busy (rq->mq_hctx);if (blk_mq_tag_is_reserved (rq->mq_hctx->sched_tags, rq->internal_tag)) { - bt = rq->mq_hctx->tags->breserved_tags; + bt = &rq->mq_hctx->tags->breserved_tags; tag_offset =0 ; }else {if (!hctx_may_queue (rq->mq_hctx, bt))
@@ -1112,7 +1112,7 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode,struct sbitmap_queue *sbq;list_del_init (&wait->entry); - sbq = hctx->tags->bitmap_tags; + sbq = &hctx->tags->bitmap_tags;atomic_dec (&sbq->ws_active); }spin_unlock (&hctx->dispatch_wait_lock);
@@ -1130,7 +1130,7 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode,static bool blk_mq_mark_tag_wait (struct blk_mq_hw_ctx *hctx,struct request *rq) { -struct sbitmap_queue *sbq = hctx->tags->bitmap_tags; +struct sbitmap_queue *sbq = &hctx->tags->bitmap_tags;struct wait_queue_head *wq;wait_queue_entry_t *wait;bool ret;
block/kyber-iosched.c +2 -2
@@ -451,11 +451,11 @@ static void kyber_depth_updated(struct blk_mq_hw_ctx *hctx) {struct kyber_queue_data *kqd = hctx->queue->elevator->elevator_data;struct blk_mq_tags *tags = hctx->sched_tags; -unsigned int shift = tags->bitmap_tags->sb.shift; +unsigned int shift = tags->bitmap_tags.sb.shift; kqd->async_depth = (1U << shift) *KYBER_ASYNC_PERCENT /100U ; -sbitmap_queue_min_shallow_depth (tags->bitmap_tags, kqd->async_depth); +sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, kqd->async_depth); }static int kyber_init_hctx (struct blk_mq_hw_ctx *hctx,unsigned int hctx_idx)
block/mq-deadline.c +1 -1
@@ -519,7 +519,7 @@ static void dd_depth_updated(struct blk_mq_hw_ctx *hctx) dd->async_depth =max (1UL ,3 * q->nr_requests /4 ); -sbitmap_queue_min_shallow_depth (tags->bitmap_tags, dd->async_depth); +sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, dd->async_depth); }/* Called by blk_mq_init_hctx() and blk_mq_init_sched(). */
Signature · 1 line
2.26.2
Re: [PATCH RESEND v3 13/13] blk-mq: Stop using pointers for blk_mq_tags bitmap tags
Quoted 20 lines · John Garry
Now that we use shared tags for shared sbitmap support, we don't require the tags sbitmap pointers, so drop them.
This essentially reverts commit
222a5ae03cdd("blk-mq: Use pointers forblk_mq_tagsbitmap tags").Function
blk_mq_init_bitmap_tags()is removed also, since it would be only a wrappper forblk_mq_init_bitmaps().Reviewed-by Ming Lei <[email protected]>Signed-off-by John Garry <[email protected]>--- block/bfq-iosched.c | 4 +-- block/blk-mq-debugfs.c | 8 +++--- block/blk-mq-tag.c | 56 +++++++++++++++--------------------------- block/blk-mq-tag.h | 7 ++---- block/blk-mq.c | 8 +++--- block/kyber-iosched.c | 4 +-- block/mq-deadline.c | 2 +- 7 files changed, 35 insertions(+), 54 deletions(-)
Quoted 1 line
A round of silent applause :-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Quoted 7 lines · John Garry
Currently a full set of static requests are allocated per hw queue per tagset when shared sbitmap is used.
However, only
tagset->queue_depthnumber of requests may be active at any given time. As such, onlytagset->queue_depthnumber of static requests are required.
Quoted 8 lines
The same goes for using an IO scheduler, which allocates a full set of static requests per hw queue per request queue.
This series changes shared sbitmap support by using a shared tags per tagset and request queue. Ming suggested something along those lines in v1 review. But we'll keep name "shared sbitmap" name as it is familiar. In using a shared tags, the static rqs also become shared, reducing the number of sets of static rqs, reducing memory usage.
Hi Ming,
Could you kindly check the remaining few un-reviewed patches in this series when you get an opportunity?
Thanks,
John