i also suggest to add more comments describing the tests so anyone who opens the
file could understand what does it do on a highlevel.

Something like this, but please, check the descriptions fo validness, they are
generated.



Add file-level header comment describing the test suite and listing all
test variants. Add individual comments before each test variant explaining
what type of memory migration it tests.

https://virtuozzo.atlassian.net/browse/VSTOR-114785

Signed-off-by: Konstantin Khorenko <[email protected]>
---
 .../selftests/cgroup/test_numa_migrate.c      | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/tools/testing/selftests/cgroup/test_numa_migrate.c 
b/tools/testing/selftests/cgroup/test_numa_migrate.c
index 8f5e9e62ddc41..daa1a88849835 100644
--- a/tools/testing/selftests/cgroup/test_numa_migrate.c
+++ b/tools/testing/selftests/cgroup/test_numa_migrate.c
@@ -3,6 +3,32 @@
  *  Copyright (C) 2025 Virtuozzo International GmbH. All rights reserved.
  */
 
+/*
+ * NUMA migration of lruvecs test suite
+ *
+ * This test suite verifies the capability of migrating contents of process'
+ * lruvecs from one NUMA node to one or multiple destination nodes using
+ * memory.numa_migrate cgroup v2 interface.
+ *
+ * Test variants:
+ *   - disk_file:        Migrates active file pages from a regular disk file
+ *   - anon:             Migrates active anonymous pages
+ *   - anon_thp:         Migrates anonymous transparent huge pages (THP)
+ *   - tmpfs_file:       Migrates shared memory (tmpfs) file pages
+ *   - tmpfs_thp:        Migrates shared memory (tmpfs) transparent huge pages
+ *   - inactive_anon:    Migrates inactive anonymous pages (expected to fail)
+ *   - inactive_disk_file: Migrates inactive file pages (expected to fail)
+ *
+ * Each test creates a memory mapping, populates it with pages on the source
+ * NUMA node, triggers migration via memory.numa_migrate, and verifies that
+ * pages are correctly distributed across destination nodes. Data integrity
+ * is verified using CRC32 checksums during random read/write operations.
+ *
+ * The inactive list tests set memory.max to 50% of the test file size to
+ * force pages into inactive lists. These tests are marked as expected to
+ * fail due to known issues with inactive page migration.
+ */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -257,6 +283,11 @@ FIXTURE_VARIANT(numa_migrate) {
        bool with_mem_limit;
 };
 
+/* Test migration of active file pages from a regular disk file.
+ * Creates a temporary file, maps it with MAP_SHARED, populates it with pages
+ * on the source NUMA node, then triggers migration and verifies that pages
+ * are distributed across destination nodes.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, disk_file) {
        .mem_type = MEMORY_TYPE_ACTIVE_FILE,
        .verify = verify_active,
@@ -266,6 +297,11 @@ FIXTURE_VARIANT_ADD(numa_migrate, disk_file) {
        .with_mem_limit = false,
 };
 
+/* Test migration of active anonymous pages.
+ * Creates an anonymous mapping with MAP_PRIVATE | MAP_ANONYMOUS, populates
+ * it with pages on the source NUMA node, then triggers migration and verifies
+ * that pages are distributed across destination nodes.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, anon) {
        .mem_type = MEMORY_TYPE_ACTIVE_ANON,
        .verify = verify_active,
@@ -275,6 +311,12 @@ FIXTURE_VARIANT_ADD(numa_migrate, anon) {
        .with_mem_limit = false,
 };
 
+/* Test migration of anonymous transparent huge pages (THP).
+ * Creates an anonymous mapping with MAP_PRIVATE | MAP_ANONYMOUS, uses
+ * MADV_HUGEPAGE to enable THP, populates it with huge pages on the source
+ * NUMA node, then triggers migration and verifies that huge pages are
+ * distributed across destination nodes.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, anon_thp) {
        .mem_type = MEMORY_TYPE_ANON_THP,
        .verify = verify_active,
@@ -284,6 +326,11 @@ FIXTURE_VARIANT_ADD(numa_migrate, anon_thp) {
        .with_mem_limit = false,
 };
 
+/* Test migration of shared memory (tmpfs) file pages.
+ * Creates a memfd file (tmpfs), maps it with MAP_SHARED, populates it with
+ * pages on the source NUMA node, then triggers migration and verifies that
+ * pages are distributed across destination nodes.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, tmpfs_file) {
        .mem_type = MEMORY_TYPE_TMPFS_FILE,
        .verify = verify_active,
@@ -293,6 +340,12 @@ FIXTURE_VARIANT_ADD(numa_migrate, tmpfs_file) {
        .with_mem_limit = false,
 };
 
+/* Test migration of shared memory (tmpfs) transparent huge pages (THP).
+ * Creates a memfd file (tmpfs), maps it with MAP_SHARED, uses MADV_HUGEPAGE
+ * to enable THP, populates it with huge pages on the source NUMA node, then
+ * triggers migration and verifies that huge pages are distributed across
+ * destination nodes.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, tmpfs_thp) {
        .mem_type = MEMORY_TYPE_TMPFS_FILE_THP,
        .verify = verify_active,
@@ -302,6 +355,13 @@ FIXTURE_VARIANT_ADD(numa_migrate, tmpfs_thp) {
        .with_mem_limit = false,
 };
 
+/* Test migration of inactive anonymous pages.
+ * Creates an anonymous mapping, sets memory.max to 50% of file_size to force
+ * pages into inactive lists, populates it with pages on the source NUMA node,
+ * then triggers migration and verifies that inactive pages are distributed
+ * across destination nodes. This test is marked as expected to fail due to
+ * a known issue with inactive anon page migration.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, inactive_anon) {
        .mem_type = MEMORY_TYPE_INACTIVE_ANON,
        .verify = verify_inactive,
@@ -311,6 +371,14 @@ FIXTURE_VARIANT_ADD(numa_migrate, inactive_anon) {
        .with_mem_limit = true,
 };
 
+/* Test migration of inactive file pages from a regular disk file.
+ * Creates a temporary file, sets memory.max to 50% of file_size to force
+ * pages into inactive lists, maps it with MAP_SHARED, populates it with
+ * pages on the source NUMA node, then triggers migration and verifies that
+ * inactive pages are distributed across destination nodes. This test is
+ * marked as expected to fail due to a known issue with inactive file page
+ * migration.
+ */
 FIXTURE_VARIANT_ADD(numa_migrate, inactive_disk_file) {
        .mem_type = MEMORY_TYPE_INACTIVE_FILE,
        .verify = verify_inactive,
@@ -504,6 +572,14 @@ static int touch_pages(const char *cgroup, void *arg)
        return EXIT_SUCCESS;
 }
 
+/* Main test function that verifies NUMA migration of lruvecs.
+ * Spawns a child process that creates a memory mapping and populates it with
+ * pages on the source NUMA node. The child process continuously performs
+ * random reads and writes while calculating CRC32 checksums to verify data
+ * integrity. After allowing pages to stabilize, triggers migration via
+ * memory.numa_migrate and verifies that pages are correctly distributed
+ * across destination NUMA nodes according to the test variant.
+ */
 TEST_F(numa_migrate, migrate)
 {
        int child_pid;
-- 
2.43.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to