just follow this question here. Please correct me if I am on the wrong way.
A case we encounter in customer is that they are using pmem in such way:
1. devdax mode (no fs) for random access
2. no -volatile way.
3. multiple threads to do I/O on the same pmem mmap space for concurrency.
4. self defined allocation and free on pmem.
As it's said, pmem namespace is aligned in a page size of i.e. 2MB, if there are 3 threads, t1, t2, t3. A good way to reduce the fragmentation in this namespace could be like this:
t1 mmap to file + offset 0 in virtual address,
t2 mmap to file + offset 2MB in virtual address,
t3 mmap to file + offset 4MB,
Then they do allocation and free within the pagesize domain(2MB). This kind of mmap could be better in avoiding fragmentation in physical address than mmap to file + 1MB or so which cross two pages in pmem alignment.
Am I right？
based on my understanding, if the physical address is not continuous in pmem due to not aligned allocation, the pmem page swap in/out may encounter the similar problem as memory in OS kernel. For example, if pmem physical address is truncated like below, it may impossible for kernel to allocate new 2MB pmem page.
| 1MB free |--allocated 1MB-| 1MBfree | -- allocated1MB--| ........|