• Zach O'Keefe's avatar
    selftests/vm: dedup THP helpers · c07c343c
    Zach O'Keefe authored
    These files:
    
    tools/testing/selftests/vm/vm_util.c
    tools/testing/selftests/vm/khugepaged.c
    
    Both contain logic to:
    
    1) Determine hugepage size on current system
    2) Read /proc/self/smaps to determine number of THPs at an address
    
    Refactor selftests/vm/khugepaged.c to use the vm_util common helpers and
    add it as a build dependency.
    
    Since selftests/vm/khugepaged.c is the largest user of check_huge(),
    change the signature of check_huge() to match selftests/vm/khugepaged.c's
    useage: take an expected number of hugepages, and return a bool indicating
    if the correct number of hugepages were found.  Add a wrapper,
    check_huge_anon(), in anticipation of checking smaps for file and shmem
    hugepages.
    
    Update existing callsites to use the new pattern / function.
    
    Likewise, check_for_pattern() was duplicated, and it's a general enough
    helper to include in vm_util helpers as well.
    
    Link: https://lkml.kernel.org/r/20220907144521.3115321-6-zokeefe@google.com
    Link: https://lkml.kernel.org/r/20220922224046.1143204-6-zokeefe@google.comSigned-off-by: default avatarZach O'Keefe <zokeefe@google.com>
    Reviewed-by: default avatarZi Yan <ziy@nvidia.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Chris Kennelly <ckennelly@google.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: James Houghton <jthoughton@google.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Rongwei Wang <rongwei.wang@linux.alibaba.com>
    Cc: SeongJae Park <sj@kernel.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Yang Shi <shy828301@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    c07c343c
soft-dirty.c 5.41 KB