On 08/02/2018 07:56 PM, Matthew Wilcox wrote: > >> One of the nice things about this is that dma_pool_free() can do some >> additional sanity checks: >> *) Check that the offset of the passed-in address corresponds to a valid >> block offset. > Can't we do that already? Subtract the base address of the page from > the passed-in vaddr and check it's a multiple of pool->size? The gaps caused by 'boundary' make it a lot more complicated than that. See pool_offset_to_blk_idx(). Your suggestion is the fast-path top part of pool_offset_to_blk_idx() where dma_pool_create() set blks_per_boundary to 0 to get a speed boost. The ugly slow case to take the boundary into account is the bottom part of pool_offset_to_blk_idx().