Re: [RFC PATCH v5 2/2] mm: Fix OOM killer inaccuracy on large many-core systems

From: Mathieu Desnoyers
Date: Thu Jul 03 2025 - 15:45:07 EST


On 2025-07-03 13:38, Mathieu Desnoyers wrote:
[...]
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e51dba8398f7..18ccb51dad88 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2705,28 +2705,30 @@ static inline bool get_user_page_fast_only(unsigned long addr,
*/
static inline unsigned long get_mm_counter(struct mm_struct *mm, int member)
{
- return percpu_counter_read_positive(&mm->rss_stat[member]);
+ int v = percpu_counter_tree_approximate_sum(&mm->rss_stat[member]);
+
+ return v > 0 ? v : 0;
}

In a follow up version, I plan to introduce a new
percpu_counter_tree_approximate_sum_positive() to wrap this
>= 0 logic.

Thanks,

Mathieu



--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com