[RFC PATCH] mm: use precise current RSS for high-water accounting
From: Nirmoy Das
Date: Thu Jul 23 2026 - 09:52:14 EST
get_mm_rss() reads approximate per-CPU RSS counters. On large systems,
this can under-report the current RSS used for high-water accounting.
On a 352-CPU, 2-node system with 64 KiB pages, reproduce with:
sudo -E env LTPROOT=/opt/ltp \
PATH=/opt/ltp/testcases/bin:$PATH LTP_TIMEOUT_MUL=5 \
bash -c "cd /opt/ltp/testcases/bin && ./getrusage03"
The test failed 10/10 times with child.children=270336 instead of
307200.
Use get_mm_rss_sum() when reading and resetting high-water RSS. Keep
update_hiwater_rss() on the approximate path because it runs before
RSS-decreasing operations.
The patched kernel passed getrusage03 20/20 times. getrusage01,
getrusage02 and getrusage04 also passed.
Fixes: f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: Cursor:claude-opus-4-8-thinking-max
Signed-off-by: Nirmoy Das <nirmoyd@xxxxxxxxxx>
---
include/linux/mm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 485df9c2dbddb..1b613c6356baa 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3405,7 +3405,7 @@ static inline unsigned long get_mm_rss_sum(struct mm_struct *mm)
static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
{
- return max(mm->hiwater_rss, get_mm_rss(mm));
+ return max(mm->hiwater_rss, get_mm_rss_sum(mm));
}
static inline unsigned long get_mm_hiwater_vm(struct mm_struct *mm)
@@ -3429,7 +3429,7 @@ static inline void update_hiwater_vm(struct mm_struct *mm)
static inline void reset_mm_hiwater_rss(struct mm_struct *mm)
{
- mm->hiwater_rss = get_mm_rss(mm);
+ mm->hiwater_rss = get_mm_rss_sum(mm);
}
static inline void setmax_mm_hiwater_rss(unsigned long *maxrss,
base-commit: 4539944e515183668109bdf4d0c3d7d228383d88
--
2.43.0