- Install prerequisites, e.g. on Ubuntu install the following packages:
$ apt install build-essential linux-headers-generic
- Build kernel module
$ cd dma/driver/driver
$ make
- Create a group for users of hugepages, and retrieve its GID (in this example, 1001) then add yourself to the group.
$ groupadd hugetlbfs
$ getent group hugetlbfs
$ adduser dasidler hugetlbfs
- Edit
/etc/sysctl.conf
and add this text to specify the number of pages you want to reserve (see page-size)
# Allocate 8192*2MiB for HugePageTables
vm.nr_hugepages = 8192
# Members of group hugetlbfs(1001) can allocate "huge" shared memory segments
vm.hugetlb_shm_group = 1001
- Create a mount point for the file system
$ mkdir /media/huge
- Add this line in
/etc/fstab
(The mode 1770 allows anyone in the group to create files but not unlink or rename each other's files.)
# hugetlbfs
hugetlbfs /media/huge hugetlbfs mode=1770,gid=1001 0 0
-
Reboot
-
Add the following line to
/etc/security/limits.conf
to configure the amount of memory a user can lock, so an application can't crash your operating system by locking all the memory.
@hugetlbfs hard memlock 1048576
- Install prerequisites, e.g. on Ubuntu install the following packages:
$ apt install libboost-program-options-dev cmake
- Compile example application
$ cd dma-driver/sw
$ mkdir build && cd build
$ cmake ../src
$ make
- Load kernel module if not loaded yet.
$ cd dma-driver/driver
$ insmod xdma_driver.ko
- Run the Application (requires root permission)
$ cd dma-driver/sw/build
$ ./dma-example
- Load kernel module if not loaded yet.
$ cd dma-driver/driver
$ insmod xdma_driver.ko
- Run the Application (requires root permission)
$ cd dma-driver/sw/build
$ ./debug