On Mon, Mar 30, 2009 at 06:46:22PM +0100, Eric B Munson wrote:
> 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 <ebmun...@us.ibm.com>
> ---
>  hugeadm.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/hugeadm.c b/hugeadm.c
> index 345bed5..2e99b44 100644
> --- a/hugeadm.c
> +++ b/hugeadm.c
> @@ -60,6 +60,8 @@ extern char *optarg;
>  #define MAX_SIZE_MNTENT (64 + PATH_MAX + 32 + 128 + 2 * sizeof(int))
>  #define FORMAT_LEN 20
>  
> +#define SWAP_FREE "SwapFree:"
> +
>  void print_usage()
>  {
>       fprintf(stderr, "hugeadm [options]\n");
> @@ -424,6 +426,20 @@ 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()
> +{
> +     /* TODO: Move these messages to an external resource. */
> +     long swap_sz = read_meminfo(SWAP_FREE);
> +     if (swap_sz <= 0)
> +             WARNING("Swap is full or no swap space configured, resizing 
> pool may fail.\n");
> +}

We can easily distinguish between these cases. How about;

#define SWAP_TOTAL "SwapTotal:"

long swap_total = read_meminfo(SWAP_TOTAL);
if (swap_total <= 0) {
        WARNING("There is no swap space configured, resizing hugepage pool may 
fail.\n");
        return;
}

long 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 +518,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
> Libhugetlbfs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
> 

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

------------------------------------------------------------------------------
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to