aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gibson <dwg@au1.ibm.com>2009-11-19 19:11:28 +1100
committerEric B Munson <ebmunson@us.ibm.com>2009-11-19 08:35:07 +0000
commitc5f56f187505f039ebb692a615fefe766830b210 (patch)
tree6dbb1040a4e28e7524f6e09e800d7bc2d167f3b6
parent018405308d9e8d77430ff38b5dfb3c7aa227fb15 (diff)
downloadlibhugetlbfs-c5f56f187505f039ebb692a615fefe766830b210.tar.gz
Don't try to test multiple pagesizes for SysV shm
Currently, run_tests.py attempts to run each test case for each available page size and word size. It does this by setting the HUGETLB_DEFAULT_PAGE_SIZE environment variable to instruct the testcase's instance of libhugetlbfs to use the specified pagesize. However some of the testcases use shmget() with the SHM_HUGETLB flag to obtain hugepage backed memory, rather than mmap() or the libhugetlbfs interfaces. This means of obtaining hugepage memory has no way to specify the pagesize, and will always use the system default huge page size. Therefore, running the test multiple times when it won't actually use a different pagesize is silly. Furthermore in some of the cases, using the non-default sizes results in test failures (because we don't allocate as much memory as we expect) which have to be suppressed with a wrapper script which turns them into expected failures. This patch, therefore, alters run_tests.py to run the shm only tests with only the default page size. This is accomplished with a new helper function 'do_shm_test', which also folds in the setting and restoring of the shmmax limit for added convenience. The no longer necessary wrappers for shm-fork and shm-getraw are removed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
-rw-r--r--tests/Makefile2
-rwxr-xr-xtests/run_tests.py44
-rwxr-xr-xtests/shm-fork.sh18
-rwxr-xr-xtests/shm-getraw.sh18
4 files changed, 31 insertions, 51 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 737c44d..0e01237 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -18,7 +18,7 @@ LDSCRIPT_TESTS = zero_filesize_segment
HUGELINK_TESTS = linkhuge linkhuge_nofd linkshare
HUGELINK_RW_TESTS = linkhuge_rw
STRESS_TESTS = mmap-gettest mmap-cow shm-gettest shm-getraw shm-fork
-WRAPPERS = quota shm-fork shm-getraw counters madvise_reserve fadvise_reserve \
+WRAPPERS = quota counters madvise_reserve fadvise_reserve \
readahead_reserve
HELPERS = get_hugetlbfs_path compare_kvers
HELPER_LIBS = libheapshrink.so
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 547dd72..e53b71c 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -460,6 +460,20 @@ def restore_shm_sysctl(sysctls):
fh.write(val)
fh.close()
+def do_shm_test(cmd, limit=None, bits=None, **env):
+ """
+ Run a test case with temporarily expanded SysV shm limits, testing
+ each indicated word size.
+ """
+ if bits == None:
+ bits = wordsizes
+ if limit != None:
+ tmp = setup_shm_sysctl(limit)
+ for b in bits:
+ run_test(system_default_hpage_size, b, cmd, **env)
+ if limit != None:
+ restore_shm_sysctl(tmp)
+
def functional_tests():
"""
Run the set of functional tests.
@@ -510,9 +524,7 @@ def functional_tests():
do_test("readahead_reserve.sh")
do_test("madvise_reserve.sh")
do_test("fadvise_reserve.sh")
- sysctls = setup_shm_sysctl(64*1048576)
- do_test("shm-perms")
- restore_shm_sysctl(sysctls)
+ do_shm_test("shm-perms", 64*1024*1024)
# Tests requiring an active mount and hugepage COW
do_test("private")
@@ -562,8 +574,8 @@ def functional_tests():
do_test("get_huge_pages")
# Test overriding of shmget()
- do_test("shmoverride_linked")
- do_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so")
+ do_shm_test("shmoverride_linked")
+ do_shm_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so")
# Test hugetlbfs filesystem quota accounting
do_test("quota.sh")
@@ -589,23 +601,20 @@ def stress_tests():
do_test(("mmap-cow", repr(nr_pages-1), repr(nr_pages)))
(rc, tot_pages) = total_hpages()
- (rc, size) = hpage_size()
- sysctls = setup_shm_sysctl(tot_pages * size)
+ limit = system_default_hpage_size * tot_pages
threads = 10 # Number of threads for shm-fork
+
# Run shm-fork once using half available hugepages, then once using all
# This is to catch off-by-ones or races in the kernel allocated that
# can make allocating all hugepages a problem
if nr_pages > 1:
- do_test(("shm-fork.sh", repr(threads), repr(nr_pages / 2)))
- do_test(("shm-fork.sh", repr(threads), repr(nr_pages)))
-
- do_test(("shm-getraw.sh", repr(nr_pages), "/dev/full"))
- restore_shm_sysctl(sysctls)
-
+ do_shm_test(("shm-fork", repr(threads), repr(nr_pages / 2)), limit)
+ do_shm_test(("shm-fork", repr(threads), repr(nr_pages)), limit)
+ do_shm_test(("shm-getraw", repr(nr_pages), "/dev/full"), limit)
def main():
- global wordsizes, pagesizes, dangerous, paranoid_pool_check
+ global wordsizes, pagesizes, dangerous, paranoid_pool_check, system_default_hpage_size
testsets = set()
env_override = {"QUIET_TEST": "1", "HUGETLBFS_MOUNTS": "",
"HUGETLB_ELFMAP": None, "HUGETLB_MORECORE": None}
@@ -647,6 +656,13 @@ def main():
setup_env(env_override, env_defaults)
init_results()
+
+ (rc, system_default_hpage_size) = hpage_size()
+ if rc != 0:
+ print "Unable to find system default hugepage size."
+ print "Is hugepage supported included in this kernel?"
+ return 1
+
check_hugetlbfs_path()
if "func" in testsets: functional_tests()
diff --git a/tests/shm-fork.sh b/tests/shm-fork.sh
deleted file mode 100755
index 174c543..0000000
--- a/tests/shm-fork.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-. wrapper-utils.sh
-
-#shm-fork will fail if the hugepage size is different from the system default
-
-def_hpage_size=`grep 'Hugepagesize:' /proc/meminfo | awk '{print $2}'`
-let "def_hpage_size *= 1024"
-
-if [ -z "$HUGETLB_DEFAULT_PAGE_SIZE" ]; then
- EXP_RC=$RC_PASS
-elif [ "$def_hpage_size" -eq "$HUGETLB_DEFAULT_PAGE_SIZE" ]; then
- EXP_RC=$RC_PASS
-else
- EXP_RC=$RC_FAIL
-fi
-
-exec_and_check $EXP_RC shm-fork "$@"
diff --git a/tests/shm-getraw.sh b/tests/shm-getraw.sh
deleted file mode 100755
index fb4f917..0000000
--- a/tests/shm-getraw.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-. wrapper-utils.sh
-
-#shm-getraw will fail if the hugepage size is different from the system default
-
-def_hpage_size=`grep 'Hugepagesize:' /proc/meminfo | awk '{print $2}'`
-let "def_hpage_size *= 1024"
-
-if [ -z "$HUGETLB_DEFAULT_PAGE_SIZE" ]; then
- EXP_RC=$RC_PASS
-elif [ "$def_hpage_size" -eq "$HUGETLB_DEFAULT_PAGE_SIZE" ]; then
- EXP_RC=$RC_PASS
-else
- EXP_RC=$RC_FAIL
-fi
-
-exec_and_check $EXP_RC shm-getraw "$@"