From patchwork Wed Jun 15 10:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882048 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65739C433EF for ; Wed, 15 Jun 2022 10:20:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-XPoa-_CYPg2XDF2h1F38IA-1; Wed, 15 Jun 2022 06:20:00 -0400 X-MC-Unique: XPoa-_CYPg2XDF2h1F38IA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FD5D801E67; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4B91415106; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D65631947B84; Wed, 15 Jun 2022 10:19:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A7C01949759 for ; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D0293400DF1D; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBB7740CFD0A for ; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B42993804516 for ; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-94gJWWA1P0KVGJsrQ5nbjw-1; Wed, 15 Jun 2022 06:19:48 -0400 X-MC-Unique: 94gJWWA1P0KVGJsrQ5nbjw-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101947euoutp023669c17652f78ea718ddba73f6da33ec~4xAS1yZmz2930429304euoutp02G for ; Wed, 15 Jun 2022 10:19:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101947euoutp023669c17652f78ea718ddba73f6da33ec~4xAS1yZmz2930429304euoutp02G Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615101945eucas1p1d5342ae55cf549f7f52be0f3f500a61c~4xARRJUWa2260522605eucas1p1F; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 39.3B.09664.142B9A26; Wed, 15 Jun 2022 11:19:45 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2~4xAQvVa5T1177311773eucas1p1k; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101945eusmtrp22c89343c319808137c8290492d5eddfa~4xAQudBoS0361403614eusmtrp2X; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-f7-62a9b24146d1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B5.55.09095.142B9A26; Wed, 15 Jun 2022 11:19:45 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101943eusmtip1dcf863a2a0f7ec36b4725dadaac7a2c0~4xAPefbdk0536005360eusmtip1f; Wed, 15 Jun 2022 10:19:43 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:13 +0200 Message-Id: <20220615101920.329421-7-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7djPc7qOm1YmGVzYbWSx+m4/m8W0Dz+Z LX6fPc9s0dr+jcli77vZrBYXfjQyWdw8sJPJYs+iSUwWK1cfZbJ4sn4Ws0XPgQ8sFn+77gHF Wh4yW+y9pW1xedccNov5y56yW9yY8JTR4vPSFnaLNTefs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ZGp3yv/b7 J/6YHV71Ju69/hGdsq6i5c73f5ltidkvHHtEUdwok1NYRuK2yJ7W7IOVmnyrUlwvMy1VYinO SDTUYi4qTgQABDAVGH8DAAA= X-CMS-MailID: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 X-Msg-Generator: CA X-RootMTR: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v7 06/13] null_blk: use zone_size_sects_shift for power of 2 zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , Damien Le Moal , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of doing is_power_of_2 and ilog2 operation for every IO, cache the zone_size_sects_shift variable and use it for power of 2 zoned devices. This variable will be set to zero for non power of 2 zoned devices. Suggested-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/null_blk.h | 6 ++++++ drivers/block/null_blk/zoned.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 8359b4384..3bc7cbf25 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -83,6 +83,12 @@ struct nullb_device { unsigned int imp_close_zone_no; struct nullb_zone *zones; sector_t zone_size_sects; + /* + * zone_size_sects_shift is only useful when the zone size is + * power of 2. This variable is set to zero when zone size is non + * power of 2. + */ + unsigned int zone_size_sects_shift; bool need_zone_res_mgmt; spinlock_t zone_res_lock; diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index daf327015..5f929944b 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -16,8 +16,8 @@ static inline sector_t mb_to_sects(unsigned long mb) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) { - if (is_power_of_2(dev->zone_size_sects)) - return sect >> ilog2(dev->zone_size_sects); + if (dev->zone_size_sects_shift) + return sect >> dev->zone_size_sects_shift; return div64_u64(sect, dev->zone_size_sects); } @@ -85,9 +85,14 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) zone_capacity_sects = mb_to_sects(dev->zone_capacity); dev_capacity_sects = mb_to_sects(dev->size); dev->zone_size_sects = mb_to_sects(dev->zone_size); + + if (is_power_of_2(dev->zone_size_sects)) + dev->zone_size_sects_shift = ilog2(dev->zone_size_sects); + else + dev->zone_size_sects_shift = 0; + dev->nr_zones = DIV_ROUND_UP_SECTOR_T(dev_capacity_sects, dev->zone_size_sects); - dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), GFP_KERNEL | __GFP_ZERO); if (!dev->zones)