[PATCH] nvme-pci: derive and better document max segments limits

Keith Busch kbusch at kernel.org
Fri May 16 08:17:26 PDT 2025


On Fri, May 16, 2025 at 09:21:52AM +0200, Christoph Hellwig wrote:
> Redefine the max segments and max integrity limits based on the limiting
> factors without changing the final values and add comments explaining
> them.

...
 
>  #define NVME_MAX_KB_SZ	8192
> -#define NVME_MAX_SEGS	128
> -#define NVME_MAX_META_SEGS 15
>  #define NVME_MAX_NR_DESCRIPTORS	5
>  
> +/*
> + * For data SGLs we support a single descriptors worth of SGL entries, but for
> + * now we also limit it to avoid an allocation larger than PAGE_SIZE for the
> + * scatterlist.
> + */
> +#define NVME_MAX_SEGS \
> +	min(NVME_CTRL_PAGE_SIZE / sizeof(struct nvme_sgl_desc), \
> +	    (PAGE_SIZE / sizeof(struct scatterlist)))

If your page size is >=8k, this should change the value of NVME_MAX_SEGS
to 256. I don't think that's a bad thing, but the commit message doesn't
reflect that.

The diff looks good.

Reviewed-by: Keith Busch <kbusch at kernel.org>



More information about the Linux-nvme mailing list