The hugepage test really needs to check multiple things on Linux: 1. Are hugepages reserved in the system?
2. Is the hugepage mountpoint available so that we can allocate them? 3. Do we have permissions to write into the hugepage mountpoint? The existing hugepage check only verifies the first. On some setups, a non-root user won't have access to the mountpoint for hugepages to be allocated and that needs to be reflected in the test as well. Add such checks for Linux OS to give a more check when running test suites. Signed-off-by: Aaron Conole <acon...@redhat.com> --- app/test/has-hugepage.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh index d600fad319..1c3cfb665a 100755 --- a/app/test/has-hugepage.sh +++ b/app/test/has-hugepage.sh @@ -3,7 +3,17 @@ # Copyright 2020 Mellanox Technologies, Ltd if [ "$(uname)" = "Linux" ] ; then - cat /proc/sys/vm/nr_hugepages || echo 0 + nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) + # Need to check if we have permissions to access hugepages + perm="" + for mount in `mount | grep hugetlbfs | awk '{ print $3; }'`; do + test ! -w $mount/. || perm="$mount" + done + if [ "$perm" = "" -o "$nr_hugepages" = "0" ]; then + echo 0 + else + echo $nr_hugepages + fi elif [ "$(uname)" = "FreeBSD" ] ; then echo 1 # assume FreeBSD always has hugepages else -- 2.25.4