[PATCH 5/7] nvme-pci: use a better encoding for small prp pool allocations
Keith Busch
kbusch at kernel.org
Tue May 13 08:06:38 PDT 2025
On Tue, May 13, 2025 at 09:00:21AM +0200, Christoph Hellwig wrote:
> +static inline struct dma_pool *nvme_dma_pool(struct nvme_queue *nvmeq,
> + struct nvme_iod *iod)
> +{
> + if (iod->flags & IOD_SMALL_DESCRIPTOR)
> + return nvmeq->descriptor_pools.small;
> + return nvmeq->descriptor_pools.large;
> +}
...
> if (i == NVME_CTRL_PAGE_SIZE >> 3) {
> __le64 *old_prp_list = prp_list;
> - prp_list = dma_pool_alloc(pool, GFP_ATOMIC, &prp_dma);
> +
> + prp_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod),
> + GFP_ATOMIC, &prp_dma);
You could assume nvmeq->descriptor_pools.large here. We'd never use the
small pool if we've enough elements to chain lists, and it would skip
the extra condition branch on each loop.
The same optimization is done in the free side already, too.
More information about the Linux-nvme
mailing list