MAP_POPULATE does not work with XIP on ramdisk

From: Andiry Xu
Date: Tue Jan 06 2015 - 18:14:46 EST


Hi,

I'm testing mmap() performance on a ramdisk. The kernel is 3.19-rc3.

The device driver is brd, and the file system is ext2. Normal mmap()
does not make sense on a ramdisk because it adds additional memory
copy, so XIP is enabled to map the pages directly into application's
address space.

With XIP, MAP_POPULATE flag does not work. i.e. prefault fails.
Basically it fails in vm_normal_page(), where it's supposed to find
the struct page from pfn, but the vma has flag VM_MIXEDMAP and the
method returns NULL.

As I understand, VM_MIXEDMAP means the memory may not contain a struct
page backing, so the code logic is reasonable. However brd driver does
provide struct page for each memory page. If I modify the
__get_user_pages() and let the prefault runs for all the pages,
MAP_POPULATE works as expected.

My question is, is there any elegant way to workaround this? I do want
to make MAP_POPULATE works with XIP. This is because as the device is
memory and access latency is pretty low, page fault as well as the
mode switch play an important part in the software overhead. In my
experiment, MAP_POPULATE provides a 3x improvement on latency when
access a big file for the first time.

Thanks,
Andiry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/