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 <[email protected]> --- Changes from V1: Check both for no swap configured and swap full conditions hugeadm.c | 27 +++++++++++++++++++++++++++ 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; -- 1.6.1.2 ------------------------------------------------------------------------------ _______________________________________________ Libhugetlbfs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
