[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81258c9e-1436-4a4f-9343-ef574b8b0de6@efficios.com>
Date: Fri, 7 Nov 2025 11:04:01 -0500
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Shakeel Butt <shakeel.butt@...ux.dev>,
kernel test robot <oliver.sang@...el.com>
Cc: oe-lkp@...ts.linux.dev, lkp@...el.com,
Andrew Morton <akpm@...ux-foundation.org>,
"Paul E. McKenney" <paulmck@...nel.org>, Steven Rostedt
<rostedt@...dmis.org>, Masami Hiramatsu <mhiramat@...nel.org>,
Dennis Zhou <dennis@...nel.org>, Tejun Heo <tj@...nel.org>,
Christoph Lameter <cl@...ux.com>, Martin Liu <liumartin@...gle.com>,
David Rientjes <rientjes@...gle.com>, SeongJae Park <sj@...nel.org>,
Michal Hocko <mhocko@...e.com>, Johannes Weiner <hannes@...xchg.org>,
Sweet Tea Dorminy <sweettea@...gle.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R . Howlett" <liam.howlett@...cle.com>, Mike Rapoport
<rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>, Christian Brauner <brauner@...nel.org>,
Wei Yang <richard.weiyang@...il.com>, David Hildenbrand <david@...hat.com>,
Miaohe Lin <linmiaohe@...wei.com>, Al Viro <viro@...iv.linux.org.uk>,
Yu Zhao <yuzhao@...gle.com>, Roman Gushchin <roman.gushchin@...ux.dev>,
Mateusz Guzik <mjguzik@...il.com>, Matthew Wilcox <willy@...radead.org>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
Aboorva Devarajan <aboorvad@...ux.ibm.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
christian.koenig@....com
Subject: Re: [RFC PATCH v7 2/2] mm: Fix OOM killer inaccuracy on large
many-core systems
On 2025-11-07 10:53, Mathieu Desnoyers wrote:
[...]
>
> It would make sense to call an explicit percpu counter tree init
> function from start_kernel() between the call to mm_core_init() and the
> call to maple_tree_init(). This way it would be initialized right after
> mm, but given that the hierarchical counter tree is a lib that can be
> used for other purposes than mm accounting, I think it makes sense
> to call its init explicitly from start_kernel() rather than bury
> it within mm_core_init().
See the following diff. If nobody object, I'll prepare a v8 which
includes it.
diff --git a/include/linux/percpu_counter_tree.h
b/include/linux/percpu_counter_tree.h
index 8795e782680a..40fcdd6456b6 100644
--- a/include/linux/percpu_counter_tree.h
+++ b/include/linux/percpu_counter_tree.h
@@ -41,6 +41,7 @@ int percpu_counter_tree_precise_compare(struct
percpu_counter_tree *a, struct pe
int percpu_counter_tree_precise_compare_value(struct
percpu_counter_tree *counter, int v);
void percpu_counter_tree_set(struct percpu_counter_tree *counter, int v);
unsigned int percpu_counter_tree_inaccuracy(struct percpu_counter_tree
*counter);
+int percpu_counter_tree_subsystem_init(void);
/* Fast paths */
@@ -191,6 +192,12 @@ int percpu_counter_tree_approximate_sum(struct
percpu_counter_tree *counter)
return percpu_counter_tree_precise_sum(counter);
}
+static inline
+int percpu_counter_tree_subsystem_init(void)
+{
+ return 0;
+}
+
#endif /* CONFIG_SMP */
static inline
diff --git a/init/main.c b/init/main.c
index 07a3116811c5..204d9f913130 100644
--- a/init/main.c
+++ b/init/main.c
@@ -104,6 +104,7 @@
#include <linux/pidfs.h>
#include <linux/ptdump.h>
#include <linux/time_namespace.h>
+#include <linux/percpu_counter_tree.h>
#include <net/net_namespace.h>
#include <asm/io.h>
@@ -969,6 +970,7 @@ void start_kernel(void)
sort_main_extable();
trap_init();
mm_core_init();
+ percpu_counter_tree_subsystem_init();
maple_tree_init();
poking_init();
ftrace_init();
diff --git a/lib/percpu_counter_tree.c b/lib/percpu_counter_tree.c
index 9577d94251d1..05c3db0ce5b1 100644
--- a/lib/percpu_counter_tree.c
+++ b/lib/percpu_counter_tree.c
@@ -379,7 +379,7 @@ static unsigned int __init
calculate_inaccuracy_multiplier(void)
return inaccuracy;
}
-static int __init percpu_counter_startup(void)
+int __init percpu_counter_tree_subsystem_init(void)
{
nr_cpus_order = get_count_order(nr_cpu_ids);
@@ -391,4 +391,3 @@ static int __init percpu_counter_startup(void)
inaccuracy_multiplier = calculate_inaccuracy_multiplier();
return 0;
}
-module_init(percpu_counter_startup);
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Powered by blists - more mailing lists