On Wed, May 13, 2009 at 10:07:50AM +0100, Eric B Munson wrote:
> Prefaulting should be disabled when the kernel supports private reservations.
> Currently this check is part of the morecore_setup function and is only made
> if HUGETLB_MORECORE is 'yes'.  This is a problem for users of
> get_hugepage_region because prefaulting will slow allocation down 
> significantly.

Slow down allocation significantly *and* screw with NUMA placement
policies where we want to do demand faulting.

> This patch moves the check for private reservations into s separate function
> that is called during hugetlb_setup.
> 
> Signed-off-by: Eric B Munson <ebmun...@us.ibm.com>

Looks good.

Acked-by: Mel Gorman <m...@csn.ul.ie>

> ---
>  hugeutils.c             |   14 ++++++++++++++
>  init.c                  |    1 +
>  libhugetlbfs_internal.h |    2 ++
>  morecore.c              |   11 -----------
>  4 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/hugeutils.c b/hugeutils.c
> index 86dd120..d6f8940 100644
> --- a/hugeutils.c
> +++ b/hugeutils.c
> @@ -302,6 +302,20 @@ void hugetlbfs_setup_env()
>               __hugetlb_opts.shm_enabled = 1;
>  }
>  
> +void hugetlbfs_check_priv_resv()
> +{
> +     /*
> +      * If the kernel supports MAP_PRIVATE reservations, we can skip
> +      * prefaulting the huge pages we allocate since the kernel
> +      * guarantees them.  This can help NUMA performance quite a bit.
> +      */
> +     if (hugetlbfs_test_feature(HUGETLB_FEATURE_PRIVATE_RESV)) {
> +             INFO("Kernel has MAP_PRIVATE reservations.  Disabling "
> +                     "heap prefaulting.\n");
> +             __hugetlbfs_prefault = 0;
> +     }
> +}
> +
>  /*
>   * Pool counters are typically exposed in sysfs in modern kernels, the
>   * counters for the default page size are exposed in procfs in all kernels
> diff --git a/init.c b/init.c
> index 794e03c..e95cb5c 100644
> --- a/init.c
> +++ b/init.c
> @@ -25,6 +25,7 @@ static void __attribute__ ((constructor)) 
> setup_libhugetlbfs(void)
>       hugetlbfs_setup_debug();
>       setup_mounts();
>       setup_features();
> +     hugetlbfs_check_priv_resv();
>  #ifndef NO_ELFLINK
>       hugetlbfs_setup_elflink();
>  #endif
> diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
> index b3c3a38..05c22e0 100644
> --- a/libhugetlbfs_internal.h
> +++ b/libhugetlbfs_internal.h
> @@ -98,6 +98,8 @@ extern void hugetlbfs_setup_debug();
>  extern void setup_mounts();
>  #define setup_features __lh_setup_features
>  extern void setup_features();
> +#define hugetlbfs_check_priv_resv __lh_hugetlbfs_check_priv_resv
> +extern void hugetlbfs_check_priv_resv();
>  #define __hugetlbfs_hostname __lh___hugetlbfs_hostname
>  extern char __hugetlbfs_hostname[];
>  #define hugetlbfs_prefault __lh_hugetlbfs_prefault
> diff --git a/morecore.c b/morecore.c
> index 56acf44..232e04a 100644
> --- a/morecore.c
> +++ b/morecore.c
> @@ -227,17 +227,6 @@ void hugetlbfs_setup_morecore(void)
>               return;
>       }
>  
> -     /*
> -      * If the kernel supports MAP_PRIVATE reservations, we can skip
> -      * prefaulting the huge pages we allocate for the heap since the
> -      * kernel guarantees them.  This can help NUMA performance quite a bit.
> -      */
> -     if (hugetlbfs_test_feature(HUGETLB_FEATURE_PRIVATE_RESV)) {
> -             INFO("Kernel has MAP_PRIVATE reservations.  Disabling "
> -                     "heap prefaulting.\n");
> -             __hugetlbfs_prefault = 0;
> -     }
> -
>       if (hpage_size <= 0) {
>               if (errno == ENOSYS)
>                       WARNING("Hugepages unavailable\n");
> -- 
> 1.6.1.2
> 
> 
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image 
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> 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

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to