On Thu, Oct 23, 2025 at 4:52 PM Lyude Paul <[email protected]> wrote:
> One other change we should consider making though: can we make page_shift 32
> bit? A page shift of 32 would give us 2GB pages and I think that sounds way
> larger then anything we'd expect to encounter. Plus, we could just warn if we
> get a page shift larger then 32 bit and fail the ioctl. 64bit % 32bit should
> be faster and at least alleviate some of the overhead from the math here.
If the 64-bit modulo is a big concern, then this could also be
re-written to use bit arithmetic like this:
static bool
op_map_aligned_to_page_shift(const struct drm_gpuva_op_map *op, u8 page_shift)
{
u64 non_page_bits = (1ULL << page_shift) - 1;
return op->va.addr & non_page_bits == 0 &&
op->va.range & non_page_bits == 0 &&
op->gem.offset & non_page_bits == 0;
}