more BLK_MQ_F_* simplification
Subsystems (7)
Christoph Hellwig
maintainerHi Jens,
this series removes another BLK_MQ_F_ that just duplicates an implicit condition and cleans up the tag allocation policy selection by using an actual BLK_MQ_F_ flag instead of a two-value enum awkwardly encoded into it. If we'd ever grow another policy we'd be much better off just adding a separate field to the tagset for it.
Diffstat:
block/blk-mq-debugfs.c | 26 +++----------------- block/blk-mq-tag.c | 41 ++++++++++----------------------- block/blk-mq.c | 3 -- block/blk-mq.h | 5 ---- block/bsg-lib.c | 2 - block/elevator.c | 20 ---------------- block/genhd.c | 28 ++++++++++++---------- drivers/ata/ahci.h | 2 - drivers/ata/pata_macio.c | 2 - drivers/ata/sata_mv.c | 2 - drivers/ata/sata_nv.c | 4 +-- drivers/ata/sata_sil24.c | 2 - drivers/block/null_blk/main.c | 4 +-- drivers/nvme/host/apple.c | 1 drivers/nvme/host/core.c | 1 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 - drivers/scsi/scsi_lib.c | 4 +-- drivers/ufs/core/ufshcd.c | 1 include/linux/blk-mq.h | 24 +++++-------------- include/linux/libata.h | 4 +-- include/scsi/scsi_host.h | 7 ++++- 21 files changed, 61 insertions(+), 124 deletions(-)
Christoph Hellwig
maintainerPATCH 1/4 block: better split mq vs non-mq code in add_disk_fwnode
Add a big conditional for blk-mq vs not mq at the beginning of add_disk_fwnode so that elevator_init_mq is only called for blk-mq disks, and add checks that the right methods or set or not set based on the queue type.
--- block/genhd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
block/genhd.c +15 -13
@@ -400,21 +400,23 @@ int __must_check add_disk_fwnode(struct device *parent, struct gendisk *disk,struct device *ddev =disk_to_dev (disk);int ret; -/* Only makes sense for bio-based to set ->poll_bio */ -if (queue_is_mq (disk->queue) && disk->fops->poll_bio) -return -EINVAL ; - -/* -* The disk queue should now be all set with enough information about -* the device for the elevator code to pick an adequate default -* elevator if one is needed, that is, for devices requesting queue -* registration. -*/ -elevator_init_mq (disk->queue); +if (queue_is_mq (disk->queue)) { +/* +* ->submit_bio and ->poll_bio are bypassed for blk-mq drivers. +*/ +if (disk->fops->submit_bio || disk->fops->poll_bio) +return -EINVAL ; -/* Mark bdev as having a submit_bio, if needed */ -if (disk->fops->submit_bio) +/* +* Initialize the I/O scheduler code and pick a default one if +* needed. +*/ +elevator_init_mq (disk->queue); + }else { +if (!disk->fops->submit_bio) +return -EINVAL ;bdev_set_flag (disk->part0,BD_HAS_SUBMIT_BIO ); + }/* * If the driver provides an explicit major number it also must provide
Signature · 1 line
2.45.2
Christoph Hellwig
maintainerPATCH 2/4 block: remove blk_mq_init_bitmaps
In reply to Christoph HellwigThe little work done in blk_mq_init_bitmaps is easier done in the only caller.
--- block/blk-mq-tag.c | 38 ++++++++++++-------------------------- block/blk-mq.h | 3 --- 2 files changed, 12 insertions(+), 29 deletions(-)
block/blk-mq-tag.c +12 -26
@@ -544,30 +544,12 @@ static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth, node); } -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) -{ -unsigned int depth = queue_depth - reserved; -bool round_robin = alloc_policy ==BLK_TAG_ALLOC_RR ; - -if (bt_alloc (bitmap_tags, depth, round_robin, node)) -return -ENOMEM ; -if (bt_alloc (breserved_tags, reserved, round_robin, node)) - goto free_bitmap_tags; - -return 0 ; - -free_bitmap_tags: -sbitmap_queue_free (bitmap_tags); -return -ENOMEM ; -} -struct blk_mq_tags *blk_mq_init_tags (unsigned int total_tags,unsigned int reserved_tags,int node,int alloc_policy) { +unsigned int depth = total_tags - reserved_tags; +bool round_robin = alloc_policy ==BLK_TAG_ALLOC_RR ;struct blk_mq_tags *tags;if (total_tags >BLK_MQ_TAG_MAX ) {
@@ -582,14 +564,18 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags, tags->nr_tags = total_tags; tags->nr_reserved_tags = reserved_tags;spin_lock_init (&tags->lock); +if (bt_alloc (&tags->bitmap_tags, depth, round_robin, node)) + goto out_free_tags; +if (bt_alloc (&tags->breserved_tags, reserved_tags, round_robin, node)) + goto out_free_bitmap_tags; -if (blk_mq_init_bitmaps (&tags->bitmap_tags, &tags->breserved_tags, - total_tags, reserved_tags, node, - alloc_policy) <0 ) { -kfree (tags); -return NULL ; - }return tags; + +out_free_bitmap_tags: +sbitmap_queue_free (&tags->bitmap_tags); +out_free_tags: +kfree (tags); +return NULL ; }void blk_mq_free_tags (struct blk_mq_tags *tags)
block/blk-mq.h +0 -3
@@ -165,9 +165,6 @@ struct blk_mq_alloc_data {struct blk_mq_tags *blk_mq_init_tags (unsigned int nr_tags,unsigned int reserved_tags,int node,int alloc_policy);void blk_mq_free_tags (struct blk_mq_tags *tags); -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);unsigned int blk_mq_get_tag (struct blk_mq_alloc_data *data); unsigned long blk_mq_get_tags(struct blk_mq_alloc_data *data, int nr_tags,
Signature · 1 line
2.45.2
Re: [PATCH 2/4] block: remove blk_mq_init_bitmaps
Quoted 4 lines · Christoph Hellwig
The little work done in
blk_mq_init_bitmapsis easier done in the only caller.Signed-off-by Christoph Hellwig<[email protected]>
Christoph Hellwig
maintainerPATCH 3/4 block: remove BLK_MQ_F_NO_SCHED
In reply to Christoph HellwigThe only queues that really can't support a scheduler are those that do not have a gendisk associated with them, and thus can't be used for non-passthrough commands. In addition to those null_blk can optionally set the flag, which is a bad odd. Replace the null_blk usage with BLK_MQ_F_NO_SCHED_BY_DEFAULT to keep the expected semantics and then remove BLK_MQ_F_NO_SCHED as the non-disk queues never call into elevator_init_mq or blk_register_queue which adds the sysfs attributes.
--- block/blk-mq-debugfs.c | 1 - block/bsg-lib.c | 2 +- block/elevator.c | 20 -------------------- drivers/block/null_blk/main.c | 4 ++-- drivers/nvme/host/apple.c | 1 - drivers/nvme/host/core.c | 1 - drivers/ufs/core/ufshcd.c | 1 - include/linux/blk-mq.h | 2 -- 8 files changed, 3 insertions(+), 29 deletions(-)
block/blk-mq-debugfs.c +0 -1
@@ -185,7 +185,6 @@ static const char *const hctx_flag_name[] = {HCTX_FLAG_NAME (STACKING ),HCTX_FLAG_NAME (TAG_HCTX_SHARED ),HCTX_FLAG_NAME (BLOCKING ), -HCTX_FLAG_NAME (NO_SCHED ), HCTX_FLAG_NAME(NO_SCHED_BY_DEFAULT), };#undef HCTX_FLAG_NAME
block/bsg-lib.c +1 -1
@@ -381,7 +381,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, set->queue_depth =128 ; set->numa_node =NUMA_NO_NODE ; set->cmd_size =sizeof (struct bsg_job ) + dd_job_size; - set->flags =BLK_MQ_F_NO_SCHED |BLK_MQ_F_BLOCKING ; + set->flags =BLK_MQ_F_BLOCKING ;if (blk_mq_alloc_tag_set (set)) goto out_tag_set;
block/elevator.c +0 -20
@@ -547,14 +547,6 @@ void elv_unregister(struct elevator_type *e) }EXPORT_SYMBOL_GPL (elv_unregister); -static inline bool elv_support_iosched (struct request_queue *q) -{ -if (!queue_is_mq (q) || - (q->tag_set->flags &BLK_MQ_F_NO_SCHED )) -return false; -return true; -} -/* * For single queue devices, default to using mq-deadline. If we have multiple * queues or mq-deadline is not available, default to "none".
@@ -580,9 +572,6 @@ void elevator_init_mq(struct request_queue *q)struct elevator_type *e;int err; -if (!elv_support_iosched (q)) -return ; -WARN_ON_ONCE (blk_queue_registered (q));if (unlikely (q->elevator))
@@ -714,9 +703,6 @@ void elv_iosched_load_module(struct gendisk *disk, const char *buf,struct elevator_type *found;const char *name; -if (!elv_support_iosched (disk->queue)) -return ; -strscpy (elevator_name, buf,sizeof (elevator_name)); name =strstrip (elevator_name);
@@ -734,9 +720,6 @@ ssize_t elv_iosched_store(struct gendisk *disk, const char *buf,char elevator_name[ELV_NAME_MAX ];int ret; -if (!elv_support_iosched (disk->queue)) -return count; -strscpy (elevator_name, buf,sizeof (elevator_name)); ret =elevator_change (disk->queue,strstrip (elevator_name));if (!ret)
@@ -751,9 +734,6 @@ ssize_t elv_iosched_show(struct gendisk *disk, char *name)struct elevator_type *cur =NULL , *e;int len =0 ; -if (!elv_support_iosched (q)) -return sprintf (name,"none\n" ); -if (!q->elevator) { len +=sprintf (name+len,"[none] " ); }else {
drivers/block/null_blk/main.c +2 -2
@@ -1792,7 +1792,7 @@ static int null_init_global_tag_set(void) tag_set.queue_depth = g_hw_queue_depth; tag_set.numa_node = g_home_node;if (g_no_sched) - tag_set.flags |=BLK_MQ_F_NO_SCHED ; + tag_set.flags |=BLK_MQ_F_NO_SCHED_BY_DEFAULT ;if (g_shared_tag_bitmap) tag_set.flags |=BLK_MQ_F_TAG_HCTX_SHARED ;if (g_blocking)
@@ -1817,7 +1817,7 @@ static int null_setup_tagset(struct nullb *nullb) nullb->tag_set->queue_depth = nullb->dev->hw_queue_depth; nullb->tag_set->numa_node = nullb->dev->home_node;if (nullb->dev->no_sched) - nullb->tag_set->flags |=BLK_MQ_F_NO_SCHED ; + nullb->tag_set->flags |=BLK_MQ_F_NO_SCHED_BY_DEFAULT ;if (nullb->dev->shared_tag_bitmap) nullb->tag_set->flags |=BLK_MQ_F_TAG_HCTX_SHARED ;if (nullb->dev->blocking)
drivers/nvme/host/apple.c +0 -1
@@ -1251,7 +1251,6 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv) anv->admin_tagset.timeout =NVME_ADMIN_TIMEOUT ; anv->admin_tagset.numa_node =NUMA_NO_NODE ; anv->admin_tagset.cmd_size =sizeof (struct apple_nvme_iod ); - anv->admin_tagset.flags =BLK_MQ_F_NO_SCHED ; anv->admin_tagset.driver_data = &anv->adminq; ret =blk_mq_alloc_tag_set (&anv->admin_tagset);
drivers/nvme/host/core.c +0 -1
@@ -4564,7 +4564,6 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,/* Reserved for fabric connect and keep alive */ set->reserved_tags =2 ; set->numa_node = ctrl->numa_node; - set->flags =BLK_MQ_F_NO_SCHED ;if (ctrl->ops->flags &NVME_F_BLOCKING ) set->flags |=BLK_MQ_F_BLOCKING ; set->cmd_size = cmd_size;
drivers/ufs/core/ufshcd.c +0 -1
@@ -10412,7 +10412,6 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba) .nr_hw_queues = 1, .queue_depth = hba->nutmrs, .ops = &ufshcd_tmf_ops, - .flags = BLK_MQ_F_NO_SCHED, }; err =blk_mq_alloc_tag_set (&hba->tmf_tag_set);if (err <0 )
include/linux/blk-mq.h +0 -2
@@ -676,8 +676,6 @@ enum {BLK_MQ_F_STACKING =1 <<2 ,BLK_MQ_F_TAG_HCTX_SHARED =1 <<3 , BLK_MQ_F_BLOCKING = 1 << 4, -/* Do not allow an I/O scheduler to be configured. */ - BLK_MQ_F_NO_SCHED = 1 << 5,/* * Select 'none' during queue registration in case of a single hwq
Signature · 1 line
2.45.2
Christoph Hellwig
maintainerPATCH 4/4 block: simplify tag allocation policy selection
In reply to Christoph HellwigUse a plain BLK_MQ_F_* flag to select the round robin tag selection instead of overlaying an enum with just two possible values into the flags space. Keep the value based selection inside of SCSI as the BLK_MQ_F_ flags aren't directly exposed to SCSI LLDDs.
Doing so allows adding a BLK_MQ_F_MAX sentinel for simplified overflow checking in the messy debugfs helpers.
--- block/blk-mq-debugfs.c | 25 ++++--------------------- block/blk-mq-tag.c | 5 ++--- block/blk-mq.c | 3 +-- block/blk-mq.h | 2 +- drivers/ata/ahci.h | 2 +- drivers/ata/pata_macio.c | 2 +- drivers/ata/sata_mv.c | 2 +- drivers/ata/sata_nv.c | 4 ++-- drivers/ata/sata_sil24.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/scsi_lib.c | 4 ++-- include/linux/blk-mq.h | 22 +++++++--------------- include/linux/libata.h | 4 ++-- include/scsi/scsi_host.h | 7 ++++++- 14 files changed, 32 insertions(+), 54 deletions(-)
block/blk-mq-debugfs.c +4 -21
@@ -172,19 +172,13 @@ static int hctx_state_show(void *data, struct seq_file *m)return 0 ; } -#define BLK_TAG_ALLOC_NAME (name) [BLK_TAG_ALLOC_##name] = #name -static const char *const alloc_policy_name[] = { -BLK_TAG_ALLOC_NAME (FIFO ), -BLK_TAG_ALLOC_NAME (RR ), -}; -#undef BLK_TAG_ALLOC_NAME -#define HCTX_FLAG_NAME (name) [ilog2(BLK_MQ_F_##name)] = #namestatic const char *const hctx_flag_name[] = {HCTX_FLAG_NAME (TAG_QUEUE_SHARED ),HCTX_FLAG_NAME (STACKING ),HCTX_FLAG_NAME (TAG_HCTX_SHARED ),HCTX_FLAG_NAME (BLOCKING ), +HCTX_FLAG_NAME (TAG_RR ),HCTX_FLAG_NAME (NO_SCHED_BY_DEFAULT ), };#undef HCTX_FLAG_NAME
@@ -192,22 +186,11 @@ static const char *const hctx_flag_name[] = {static int hctx_flags_show (void *data,struct seq_file *m) {struct blk_mq_hw_ctx *hctx = data; -const int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (hctx->flags); -BUILD_BUG_ON (ARRAY_SIZE (hctx_flag_name) != -BLK_MQ_F_ALLOC_POLICY_START_BIT ); -BUILD_BUG_ON (ARRAY_SIZE (alloc_policy_name) !=BLK_TAG_ALLOC_MAX ); +BUILD_BUG_ON (ARRAY_SIZE (hctx_flag_name) !=ilog2 (BLK_MQ_F_MAX )); -seq_puts (m,"alloc_policy=" ); -if (alloc_policy <ARRAY_SIZE (alloc_policy_name) && - alloc_policy_name[alloc_policy]) -seq_puts (m, alloc_policy_name[alloc_policy]); -else -seq_printf (m,"%d" , alloc_policy); -seq_puts (m," " ); -blk_flags_show (m, - hctx->flags ^BLK_ALLOC_POLICY_TO_MQ_FLAG (alloc_policy), - hctx_flag_name,ARRAY_SIZE (hctx_flag_name)); +blk_flags_show (m, hctx->flags, hctx_flag_name, +ARRAY_SIZE (hctx_flag_name));seq_puts (m,"\n" );return 0 ; }
block/blk-mq-tag.c +2 -3
@@ -545,11 +545,10 @@ static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth, }struct blk_mq_tags *blk_mq_init_tags (unsigned int total_tags, -unsigned int reserved_tags, -int node,int alloc_policy) +unsigned int reserved_tags,unsigned int flags,int node) {unsigned int depth = total_tags - reserved_tags; -bool round_robin = alloc_policy ==BLK_TAG_ALLOC_RR ; +bool round_robin = flags &BLK_MQ_F_TAG_RR ;struct blk_mq_tags *tags;if (total_tags >BLK_MQ_TAG_MAX ) {
block/blk-mq.c +1 -2
@@ -3476,8 +3476,7 @@ 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, -BLK_MQ_FLAG_TO_ALLOC_POLICY (set->flags)); + tags =blk_mq_init_tags (nr_tags, reserved_tags, set->flags, node);if (!tags)return NULL ;
block/blk-mq.h +1 -1
@@ -163,7 +163,7 @@ struct blk_mq_alloc_data { };struct blk_mq_tags *blk_mq_init_tags (unsigned int nr_tags, -unsigned int reserved_tags,int node,int alloc_policy); +unsigned int reserved_tags,unsigned int flags,int node);void blk_mq_free_tags (struct blk_mq_tags *tags);unsigned int blk_mq_get_tag (struct blk_mq_alloc_data *data);
drivers/ata/ahci.h +1 -1
@@ -396,7 +396,7 @@ extern const struct attribute_group *ahci_sdev_groups[]; .shost_groups = ahci_shost_groups, \ .sdev_groups = ahci_sdev_groups, \ .change_queue_depth = ata_scsi_change_queue_depth, \ - .tag_alloc_policy = BLK_TAG_ALLOC_RR, \ + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, \ .device_configure = ata_scsi_device_configureextern struct ata_port_operations ahci_ops;
drivers/ata/pata_macio.c +1 -1
@@ -935,7 +935,7 @@ static const struct scsi_host_template pata_macio_sht = { .device_configure = pata_macio_device_configure, .sdev_groups = ata_common_sdev_groups, .can_queue = ATA_DEF_QUEUE, - .tag_alloc_policy = BLK_TAG_ALLOC_RR, + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, };static struct ata_port_operations pata_macio_ops = {
drivers/ata/sata_mv.c +1 -1
@@ -672,7 +672,7 @@ static const struct scsi_host_template mv6_sht = { .dma_boundary = MV_DMA_BOUNDARY, .sdev_groups = ata_ncq_sdev_groups, .change_queue_depth = ata_scsi_change_queue_depth, - .tag_alloc_policy = BLK_TAG_ALLOC_RR, + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, .device_configure = ata_scsi_device_configure };
drivers/ata/sata_nv.c +2 -2
@@ -385,7 +385,7 @@ static const struct scsi_host_template nv_adma_sht = { .device_configure = nv_adma_device_configure, .sdev_groups = ata_ncq_sdev_groups, .change_queue_depth = ata_scsi_change_queue_depth, - .tag_alloc_policy = BLK_TAG_ALLOC_RR, + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, };static const struct scsi_host_template nv_swncq_sht = {
@@ -396,7 +396,7 @@ static const struct scsi_host_template nv_swncq_sht = { .device_configure = nv_swncq_device_configure, .sdev_groups = ata_ncq_sdev_groups, .change_queue_depth = ata_scsi_change_queue_depth, - .tag_alloc_policy = BLK_TAG_ALLOC_RR, + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, };/*
drivers/ata/sata_sil24.c +1 -1
@@ -378,7 +378,7 @@ static const struct scsi_host_template sil24_sht = { .can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, - .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, + .tag_alloc_policy = SCSI_TAG_ALLOC_FIFO, .sdev_groups = ata_ncq_sdev_groups, .change_queue_depth = ata_scsi_change_queue_depth, .device_configure = ata_scsi_device_configure
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -1
@@ -3345,7 +3345,7 @@ static const struct scsi_host_template sht_v3_hw = { .slave_alloc = hisi_sas_slave_alloc, .shost_groups = host_v3_hw_groups, .sdev_groups = sdev_groups_v3_hw, - .tag_alloc_policy = BLK_TAG_ALLOC_RR, + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, .host_reset = hisi_sas_host_reset, .host_tagset = 1, .mq_poll = queue_complete_v3_hw,
drivers/scsi/scsi_lib.c +2 -2
@@ -2065,8 +2065,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) tag_set->queue_depth = shost->can_queue; tag_set->cmd_size = cmd_size; tag_set->numa_node =dev_to_node (shost->dma_dev); - tag_set->flags |= -BLK_ALLOC_POLICY_TO_MQ_FLAG (shost->hostt->tag_alloc_policy); +if (shost->hostt->tag_alloc_policy ==SCSI_TAG_ALLOC_RR ) + tag_set->flags |=BLK_MQ_F_TAG_RR ;if (shost->queuecommand_may_block) tag_set->flags |=BLK_MQ_F_BLOCKING ; tag_set->driver_data = shost;
include/linux/blk-mq.h +7 -15
@@ -296,13 +296,6 @@ enum blk_eh_timer_return { BLK_EH_RESET_TIMER, }; -/* Keep alloc_policy_name[] in sync with the definitions below */ -enum { -BLK_TAG_ALLOC_FIFO ,/* allocate starting from 0 */ -BLK_TAG_ALLOC_RR ,/* allocate starting from last allocated tag */ -BLK_TAG_ALLOC_MAX -}; -/** * struct blk_mq_hw_ctx - State for a hardware queue facing the hardware * block device
@@ -677,20 +670,19 @@ enum {BLK_MQ_F_TAG_HCTX_SHARED =1 <<3 ,BLK_MQ_F_BLOCKING =1 <<4 , +/* +* Alloc tags on a round-robin base instead of the first available one. +*/ +BLK_MQ_F_TAG_RR =1 <<5 , +/* * Select 'none' during queue registration in case of a single hwq * or shared hwqs instead of 'mq-deadline'. */ BLK_MQ_F_NO_SCHED_BY_DEFAULT =1 <<6 , -BLK_MQ_F_ALLOC_POLICY_START_BIT =7 , - BLK_MQ_F_ALLOC_POLICY_BITS = 1, + + BLK_MQ_F_MAX = 1 << 7, }; -#define BLK_MQ_FLAG_TO_ALLOC_POLICY (flags) \ - ((flags >> BLK_MQ_F_ALLOC_POLICY_START_BIT) & \ - ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) -#define BLK_ALLOC_POLICY_TO_MQ_FLAG (policy) \ - ((policy & ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) \ - << BLK_MQ_F_ALLOC_POLICY_START_BIT)#define BLK_MQ_MAX_DEPTH (10240)#define BLK_MQ_NO_HCTX_IDX (-1U)
include/linux/libata.h +2 -2
@@ -1467,13 +1467,13 @@ extern const struct attribute_group *ata_common_sdev_groups[];#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \ .can_queue = ATA_DEF_QUEUE, \ - .tag_alloc_policy = BLK_TAG_ALLOC_RR, \ + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, \ .device_configure = ata_scsi_device_configure#define ATA_SUBBASE_SHT_QD (drv_name, drv_qd) \ __ATA_BASE_SHT(drv_name), \ .can_queue = drv_qd, \ - .tag_alloc_policy = BLK_TAG_ALLOC_RR, \ + .tag_alloc_policy = SCSI_TAG_ALLOC_RR, \ .device_configure = ata_scsi_device_configure#define ATA_BASE_SHT (drv_name) \
include/scsi/scsi_host.h +6 -1
@@ -39,6 +39,11 @@ enum scsi_timeout_action { SCSI_EH_NOT_HANDLED, }; +enum scsi_tag_alloc_policy { +SCSI_TAG_ALLOC_FIFO ,/* allocate starting from 0 */ +SCSI_TAG_ALLOC_RR ,/* allocate starting from last allocated tag */ +}; +struct scsi_host_template {/* * Put fields referenced in IO submission path together in
@@ -439,7 +444,7 @@ struct scsi_host_template {short cmd_per_lun;/* If use block layer to manage tags, this is tag allocation policy */ -int tag_alloc_policy; +enum scsi_tag_alloc_policy tag_alloc_policy;/* * Track QUEUE_FULL events and reduce queue depth on demand.
Signature · 1 line
2.45.2
Re: [PATCH 4/4] block: simplify tag allocation policy selection
Quoted 5 lines
}; #undef HCTX_FLAG_NAMEblock/blk-mq-debugfs.c +0
-0@@ -192,22 +186,11 @@ static const char *const hctx_flag_name[] = {static int hctx_flags_show (void *data,struct seq_file *m)
block/blk-mq-debugfs.c static const char *const hctx_flag_name[] = { · line 201
Quoted 10 lines
block/blk-mq-debugfs.c +1
-5{struct blk_mq_hw_ctx *hctx = data; -const int alloc_policy =BLK_MQ_FLAG_TO_ALLOC_POLICY (hctx->flags); -BUILD_BUG_ON (ARRAY_SIZE (hctx_flag_name) != -BLK_MQ_F_ALLOC_POLICY_START_BIT ); -BUILD_BUG_ON (ARRAY_SIZE (alloc_policy_name) !=BLK_TAG_ALLOC_MAX ); +BUILD_BUG_ON (ARRAY_SIZE (hctx_flag_name) !=ilog2 (BLK_MQ_F_MAX )); -seq_puts (m,"alloc_policy=" );
Maybe it's nice to preserve this formatting, but I know that debugfs is not a stable ABI...
Quoted 22 lines
block/blk-mq-debugfs.c +2
-9-if (alloc_policy <ARRAY_SIZE (alloc_policy_name) && - alloc_policy_name[alloc_policy]) -seq_puts (m, alloc_policy_name[alloc_policy]); -else -seq_printf (m,"%d" , alloc_policy); -seq_puts (m," " ); -blk_flags_show (m, - hctx->flags ^BLK_ALLOC_POLICY_TO_MQ_FLAG (alloc_policy), - hctx_flag_name,ARRAY_SIZE (hctx_flag_name)); +blk_flags_show (m, hctx->flags, hctx_flag_name, +ARRAY_SIZE (hctx_flag_name));seq_puts (m,"\n" );return 0 ;/*
drivers/ata/sata_sil24.c +0
-0
drivers/ata/sata_sil24.c static const struct scsi_host_template sil24_sht = { · line 381
Quoted 5 lines
drivers/ata/sata_sil24.c +1
-1@@ -378,7 +378,7 @@ static const struct scsi_host_template sil24_sht = { .can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, - .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, + .tag_alloc_policy = SCSI_TAG_ALLOC_FIFO,
do we actually need to set tag_alloc_policy to the default (SCSI_TAG_ALLOC_FIFO)?
drivers/ata/sata_sil24.c enum scsi_timeout_action { · line 45
Quoted 10 lines
drivers/ata/sata_sil24.c +4
-0.sdev_groups = ata_ncq_sdev_groups,@@ -39,6 +39,11 @@ enum scsi_timeout_action { SCSI_EH_NOT_HANDLED, }; +enum scsi_tag_alloc_policy { +SCSI_TAG_ALLOC_FIFO ,/* allocate starting from 0 */ +SCSI_TAG_ALLOC_RR ,/* allocate starting from last allocated tag */ +};
Could we just have
struct scsi_host_template {
...
int tag_alloc_policy_rr:1instead of this enum?
Or does that cause issues for the ATA SHT and descendants where it overrides members? I didn't think that it would.
Quoted 13 lines
drivers/ata/sata_sil24.c +2
-1+struct scsi_host_template {/* * Put fields referenced in IO submission path together in @@ -439,7 +444,7 @@ struct scsi_host_template {short cmd_per_lun;/* If use block layer to manage tags, this is tag allocation policy */ -int tag_alloc_policy; +enum scsi_tag_alloc_policy tag_alloc_policy;/* * Track QUEUE_FULL events and reduce queue depth on demand.
Christoph Hellwig
maintainerRe: [PATCH 4/4] block: simplify tag allocation policy selection
Quoted 6 lines · John Garry
block/blk-mq-debugfs.c static const char *const hctx_flag_name[] = {
Quoted 3 lines
block/blk-mq-debugfs.c +1
-1-BUILD_BUG_ON (ARRAY_SIZE (alloc_policy_name) !=BLK_TAG_ALLOC_MAX ); +BUILD_BUG_ON (ARRAY_SIZE (hctx_flag_name) !=ilog2 (BLK_MQ_F_MAX )); -seq_puts (m,"alloc_policy=" );Maybe it's nice to preserve this formatting, but I know that debugfs is not a stable ABI...
It's not a stable API indeed, and I'd rather not keep extra code for debugging.
Quoted 4 lines
Quoted 4 lines
index
72c03cbdaff4..d51eeba4da3c100644drivers/ata/sata_sil24.c +0
-0@@ -378,7 +378,7 @@ static const struct scsi_host_template sil24_sht = {
Quoted 8 lines
drivers/ata/sata_sil24.c static const struct scsi_host_template sil24_sht = { · line 381
Quoted 5 lines
drivers/ata/sata_sil24.c +1
-1.can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, - .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, + .tag_alloc_policy = SCSI_TAG_ALLOC_FIFO,do we actually need to set
tag_alloc_policyto the default (SCSI_TAG_ALLOC_FIFO)?
libata uses weird inheritance where __ATA_BASE_SHT sets default fields that can then later be override, so this is indeed needed to set the field back to the original default after the previous assignment changed it. (Did I mentioned I hate this style of programming? :))
Quoted 7 lines
Could we just have
struct scsi_host_template { ... int tag_alloc_policy_rr:1instead of this enum?
This should probably work. I tried to reduce the churn a bit, but due to the change of the enum value names that didn't actually work.
Quoted 3 lines
Or does that cause issues for the ATA SHT and descendants where it overrides members? I didn't think that it would.
It'll still work fine. It will be even less obvious, so the case mentioned above by you will probably have to grow a comment explaining it to preempt the cleanup brigade from removing it.
Christoph Hellwig
maintainerRe: [PATCH 4/4] block: simplify tag allocation policy selection
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines
drivers/ata/sata_sil24.c static const struct scsi_host_template sil24_sht = { · line 381
Quoted 8 lines
drivers/ata/sata_sil24.c +1
-1@@ -378,7 +378,7 @@ static const struct scsi_host_template sil24_sht = { .can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, - .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, + .tag_alloc_policy = SCSI_TAG_ALLOC_FIFO,do we actually need to set
tag_alloc_policyto the default (SCSI_TAG_ALLOC_FIFO)?
Quoted 4 lines
libata uses weird inheritance where
__ATA_BASE_SHTsets default fields that can then later be override, so this is indeed needed to set the field back to the original default after the previous assignment changed it. (Did I mentioned I hate this style of programming? :))
It turns out the clearning is not needed here, as the driver only uses __ATA_BASE_SHT and not ATA_BASE_SHT (did I mentioned I hate this templating?)
Re: [PATCH 4/4] block: simplify tag allocation policy selection
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Christoph Hellwig
Quoted 10 lines
drivers/ata/sata_sil24.c static const struct scsi_host_template sil24_sht = { · line 381
Quoted 8 lines
drivers/ata/sata_sil24.c +1
-1@@ -378,7 +378,7 @@ static const struct scsi_host_template sil24_sht = { .can_queue = SIL24_MAX_CMDS, .sg_tablesize = SIL24_MAX_SGE, .dma_boundary = ATA_DMA_BOUNDARY, - .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, + .tag_alloc_policy = SCSI_TAG_ALLOC_FIFO,do we actually need to set
tag_alloc_policyto the default (SCSI_TAG_ALLOC_FIFO)?
Quoted 6 lines
Quoted 4 lines
libata uses weird inheritance where
__ATA_BASE_SHTsets default fields that can then later be override, so this is indeed needed to set the field back to the original default after the previous assignment changed it. (Did I mentioned I hate this style of programming? :))It turns out the clearning is not needed here, as the driver only uses
__ATA_BASE_SHTand notATA_BASE_SHT
Yeah, if you build with W=1, you get "initialized field overwritten" error when trying to set a value more than once in the structure.
(did I mentioned I hate this
Quoted 1 line
templating?
Sure, but it reduces lots of code. Maybe a nicer model is something like scsi_host_alloc(), which sets defaults (when not set).
)