* [LTP] [PATCH] memcontrol04: Fix test failure by keeping pagecache children alive
@ 2026-04-27 17:17 Pavithra
2026-04-27 17:29 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 2+ messages in thread
From: Pavithra @ 2026-04-27 17:17 UTC (permalink / raw)
To: ltp; +Cc: pavrampu
The test was failing with memory.current values much lower than expected:
TFAIL: (A/B/C memory.current=6684672) ~= 34603008
TFAIL: (A/B/D memory.current=5373952) ~= 17825792
Root cause:
Child processes allocating pagecache were exiting immediately after
allocation (via tst_reap_children()), causing the pagecache to be
freed before the test could measure memory.current values.
Fix:
Modified alloc_pagecache_in_child() to keep children alive during test:
- Added TEST_DONE checkpoint for child lifecycle coordination
- Parent waits for CHILD_IDLE checkpoint before proceeding
- Child signals CHILD_IDLE after allocation and fsync
- Child waits for TEST_DONE to keep memory allocated during test
- Modified cleanup_sub_groups() to wake waiting children before cleanup
- Changed alloc_anon_in_child() to use SAFE_WAITPID() for specific child
This matches the pattern used in memcontrol03.c and ensures pagecache
remains allocated during memory pressure testing, allowing correct
memory.current measurements.
Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>, Pavithra <pavrampu@linux.ibm.com>
---
.../kernel/controllers/memcg/memcontrol04.c | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/controllers/memcg/memcontrol04.c b/testcases/kernel/controllers/memcg/memcontrol04.c
index 715cc5bcd..d0188a1da 100644
--- a/testcases/kernel/controllers/memcg/memcontrol04.c
+++ b/testcases/kernel/controllers/memcg/memcontrol04.c
@@ -47,7 +47,8 @@ static struct tst_cg_group *leaf_cg[4];
static int fd = -1;
enum checkpoints {
- CHILD_IDLE
+ CHILD_IDLE,
+ TEST_DONE,
};
enum trunk_cg {
@@ -67,6 +68,16 @@ static void cleanup_sub_groups(void)
{
size_t i;
+ for (i = ARRAY_SIZE(leaf_cg); i > 0; i--) {
+ if (!leaf_cg[i - 1])
+ continue;
+
+ TST_CHECKPOINT_WAKE2(TEST_DONE,
+ ARRAY_SIZE(leaf_cg) - 1);
+ tst_reap_children();
+ break;
+ }
+
for (i = ARRAY_SIZE(leaf_cg); i > 0; i--) {
if (!leaf_cg[i - 1])
continue;
@@ -88,7 +99,7 @@ static void alloc_anon_in_child(const struct tst_cg_group *const cg,
const pid_t pid = SAFE_FORK();
if (pid) {
- tst_reap_children();
+ SAFE_WAITPID(pid, NULL, 0);
return;
}
@@ -107,7 +118,7 @@ static void alloc_pagecache_in_child(const struct tst_cg_group *const cg,
const pid_t pid = SAFE_FORK();
if (pid) {
- tst_reap_children();
+ TST_CHECKPOINT_WAIT(CHILD_IDLE);
return;
}
@@ -117,6 +128,11 @@ static void alloc_pagecache_in_child(const struct tst_cg_group *const cg,
getpid(), tst_cg_group_name(cg), size);
alloc_pagecache(fd, size);
+ SAFE_FSYNC(fd);
+
+ TST_CHECKPOINT_WAKE(CHILD_IDLE);
+ TST_CHECKPOINT_WAIT(TEST_DONE);
+
exit(0);
}
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] memcontrol04: Fix test failure by keeping pagecache children alive
2026-04-27 17:17 [LTP] [PATCH] memcontrol04: Fix test failure by keeping pagecache children alive Pavithra
@ 2026-04-27 17:29 ` linuxtestproject.agent
0 siblings, 0 replies; 2+ messages in thread
From: linuxtestproject.agent @ 2026-04-27 17:29 UTC (permalink / raw)
To: Pavithra; +Cc: ltp
Hi Pavithra,
On Mon, 27 Apr 2026, Pavithra wrote:
> memcontrol04: Fix test failure by keeping pagecache children alive
> Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>, Pavithra <pavrampu@linux.ibm.com>
Each contributor must have their own Signed-off-by line:
Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>
Signed-off-by: Pavithra <pavrampu@linux.ibm.com>
This is a bug fix; please add a Fixes: tag pointing to the commit that
introduced the broken behaviour.
> + for (i = ARRAY_SIZE(leaf_cg); i > 0; i--) {
> + if (!leaf_cg[i - 1])
> + continue;
> +
> + TST_CHECKPOINT_WAKE2(TEST_DONE,
> + ARRAY_SIZE(leaf_cg) - 1);
> + tst_reap_children();
> + break;
> + }
ARRAY_SIZE(leaf_cg) - 1 = 3 assumes all three pagecache children were
created. If cleanup() is invoked during partial setup, TST_CHECKPOINT_WAKE2
will time out waiting for missing processes and emit a spurious TBROK.
Track the number of children actually spawned and wake only that many.
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-27 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 17:17 [LTP] [PATCH] memcontrol04: Fix test failure by keeping pagecache children alive Pavithra
2026-04-27 17:29 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox