• Zach O'Keefe's avatar
    selftests/vm: add thp collapse file and tmpfs testing · 1b03d0d5
    Zach O'Keefe authored
    Add memory operations for file-backed and tmpfs memory.  Call existing
    tests with these new memory operations to test collapse functionality of
    khugepaged and MADV_COLLAPSE on file-backed and tmpfs memory.  Not all
    tests are reusable; for example, collapse_swapin_single_pte() which checks
    swap usage.
    
    Refactor test arguments.  Usage is now:
    
    Usage: ./khugepaged <test type> [dir]
    
            <test type>     : <context>:<mem_type>
            <context>       : [all|khugepaged|madvise]
            <mem_type>      : [all|anon|file]
    
            "file,all" mem_type requires [dir] argument
    
            "file,all" mem_type requires kernel built with
            CONFIG_READ_ONLY_THP_FOR_FS=y
    
            if [dir] is a (sub)directory of a tmpfs mount, tmpfs must be
            mounted with huge=madvise option for khugepaged tests to work
    
    Refactor calling tests to make it clear what collapse context / memory
    operations they support, but only invoke tests requested by user.  Also
    log what test is being ran, and with what context / memory, to make test
    logs more human readable.
    
    A new test file is created and deleted for every test to ensure no pages
    remain in the page cache between tests (tests also may attempt to collapse
    different amount of memory).
    
    For file-backed memory where the file is stored on a block device, disable
    /sys/block/<device>/queue/read_ahead_kb so that pages don't find their way
    into the page cache without the tests faulting them in.
    
    Add file and shmem wrappers to vm_utils check for file and shmem hugepages
    in smaps.
    
    [zokeefe@google.com: fix "add thp collapse file and tmpfs testing" for
      tmpfs]
      Link: https://lkml.kernel.org/r/20220913212517.3163701-1-zokeefe@google.com
    Link: https://lkml.kernel.org/r/20220907144521.3115321-8-zokeefe@google.com
    Link: https://lkml.kernel.org/r/20220922224046.1143204-8-zokeefe@google.comSigned-off-by: default avatarZach O'Keefe <zokeefe@google.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>
    1b03d0d5
khugepaged.c 35.1 KB