diff mbox series

[1/2] selftests/mm: add separate UFFDIO_MOVE test for PMD splitting

Message ID 20231230025636.2477429-1-surenb@google.com (mailing list archive)
State New
Headers show
Series [1/2] selftests/mm: add separate UFFDIO_MOVE test for PMD splitting | expand

Commit Message

Suren Baghdasaryan Dec. 30, 2023, 2:56 a.m. UTC
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.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
Patch applies over mm-unstable.

 tools/testing/selftests/mm/uffd-unit-tests.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Suren Baghdasaryan Dec. 30, 2023, 2:59 a.m. UTC | #1
Sorry, I screwed up when sending it out. It's not [1/2], it's supposed
to be a stand-alone patch. IOW, don't expect a [2/2] followup :)

On Fri, Dec 29, 2023 at 6:56 PM Suren Baghdasaryan <surenb@google.com> wrote:
>
> 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.
>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> Patch applies over mm-unstable.
>
>  tools/testing/selftests/mm/uffd-unit-tests.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
> index d8091523c2df..cce90a10515a 100644
> --- a/tools/testing/selftests/mm/uffd-unit-tests.c
> +++ b/tools/testing/selftests/mm/uffd-unit-tests.c
> @@ -1199,6 +1199,16 @@ static void uffd_move_test(uffd_test_args_t *targs)
>
>  static void uffd_move_pmd_test(uffd_test_args_t *targs)
>  {
> +       if (madvise(area_dst, nr_pages * page_size, MADV_HUGEPAGE))
> +               err("madvise(MADV_HUGEPAGE) failure");
> +       uffd_move_test_common(targs, read_pmd_pagesize(),
> +                             uffd_move_pmd_handle_fault);
> +}
> +
> +static void uffd_move_pmd_split_test(uffd_test_args_t *targs)
> +{
> +       if (madvise(area_dst, nr_pages * page_size, MADV_NOHUGEPAGE))
> +               err("madvise(MADV_NOHUGEPAGE) failure");
>         uffd_move_test_common(targs, read_pmd_pagesize(),
>                               uffd_move_pmd_handle_fault);
>  }
> @@ -1330,6 +1340,13 @@ uffd_test_case_t uffd_tests[] = {
>                 .uffd_feature_required = UFFD_FEATURE_MOVE,
>                 .test_case_ops = &uffd_move_test_pmd_case_ops,
>         },
> +       {
> +               .name = "move-pmd-split",
> +               .uffd_fn = uffd_move_pmd_split_test,
> +               .mem_targets = MEM_ANON,
> +               .uffd_feature_required = UFFD_FEATURE_MOVE,
> +               .test_case_ops = &uffd_move_test_pmd_case_ops,
> +       },
>         {
>                 .name = "wp-fork",
>                 .uffd_fn = uffd_wp_fork_test,
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index d8091523c2df..cce90a10515a 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1199,6 +1199,16 @@  static void uffd_move_test(uffd_test_args_t *targs)
 
 static void uffd_move_pmd_test(uffd_test_args_t *targs)
 {
+	if (madvise(area_dst, nr_pages * page_size, MADV_HUGEPAGE))
+		err("madvise(MADV_HUGEPAGE) failure");
+	uffd_move_test_common(targs, read_pmd_pagesize(),
+			      uffd_move_pmd_handle_fault);
+}
+
+static void uffd_move_pmd_split_test(uffd_test_args_t *targs)
+{
+	if (madvise(area_dst, nr_pages * page_size, MADV_NOHUGEPAGE))
+		err("madvise(MADV_NOHUGEPAGE) failure");
 	uffd_move_test_common(targs, read_pmd_pagesize(),
 			      uffd_move_pmd_handle_fault);
 }
@@ -1330,6 +1340,13 @@  uffd_test_case_t uffd_tests[] = {
 		.uffd_feature_required = UFFD_FEATURE_MOVE,
 		.test_case_ops = &uffd_move_test_pmd_case_ops,
 	},
+	{
+		.name = "move-pmd-split",
+		.uffd_fn = uffd_move_pmd_split_test,
+		.mem_targets = MEM_ANON,
+		.uffd_feature_required = UFFD_FEATURE_MOVE,
+		.test_case_ops = &uffd_move_test_pmd_case_ops,
+	},
 	{
 		.name = "wp-fork",
 		.uffd_fn = uffd_wp_fork_test,