Re: [RFC v2 1/2] dmapool: Move pool metadata into non-DMA memory

From: Christoph Hellwig
Date: Wed Nov 20 2024 - 04:37:30 EST


On Tue, Nov 19, 2024 at 09:55:28PM +0100, Brian Johannesmeyer wrote:

> + page->blocks_per_page = pool->allocation / pool->size;
> + page->blocks = kmalloc_array(page->blocks_per_page,
> + sizeof(struct dma_block), GFP_KERNEL);

Given that you now need an array of the blocks anyway, it might make
sense to switch from a linked list to a bitmap for tracking free state,
which would be a lot more efficient as you only need a bit per block
as tracking overhead instead of a two pointers and a dma_addr_t.

e.g. do a find_first_zero_bit() to find the ffree slot, then calculate
the dma_addr and virt address by simple offseting into the dma_page
ones with bitnr * pool->size.