Eric B Munson wrote:
> If a machine has a /proc/mounts file larger than 4kb and the hugetlb mount 
> point
> is after the 4kb mark the library currently fails to find the hugetlb mount.
> This patch ensures that the entire mounts file is searched for the hugetlb 
> mount
> before giving up.  This patch also records the hpage_size for the specified
> mount point when it is found.
> 
> Signed-off-by: Eric Munson <[EMAIL PROTECTED]>
> 
> ---
> V2
> Changes from V1:
> Use statfs to save the hugepage size when we find a mount point.
> 
>  hugeutils.c |  111 
> ++++++++++++++++++++++++++++++++++++++++++++----------------
>  init.c      |    2 +
>  2 files changed, 84 insertions(+), 29 deletions(-)
> 
> diff -upNr libhugetlbfs.orig/hugeutils.c libhugetlbfs-dev-20080516/hugeutils.c
> --- libhugetlbfs.orig/hugeutils.c     2008-05-16 13:52:41.000000000 -0700
> +++ libhugetlbfs-dev-20080516/hugeutils.c     2008-06-11 16:23:54.000000000 
> -0700
> @@ -158,13 +158,38 @@ int hugetlbfs_test_path(const char *moun
>  }
>  
>  #define MOUNTS_SZ    4096
> +#define READ_SZ              (MOUNTS_SZ - 1)
> +
> +static const char *path_search(char *buf)
> +{
> +     int err;
> +     char *tmp = buf;
> +     while (tmp) {
> +             err = sscanf(tmp,
> +                  "%*s %" stringify(PATH_MAX)
> +                  "s hugetlbfs ",
> +                  htlb_mount);
> +             if ((err == 1) && (hugetlbfs_test_path(htlb_mount) == 1))
> +                     return htlb_mount;

The "hugetlbfs" in the sscanf format string doesn't do anything useful, 
unfortunately.  The return value from sscanf is the same whether the fs 
type is hugetlbfs or not.

Something like this would eliminate the need to call hugetlbfs_test_path:

   int dummy;
   err = sscanf(tmp,
                "%*s %" stringify(PATH_MATH)
                "s hugetlbfs %*s %d",
                htlb_mount, &dummy);
   if (err == 2)
           return htlb_mount;

Not sure whether it's worth it, though.

-Andrew Hastings
  Cray Inc.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to