* [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT
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 ` Eva Kurchatova
2026-11-13 4:28 ` no-reply
2026-11-13 19:57 ` Konstantin Khorenko
2026-11-13 4:19 ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts Eva Kurchatova
` (3 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Eva Kurchatova @ 2026-11-13 4:19 UTC (permalink / raw)
To: khorenko; +Cc: devel
When an ASSERT fails in a TEST_F(), __bail() longjmp()s back to the
setjmp() in the test wrapper, where the grandchild that ran the test
should see child == 0 and run the fixture teardown. child is a local
that fork() sets after setjmp(), so its value after longjmp() is
indeterminate. With -O2 it comes back as 1, its value at setjmp(): the
grandchild takes the parent's path, skips the teardown and aborts. A
failed test then leaves its cgroups, files or mounts behind, and the
next test can fail on them, as test_cache does on the cgroup that a
failed test_numa_migrate left.
Make the variable volatile, so it keeps the value fork() returned.
Mainline no longer uses setjmp() here since commit 869c788909b9
("selftests: harness: Stop using setjmp()/longjmp()"), which was a
large rewrite, and out of scope for this series.
https://virtuozzo.atlassian.net/browse/VSTOR-154520
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
tools/testing/selftests/kselftest_harness.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 19b05734b18c..5c46b8a854cf 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -407,7 +407,7 @@
{ \
/* fixture data is alloced, setup, and torn down per call. */ \
FIXTURE_DATA(fixture_name) self_private, *self = NULL; \
- pid_t child = 1; \
+ volatile pid_t child = 1; \
int status = 0; \
/* Makes sure there is only one teardown, even when child forks again. */ \
bool *teardown = mmap(NULL, sizeof(*teardown), \
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT
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
1 sibling, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-13 4:28 UTC (permalink / raw)
To: Eva Kurchatova, khorenko; +Cc: devel
> When an ASSERT fails in a TEST_F(), __bail() longjmp()s back to the
> setjmp() in the test wrapper, where the grandchild that ran the test
> should see child == 0 and run the fixture teardown. child is a local
> that fork() sets after setjmp(), so its value after longjmp() is
> indeterminate. With -O2 it comes back as 1, its value at setjmp(): the
> grandchild takes the parent's path, skips the teardown and aborts. A
> failed test then leaves its cgroups, files or mounts behind, and the
> next test can fail on them, as test_cache does on the cgroup that a
> failed test_numa_migrate left.
>
> Make the variable volatile, so it keeps the value fork() returned.
>
> Mainline no longer uses setjmp() here since commit 869c788909b9
> ("selftests: harness: Stop using setjmp()/longjmp()"), which was a
> large rewrite, and out of scope for this series.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-154520
> Feature: fix selftests
>
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261113042331.517488-1-eva.kurchatova@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT
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
1 sibling, 0 replies; 12+ messages in thread
From: Konstantin Khorenko @ 2026-11-13 19:57 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
Applying with these fixes on my side:
- "With -O2 it comes back as 1" -> "With -O2 it can come back as 1"
- "which was a large rewrite, and out of scope for this series" ->
"which depends on earlier harness changes missing here"
- added: Fixes: 0710a1a73fb4 ("selftests/harness: Merge TEST_F_FORK()
into TEST_F()")
On Fri, 13 Nov 2026 06:19:58 +0200, Eva Kurchatova wrote:
> indeterminate. With -O2 it comes back as 1, its value at setjmp(): the
Why: the value is indeterminate by the standard, what -O2 returns
depends on where the compiler keeps child.
> ("selftests: harness: Stop using setjmp()/longjmp()"), which was a
> large rewrite, and out of scope for this series.
Why: 869c788909b9 itself is small, but it needs several earlier
harness commits that this tree does not have.
> https://virtuozzo.atlassian.net/browse/VSTOR-154520
Why the tag: 0710a1a73fb4 is the commit that sets child between
setjmp() and longjmp() and reads it after the jump.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts
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:19 ` Eva Kurchatova
2026-11-13 4:27 ` 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
` (2 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Eva Kurchatova @ 2026-11-13 4:19 UTC (permalink / raw)
To: khorenko; +Cc: devel
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
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts
2026-11-13 4:19 ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts Eva Kurchatova
@ 2026-11-13 4:27 ` no-reply
2026-11-13 19:57 ` Konstantin Khorenko
1 sibling, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-13 4:27 UTC (permalink / raw)
To: khorenko, Eva Kurchatova; +Cc: devel
> 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>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261113042331.517488-1-eva.kurchatova@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts
2026-11-13 4:19 ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts Eva Kurchatova
2026-11-13 4:27 ` no-reply
@ 2026-11-13 19:57 ` Konstantin Khorenko
1 sibling, 0 replies; 12+ messages in thread
From: Konstantin Khorenko @ 2026-11-13 19:57 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
Applying with these fixes on my side:
- "as soon as 85% of the pages" -> "as soon as about 74% of the pages"
- "and up to the 15% that verify_stats() tolerates can stay behind" ->
"and more of them can stay behind than verify_stats() tolerates"
On Fri, 13 Nov 2026 06:19:59 +0200, Eva Kurchatova wrote:
> 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
Why: wait_src_node_stat() uses values_close(a, b, 15), which compares
the difference with 15% of the sum, so it passes once the source node
holds about 74% of 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
Why: the test fails when more pages stay behind than verify_stats()
tolerates, not up to that much.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Devel] [PATCH hci-8.1 3/3] selftests: cgroup: populate the inactive file with read faults
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:19 ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts Eva Kurchatova
@ 2026-11-13 4:20 ` 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
4 siblings, 2 replies; 12+ messages in thread
From: Eva Kurchatova @ 2026-11-13 4:20 UTC (permalink / raw)
To: khorenko; +Cc: devel
memory.numa_migrate migrates asynchronously, so it skips the folios that
are under writeback or locked for it when it gets to them. The
inactive_disk_file variant dirties 1 GiB of a disk file with write
faults, and writeback of that file is still running when the test
migrates it, so part of the file can stay on the source node.
Populate that file with read faults instead. The file is a hole, so its
page cache stays clean and nothing is written back. disk_file keeps
writing to its pages while they are migrated and is left as is.
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>
---
tools/testing/selftests/cgroup/test_numa_migrate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cgroup/test_numa_migrate.c b/tools/testing/selftests/cgroup/test_numa_migrate.c
index 12c9bab79d6e..5e9f594ffb9f 100644
--- a/tools/testing/selftests/cgroup/test_numa_migrate.c
+++ b/tools/testing/selftests/cgroup/test_numa_migrate.c
@@ -588,6 +588,7 @@ static int touch_pages(const char *cgroup, void *arg)
volatile uint8_t *ptr;
enum memory_type mem_type;
bool inactive;
+ int populate;
char tmp = 's';
struct test_context *ctx = arg;
int ret = EXIT_SUCCESS;
@@ -596,6 +597,9 @@ static int touch_pages(const char *cgroup, void *arg)
mem_type = variant->mem_type;
inactive = mem_type == MEMORY_TYPE_INACTIVE_FILE ||
mem_type == MEMORY_TYPE_INACTIVE_ANON;
+ /* Read faults leave the file clean, so writeback cannot hold pages back */
+ populate = mem_type == MEMORY_TYPE_INACTIVE_FILE ?
+ MADV_POPULATE_READ : MADV_POPULATE_WRITE;
numa_bind(src_mask);
@@ -624,7 +628,7 @@ static int touch_pages(const char *cgroup, void *arg)
}
}
- if (madvise(mmap_ptr, file_size, MADV_POPULATE_WRITE) < 0) {
+ if (madvise(mmap_ptr, file_size, populate) < 0) {
ksft_perror("failed to populate test mapping\n");
ret = EXIT_FAILURE;
goto err_unmap;
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 3/3] selftests: cgroup: populate the inactive file with read faults
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
1 sibling, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-13 4:28 UTC (permalink / raw)
To: Eva Kurchatova, khorenko; +Cc: devel
> memory.numa_migrate migrates asynchronously, so it skips the folios that
> are under writeback or locked for it when it gets to them. The
> inactive_disk_file variant dirties 1 GiB of a disk file with write
> faults, and writeback of that file is still running when the test
> migrates it, so part of the file can stay on the source node.
>
> Populate that file with read faults instead. The file is a hole, so its
> page cache stays clean and nothing is written back. disk_file keeps
> writing to its pages while they are migrated and is left as is.
>
> 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>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261113042331.517488-1-eva.kurchatova@virtuozzo.com?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 3/3] selftests: cgroup: populate the inactive file with read faults
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
1 sibling, 0 replies; 12+ messages in thread
From: Konstantin Khorenko @ 2026-11-13 19:57 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
Applying as is.
On Fri, 13 Nov 2026 06:20:00 +0200, Eva Kurchatova wrote:
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file
2026-11-13 4:19 [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Eva Kurchatova
` (2 preceding siblings ...)
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 19:57 ` Konstantin Khorenko
2026-11-13 19:59 ` Konstantin Khorenko
4 siblings, 0 replies; 12+ messages in thread
From: Konstantin Khorenko @ 2026-11-13 19:57 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
Applying with these fixes on my side:
- patch 1, commit message: "can come back as 1"; why 869c788909b9 is
not taken; added a Fixes tag for 0710a1a73fb4
- patch 2, commit message: the threshold of wait_src_node_stat() and
what verify_stats() tolerates
On Fri, 13 Nov 2026 06:19:57 +0200, Eva Kurchatova wrote:
> Eva Kurchatova (3):
> selftests: harness: run the fixture teardown after a failed ASSERT
> selftests: cgroup: mark the pages cold before numa_migrate starts
> selftests: cgroup: populate the inactive file with read faults
The code of all three patches is fine. Details are in the replies to
the patches.
One question, not needed for this series: disk_file also fills its
file with MADV_POPULATE_WRITE and migrates right after the wait, and
numa_migrate skips its folios under writeback too. Why does it not
fail the same way as inactive_disk_file did?
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file
2026-11-13 4:19 [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Eva Kurchatova
` (3 preceding siblings ...)
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
4 siblings, 0 replies; 12+ messages in thread
From: Konstantin Khorenko @ 2026-11-13 19:59 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
On Fri, 13 Nov 2026 06:19:57 +0200, Eva Kurchatova wrote:
> selftests: cgroup: fix test_numa_migrate, inactive_disk_file
>
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-154520
>
> Eva Kurchatova (3):
> selftests: harness: run the fixture teardown after a failed ASSERT
> selftests: cgroup: mark the pages cold before numa_migrate starts
> selftests: cgroup: populate the inactive file with read faults
>
> [...]
Applied to branch-rh10-6.12.0-211.75.1.24.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.2.vz10, thanks!
[1/3] selftests: harness: run the fixture teardown after a failed ASSERT
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/7a30fde1fb06
[2/3] selftests: cgroup: mark the pages cold before numa_migrate starts
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/0985be1fe828
[3/3] selftests: cgroup: populate the inactive file with read faults
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/3bac3a09e842
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 12+ messages in thread