User Tools

Site Tools


how_to_choose_the_correct_memmap_kernel_parameter_for_pmem_on_your_system

This is an old revision of the document!


When selecting a memmap kernel parameter for PMEM you have to be careful that the physical addresses you are trying to reserve represent usable RAM. This information is easily available in the e820 table, available via dmesg.

Here is an example setup using a virtual machine with 20GiB of memory:

# dmesg | grep BIOS-e820
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bffdffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bffe0000-0x00000000bfffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000053fffffff] usable

In this output the regions marked as “usable” are fair game to be reserved for the PMEM driver, while the “reserved” regions are not. The last usable region represents the bulk of our available space, so we'll use that.

[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000053fffffff] usable

Plugging these physical addresses into our hex calculator, the region starts at 0x0000000100000000 (4 GiB) and ends at 0x000000053fffffff (21 GiB). Say we want to reserve 16 GiB to be used by PMEM. We can start this reservation at 4 GiB, and with size 16 GiB it will end at 20 GiB which is still within this usable range. The syntax for this reservation will then be as follows:

memmap=16G!4G

After rebooting with our new kernel parameter, we can see our new user defined e820 table via dmesg as well (the old table is still present, in case you want to compare):

# dmesg | grep user:
[    0.000000] user: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] user: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] user: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] user: [mem 0x0000000000100000-0x00000000bffdffff] usable
[    0.000000] user: [mem 0x00000000bffe0000-0x00000000bfffffff] reserved
[    0.000000] user: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] user: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] user: [mem 0x0000000100000000-0x00000004ffffffff] persistent (type 12)
[    0.000000] user: [mem 0x0000000500000000-0x000000053fffffff] usable

We can see that our new persistent memory range does indeed start at 4 GiB and end at 20 GiB, fully overlapping the usable memory range defined in the e820 table output.

If we have the pmem driver loaded, we will see this reserved memory range as /dev/pmem0:

# fdisk -l /dev/pmem0 
Disk /dev/pmem0: 16 GiB, 17179869184 bytes, 33554432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
how_to_choose_the_correct_memmap_kernel_parameter_for_pmem_on_your_system.1454690002.txt.gz · Last modified: 2016/02/05 16:33 by Ross Zwisler