Skip to contentSkip to conversation

virtually and physically (page) aligned allocation

DISCUSSION Parav Pandit 3 participants 3 messages Feb 24, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

Can user space application allocate memory which is virtually and physically aligned to the system's page boundary in the Linux 2.6.x? Such as using posix_memalign().

In other way,
If user space application allocates memory which is aligned to page boundary for say 4 pages using posix_memalign(), will is ensure that it corresponds to exactly 4 physical pages in kernel which can be pinned down?

Regards,
Parav Pandit

#1 lore raw
Quoted 8 lines · Parav Pandit

Hi,

Can user space application allocate memory which is virtually and physically aligned to the system's page boundary in the Linux 2.6.x? Such as using posix_memalign().

In other way,
If user space application allocates memory which is aligned to page boundary for say 4 pages using posix_memalign(), will is ensure that it corresponds to exactly 4 physical pages in kernel which can be pinned down?

You can use hugetlbfs to allocate a 2 MB page, otherwise no.

-hpa

#2 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 5 lines · Parav Pandit

In other way,
If user space application allocates memory which is aligned to page boundary for say 4 pages using posix_memalign(), will is ensure that it corresponds to exactly 4 physical pages in kernel which can be pinned down?

You can use hugetlbfs to allocate a 2 MB page, otherwise no.

Well, posix_memalign should be able to give you alignment of up to page size in real addresses (which I think is what Parav was asking for), but can not guarantee larger than page size real alignment.

If an address is page aligned in user space, it is also guaranteed to be page aligned in real storage. Alignment larger than page size can not be forced or detected in user space except when using hugetlbfs.

	Arnd <><