On (09/10/08 20:20), Andy Whitcroft didst pronounce:
> From: Adam Litke <[EMAIL PROTECTED]>
> 
> As originally written, the functions hugetlbfs_find_path_for_size() and
> hugetlbfs_unlinked_fd_for_size() accepted 0 as a valid page size.  A page size
> of zero was interpreted to mean the default size (as defined by libhugetlbfs,
> not the kernel).
> 
> This behavior is undesirable in pagesize-specific functions for two reasons.
> First, the libhugetlbfs default size can be nebulous since it depends on what
> page sizes are available, which sizes have appropriate mount points, and the
> value of an environment variable.  This amount of variability adds uncertainty
> to what should be an explicit API.  Second, the functions 
> hugetlbfs_find_path()
> and hugetlbfs_unlinked_fd() already exist as a means to delegate page size
> selection to the library.  It is my view that all functions that take a page
> size paramater shall expect a valid page size.
> 
> Signed-off-by: Adam Litke <[EMAIL PROTECTED]>

Acked-by: Mel Gorman <[EMAIL PROTECTED]>

> ---
>  hugeutils.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/hugeutils.c b/hugeutils.c
> index 7e730aa..724feb8 100644
> --- a/hugeutils.c
> +++ b/hugeutils.c
> @@ -241,10 +241,6 @@ int select_pool_counter(unsigned int counter, unsigned 
> long pagesize,
>               return -1;
>       }
>  
> -     /* Convert a pagesize of 0 to the libhugetlbfs default size */
> -     if (pagesize == 0)
> -             pagesize = default_size;
> -
>       /* If the user is dealing in the default page size, we can use /proc */
>       if (pagesize == default_size) {
>               if (meminfo_key && key) {
> @@ -515,11 +511,7 @@ const char *hugetlbfs_find_path_for_size(long page_size)
>       char *path;
>       int idx;
>  
> -     if (page_size == 0)
> -             idx = hpage_sizes_default_idx;
> -     else
> -             idx = hpage_size_to_index(page_size);
> -
> +     idx = hpage_size_to_index(page_size);
>       if (idx >= 0) {
>               path = hpage_sizes[idx].mount;
>               if (strlen(path))
> @@ -530,7 +522,11 @@ const char *hugetlbfs_find_path_for_size(long page_size)
>  
>  const char *hugetlbfs_find_path(void)
>  {
> -     return hugetlbfs_find_path_for_size(0);
> +     long hpage_size = gethugepagesize();
> +     if (hpage_size > 0)
> +             return hugetlbfs_find_path_for_size(hpage_size);
> +     else
> +             return NULL;
>  }
>  
>  int hugetlbfs_unlinked_fd_for_size(long page_size)
> @@ -563,7 +559,11 @@ int hugetlbfs_unlinked_fd_for_size(long page_size)
>  
>  int hugetlbfs_unlinked_fd(void)
>  {
> -     return hugetlbfs_unlinked_fd_for_size(0);
> +     long hpage_size = gethugepagesize();
> +     if (hpage_size > 0)
> +             return hugetlbfs_unlinked_fd_for_size(hpage_size);
> +     else
> +             return -1;
>  }
>  
>  #define IOV_LEN 64
> -- 
> 1.6.0.1.451.gc8d31
> 

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to