[PATCH v9 22/24] nvme-pci: use a better encoding for small prp pool allocations
Leon Romanovsky
leon at kernel.org
Wed Apr 23 06:39:39 PDT 2025
On Wed, Apr 23, 2025 at 11:05:52AM +0200, Christoph Hellwig wrote:
> On Wed, Apr 23, 2025 at 11:13:13AM +0300, Leon Romanovsky wrote:
> > From: Christoph Hellwig <hch at lst.de>
> >
> > There is plenty of unused space in the iod next to nr_descriptors.
> > Add a separate flag to encode that the transfer is using the full
> > page sized pool, and use a normal 0..n count for the number of
> > descriptors.
> >
> > Signed-off-by: Christoph Hellwig <hch at lst.de>
> > Tested-by: Jens Axboe <axboe at kernel.dk>
> > [ Leon: changed original bool variable to be flag as was proposed by Kanchan ]
> > Signed-off-by: Kanchan Joshi <joshi.k at samsung.com>
> > Signed-off-by: Leon Romanovsky <leonro at nvidia.com>
> > ---
> > drivers/nvme/host/pci.c | 93 ++++++++++++++++++++---------------------
> > 1 file changed, 46 insertions(+), 47 deletions(-)
> >
> > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> > index 638e759b29ad..7e93536d01cb 100644
> > --- a/drivers/nvme/host/pci.c
> > +++ b/drivers/nvme/host/pci.c
> > @@ -44,6 +44,7 @@
> > #define NVME_MAX_SEGS 128
> > #define NVME_MAX_META_SEGS 15
> > #define NVME_MAX_NR_DESCRIPTORS 5
> > +#define NVME_SMALL_DESCRIPTOR_SIZE 256
> >
> > static int use_threaded_interrupts;
> > module_param(use_threaded_interrupts, int, 0444);
> > @@ -219,6 +220,10 @@ struct nvme_queue {
> > struct completion delete_done;
> > };
> >
> > +enum {
> > + IOD_LARGE_DESCRIPTORS = 1, /* uses the full page sized descriptor pool */
>
> This is used as a ORable flag, I'd make that explicit:
>
> /* uses the full page sized descriptor pool */
> IOD_LARGE_DESCRIPTORS = 1U << 0,
>
> and similar for the next flag added in the next patch.
>
> > struct nvme_request req;
> > struct nvme_command cmd;
> > bool aborted;
> > - /* # of PRP/SGL descriptors: (0 for small pool) */
> > - s8 nr_descriptors;
> > + u8 nr_descriptors; /* # of PRP/SGL descriptors */
> > + unsigned int flags;
>
> And this should be limited to a u16 to not bloat the structure.
I'll limit it to u8.
Thanks
>
More information about the Linux-nvme
mailing list