[LTP] [PATCH] hugeshmat04: don't attach at specific address

Cyril Hrubis chrubis@suse.cz
Wed Sep 22 16:29:11 CEST 2021


Hi!
> > The test intermittently fails on ppc64le, when heap
> > happens to overlap with segment that the test is trying
> > to attach at 1GB boundary.
> >
> > Let the kernel find suitable address.
> >
> 
> I'm not sure why the original way uses fixed address, but
> it should be fine to cancel that limitation.

It seems to be regression test for:

commit c5c99429fa57dcf6e05203ebe3676db1ec646793
Author: Larry Woodman <lwoodman@redhat.com>
Date:   Thu Jan 24 05:49:25 2008 -0800

    fix hugepages leak due to pagetable page sharing

    The shared page table code for hugetlb memory on x86 and x86_64
    is causing a leak.  When a user of hugepages exits using this code
    the system leaks some of the hugepages.

    -------------------------------------------------------
    Part of /proc/meminfo just before database startup:
    HugePages_Total:  5500
    HugePages_Free:   5500
    HugePages_Rsvd:      0
    Hugepagesize:     2048 kB

    Just before shutdown:
    HugePages_Total:  5500
    HugePages_Free:   4475
    HugePages_Rsvd:      0
    Hugepagesize:     2048 kB

    After shutdown:
    HugePages_Total:  5500
    HugePages_Free:   4988
    HugePages_Rsvd:
    0 Hugepagesize:     2048 kB
    ----------------------------------------------------------

    The problem occurs durring a fork, in copy_hugetlb_page_range().  It
    locates the dst_pte using huge_pte_alloc().  Since huge_pte_alloc() calls
    huge_pmd_share() it will share the pmd page if can, yet the main loop in
    copy_hugetlb_page_range() does a get_page() on every hugepage.  This is a
    violation of the shared hugepmd pagetable protocol and creates additional
    referenced to the hugepages causing a leak when the unmap of the VMA
    occurs.  We can skip the entire replication of the ptes when the hugepage
    pagetables are shared.  The attached patch skips copying the ptes and the
    get_page() calls if the hugetlbpage pagetable is shared.


As far as I can tell there is no reason to allocate the memory on a
fixed address to trigger this bug but it should be easy enough to check
if the test fails on a kernel that has the two lines this patch adds
commented before and after the change it test.

Also can we pretty please add the commit hash to the test metadata?

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list