Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] nvme/pci: PRP list DMA pool partitioning
@ 2025-04-21 16:17 Caleb Sander Mateos
  2025-04-21 16:17 ` [PATCH v2 1/2] nvme/pci: factor out nvme_init_hctx() helper Caleb Sander Mateos
  2025-04-21 16:17 ` [PATCH v2 2/2] nvme/pci: make PRP list DMA pools per-NUMA-node Caleb Sander Mateos
  0 siblings, 2 replies; 5+ messages in thread
From: Caleb Sander Mateos @ 2025-04-21 16:17 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Kanchan Joshi, linux-nvme, linux-kernel, Caleb Sander Mateos

NVMe commands with more than 4 KB of data allocate PRP list pages from
the per-nvme_device dma_pool prp_page_pool or prp_small_pool. Each call
to dma_pool_alloc() and dma_pool_free() takes the per-dma_pool spinlock.
These device-global spinlocks are a significant source of contention
when many CPUs are submitting to the same NVMe devices. On a workload
issuing 32 KB reads from 16 CPUs (8 hypertwin pairs) across 2 NUMA nodes
to 23 NVMe devices, we observed 2.4% of CPU time spent in
_raw_spin_lock_irqsave called from dma_pool_alloc and dma_pool_free.

Ideally, the dma_pools would be per-hctx to minimize
contention. But that could impose considerable resource costs in a
system with many NVMe devices and CPUs.

As a compromise, allocate per-NUMA-node PRP list DMA pools. Map each
nvme_queue to the set of DMA pools corresponding to its device and its
hctx's NUMA node. This reduces the _raw_spin_lock_irqsave overhead by
about half, to 1.2%. Preventing the sharing of PRP list pages across
NUMA nodes also makes them cheaper to initialize.

Caleb Sander Mateos (2):
  nvme/pci: factor out nvme_init_hctx() helper
  nvme/pci: make PRP list DMA pools per-NUMA-node

 drivers/nvme/host/pci.c | 172 +++++++++++++++++++++++-----------------
 1 file changed, 99 insertions(+), 73 deletions(-)

v2:
- Initialize admin nvme_queue's nvme_prp_dma_pools (Kanchan)
- Shrink nvme_dev's prp_pools array from MAX_NUMNODES to nr_node_ids (Kanchan)

-- 
2.45.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-21 16:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 16:17 [PATCH v2 0/2] nvme/pci: PRP list DMA pool partitioning Caleb Sander Mateos
2025-04-21 16:17 ` [PATCH v2 1/2] nvme/pci: factor out nvme_init_hctx() helper Caleb Sander Mateos
2025-04-21 16:17 ` [PATCH v2 2/2] nvme/pci: make PRP list DMA pools per-NUMA-node Caleb Sander Mateos
2025-04-21 16:33   ` Keith Busch
2025-04-21 16:43     ` Caleb Sander Mateos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox