• David Hildenbrand's avatar
    selftests/vm: add KSM unmerge tests · 93fb70aa
    David Hildenbrand authored
    Patch series "mm/ksm: break_ksm() cleanups and fixes", v2.
    
    This series cleans up and fixes break_ksm().  In summary, we no longer use
    fake write faults to break COW but instead FAULT_FLAG_UNSHARE.  Further,
    we move away from using follow_page() --- that we can hopefully remove
    completely at one point --- and use new walk_page_range_vma() instead.
    
    Fortunately, we can get rid of VM_FAULT_WRITE and FOLL_MIGRATION in common
    code now.
    
    Extend the existing ksm tests by an unmerge benchmark, and a some new
    unmerge tests.
    
    Also, add a selftest to measure MADV_UNMERGEABLE performance.  In my setup
    (AMD Ryzen 9 3900X), running the KSM selftest to test unmerge performance
    on 2 GiB (taskset 0x8 ./ksm_tests -D -s 2048), this results in a
    performance degradation of ~6% -- 7% (old: ~5250 MiB/s, new: ~4900 MiB/s).
    I don't think we particularly care for now, but it's good to be aware of
    the implication.
    
    
    This patch (of 9):
    
    Let's add three unmerge tests (MADV_UNMERGEABLE unmerging all pages in the
    range).
    
    test_unmerge(): basic unmerge tests
    test_unmerge_discarded(): have some pte_none() entries in the range
    test_unmerge_uffd_wp(): protect the merged pages using uffd-wp
    
    ksm_tests.c currently contains a mixture of benchmarks and tests, whereby
    each test is carried out by executing the ksm_tests binary with specific
    parameters.  Let's add new ksm_functional_tests.c that performs multiple,
    smaller functional tests all at once.
    
    Link: https://lkml.kernel.org/r/20221021101141.84170-1-david@redhat.com
    Link: https://lkml.kernel.org/r/20221021101141.84170-5-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Jason Gunthorpe <jgg@nvidia.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    93fb70aa
vm_util.h 675 Bytes