[PATCH 18/19] iommu: Update various drivers to pass in lg2sz instead of order to iommu pages

Jason Gunthorpe jgg at nvidia.com
Wed Feb 5 10:39:59 PST 2025


On Wed, Feb 05, 2025 at 06:03:54PM +0000, Robin Murphy wrote:
> But what's the benefit of having extra stuff capable of turning a constant
> into a different constant that doesn't represent anything we
> actually want?

The API is inherently log2 based, like alloc_pages() is. You could
make the same argument that alloc_pages() should accept a size and do
order internally too.

> We still end up doing more runtime arithmetic on lg2sz within the allocation
> function itself to turn it into the order we ultimately still need, so that
> arithmetic could just as well be get_order(size) and have nothing to inline

Okay, sure it isn't fast path or anything. It just seems weird to
start out with a lg2 constant value in most callers, shift it to a
size, then ilog2 it back to a lg2. There are few places that don't
have a compile time lg2 available.

Jason



More information about the linux-riscv mailing list