Eric,

On 07/11/11 10:51, Eric B Munson wrote:
> diff --git a/morecore.c b/morecore.c
> index 6b4364c..c2a445c 100644
> --- a/morecore.c
> +++ b/morecore.c
> @@ -202,6 +202,72 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
>       return p;
>  }
>  
> +static void *thp_morecore(ptrdiff_t increment)
> +{
> +     void *p;
> +     long delta;
> +
> +     INFO("thp_morecore(%ld) = ...\n", (long)increment);
> +
> +     delta = (heaptop - heapbase) + increment - mapsize;
> +     delta = ALIGN(delta, hpage_size);
> +
> +     if (delta > 0) {
> +             /*
> +              * This first time we expand the mapping we need to account for
> +              * the initial heap mapping not necessarily being huge page
> +              * aligned
> +              */
> +             if (!mapsize)
> +                     delta = hugetlbfs_next_addr((long)heapbase + delta) -
> +                                     (unsigned long)heapbase;
> +
> +             INFO("Adding %ld bytes to heap\n", delta);
> +
> +             p = sbrk(delta);
> +             if (p == (void *)-1) {
> +                     WARNING("sbrk returned ENOMEM\n");
> +                     return NULL;
> +             }
> +
> +             if (!mapsize) {
> +                     if (heapbase && (heapbase != p)) {
> +                             WARNING("Heap originates at %p instead of %p\n",
> +                                     p, heapbase);
> +                             if (__hugetlbfs_debug)
> +                                     dump_proc_pid_maps();
> +                     }
> +                     heapbase = heaptop = p;
> +             }
> +
> +             mapsize += delta;
> +#ifdef MADV_HUGEPAGE
> +             madvise(p, delta, MADV_HUGEPAGE);
> +#endif

If the user has specified HUGETLB_MORECORE_HEAPBASE and the value
doesn't match the brk value at the time of the first call to
thp_morecore(), the user will see the "Heap originates" warning, no?

This seems undesirable.

Is HUGETLB_MORECORE_HEAPBASE even useful with HUGETLB_MORECORE=thp?
Maybe just document that HUGETLB_MORECORE_HEAPBASE shouldn't be used
with HUGETLB_MORECORE=thp, and issue a warning "don't do that" if it is.

-Andrew

------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to