dma-pool: dynamically expanding atomic pools
authorDavid Rientjes <rientjes@google.com>
Mon, 20 Apr 2020 10:09:58 +0000 (12:09 +0200)
committerChristoph Hellwig <hch@lst.de>
Sat, 25 Apr 2020 11:17:02 +0000 (13:17 +0200)
commit54adadf9b08571fb8b11dc9d0d3a2ddd39825efd
tree0aef45e03984a968dba71522c6c9528ba4ae58f9
parentc84dc6e68a1d2464e050d9694be4e4ff49e32bfd
dma-pool: dynamically expanding atomic pools

When an atomic pool becomes fully depleted because it is now relied upon
for all non-blocking allocations through the DMA API, allow background
expansion of each pool by a kworker.

When an atomic pool has less than the default size of memory left, kick
off a kworker to dynamically expand the pool in the background.  The pool
is doubled in size, up to MAX_ORDER-1.  If memory cannot be allocated at
the requested order, smaller allocation(s) are attempted.

This allows the default size to be kept quite low when one or more of the
atomic pools is not used.

Allocations for lowmem should also use GFP_KERNEL for the benefits of
reclaim, so use GFP_KERNEL | GFP_DMA and GFP_KERNEL | GFP_DMA32 for
lowmem allocations.

This also allows __dma_atomic_pool_init() to return a pointer to the pool
to make initialization cleaner.

Also switch over some node ids to the more appropriate NUMA_NO_NODE.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/pool.c