I am building a user-mode NUMA-aware memory allocator for linux. The allocator during its initialization grabs a large chunk of memory, one chunk per NUMA node. After this, memory pages requested by the user are met by giving as many memory pages from the large chunk pool.
If the user asks for n pages, it is easy to give n pages from a particular chunk. But now I want to implement an interleaved allocation policy, where the user gets one page from each chunk, round-robin up to n pages. This brings up the problem of the virtual addresses of these pages no longer being contiguous.
Q1: Is there a way to return virtually addressable contiguous memory? The only solution I can think of is using a "smart" pointer who knows how to jump from one page to another.
One of the reasons I am walking this path is that I am not happy with the MPOL_INTERLEAVE memory allocation policy of linux whose round-robin policy is not strict (deterministic).
Q2: Is there an inexpensive way of knowing which page and NUMA node a given virtual address range is mapped to? More precisely I do not how to get fine-grained page-level information from reading /proc/< proc_id >/numa_maps .
Thank you for your answers.