[PATCHv2] nvme: only use power of two io boundaries

Damien Le Moal Damien.LeMoal at wdc.com
Thu Aug 27 21:03:30 EDT 2020


On 2020/08/28 0:35, Keith Busch wrote:
> The kernel requires a power of two for boundaries because that's the
> only way it can efficiently split commands that cross them. A
> controller, however, may report a non-power of two boundary.

I can understand that using a power of 2 limit for splitting can be more
efficient CPU-wise, but I do not think the kernel "requires" such a limit
alignment for splitting BIOs. BLK_SAFE_MAX_SECTORS is 255 after all. What I am
missing here ?

> 
> The driver had been rounding the controller's value to one the kernel
> can use, but splitting on the wrong boundary provides no benefit on the
> device side, and actually incurs additional submission overhead from
> non-optimal splits. Don't provide any boundary hint if the controller's
> value can't be used and log a warning when initially observing a disk's
> unreported io boundary.
> 
> Signed-off-by: Keith Busch <kbusch at kernel.org>
> ---
> v1->v2:
> 
>   Warn for the namespace with unusable io boundary.
> 
>  drivers/nvme/host/core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 154942fc64eb..9bbbd600621f 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2097,8 +2097,12 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
>  		}
>  	}
>  
> -	if (iob && !blk_queue_is_zoned(ns->queue))
> -		blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(iob));
> +	if (is_power_of_2(iob) && !blk_queue_is_zoned(ns->queue))
> +		blk_queue_chunk_sectors(ns->queue, iob);
> +	else if (iob && !(disk->flags & GENHD_FL_UP))
> +		dev_warn(ctrl->device, "namespace:%u has unused io boundary:%u\n",
> +			ns->head->ns_id, iob);

Isn't this going to generate a warning all the time for a ZNS drive ?

> +
>  	nvme_update_disk_info(disk, ns, id);
>  #ifdef CONFIG_NVME_MULTIPATH
>  	if (ns->head->disk) {
> 


-- 
Damien Le Moal
Western Digital Research



More information about the Linux-nvme mailing list