aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dmm/dmm_scripts/setup_hugepage.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dmm/dmm_scripts/setup_hugepage.sh')
-rwxr-xr-xtests/dmm/dmm_scripts/setup_hugepage.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/dmm/dmm_scripts/setup_hugepage.sh b/tests/dmm/dmm_scripts/setup_hugepage.sh
new file mode 100755
index 0000000000..be25709e01
--- /dev/null
+++ b/tests/dmm/dmm_scripts/setup_hugepage.sh
@@ -0,0 +1,37 @@
+#!/bin/bash -x
+
+# check and setup the hugepages
+SYS_HUGEPAGE=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages)
+hugepageFree=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/free_hugepages)
+
+if [ ${SYS_HUGEPAGE} -lt 1536 ] || [ $hugepageFree -eq 0 ]; then
+ MOUNT=$(mount | grep /mnt/nstackhuge)
+ count=$(mount | grep /mnt/nstackhuge | wc -l)
+
+ while [ "${MOUNT}" != "" ] || [ "${count}" -ne 0 ]
+ do
+ sudo umount /mnt/nstackhuge
+ sleep 1
+ MOUNT=$(mount | grep /mnt/nstackhuge)
+ count=$[$count -1]
+ done
+
+ sock_count=$(lscpu | grep 'Socket(s):' | head -1 | awk '{print $2}')
+ ls -l /sys/devices/system/node/
+
+ while [ "${sock_count}" -ne 0 ]
+ do
+ sock_count=$[$sock_count - 1]
+ echo 1536 | sudo tee /sys/devices/system/node/node"$sock_count"/hugepages/hugepages-2048kB/nr_hugepages
+ done
+
+ sudo mkdir -p /mnt/nstackhuge
+ sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
+ test $? -eq 0 || exit 1
+else
+ sudo mkdir -p /mnt/nstackhuge
+ sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
+fi
+
+cat /proc/meminfo
+exit 0