pmdk icon indicating copy to clipboard operation
pmdk copied to clipboard

pmem_map_file 1G limited mapped size

Open DanielLee343 opened this issue 3 years ago • 2 comments

QUESTION: Why my pmem_map_file has a maximum mapping size of 1G

Details

I was testing with RPMA example code, in which a function calls pmem_map_file().

mem->mr_ptr = pmem_map_file(path, 0 /* len */, 0 /* flags */, 0 /* mode */, &mem->mr_size, &mem->is_pmem);
            printf("memory size is: %d\n",mem->mr_size);//maximum is 1073741824 (1G)
            printf("is pmem? %d\n",mem->is_pmem); // 1

When the file size is below 1G, it works fine that the entire address space is mapped. However, when the file size is larger than 1G, the maximum mapped size is always 1G (mem->mr_sizeabove) Is it related to server's configuration or something? Thx!

DanielLee343 avatar Jun 13 '22 20:06 DanielLee343

The printf format specifier %d is not for size_t but for (signed) int, so your printf call may not output a proper value of mem->mr_size. How about using %zu instead of %d?

AFAIK, when all of the len, flags, and mode are 0, pmem_map_file opens the existing file on the path, maps the whole of it into memory, then stores its size in bytes into mapped_len (mem->mr_size here). If the size of your file on the path is 2G and the pmem_map_file call succeeds, mem->mr_size should also be 2G.

tmenjo avatar Jun 23 '22 06:06 tmenjo

Or, how about setting PMEM_LOG_LEVEL for dumping debug log? Please see the "DEBUGGING AND ERROR HANDLING" section in the libpmem man page.

https://pmem.io/pmdk/manpages/linux/master/libpmem/libpmem.7/

tmenjo avatar Jun 23 '22 07:06 tmenjo

This issue seems inactive now, if you still have some questions, please re-open it.

lukaszstolarczuk avatar Mar 13 '23 11:03 lukaszstolarczuk