Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2064504ioo; Mon, 23 May 2022 09:18:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBqj4EELBarYDgdrAup9lsyKjUlo/Ly4PS43SC+b5QfTu+azQZ83cRMHYBMmBvbnoB/iPR X-Received: by 2002:a17:90a:bb10:b0:1e0:383b:de80 with SMTP id u16-20020a17090abb1000b001e0383bde80mr9430370pjr.67.1653322708446; Mon, 23 May 2022 09:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653322708; cv=none; d=google.com; s=arc-20160816; b=HVCGg4k+i2pzBG/u+igEyPIZiSaewNxRR2J+2U/jxyjOzzXUxu3exF1gLlHtV7BF9a n5xJmqYXYfNBWvIQ9t0CARsJuDtvqnNLHjWxjnRyVoaIp851tE2e3XA3X3oid+OBCJ/8 kTmTlq0ycmOXvWVMSnAJ7lAkYY/P03Z6EKbyAunGHpgy6Tp04AwFHke70ISnmBpQEfQN 1yIPEEs+wEYQ3GfprjufLqyBShGy8a9NFCahb64Im7aq21prXMOKOtoyYBhxNBiGbLll u9ZSkQ9mEQDi9QzwCKUYiBjAVdO//mYEM7NdoKBJEwxTfHLCs3CekBaJzHFa28NrtjiL mcEw== 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=fIf/6lZBIMLYnlgjkIJlslbFXYFBpGgwHc1kbNxW2m0=; b=DvZN5DNmsDhoN2t9LjGbit9uK6UjTpqEut6aICwNWivtgeKf6EUkzq0BTzRH/lkgBs VE83NjUwX6nT1E2pw0g1J0SesNVmq1BFPrPf6rJ0NSy2rkbtPHyCxu7J5SLawZmuusbW ZNa9+b6a4idU9+l4anTRtGhya86Ggv3etZIUGTByzaaBVi1JEYTP5w4G2c4ztPmin6st Y3uvlDv/T4z7lhJRhLrByTDct5WjiJqk3Nyy84pG8N1S12+fLnXYXBpCoLg+oMsZ+mfE vqgzMDTjsG/IIKt3JXCL1NZtmSMJRKPKMAFjDddJ2+XpkokDdCdHOeK35c/ewrwo+fo2 rdaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=vMHsFW9r; 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 u7-20020a626007000000b0050dc64e0685si13052028pfb.377.2022.05.23.09.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 09:18:28 -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=vMHsFW9r; 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 2E8E266AE5; Mon, 23 May 2022 09:18:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238670AbiEWQRF (ORCPT + 99 others); Mon, 23 May 2022 12:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238629AbiEWQQQ (ORCPT ); Mon, 23 May 2022 12:16:16 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 134802CCA9 for ; Mon, 23 May 2022 09:16:15 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220523161613euoutp024041b9ad4cf386719facd811831e9380~xyB8M_9by1865418654euoutp02Q for ; Mon, 23 May 2022 16:16:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220523161613euoutp024041b9ad4cf386719facd811831e9380~xyB8M_9by1865418654euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653322573; bh=fIf/6lZBIMLYnlgjkIJlslbFXYFBpGgwHc1kbNxW2m0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vMHsFW9rVTyOZMygBC1/GLnSpvbWzJm1jdrcQ8fenFlgbmnUcMzJBDHE7PdeV3hJj GybFytSWFkMqSSv/MIoA7/Tcg7kEpMAoVsemHMw9c/02aIRAo/uE0OE4JeDzCoiHqU 0WA3HRc90BS+aWkloGzfwKXOBD9/VjgbFiVAcltg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220523161612eucas1p1a9d5050929914d94c05669bd95e7e5c5~xyB66Yz_y1870118701eucas1p17; Mon, 23 May 2022 16:16:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FA.7E.09887.C43BB826; Mon, 23 May 2022 17:16:12 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220523161612eucas1p102a76ba431c934230309042521018915~xyB6eyhDU1546315463eucas1p1U; Mon, 23 May 2022 16:16:12 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220523161612eusmtrp291363c1e24ed18c446c30856c864aca3~xyB6eBYUJ0219402194eusmtrp2L; Mon, 23 May 2022 16:16:12 +0000 (GMT) X-AuditID: cbfec7f4-471ff7000000269f-21-628bb34c5ddf Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AE.92.09522.B43BB826; Mon, 23 May 2022 17:16:11 +0100 (BST) Received: from localhost (unknown [106.210.248.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220523161611eusmtip23dcc1d85f474d9be5b8476ac221bd377~xyB6E6DfN0632306323eusmtip2G; Mon, 23 May 2022 16:16:11 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, hare@suse.de, Johannes.Thumshirn@wdc.com Cc: linux-nvme@lists.infradead.org, dm-devel@redhat.com, dsterba@suse.com, jiangbo.365@bytedance.com, linux-kernel@vger.kernel.org, gost.dev@samsung.com, linux-block@vger.kernel.org, jaegeuk@kernel.org, Pankaj Raghav , Damien Le Moal Subject: [PATCH v5 6/7] null_blk: use zone_size_sects_shift for power of 2 zoned devices Date: Mon, 23 May 2022 18:16:00 +0200 Message-Id: <20220523161601.58078-7-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220523161601.58078-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLKsWRmVeSWpSXmKPExsWy7djP87o+m7uTDJ7skrFYfbefzeL32fPM Fq3t35gs9r6bzWpx4Ucjk8XNAzuZLPYsmsRksXL1USaLJ+tnMVv0HPjAYvG36x5Q3S1ti8u7 5rBZzF/2lN3i89IWdou2jV8ZHQQ8/p1Yw+Zx+Wypx6ZVnWwem5fUe+y+2cDmsbP1PqvH+31X 2Tz6tqxi9Fi/5SqLx+bT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161612eucas1p102a76ba431c934230309042521018915 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220523161612eucas1p102a76ba431c934230309042521018915 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220523161612eucas1p102a76ba431c934230309042521018915 References: <20220523161601.58078-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 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 Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/null_blk.h | 6 ++++++ drivers/block/null_blk/zoned.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 78eb56b0ca55..3d6e41a9491f 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -74,6 +74,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 00c34e65ef0a..806bef98ac83 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -13,8 +13,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); } @@ -82,6 +82,12 @@ 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 = div64_u64(roundup(dev_capacity_sects, dev->zone_size_sects), dev->zone_size_sects); -- 2.25.1