diff options
author | Adam Litke <agl@us.ibm.com> | 2008-08-26 15:57:16 +0000 |
---|---|---|
committer | Adam Litke <agl@us.ibm.com> | 2008-08-26 15:57:16 +0000 |
commit | 4d5366d8f65a6a1e7d34a6dfe4fb2ec7e4e5b149 (patch) | |
tree | 98d4e5a58edc2e1f9b02e9dcf120606d38282add /tests/testutils.c | |
parent | 30a7d5cb19a593a246b1da2f6dd36ff84ace9903 (diff) | |
download | libhugetlbfs-4d5366d8f65a6a1e7d34a6dfe4fb2ec7e4e5b149.tar.gz |
tests: Function to check if default mount point uses system default page size
Add a function to compare the huge page size displayed in /proc/meminfo (which
is the kernel's default size) with the size used by a given mount point. This
will be used by the quota test to determine if a special mount option must be
used.
Signed-off-by: Adam Litke <agl@us.ibm.com>
Diffstat (limited to 'tests/testutils.c')
-rw-r--r-- | tests/testutils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/testutils.c b/tests/testutils.c index 9aa6c3d..76ce860 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -467,3 +467,27 @@ int kernel_has_private_reservations(int fd) } return -1; } + +int using_system_hpage_size(const char *mount) +{ + struct statfs64 sb; + int err; + long meminfo_size, mount_size; + + if (!mount) + FAIL("using_system_hpage_size: hugetlbfs is not mounted\n"); + + err = statfs64(mount, &sb); + if (err) + FAIL("statfs64: %s\n", strerror(errno)); + + meminfo_size = file_read_ulong("/proc/meminfo", "Hugepagesize:"); + if (meminfo_size < 0) + FAIL("using_system_hpage_size: Failed to read /proc/meminfo\n"); + + mount_size = sb.f_bsize / 1024; /* Compare to meminfo in kB */ + if (mount_size == meminfo_size) + return 1; + else + return 0; +} |