mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
BACKPORT: selftests/mm: add separate UFFDIO_MOVE test for PMD splitting
Add a test for UFFDIO_MOVE ioctl operating on a hugepage which has to be split because destination is marked with MADV_NOHUGEPAGE. With this we cover all 3 cases: normal page move, hugepage move, hugepage splitting before move. Link: https://lkml.kernel.org/r/20231230025636.2477429-1-surenb@google.com Signed-off-by: Suren Baghdasaryan <surenb@google.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Brian Geffon <bgeffon@google.com> Cc: Christian Brauner <brauner@kernel.org> Cc: David Hildenbrand <david@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jann Horn <jannh@google.com> Cc: Kalesh Singh <kaleshsingh@google.com> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Lokesh Gidra <lokeshgidra@google.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Nicolas Geoffray <ngeoffray@google.com> Cc: Peter Xu <peterx@redhat.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: ZhangPeng <zhangpeng362@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit a5b7620bab81f16e8bbb04f4aea94c4c7feb0d77) Conflicts: tools/testing/selftests/mm/uffd-unit-tests.c tools/testing/selftests/vm/userfaultfd.c 1. Add request_src_hugepages() to enable THP on src 2. Add madvise() to enable THP on dst in request_hugepages() 3. Add request_split_hugepages() to enable THP on src and disable on dst 4. Change return type of uffd_move_pmd_split_test() to int Bug: 274911254 Change-Id: I21147a5b7f3e8bbe2befa8bff536e62826e9f6e3 Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
This commit is contained in:
committed by
Lokesh Gidra
parent
f152691515
commit
51eab7ecc4
@@ -1255,7 +1255,7 @@ static void prevent_hugepages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void request_hugepages()
|
static void request_src_hugepages()
|
||||||
{
|
{
|
||||||
/* This should be done before source area is populated */
|
/* This should be done before source area is populated */
|
||||||
if (madvise(area_src, nr_pages * page_size, MADV_HUGEPAGE)) {
|
if (madvise(area_src, nr_pages * page_size, MADV_HUGEPAGE)) {
|
||||||
@@ -1266,6 +1266,20 @@ static void request_hugepages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void request_hugepages()
|
||||||
|
{
|
||||||
|
request_src_hugepages();
|
||||||
|
if (madvise(area_dst, nr_pages * page_size, MADV_HUGEPAGE))
|
||||||
|
err("madvise(MADV_HUGEPAGE) failure");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void request_split_hugepages()
|
||||||
|
{
|
||||||
|
request_src_hugepages();
|
||||||
|
if (madvise(area_dst, nr_pages * page_size, MADV_NOHUGEPAGE))
|
||||||
|
err("madvise(MADV_NOHUGEPAGE) failure");
|
||||||
|
}
|
||||||
|
|
||||||
struct uffd_test_case_ops uffd_move_test_case_ops = {
|
struct uffd_test_case_ops uffd_move_test_case_ops = {
|
||||||
.post_alloc = prevent_hugepages,
|
.post_alloc = prevent_hugepages,
|
||||||
};
|
};
|
||||||
@@ -1274,6 +1288,10 @@ struct uffd_test_case_ops uffd_move_test_pmd_case_ops = {
|
|||||||
.post_alloc = request_hugepages,
|
.post_alloc = request_hugepages,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct uffd_test_case_ops uffd_move_test_pmd_split_case_ops = {
|
||||||
|
.post_alloc = request_split_hugepages,
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uffd_move_handle_fault_common(struct uffd_msg *msg, struct uffd_stats *args,
|
uffd_move_handle_fault_common(struct uffd_msg *msg, struct uffd_stats *args,
|
||||||
unsigned long len)
|
unsigned long len)
|
||||||
@@ -1420,6 +1438,14 @@ static int uffd_move_pmd_test(void)
|
|||||||
uffd_move_pmd_handle_fault);
|
uffd_move_pmd_handle_fault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int uffd_move_pmd_split_test(void)
|
||||||
|
{
|
||||||
|
printf("move-pmd-split ");
|
||||||
|
return uffd_move_test_common(&uffd_move_test_pmd_split_case_ops,
|
||||||
|
read_pmd_pagesize(),
|
||||||
|
uffd_move_pmd_handle_fault);
|
||||||
|
}
|
||||||
|
|
||||||
static int userfaultfd_move_test(void)
|
static int userfaultfd_move_test(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1430,7 +1456,8 @@ static int userfaultfd_move_test(void)
|
|||||||
printf("testing UFFDIO_MOVE: ");
|
printf("testing UFFDIO_MOVE: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
ret = uffd_move_test() || uffd_move_pmd_test();
|
ret = uffd_move_test() || uffd_move_pmd_test()
|
||||||
|
|| uffd_move_pmd_split_test();
|
||||||
|
|
||||||
printf("done.\n");
|
printf("done.\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user