On 22 Sep 2022, at 18:40, Zach O'Keefe wrote: > 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@xxxxxxxxxx > Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx> > Cc: Axel Rasmussen <axelrasmussen@xxxxxxxxxx> > Cc: Chris Kennelly <ckennelly@xxxxxxxxxx> > Cc: David Hildenbrand <david@xxxxxxxxxx> > Cc: David Rientjes <rientjes@xxxxxxxxxx> > Cc: Hugh Dickins <hughd@xxxxxxxxxx> > Cc: James Houghton <jthoughton@xxxxxxxxxx> > Cc: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> > Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx> > Cc: Minchan Kim <minchan@xxxxxxxxxx> > Cc: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> > Cc: Peter Xu <peterx@xxxxxxxxxx> > Cc: Rongwei Wang <rongwei.wang@xxxxxxxxxxxxxxxxx> > Cc: SeongJae Park <sj@xxxxxxxxxx> > Cc: Song Liu <songliubraving@xxxxxx> > Cc: Vlastimil Babka <vbabka@xxxxxxx> > Cc: Yang Shi <shy828301@xxxxxxxxx> > --- > tools/testing/selftests/vm/Makefile | 1 + > tools/testing/selftests/vm/khugepaged.c | 64 ++----------------- > tools/testing/selftests/vm/soft-dirty.c | 2 +- > .../selftests/vm/split_huge_page_test.c | 12 ++-- > tools/testing/selftests/vm/vm_util.c | 26 +++++--- > tools/testing/selftests/vm/vm_util.h | 3 +- > 6 files changed, 32 insertions(+), 76 deletions(-) LGTM. Thanks. Reviewed-by: Zi Yan <ziy@xxxxxxxxxx> -- Best Regards, Yan, Zi
Attachment:
signature.asc
Description: OpenPGP digital signature