aboutsummaryrefslogtreecommitdiff
path: root/hugeadm.c
diff options
context:
space:
mode:
authorEric B Munson <ebmunson@us.ibm.com>2009-03-31 14:26:14 +0100
committerEric B Munson <ebmunson@us.ibm.com>2009-03-31 14:55:07 +0100
commit1fe8f9cefecb657b77dcf46a49737efb16b56dd0 (patch)
tree6461ba853e92c60116937efd723c38c44d552d26 /hugeadm.c
parentfff508be15893c95791d723eafb0e023d3b90a20 (diff)
downloadlibhugetlbfs-1fe8f9cefecb657b77dcf46a49737efb16b56dd0.tar.gz
Print warning if pool resize is atempted without swap space
This adds a check when the pool is being resized that will warn the user about possible resize failures if no swap space is configured or swap is full. Signed-off-by: Eric B Munson <ebmunson@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie>
Diffstat (limited to 'hugeadm.c')
-rw-r--r--hugeadm.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/hugeadm.c b/hugeadm.c
index 345bed5..e713b9e 100644
--- a/hugeadm.c
+++ b/hugeadm.c
@@ -60,6 +60,9 @@ extern char *optarg;
#define MAX_SIZE_MNTENT (64 + PATH_MAX + 32 + 128 + 2 * sizeof(int))
#define FORMAT_LEN 20
+#define SWAP_FREE "SwapFree:"
+#define SWAP_TOTAL "SwapTotal:"
+
void print_usage()
{
fprintf(stderr, "hugeadm [options]\n");
@@ -424,6 +427,28 @@ void create_mounts(char *user, char *group, char *base, mode_t mode)
}
}
+/**
+ * check_swap shouldn't change the behavior of any of its
+ * callers, it only prints a message to the user if something
+ * is being done that might fail without swap available. i.e.
+ * resizing a huge page pool
+ */
+void check_swap()
+{
+ long swap_sz;
+ long swap_total;
+
+ swap_total = read_meminfo(SWAP_TOTAL);
+ if (swap_total <= 0) {
+ WARNING("There is no swap space configured, resizing hugepage pool may fail\n");
+ return;
+ }
+
+ swap_sz = read_meminfo(SWAP_FREE);
+ if (swap_sz <= gethugepagesize())
+ WARNING("There is very little swap space free, resizing hugepage pool may fail\n");
+}
+
enum {
POOL_MIN,
POOL_MAX,
@@ -502,6 +527,8 @@ void pool_adjust(char *cmd, unsigned int counter)
exit(EXIT_FAILURE);
}
+ check_swap();
+
min = pools[pos].minimum;
max = pools[pos].maximum;