On (03/10/08 18:36), 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]>
Seems ok. This patch can be treated separate from hpoolcfg. > --- > hugeutils.c | 18 +++++++++++------- > 1 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/hugeutils.c b/hugeutils.c > index 830c844..1af26bb 100644 > --- a/hugeutils.c > +++ b/hugeutils.c > @@ -413,11 +413,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)) > @@ -428,7 +424,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) > @@ -461,7 +461,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