Message ID | 1666693096-180008-4-git-send-email-john.garry@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907341wru; Tue, 25 Oct 2022 02:51:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qgElAmJ4QMXGH6shrhJZy8+zS0jNir3/VbyQbEBb81bO/bYDb5PT4b6m65MQURMSnTn4/ X-Received: by 2002:a63:eb4a:0:b0:46f:63f:a892 with SMTP id b10-20020a63eb4a000000b0046f063fa892mr8805659pgk.33.1666691460138; Tue, 25 Oct 2022 02:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691460; cv=none; d=google.com; s=arc-20160816; b=pjEl834c4lqQ+f2PTyTFPtRGIpLjIt4V3g2+vOs9wiK3hTFHFGsZP9o1EhA8EF3Zoh Q4fgLRtmQAPKKlICZGDKPGwxnnx3LU3tLKtUVi2qElXfHB13Go/e6yKbza6a7HBtwJcx sRBCp62y1+NDi6Z/LaXaxwfGw4IK7vW/qagHc0cxST3814L7cRB1h4tgWqrjxEFV0+kY jyXXxOp0ASXkD1yCaJwjKh+qVOIFq06W54wk9SmzAcYW/MQ6fWGZCOl6bHfqgUb1Tkpt mrZEkDrn8WRLW9tfzq0O5mL4zSeO52i6Cywe6PGueE6PW8uwUHN51eA82FBusvdy6N2n Tnew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qTQOiahHLDfY4mgkx9YMjHO7E5GBSJKU3yE+4wLsVqA=; b=Q9DA08k6wcxj5TTl67ViU3frRYaeNVAV54Qe+Jnzb5SAxWxo7TfEA8lTp0N/dUch4E S+7lKsmgbG9lWJDaMtdyFbZkKZltg1pl5Ks6cxzmBET4MMo9XCU3uKE/9tV0cofTI2Av ZX0i2Rqe3C81tFg6TZaEJQcyU+Bt973CSqMvEqRbygMaJyOnbMikCfaGWrxIwFJIiD+L rScRbTGFL7oHj8eUxf6Uhm5EGKi0064ZZAaVZ3r4TnG+CEdnPTsycNxza2iPE12+pX9f r694h4gu4RtJogElh/SBtubRmLg+pYhUHEf9JCAdTtV4sNSj2WS2xvxDGhox+yyufG+p m9Vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a633c06000000b004404162e5e0si2527202pga.593.2022.10.25.02.50.46; Tue, 25 Oct 2022 02:51:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbiJYJsR (ORCPT <rfc822;lucius.rs.storz@gmail.com> + 99 others); Tue, 25 Oct 2022 05:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiJYJsI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Oct 2022 05:48:08 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DCE4E625; Tue, 25 Oct 2022 02:48:07 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRqR2sY4z689TS; Tue, 25 Oct 2022 17:44:35 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:05 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 10:48:01 +0100 From: John Garry <john.garry@huawei.com> To: <axboe@kernel.dk>, <damien.lemoal@opensource.wdc.com>, <jejb@linux.ibm.com>, <martin.petersen@oracle.com>, <jinpu.wang@cloud.ionos.com>, <hare@suse.de>, <bvanassche@acm.org>, <hch@lst.de>, <ming.lei@redhat.com>, <niklas.cassel@wdc.com> CC: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-ide@vger.kernel.org>, <linux-scsi@vger.kernel.org>, <linuxarm@huawei.com>, John Garry <john.garry@huawei.com> Subject: [PATCH RFC v3 03/22] scsi: core: Implement reserved command handling Date: Tue, 25 Oct 2022 18:17:57 +0800 Message-ID: <1666693096-180008-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693096-180008-1-git-send-email-john.garry@huawei.com> References: <1666693096-180008-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747652664882457301?= X-GMAIL-MSGID: =?utf-8?q?1747652664882457301?= |
Series |
blk-mq/libata/scsi: SCSI driver tagging improvements Part I
|
|
Commit Message
John Garry
Oct. 25, 2022, 10:17 a.m. UTC
From: Hannes Reinecke <hare@suse.de> Quite some drivers are using management commands internally, which typically use the same hardware tag pool (ie they are being allocated from the same hardware resources) as the 'normal' I/O commands. These commands are set aside before allocating the block-mq tag bitmap, so they'll never show up as busy in the tag map. The block-layer, OTOH, already has 'reserved_tags' to handle precisely this situation. So this patch adds a new field 'nr_reserved_cmds' to the SCSI host template to instruct the block layer to set aside a tag space for these management commands by using reserved tags. Signed-off-by: Hannes Reinecke <hare@suse.de> #jpg: Set tag_set->queue_depth = shost->can_queue, and not = shost->can_queue + shost->nr_reserved_cmds; Signed-off-by: John Garry <john.garry@huawei.com> --- drivers/scsi/hosts.c | 3 +++ drivers/scsi/scsi_lib.c | 2 ++ include/scsi/scsi_host.h | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-)
Comments
On 10/25/22 19:17, John Garry wrote: > From: Hannes Reinecke <hare@suse.de> > > Quite some drivers are using management commands internally, which > typically use the same hardware tag pool (ie they are being allocated > from the same hardware resources) as the 'normal' I/O commands. > These commands are set aside before allocating the block-mq tag bitmap, > so they'll never show up as busy in the tag map. > The block-layer, OTOH, already has 'reserved_tags' to handle precisely > this situation. > So this patch adds a new field 'nr_reserved_cmds' to the SCSI host > template to instruct the block layer to set aside a tag space for these > management commands by using reserved tags. > > Signed-off-by: Hannes Reinecke <hare@suse.de> > #jpg: Set tag_set->queue_depth = shost->can_queue, and not > = shost->can_queue + shost->nr_reserved_cmds; > Signed-off-by: John Garry <john.garry@huawei.com> > --- > drivers/scsi/hosts.c | 3 +++ > drivers/scsi/scsi_lib.c | 2 ++ > include/scsi/scsi_host.h | 15 ++++++++++++++- > 3 files changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c > index 12346e2297fd..db89afc37bc9 100644 > --- a/drivers/scsi/hosts.c > +++ b/drivers/scsi/hosts.c > @@ -489,6 +489,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) > if (sht->virt_boundary_mask) > shost->virt_boundary_mask = sht->virt_boundary_mask; > > + if (sht->nr_reserved_cmds) > + shost->nr_reserved_cmds = sht->nr_reserved_cmds; > + Nit: the if is not really necessary I think. But it does not hurt. > device_initialize(&shost->shost_gendev); > dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); > shost->shost_gendev.bus = &scsi_bus_type; > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index 39d4fd124375..a8c4e7c037ae 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -1978,6 +1978,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) > tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; > tag_set->nr_maps = shost->nr_maps ? : 1; > tag_set->queue_depth = shost->can_queue; > + tag_set->reserved_tags = shost->nr_reserved_cmds; > + Why the blank line ? > tag_set->cmd_size = cmd_size; > tag_set->numa_node = dev_to_node(shost->dma_dev); > tag_set->flags = BLK_MQ_F_SHOULD_MERGE; > diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h > index 750ccf126377..91678c77398e 100644 > --- a/include/scsi/scsi_host.h > +++ b/include/scsi/scsi_host.h > @@ -360,10 +360,17 @@ struct scsi_host_template { > /* > * This determines if we will use a non-interrupt driven > * or an interrupt driven scheme. It is set to the maximum number > - * of simultaneous commands a single hw queue in HBA will accept. > + * of simultaneous commands a single hw queue in HBA will accept > + * including reserved commands. > */ > int can_queue; > > + /* > + * This determines how many commands the HBA will set aside > + * for reserved commands. > + */ > + int nr_reserved_cmds; > + > /* > * In many instances, especially where disconnect / reconnect are > * supported, our host also has an ID on the SCSI bus. If this is > @@ -611,6 +618,12 @@ struct Scsi_Host { > */ > unsigned nr_hw_queues; > unsigned nr_maps; > + > + /* > + * Number of reserved commands to allocate, if any. > + */ > + unsigned int nr_reserved_cmds; > + > unsigned active_mode:2; > > /*
On 10/27/22 03:18, Damien Le Moal wrote: > On 10/25/22 19:17, John Garry wrote: >> From: Hannes Reinecke <hare@suse.de> >> >> Quite some drivers are using management commands internally, which >> typically use the same hardware tag pool (ie they are being allocated >> from the same hardware resources) as the 'normal' I/O commands. >> These commands are set aside before allocating the block-mq tag bitmap, >> so they'll never show up as busy in the tag map. >> The block-layer, OTOH, already has 'reserved_tags' to handle precisely >> this situation. >> So this patch adds a new field 'nr_reserved_cmds' to the SCSI host >> template to instruct the block layer to set aside a tag space for these >> management commands by using reserved tags. >> >> Signed-off-by: Hannes Reinecke <hare@suse.de> >> #jpg: Set tag_set->queue_depth = shost->can_queue, and not >> = shost->can_queue + shost->nr_reserved_cmds; >> Signed-off-by: John Garry <john.garry@huawei.com> >> --- >> drivers/scsi/hosts.c | 3 +++ >> drivers/scsi/scsi_lib.c | 2 ++ >> include/scsi/scsi_host.h | 15 ++++++++++++++- >> 3 files changed, 19 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c >> index 12346e2297fd..db89afc37bc9 100644 >> --- a/drivers/scsi/hosts.c >> +++ b/drivers/scsi/hosts.c >> @@ -489,6 +489,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) >> if (sht->virt_boundary_mask) >> shost->virt_boundary_mask = sht->virt_boundary_mask; >> >> + if (sht->nr_reserved_cmds) >> + shost->nr_reserved_cmds = sht->nr_reserved_cmds; >> + > > Nit: the if is not really necessary I think. But it does not hurt. > Yes, we do. Not all HBAs are able to figure out the number of reserved commands upfront; some modify that based on the PCI device used etc. So I'd keep it for now. Cheers, Hannes
On 27/10/2022 08:51, Hannes Reinecke wrote: >>> >>> Signed-off-by: Hannes Reinecke <hare@suse.de> >>> #jpg: Set tag_set->queue_depth = shost->can_queue, and not >>> = shost->can_queue + shost->nr_reserved_cmds; >>> Signed-off-by: John Garry <john.garry@huawei.com> >>> --- >>> drivers/scsi/hosts.c | 3 +++ >>> drivers/scsi/scsi_lib.c | 2 ++ >>> include/scsi/scsi_host.h | 15 ++++++++++++++- >>> 3 files changed, 19 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c >>> index 12346e2297fd..db89afc37bc9 100644 >>> --- a/drivers/scsi/hosts.c >>> +++ b/drivers/scsi/hosts.c >>> @@ -489,6 +489,9 @@ struct Scsi_Host *scsi_host_alloc(struct >>> scsi_host_template *sht, int privsize) >>> if (sht->virt_boundary_mask) >>> shost->virt_boundary_mask = sht->virt_boundary_mask; >>> + if (sht->nr_reserved_cmds) >>> + shost->nr_reserved_cmds = sht->nr_reserved_cmds; >>> + >> >> Nit: the if is not really necessary I think. But it does not hurt. >> > Yes, we do. > Not all HBAs are able to figure out the number of reserved commands > upfront; some modify that based on the PCI device used etc. > So I'd keep it for now. I think logically Damien is right as in the shost alloc shost->nr_reserved_cmds is initially zero, so: if (sht->nr_reserved_cmds) shost->nr_reserved_cmds = sht->nr_reserved_cmds; is same as simply: shost->nr_reserved_cmds = sht->nr_reserved_cmds; However I am just copying the coding style. Thanks, John
> >> device_initialize(&shost->shost_gendev); >> dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); >> shost->shost_gendev.bus = &scsi_bus_type; >> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >> index 39d4fd124375..a8c4e7c037ae 100644 >> --- a/drivers/scsi/scsi_lib.c >> +++ b/drivers/scsi/scsi_lib.c >> @@ -1978,6 +1978,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) >> tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; >> tag_set->nr_maps = shost->nr_maps ? : 1; >> tag_set->queue_depth = shost->can_queue; >> + tag_set->reserved_tags = shost->nr_reserved_cmds; >> + > Why the blank line ? > I don't think that it is required, I can remedy. >> tag_set->cmd_size = cmd_size; Thanks, John
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 12346e2297fd..db89afc37bc9 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -489,6 +489,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) if (sht->virt_boundary_mask) shost->virt_boundary_mask = sht->virt_boundary_mask; + if (sht->nr_reserved_cmds) + shost->nr_reserved_cmds = sht->nr_reserved_cmds; + device_initialize(&shost->shost_gendev); dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); shost->shost_gendev.bus = &scsi_bus_type; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 39d4fd124375..a8c4e7c037ae 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1978,6 +1978,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; tag_set->nr_maps = shost->nr_maps ? : 1; tag_set->queue_depth = shost->can_queue; + tag_set->reserved_tags = shost->nr_reserved_cmds; + tag_set->cmd_size = cmd_size; tag_set->numa_node = dev_to_node(shost->dma_dev); tag_set->flags = BLK_MQ_F_SHOULD_MERGE; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 750ccf126377..91678c77398e 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -360,10 +360,17 @@ struct scsi_host_template { /* * This determines if we will use a non-interrupt driven * or an interrupt driven scheme. It is set to the maximum number - * of simultaneous commands a single hw queue in HBA will accept. + * of simultaneous commands a single hw queue in HBA will accept + * including reserved commands. */ int can_queue; + /* + * This determines how many commands the HBA will set aside + * for reserved commands. + */ + int nr_reserved_cmds; + /* * In many instances, especially where disconnect / reconnect are * supported, our host also has an ID on the SCSI bus. If this is @@ -611,6 +618,12 @@ struct Scsi_Host { */ unsigned nr_hw_queues; unsigned nr_maps; + + /* + * Number of reserved commands to allocate, if any. + */ + unsigned int nr_reserved_cmds; + unsigned active_mode:2; /*