Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4805236iob; Mon, 9 May 2022 01:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe/u20mm4HNYPfZv0Qf4LnBUS5wCt8C/klALN8xsdYADLedp3jwu3yu4yGiv2Fo2Wx+ooL X-Received: by 2002:a05:6a00:18a4:b0:50d:f418:b982 with SMTP id x36-20020a056a0018a400b0050df418b982mr15201290pfh.49.1652086676819; Mon, 09 May 2022 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652086676; cv=none; d=google.com; s=arc-20160816; b=QO4pQSv0Idsbavn21E0ahiUkSiS4bbhDXTOQPUpWuYq8f1+OkDwX64sk5KhQeJOhWn kBUMAuJtZNFIwSWl9vfe0Obzf6Bc+uOoCo06KWioz+5h79iP7GNUS1fWRNbR99FJs+/f VyyP1TPPzEJ+Qauvh7nQAnK4DiWcAf7tR0pX3Pb0S7yVBqcoN06CNNn3FushnVxqM+Bp yz+7RN7EQpCYnGl4OE58mZzzigkm0WYN0AYt502XY8/MQJbRCV5CxfAzB2pZ42nAuaU+ UQWrTQVJoOQ5kQx0dJ+KoMAeD0th6STKtKRr282uHh3ZzjdEk1yN8F1o4UCir0l11Riz 9E+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=D05Y2RArrxR/ZcNMh/RJzrqiPuoU2BIWW0WuxZX2YSQ=; b=QbwUi3NgcmjcV1nusTnKHlr/2a+WZAGfjP1rdy1G4eaAds7tPLk420076xdqIuU7Mm wubtOwnLE5K92zTIhmgsSCRXIMX0hOOLMHZKaJCITAwaGEIVQqpEtdPB47bx429hKMjJ 8VDuOWv7P1TMfna1bBlec942R4Z5Yog8Zg91KFq48rSYbxdfPA62C0qjd+Zep3iWushq 1f6iBTeJxZ+D9sVsCS2U5kxt26rIdGxpso9SeCsxpccmm+Yj55i4ApwguPTiAdNO4Kp9 zViUG6y3OjWcoJa2dL3TxKPvcBh1K/Zcjv48g6hKnPMLRInglgM8UCAcGd4nCHj98mdO 3AAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AVnq6TSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y16-20020a62f250000000b0051069299ec6si12869968pfl.173.2022.05.09.01.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 01:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AVnq6TSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00DDC2871E; Mon, 9 May 2022 01:45:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380120AbiEENzl (ORCPT + 99 others); Thu, 5 May 2022 09:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380269AbiEENzG (ORCPT ); Thu, 5 May 2022 09:55:06 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BBCF2FE52 for ; Thu, 5 May 2022 06:51:14 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220505135113euoutp01f573e6041199889c1538b372aaa88d1d~sOcME4KAF3116431164euoutp011 for ; Thu, 5 May 2022 13:51:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220505135113euoutp01f573e6041199889c1538b372aaa88d1d~sOcME4KAF3116431164euoutp011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651758673; bh=D05Y2RArrxR/ZcNMh/RJzrqiPuoU2BIWW0WuxZX2YSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AVnq6TSnIid+zbL06EOGkBSL2O2TkR13NExMANbNJi+q+cDC0F4SVYMeHkkGmXaso jsh698805thBcg3VdtBGAin4C29T5s1PuG6Rv6dUVZseHbBObdreYkrtUpFxJ5rf7i pxwqPDEtjMj1WBUiXM0sNQF2Q7fKEmQlzfaC3IYw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220505135111eucas1p11ac926dfc697a45ef23092a11af516e6~sOcKakWSP1070010700eucas1p1H; Thu, 5 May 2022 13:51:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 22.0D.10009.F46D3726; Thu, 5 May 2022 14:51:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220505135110eucas1p1fc49b2574920b9a2a274f9d77feb5d18~sOcJuHBiZ2591125911eucas1p1J; Thu, 5 May 2022 13:51:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220505135110eusmtrp165d3f6c9363c20b14b019590934c8c59~sOcJtOm2O1365913659eusmtrp1L; Thu, 5 May 2022 13:51:10 +0000 (GMT) X-AuditID: cbfec7f2-e95ff70000002719-4f-6273d64f4513 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2C.6A.09404.E46D3726; Thu, 5 May 2022 14:51:10 +0100 (BST) Received: from localhost (unknown [106.210.248.170]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220505135110eusmtip2d2bc0b30a6c2752fd7d0ead76cf2177e~sOcJWiFKS1656016560eusmtip2R; Thu, 5 May 2022 13:51:10 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, dsterba@suse.com, jaegeuk@kernel.org, bvanassche@acm.org, hare@suse.de Cc: jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, matias.bjorling@wdc.com, gost.dev@samsung.com, pankydev8@gmail.com, Pankaj Raghav , Luis Chamberlain , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/11] null_blk: allow non power of 2 zoned devices Date: Thu, 5 May 2022 15:47:10 +0200 Message-Id: <20220505134710.132630-11-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220505134710.132630-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIKsWRmVeSWpSXmKPExsWy7djPc7r+14qTDK4d47FYfbefzWLah5/M Fr/Pnme2uPCjkcni5oGdTBZ7Fk1isli5+iiTxZP1s5gteg58YLFY2fKQ2WLvLW2Ly7vmsFlM aPvKbHFjwlNGi89LW9gt1tx8yuIg4HH5irfHvxNr2Dx2zrrL7nH5bKnHplWdbB4LG6Yye+y+ 2QAUb73P6tG3ZRWjx/otV1k8Np+u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S-MailID: 20220505135110eucas1p1fc49b2574920b9a2a274f9d77feb5d18 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220505135110eucas1p1fc49b2574920b9a2a274f9d77feb5d18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220505135110eucas1p1fc49b2574920b9a2a274f9d77feb5d18 References: <20220505134710.132630-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Convert the power of 2 based calculation with zone size to be generic in null_zone_no with optimization for power of 2 based zone sizes. The nr_zones calculation in null_init_zoned_dev has been replaced with a division without special handling for power of 2 based zone sizes as this function is called only during the initialization and will not invoked in the hot path. Performance Measurement: Device: zone size = 128M, blocksize=4k FIO cmd: fio --name=zbc --filename=/dev/nullb0 --direct=1 --zonemode=zbd --size=23G --io_size= --ioengine=io_uring --iodepth= --rw= --bs=4k --loops=4 The following results are an average of 4 runs on AMD Ryzen 5 5600X with 32GB of RAM: Sequential Write: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 578 | 2257 | 12.80 | 576 | 2248 | 25.78 | x-----------------x---------------------------------x---------------------------------x | With patch | 581 | 2268 | 12.74 | 576 | 2248 | 25.85 | x-----------------x---------------------------------x---------------------------------x Sequential read: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 667 | 2605 | 11.79 | 675 | 2637 | 23.49 | x-----------------x---------------------------------x---------------------------------x | With patch | 667 | 2605 | 11.79 | 675 | 2638 | 23.48 | x-----------------x---------------------------------x---------------------------------x Random read: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 522 | 2038 | 15.05 | 514 | 2006 | 30.87 | x-----------------x---------------------------------x---------------------------------x | With patch | 522 | 2039 | 15.04 | 523 | 2042 | 30.33 | x-----------------x---------------------------------x---------------------------------x Minor variations are noticed in Sequential write with io depth 8 and in random read with io depth 16. But overall no noticeable differences were noticed Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/main.c | 5 ++--- drivers/block/null_blk/zoned.c | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 5cb4c92cd..ed9a58201 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1929,9 +1929,8 @@ static int null_validate_conf(struct nullb_device *dev) if (dev->queue_mode == NULL_Q_BIO) dev->mbps = 0; - if (dev->zoned && - (!dev->zone_size || !is_power_of_2(dev->zone_size))) { - pr_err("zone_size must be power-of-two\n"); + if (dev->zoned && !dev->zone_size) { + pr_err("zone_size must not be zero\n"); return -EINVAL; } diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index dae54dd1a..00c34e65e 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -13,7 +13,10 @@ static inline sector_t mb_to_sects(unsigned long mb) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) { - return sect >> ilog2(dev->zone_size_sects); + if (is_power_of_2(dev->zone_size_sects)) + return sect >> ilog2(dev->zone_size_sects); + + return div64_u64(sect, dev->zone_size_sects); } static inline void null_lock_zone_res(struct nullb_device *dev) @@ -62,10 +65,6 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) sector_t sector = 0; unsigned int i; - if (!is_power_of_2(dev->zone_size)) { - pr_err("zone_size must be power-of-two\n"); - return -EINVAL; - } if (dev->zone_size > dev->size) { pr_err("Zone size larger than device capacity\n"); return -EINVAL; @@ -83,8 +82,9 @@ 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); - dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects) - >> ilog2(dev->zone_size_sects); + dev->nr_zones = + div64_u64(roundup(dev_capacity_sects, dev->zone_size_sects), + dev->zone_size_sects); dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), GFP_KERNEL | __GFP_ZERO); -- 2.25.1