一、pmbd介绍
This software implements a block device driver for persistent memory (PM).This module provides a block-based logical interface to manage PM that is physically attached to the system memory bus.
二、编译和安装pmbd
1.Compile the PMBD driver:
$ make
2.Install the PMBD driver:
$ sudo make install
3.Check available driver information:
$ modinfo pmbd
make之前应该将版本改为本机内核版本
可能遇到的错误
编译成功之后,设置PMBD的物理地址(在内存中划分属于他的地址范围)
前提是查看本机内存使用情况:
$dmesg | grep e820 //usable
1.修改/etc/grub.conf 设置物理地址
memmap=<PM_SIZE_GB>G$<DRAM_SIZE_GB>G numa=off
NOTE:
Assuming a total memory capacity of 24GB, and if we want to use 16GB PM and 8GB DRAM, it should be “memmap=16G$8G”.
也可理解为内存如果共24G,前8G是memory,从第8G往后16G为PM。
EXAMPLE: Assuming a 16GB PM space with physical memory addresses from 8GB to 24GB:
(1) Basic (Ramdisk):
$ sudo modprobe pmbd mode="pmbd16;hmo8;hms16;"
(2) Protected (with private mapping):
$ sudo modprobe pmbd mode="pmbd16;hmo8;hms16;pmapY;"
(3) Protected and synced (with private mapping, non-temp store):
$ sudo modprobe pmbd mode="pmbd16;hmo8;hms16;pmapY;ntsY;"
(4) * RECOMMENDED CONFIG* Protected, synced, and ordered (with private mapping, nt-store, write barrier):
$ sudo modprobe pmbd mode="pmbd16;hmo8;hms16;pmapY;ntsY;wbY;"
挂载成功后,可通过如下命令查看:
$lsmod | grep pmbd
到这一步,就可以在pmbd上挂载文件系统(ext4…..)
$Sudo mkdir /mnt/pmdisk //建立挂载目录
$Sudo fdisk /dev/pma //分区
$Sudo mkfs.ext4 /dev/pma1 //格式化为ext4
$Sudo mount -t ext4 /dev/pma1 /mnt/pmdisk/ -o nodelalloc //以nodelalloc方式挂载设备
$mount //查看当前挂载目录,如下
测试脚本
#!/bin/sh
rm -r /mnt/pmdisk
mkdir /mnt/pmdisk
modprobe pmbd mode="pmbd16;hmo4;hms16;pmapY;"
mkfs.ext4 /dev/pma
mount /dev/pma /mnt/pmdisk
卸载脚本
#!/bin/sh
umount /mnt/pmdisk
rmmod pmbd