aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <ebmunson@us.ibm.com>2008-11-12 11:09:51 +0000
committerEric B Munson <ebmunson@us.ibm.com>2008-11-17 19:38:05 +0000
commitdb161c485f3ed574370e7dd9da61ef45a8825638 (patch)
tree7c9fc4878b2cfc1249551b56d27444a149fb2ef9
parent0af3ec1c1a536e412fd80adbf6f7e7b2457f7cba (diff)
downloadlibhugetlbfs-db161c485f3ed574370e7dd9da61ef45a8825638.tar.gz
Add a facility for tests to save and restore the number of overcommit pages.
Some of the test suite will fail unexpectedly when the overcommit pool has any pages allocated. This patch introduces a simple method for saving and restoring the size of the overcommit pool so these tests can 0 it before running. Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
-rw-r--r--hugeutils.c16
-rw-r--r--libhugetlbfs_privutils.h6
2 files changed, 22 insertions, 0 deletions
diff --git a/hugeutils.c b/hugeutils.c
index 1121966..5f86780 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -874,6 +874,22 @@ int set_nr_overcommit_hugepages(long pagesize, unsigned long val)
return set_huge_page_counter(pagesize, HUGEPAGES_OC, val);
}
+long read_nr_overcommit(long page_size)
+{
+ if (!kernel_has_overcommit())
+ return -1;
+
+ return get_huge_page_counter(page_size, HUGEPAGES_OC);
+}
+
+void restore_overcommit_pages(long page_size, long oc_pool)
+{
+ if (!kernel_has_overcommit())
+ return;
+
+ set_nr_overcommit_hugepages(page_size, oc_pool);
+}
+
/********************************************************************/
/* Library user visible DIAGNOSES/DEBUGGING ONLY functions */
/********************************************************************/
diff --git a/libhugetlbfs_privutils.h b/libhugetlbfs_privutils.h
index e97c229..730c939 100644
--- a/libhugetlbfs_privutils.h
+++ b/libhugetlbfs_privutils.h
@@ -64,6 +64,12 @@ long read_meminfo(const char *tag);
#define kernel_default_hugepage_size __pu_kernel_default_hugepage_size
long kernel_default_hugepage_size(void);
+#define read_nr_overcommit __pu_read_nr_overcommit
+long read_nr_overcommit(long page_size);
+
+#define restore_overcommit_pages __pu_restore_overcommit_pages
+void restore_overcommit_pages(long page_size, long oc_pool);
+
/* Kernel feature testing */
/* This enum defines the bits in a feature bitmask */
enum {