Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH] getrusage03: account for percpu RSS counter batching
@ 2026-08-25 15:25 Nirmoy Das via ltp
  2026-08-25 17:34 ` [LTP] " linuxtestproject.agent
  2026-09-02 12:25 ` [LTP] [RFC PATCH] " Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Nirmoy Das via ltp @ 2026-08-25 15:25 UTC (permalink / raw)
  To: ltp; +Cc: Nirmoy Das

getrusage03 allows ru_maxrss to differ from the expected value by a
fixed 20 MiB. That can be too small on large systems after Linux commit
f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter").

The fast RSS read may miss percpu counter batches, and the batch size
scales with the number of online CPUs. The test child is single threaded,
but it can migrate while faulting memory, so allow two batches worth of
slack based on the online CPU count and page size. Keep the existing
20 MiB floor for smaller systems.

This is sent as RFC because it makes the test tolerate Linux's current
percpu counter batching behavior instead of treating the smaller
ru_maxrss value as a kernel failure.

Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
---
 .../kernel/syscalls/getrusage/getrusage03.h     | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.h b/testcases/kernel/syscalls/getrusage/getrusage03.h
index 58a98b430..9a7d8e8fa 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03.h
+++ b/testcases/kernel/syscalls/getrusage/getrusage03.h
@@ -7,9 +7,20 @@
 #define LTP_GETRUSAGE03_H
 
 #include <sched.h>
+#include "tst_cpu.h"
 #include "tst_test.h"
 
-#define DELTA_MAX 20480
+#define DELTA_MAX 20480L
+#define MAXRSS_BATCHES 2L
+
+static long maxrss_delta(void)
+{
+	long batch = MAX(32L, tst_ncpus() * 2);
+	long delta = MAXRSS_BATCHES * batch * SAFE_SYSCONF(_SC_PAGESIZE) / 1024;
+
+	/* Linux RSS counters can miss percpu counter batches after migration. */
+	return MAX(DELTA_MAX, delta);
+}
 
 static void force_context_switches(int iterations)
 {
@@ -40,7 +51,9 @@ static void consume_mb(int consume_nr)
 
 static int is_in_delta(long value)
 {
-	return (value >= -DELTA_MAX && value <= DELTA_MAX);
+	long delta = maxrss_delta();
+
+	return (value >= -delta && value <= delta);
 }
 
 #endif //LTP_GETRUSAGE03_H
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-02 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 15:25 [LTP] [RFC PATCH] getrusage03: account for percpu RSS counter batching Nirmoy Das via ltp
2026-08-25 17:34 ` [LTP] " linuxtestproject.agent
2026-09-02 12:25 ` [LTP] [RFC PATCH] " Cyril Hrubis
2026-09-02 16:01   ` [LTP] [PATCH v2] " Nirmoy Das via ltp
2026-09-02 17:42     ` [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