OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts
Date: Fri, 13 Nov 2026 06:19:59 +0200	[thread overview]
Message-ID: <20261113042331.517488-3-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261113042331.517488-1-eva.kurchatova@virtuozzo.com>

The inactive variants of test_numa_migrate report their pages populated
before they madvise(MADV_COLD) them. The parent starts the migration as
soon as 85% of the pages are inactive on the source node, while the
rest are still being deactivated. memory.numa_migrate takes the size of
each LRU list as its scan budget when it gets to the list, so the pages
that become inactive later are not scanned, and up to the 15% that
verify_stats() tolerates can stay behind. The slower a kernel
deactivates the pages, the more often the test fails, which made
inactive_disk_file fail often on coverage kernels.

Call madvise(MADV_COLD) before reporting the pages populated.

Fixes: 3842964f4497 ("selftests: cgroup: test numa migration of lruvecs")
https://virtuozzo.atlassian.net/browse/VSTOR-154520
Feature: fix selftests

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 .../selftests/cgroup/test_numa_migrate.c      | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/cgroup/test_numa_migrate.c b/tools/testing/selftests/cgroup/test_numa_migrate.c
index 5f4a55684f61..12c9bab79d6e 100644
--- a/tools/testing/selftests/cgroup/test_numa_migrate.c
+++ b/tools/testing/selftests/cgroup/test_numa_migrate.c
@@ -587,12 +587,15 @@ static int touch_pages(const char *cgroup, void *arg)
 	void *mmap_ptr;
 	volatile uint8_t *ptr;
 	enum memory_type mem_type;
+	bool inactive;
 	char tmp = 's';
 	struct test_context *ctx = arg;
 	int ret = EXIT_SUCCESS;
 
 	EXPAND_CTX(ctx);
 	mem_type = variant->mem_type;
+	inactive = mem_type == MEMORY_TYPE_INACTIVE_FILE ||
+		   mem_type == MEMORY_TYPE_INACTIVE_ANON;
 
 	numa_bind(src_mask);
 
@@ -627,6 +630,13 @@ static int touch_pages(const char *cgroup, void *arg)
 		goto err_unmap;
 	}
 
+	/* Deactivate all pages before the parent starts migrating them */
+	if (inactive && madvise(mmap_ptr, file_size, MADV_COLD) < 0) {
+		ksft_perror("failed to mark test mapping cold\n");
+		ret = EXIT_FAILURE;
+		goto err_unmap;
+	}
+
 	if (write(self->pipefd[1], &tmp, 1) != 1) {
 		ksft_print_msg("failed to write to pipe\n");
 		close(self->pipefd[1]);
@@ -640,15 +650,8 @@ static int touch_pages(const char *cgroup, void *arg)
 		goto err_unmap;
 	}
 
-	if (mem_type == MEMORY_TYPE_INACTIVE_FILE ||
-	    mem_type == MEMORY_TYPE_INACTIVE_ANON) {
-		if (madvise(mmap_ptr, file_size, MADV_COLD) < 0) {
-			ksft_perror("failed to mark test mapping cold\n");
-			ret = EXIT_FAILURE;
-			goto err_unmap;
-		}
+	if (inactive)
 		pause();
-	}
 
 	srand(getpid());
 	while (1) {
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-13  4:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  4:19 [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Eva Kurchatova
2026-11-13  4:19 ` [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT Eva Kurchatova
2026-11-13  4:28   ` no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13  4:19 ` Eva Kurchatova [this message]
2026-11-13  4:27   ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13  4:20 ` [Devel] [PATCH hci-8.1 3/3] selftests: cgroup: populate the inactive file with read faults Eva Kurchatova
2026-11-13  4:28   ` no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13 19:57 ` [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Konstantin Khorenko
2026-11-13 19:59 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113042331.517488-3-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox