[ewg] Re: [PATCH v2] mlx4_ib: Optimize hugetlab pages support

Roland Dreier rdreier at cisco.com
Mon Jan 26 10:07:55 PST 2009


 > +	n = PAGE_ALIGN(umem->length + (umem->address & ~HPAGE_MASK)) >> HPAGE_SHIFT;

This is still wrong I think.  What if the user, say, registers 1MB that
is aligned exactly at a 2MB huge page start?  Then wouldn't this
expression set n to 0?  I think that PAGE_ALIGN() needs to be a
"HPAGE_ALIGN()", although of course that doesn't actually exist, so we
would need to do "ALIGN(..., HPAGE_SIZE)" instead... but given that
we're just going to do ">> HPAGE_SHIFT" afterwards, maybe
"DIV_ROUND_UP(..., HPAGE_SIZE)" is a better way to write it.

It maybe is needed to make sure that the virtual address requested is
aligned appropriately for using bigger pages (although this should
always be the case in the current code I guess, since the userspace
virtual address always matches the HCA MR virtual address).

 - R.



More information about the ewg mailing list