#!/bin/sh
nr_hugepages=$(awk '/MemAvailable/{printf "%d\n", $2/(2*1024)}' /proc/meminfo)
echo Eating some pagecache
file=/mnt/data/file.1
nr_blocks=$(awk '/MemTotal/{printf "%d\n", $2/4}' /proc/meminfo)
dd of=/dev/null if=/mnt/data/file.1 bs=4096 count=$nr_blocks
cat /proc/buddyinfo
echo Trying to allocate $nr_hugepages
/bin/echo $nr_hugepages > /proc/sys/vm/nr_hugepages
cat /proc/sys/vm/nr_hugepages
cat /proc/buddyinfo
echo Try to compact
echo 1 > /proc/sys/vm/compact_memory
cat /proc/buddyinfo
echo 0 > /proc/sys/vm/nr_hugepages
