Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1454707rwb; Tue, 4 Oct 2022 23:03:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47njbt/ld6XHsUSHZKgV694Shzsile3ergF1zfmeg+4Re2uZIbfSlmXpUmaHT+afHgvUZB X-Received: by 2002:a17:907:a425:b0:78c:a4d6:5947 with SMTP id sg37-20020a170907a42500b0078ca4d65947mr8590243ejc.172.1664949800101; Tue, 04 Oct 2022 23:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664949800; cv=none; d=google.com; s=arc-20160816; b=GTv/AmsDVmpCF3NfivyTIsMbQTTLWama95yfetJGH2sWzhg8JDbjgMltjnifbKgOtm 46ZqARguC2+ICjrcDKHIcfVZ9IuT5unZmwbxlGTN/UYorZe7Q7uwIpdCwO4Z4GUra5e0 dJGLVpBn1+V0l1zqAAWKQrNH1GML1H4W0HdBrH1jAchvC7X8QQSjUBPb/cXSaBN7ONwi 70OD5FEmqauDT0FSprqH4hxhbLRBR9/h4ycxIPhAe29RF56SmvTgNweRaZsrSvOeO7k4 Q9ru8cyhWg+VriMzGJMAM0teolBnqoolkMV7ElI0CneWj/ORkBOPbIpkSP+auZhWjpNf 5wqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=Beoyi6lpSF5zXtRIxeyO4+gao6QUOyJQkR3U0Fcwf8I=; b=tzrVVzHGMDNJ+hfI+y+kMQZ9Pn4aYTMno2MK0WsVfzeLMetAgESm8zs408o+uTpq+9 cXDVuUEZpL5lPfiDsW2+o18GL2LNeImAD6LcoAaS/39k6dJwtQm8Ttv9srdDeieyzjkG H8rCNBi6eu6IlGwoZaaUt3SBJAL6mutV7trTZPVykRWeuNuvhB12eOfEKe7/v6ynq2zp J0m+WQfEhWMUZuSQ9ZMWTQH/ml3f4vLOUlzXSlk5bWVG038td4Qqk7cg9hirghn/ETtq X1r+q9mcGIZ1Cvvn+N/J1Gf8+xGRQeAzerpThPY98wWkjDYp9r+hmiFy9XzjGFIvgkIz MwKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=d5M7Nh+T; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=TIEBMvTw; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg14-20020a170907320e00b0077bc1269f8esi16828955ejb.424.2022.10.04.23.02.54; Tue, 04 Oct 2022 23:03:20 -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; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=d5M7Nh+T; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=TIEBMvTw; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiJEFLb (ORCPT + 99 others); Wed, 5 Oct 2022 01:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiJEFL1 (ORCPT ); Wed, 5 Oct 2022 01:11:27 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5055321B9 for ; Tue, 4 Oct 2022 22:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1664946686; x=1696482686; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=t4Ggk8JN7aJqaDrHkVXVhSu8+EOy8cvFecQ8rYNiwuM=; b=d5M7Nh+TDp+AuknrtRV1l+d4h9hEPpkYy8pG+r+CJKXV+Hxbs0dupCMe htuoxowDa/6i/Gu2ZlfwlGd3F2OlmqzrL32b0zmqb4FSch38qSRcR/uqQ 379XF9lgULWgc8TGSIaPel+atiP0dBH1YCKWjYCMfWjRsQCQ34ernBhya nPPMifxoi1cPOCCpZHiARSdJsMmsdlbK45LLT3gJepfBpdqqYAMGxCJln 55ux5bEU1XVslH+1dSE/6xjxuNTSrnz32sNbUbThqpiMw9fdeevzYBKuR YlPNRealJt6riCYmmmHwUAt6CKcf7YlB51X9qAU0aeA/A3OHjEj1Tp7S0 Q==; X-IronPort-AV: E=Sophos;i="5.95,159,1661788800"; d="scan'208";a="213420100" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 05 Oct 2022 13:11:26 +0800 IronPort-SDR: /A+nwWwBZ/+9ZwRqIJ7DcKtQ4h9Z7w/4o1XDTlh+gCw9kVjqB1sX87w6PtQ83VxNJwg8nAsp/s TEJAEe+5Ar8p7iagNDifG1V3BLG5f63Dnymc830WNwSsc1EefQui/RPsD30LtqUHemXoBSNYO3 N1Sjy6Kug/Y7HJrvdsmxsBh0t1C6fD9Jh6xzSqo1It/Kb42gfhYPKXMSDFueYk/Ggl0S2jTLIy D0OsqaDL/qMY8YRHqBnpZ6kxRE+8j+noMaIJBRavRlZ+aR4fqnnPsLNME4tjCHaLbGCtyhLtxV Jnc60LF8+4Ff+7gat74jIMB9 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 04 Oct 2022 21:31:14 -0700 IronPort-SDR: rgMMNNs1dWJFNKEWQnPrr71oQcaq8uzjn55gsTK7mjC1IXG4mLpC9xfOgZZ5F9oc7xn/6zFr3K gehz2SWiEuNmOZbC+5dqinP6+6Ys+0nE+cj8GPmcI/P4XQm8Y6OAa0vzt8DbKu7qNlKcxwm/ty SxY95V2qMcS3oyAMlnOA0ZJn1p+hwSc0euNkfZ0acEtp3lO+jBPWRjeraglDZ/1/F4+ciXIHuX q3ZnHJJ2PXzm3w3vUQc0AfN9NXyzy0EMUILicxkvAe5V3ZfFLeDXBIb4DGoAR4JrD9bpV6ET4x wgw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 04 Oct 2022 22:11:27 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Mj2jT25Vlz1RvTp for ; Tue, 4 Oct 2022 22:11:25 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1664946683; x=1667538684; bh=t4Ggk8JN7aJqaDrHkVXVhSu8+EOy8cvFecQ 8rYNiwuM=; b=TIEBMvTwNbQfRcdLCIdhIV1cDzUY7/zZNt4FTW87ZJI3MGaBzkb qqEGe+xann+Fr9ERkXZFiwH9qA5kw9KT1tWAv8xyW22GImuAepWY3G/bUWvxbx3+ DcHlhNaLqbjABQSXRcSsC/ZJ18eLMou237FM3i8KOcuTsorywWPIdSOHXmXMRQVh zKad+6i9lAPQe7q6dcRC1UYzId7HaifDb4E/41pWM2EEiudVUCqUjBTfW0PhB5x4 L1/2ED3lJAQXvJk1jeoGDt9yB38D0GN1mBooIkJF8nCh8QfQQq+ELcm1zBX6rfoi FK/0qGjDUpdCP6zsNMCBumXsyWKKoRV+WFQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hEt84ASWFX3O for ; Tue, 4 Oct 2022 22:11:23 -0700 (PDT) Received: from [10.225.163.106] (unknown [10.225.163.106]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Mj2jD37C6z1RvLy; Tue, 4 Oct 2022 22:11:12 -0700 (PDT) Message-ID: <6fee2d7a-7fd1-73ee-2911-87a4ed3e8769@opensource.wdc.com> Date: Wed, 5 Oct 2022 14:11:11 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [RFC PATCH 01/21] block: add and use init tagset helper Content-Language: en-US To: Chaitanya Kulkarni , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-nvme@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org Cc: axboe@kernel.dk, efremov@linux.com, josef@toxicpanda.com, idryomov@gmail.com, dongsheng.yang@easystack.cn, haris.iqbal@ionos.com, jinpu.wang@ionos.com, mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, ohad@wizery.com, andersson@kernel.org, baolin.wang@linux.alibaba.com, ulf.hansson@linaro.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, hare@suse.de, bhelgaas@google.com, john.garry@huawei.com, mcgrof@kernel.org, christophe.jaillet@wanadoo.fr, vaibhavgupta40@gmail.com, wsa+renesas@sang-engineering.com, johannes.thumshirn@wdc.com, bvanassche@acm.org, ming.lei@redhat.com, shinichiro.kawasaki@wdc.com, vincent.fu@samsung.com, christoph.boehmwalder@linbit.com, joel@jms.id.au, vincent.whitchurch@axis.com, nbd@other.debian.org, ceph-devel@vger.kernel.org, virtualization@lists.linux-foundation.org, asahi@lists.linux.dev References: <20221005032257.80681-1-kch@nvidia.com> <20221005032257.80681-2-kch@nvidia.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20221005032257.80681-2-kch@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org On 10/5/22 12:22, Chaitanya Kulkarni wrote: > Add and use the helper to initialize the common fields of the tag_set > such as blk_mq_ops, number of h/w queues, queue depth, command size, > numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization > is spread all over the block drivers. This avoids the code repetation of > the inialization code of the tag set in current block drivers and any s/inialization/initialization s/repetation/repetition > future ones. > > Signed-off-by: Chaitanya Kulkarni > --- > block/blk-mq.c | 20 ++++++++++++++++++++ > drivers/block/null_blk/main.c | 10 +++------- > include/linux/blk-mq.h | 5 +++++ > 3 files changed, 28 insertions(+), 7 deletions(-) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 8070b6c10e8d..e3a8dd81bbe2 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -4341,6 +4341,26 @@ static int blk_mq_alloc_tag_set_tags(struct blk_mq_tag_set *set, > return blk_mq_realloc_tag_set_tags(set, 0, new_nr_hw_queues); > } > > +void blk_mq_init_tag_set(struct blk_mq_tag_set *set, > + const struct blk_mq_ops *ops, unsigned int nr_hw_queues, > + unsigned int queue_depth, unsigned int cmd_size, int numa_node, > + unsigned int timeout, unsigned int flags, void *driver_data) That is an awful lot of arguments... I would be tempted to say pack all these into a struct but then that would kind of negate this patchset goal. Using a function with that many arguments will be error prone, and hard to review... Not a fan. > +{ > + if (!set) > + return; > + > + set->ops = ops; > + set->nr_hw_queues = nr_hw_queues; > + set->queue_depth = queue_depth; > + set->cmd_size = cmd_size; > + set->numa_node = numa_node; > + set->timeout = timeout; > + set->flags = flags; > + set->driver_data = driver_data; > +} > + No blank line here. > +EXPORT_SYMBOL_GPL(blk_mq_init_tag_set); > + > /* > * Alloc a tag set to be associated with one or more request queues. > * May fail with EINVAL for various error conditions. May adjust the > diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c > index 1f154f92f4c2..0b07aab980c4 100644 > --- a/drivers/block/null_blk/main.c > +++ b/drivers/block/null_blk/main.c > @@ -1926,13 +1926,9 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set) > flags |= BLK_MQ_F_BLOCKING; > } > > - set->ops = &null_mq_ops; > - set->cmd_size = sizeof(struct nullb_cmd); > - set->flags = flags; > - set->driver_data = nullb; > - set->nr_hw_queues = hw_queues; > - set->queue_depth = queue_depth; > - set->numa_node = numa_node; > + blk_mq_init_tag_set(set, &null_mq_ops, hw_queues, queue_depth, > + sizeof(struct nullb_cmd), numa_node, 0, flags, nullb); > + > if (poll_queues) { > set->nr_hw_queues += poll_queues; > set->nr_maps = 3; > diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h > index ba18e9bdb799..06087a8e4398 100644 > --- a/include/linux/blk-mq.h > +++ b/include/linux/blk-mq.h > @@ -708,6 +708,11 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, > struct request_queue *q); > void blk_mq_destroy_queue(struct request_queue *); > > + No need for the extra whiteline. > +void blk_mq_init_tag_set(struct blk_mq_tag_set *set, > + const struct blk_mq_ops *ops, unsigned int nr_hw_queues, > + unsigned int queue_depth, unsigned int cmd_size, int numa_node, > + unsigned int timeout, unsigned int flags, void *driver_data); > int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set); > int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set, > const struct blk_mq_ops *ops, unsigned int queue_depth, -- Damien Le Moal Western Digital Research