[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67e2a6a1-8c9b-43d0-b960-10cd47c08873@efficios.com>
Date: Wed, 26 Mar 2025 15:56:15 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Sweet Tea Dorminy <sweettea-kernel@...miny.me>,
Andrew Morton <akpm@...ux-foundation.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>,
Jani Nikula <jani.nikula@...el.com>, Sweet Tea Dorminy
<sweettea@...gle.com>, Johannes Weiner <hannes@...xchg.org>,
Christian Brauner <brauner@...nel.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Wei Yang <richard.weiyang@...il.com>, David Hildenbrand <david@...hat.com>,
Miaohe Lin <linmiaohe@...wei.com>, Al Viro <viro@...iv.linux.org.uk>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, Matthew Wilcox <willy@...radead.org>,
paulmck <paulmck@...nel.org>
Cc: Yu Zhao <yuzhao@...gle.com>, Roman Gushchin <roman.gushchin@...ux.dev>,
Greg Thelen <gthelen@...gle.com>
Subject: Re: [PATCH] mm: use per-numa-node atomics instead of percpu_counters
On 2025-03-25 18:15, Sweet Tea Dorminy wrote:
> From: Sweet Tea Dorminy <sweettea@...gle.com>
>
> Recently, several internal services had an RSS usage regression as part of a
> kernel upgrade. Previously, they were on a pre-6.2 kernel and were able to
> read RSS statistics in a backup watchdog process to monitor and decide if
> they'd overrun their memory budget. Now, however, a representative service
> with five threads, expected to use about a hundred MB of memory, on a 250-cpu
> machine had memory usage tens of megabytes different from the expected amount
> -- this constituted a significant percentage of inaccuracy, causing the
> watchdog to act.
>
I suspect the culprit sits here:
int percpu_counter_batch __read_mostly = 32;
EXPORT_SYMBOL(percpu_counter_batch);
static int compute_batch_value(unsigned int cpu)
{
int nr = num_online_cpus();
percpu_counter_batch = max(32, nr*2);
return 0;
}
So correct me if I'm wrong, but in this case the worse-case
inaccuracy for a 256 cpu machine would be
"+/- percpu_counter_batch" within each percpu counter,
thus globally:
+/- (256 * 2) * 256, or 131072 pages, meaning an inaccuracy
of +/- 512MB with 4kB pages. This is quite significant.
So I understand that the batch size is scaled up as the
number of CPUs increases to minimize contention on the
percpu_counter lock. Unfortunately, as the number of CPUs
increases, the inaccuracy increases with the square of the
number of cpus.
Have you tried decreasing this percpu_counter_batch value on
larger machines to see if it helps ?
Thanks,
Mathieu
[...]
>
> base-commit: b0cb56cbbdb4754918c28d6d7c294d56e28a3dd5
> prerequisite-patch-id: b7b47d1b9aa3fd887dd718ab276581f120e516e6
[...][ cutting the gazillions prerequisite-patch-id, please review you use
of tooling when preparing/sending patches. ]
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Powered by blists - more mailing lists