From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Pankaj Raghav <p.raghav@samsung.com>,
hch@lst.de, axboe@kernel.dk, snitzer@kernel.org,
Johannes.Thumshirn@wdc.com
Cc: matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, hare@suse.de,
linux-block@vger.kernel.org, pankydev8@gmail.com,
bvanassche@acm.org, jaegeuk@kernel.org, dm-devel@redhat.com,
linux-nvme@lists.infradead.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH v8 05/11] null_blk: allow non power of 2 zoned devices
Date: Thu, 28 Jul 2022 12:14:43 +0900 [thread overview]
Message-ID: <d32ed9f5-9342-e3e6-ad84-bdf40eac5b0c@opensource.wdc.com> (raw)
In-Reply-To: <20220727162245.209794-6-p.raghav@samsung.com>
On 7/28/22 01:22, Pankaj Raghav wrote:
> 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=<iosize> --ioengine=io_uring --iodepth=<iod> --rw=<mode> --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 <mcgrof@kernel.org>
> Reviewed by: Adam Manzanares <a.manzanares@samsung.com>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
> drivers/block/null_blk/main.c | 5 ++---
> drivers/block/null_blk/null_blk.h | 6 ++++++
> drivers/block/null_blk/zoned.c | 18 +++++++++++-------
> 3 files changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index c451c477978f..f1e0605dee94 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -1976,9 +1976,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("Invalid zero zone size\n");
> return -EINVAL;
> }
>
> diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
> index 94ff68052b1e..ece6dded9508 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.
> + */
Simplify:
/*
* zone_size_sects_shift is used only when the zone size is a
* power of 2 number of sectors.
*/
But personally, I would simply drop this comment. The name is obvious and
the code very clear.
> + 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 55a69e48ef8b..015f6823706c 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -16,7 +16,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 (dev->zone_size_sects_shift)
> + return sect >> dev->zone_size_sects_shift;
> +
> + return div64_u64(sect, dev->zone_size_sects);
> }
>
> static inline void null_lock_zone_res(struct nullb_device *dev)
> @@ -65,10 +68,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;
> @@ -86,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);
> - dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects)
> - >> ilog2(dev->zone_size_sects);
>
> + 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)
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-07-28 3:15 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220727162246eucas1p1a758799f13d36ba99d30bf92cc5e2754@eucas1p1.samsung.com>
2022-07-27 16:22 ` [PATCH v8 00/11] support non power of 2 zoned device Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 01/11] block: make bdev_nr_zones and disk_zone_no generic for npo2 zsze Pankaj Raghav
2022-07-28 2:54 ` Damien Le Moal
2022-07-27 16:22 ` [PATCH v8 02/11] block: allow blk-zoned devices to have non-power-of-2 zone size Pankaj Raghav
2022-07-27 23:16 ` Bart Van Assche
2022-07-28 12:11 ` Pankaj Raghav
2022-07-28 13:29 ` Bart Van Assche
2022-07-29 9:09 ` Pankaj Raghav
2022-07-28 3:07 ` Damien Le Moal
2022-07-28 12:24 ` Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 03/11] nvme: zns: Allow ZNS drives that have non-power_of_2 " Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 04/11] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Pankaj Raghav
2022-07-28 3:09 ` Damien Le Moal
2022-07-29 7:45 ` Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 05/11] null_blk: allow non power of 2 zoned devices Pankaj Raghav
2022-07-27 21:59 ` Chaitanya Kulkarni
2022-07-29 7:51 ` Pankaj Raghav
2022-07-28 3:14 ` Damien Le Moal [this message]
2022-07-27 16:22 ` [PATCH v8 06/11] zonefs: " Pankaj Raghav
2022-07-28 3:16 ` Damien Le Moal
2022-07-27 16:22 ` [PATCH v8 07/11] dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2022-07-28 3:18 ` Damien Le Moal
2022-07-28 12:15 ` David Sterba
2022-07-29 8:00 ` Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 08/11] dm-zone: use generic helpers to calculate offset from zone start Pankaj Raghav
2022-07-28 3:20 ` Damien Le Moal
2022-07-27 16:22 ` [PATCH v8 09/11] dm-table: allow non po2 zoned devices Pankaj Raghav
2022-07-28 3:22 ` Damien Le Moal
2022-07-27 16:22 ` [PATCH v8 10/11] dm: call dm_zone_endio after the target endio callback for " Pankaj Raghav
2022-07-28 3:25 ` Damien Le Moal
2022-07-29 8:48 ` Pankaj Raghav
2022-07-27 16:22 ` [PATCH v8 11/11] dm: add power-of-2 zoned target for non-power-of-2 " Pankaj Raghav
2022-07-28 4:33 ` Damien Le Moal
2022-08-01 8:35 ` Pankaj Raghav
2022-07-27 23:19 ` [PATCH v8 00/11] support non power of 2 zoned device Bart Van Assche
2022-07-28 1:52 ` Damien Le Moal
2022-07-28 2:58 ` Bart Van Assche
2022-07-28 3:28 ` Damien Le Moal
2022-07-28 11:57 ` Pankaj Raghav
2022-07-28 13:30 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d32ed9f5-9342-e3e6-ad84-bdf40eac5b0c@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Johannes.Thumshirn@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dm-devel@redhat.com \
--cc=gost.dev@samsung.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=matias.bjorling@wdc.com \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=pankydev8@gmail.com \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox