On Fri, Nov 19, 2010 at 04:33:52PM -0700, Eric B Munson wrote:
> This patch adds a check for MAP_HUGETLB support and a flag in
> __hugetlb_opts for holding the availability.
> 
> Signed-off-by: Eric B Munson <emun...@mgebm.net>
> ---
>  hugeutils.c             |   21 +++++++++++++++++++++
>  init.c                  |    1 +
>  libhugetlbfs_internal.h |    3 +++
>  3 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/hugeutils.c b/hugeutils.c
> index 3b442c3..646dea1 100644
> --- a/hugeutils.c
> +++ b/hugeutils.c
> @@ -340,6 +340,27 @@ void hugetlbfs_check_safe_noreserve()
>       }
>  }
>  
> +void hugetlbfs_check_map_hugetlb()
> +{
> +/*
> + * FIXME: MAP_HUGETLB has not been picked up by glibc so even though the
> + * kernel may support it, without the userspace mmap flag it cannot be
> + * used.  This ifdef should be removed when the MAP_HUGETLB flag makes it
> + * into glibc.
> + */
> +#ifdef MAP_HUGETLB
> +     /*
> +      * Kernels after 2.6.32 support mmaping pseudo-anonymous regions
> +      * backed by huge pages, use this feature for huge pages we
> +      * don't intend to share.
> +      */
> +     if (hugetlbfs_test_feature(HUGETLB_FEATURE_MAP_HUGETLB) > 0) {
> +             INFO("Kernel supports MAP_HUGETLB\n");
> +             __hugetlb_opts.map_hugetlb = 1;
> +     }
> +#endif
> +}
> +
>  /*
>   * 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 049c9e2..c7f5a05 100644
> --- a/init.c
> +++ b/init.c
> @@ -27,6 +27,7 @@ static void __attribute__ ((constructor)) 
> setup_libhugetlbfs(void)
>       setup_features();
>       hugetlbfs_check_priv_resv();
>       hugetlbfs_check_safe_noreserve();
> +     hugetlbfs_check_map_hugetlb();
>  #ifndef NO_ELFLINK
>       hugetlbfs_setup_elflink();
>  #endif
> diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
> index 6e9379e..ace64bd 100644
> --- a/libhugetlbfs_internal.h
> +++ b/libhugetlbfs_internal.h
> @@ -61,6 +61,7 @@ struct libhugeopts_t {
>       int             shrink_ok;
>       int             shm_enabled;
>       int             no_reserve;
> +     int             map_hugetlb;
>       unsigned long   force_elfmap;

Bah, just a side-note but some of these should have been bool, not int.

>       char            *ld_preload;
>       char            *elfmap;
> @@ -103,6 +104,8 @@ extern void setup_features();
>  extern void hugetlbfs_check_priv_resv();
>  #define hugetlbfs_check_safe_noreserve __lh_hugetlbfs_check_safe_noreserve
>  extern void hugetlbfs_check_safe_noreserve();
> +#define hugetlbfs_check_map_hugetlb __lh_hugetblfs_check_map_hugetlb
> +extern void hugetlbfs_check_map_hugetlb();
>  #define __hugetlbfs_hostname __lh___hugetlbfs_hostname
>  extern char __hugetlbfs_hostname[];
>  #define hugetlbfs_prefault __lh_hugetlbfs_prefault

Otherwise;

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


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

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to