Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"David Hildenbrand" <david@kernel.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Christoph Lameter" <cl@gentwo.org>,
	"Martin Liu" <liumartin@google.com>,
	"David Rientjes" <rientjes@google.com>,
	christian.koenig@amd.com, "Shakeel Butt" <shakeel.butt@linux.dev>,
	"SeongJae Park" <sj@kernel.org>, "Michal Hocko" <mhocko@suse.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Sweet Tea Dorminy" <sweettea-kernel@dorminy.me>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Christian Brauner" <brauner@kernel.org>,
	"Wei Yang" <richard.weiyang@gmail.com>,
	"Miaohe Lin" <linmiaohe@huawei.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Yu Zhao" <yuzhao@google.com>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Mateusz Guzik" <mjguzik@gmail.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Aboorva Devarajan" <aboorvad@linux.ibm.com>,
	"David Carlier" <devnexen@gmail.com>,
	"Josh Law" <objecting@objecting.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, "Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Kees Cook" <kees@kernel.org>, "Ingo Molnar" <mingo@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"K Prateek Nayak" <kprateek.nayak@amd.com>,
	linux-trace-kernel@vger.kernel.org, "Jan Kara" <jack@suse.cz>,
	"Oleg Nesterov" <oleg@redhat.com>
Subject: Re: [RFC PATCH v23 10/10] lib: add a benchmark of hierarchical per-cpu counters
Date: Tue, 03 Nov 2026 19:07:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-195892@kernel.org> (raw)
In-Reply-To: <20261102190708.1287100-11-mathieu.desnoyers@efficios.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] lib: stack-allocated percpu_counter in bench triggers debugobjects WARN_ON
- [Low] lib: missing kernel-parameters.txt entry for percpu_counter_tree_bench.batch
--

commit a1a6611650e4e4f4d5279cc3d46fb8ab12ea614c
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

lib: add a benchmark of hierarchical per-cpu counters

This commit adds a KUnit benchmark comparing hierarchical per-CPU counters
with struct percpu_counter across update, lifecycle, and churn workloads.
It introduces CONFIG_PERCPU_COUNTER_TREE_BENCH and the batch module
parameter to configure the hierarchical counter batch size.

> diff --git a/lib/tests/percpu_counter_tree_bench.c b/lib/tests/percpu_counter_tree_bench.c
> new file mode 100644
> index 0000000000000..bf260bef196a5
> --- /dev/null
> +++ b/lib/tests/percpu_counter_tree_bench.c

[ ... ]

> +/* Like the RSS counters by default. */
> +static unsigned int batch = 32;
> +module_param(batch, uint, 0444);
> +MODULE_PARM_DESC(batch, "Batch size of the hierarchical counters (power of 2, 2 to 128)");

[Severity: Low]
Should percpu_counter_tree_bench.batch= also be documented in
Documentation/admin-guide/kernel-parameters.txt?

Both the commit message and the CONFIG_PERCPU_COUNTER_TREE_BENCH help text in
lib/Kconfig advertise passing percpu_counter_tree_bench.batch= on the kernel
command line alongside percpu_counter_tree.arity=, which is documented there.

[ ... ]

> +static int bench_lifecycle_fn(void *data)
> +{
> +	struct bench_thread *t = data;
> +	struct percpu_counter_tree c[LIFECYCLE_NR];
> +	struct percpu_counter pc[LIFECYCLE_NR];
> +	u64 t0;
> +	int i;
> +
> +	if (bench_wait_go(t->sh))
> +		return 0;
> +	t0 = ktime_get_ns();
> +	for (i = 0; t->sh->impl == IMPL_PERCPU_COUNTER && i < LIFECYCLE_ITER; i++) {
> +		if (percpu_counter_init_many(pc, 0, GFP_KERNEL, LIFECYCLE_NR))
> +			break;
> +		percpu_counter_add(&pc[0], 1);
> +		percpu_counter_add(&pc[0], -1);
> +		percpu_counter_destroy_many(pc, LIFECYCLE_NR);
> +		cond_resched();
> +	}

[ ... ]

> +static int bench_churn_fn(void *data)
> +{
> +	struct bench_thread *t = data;
> +	unsigned int pin_period = t->sh->pin_period;
> +	struct percpu_counter_tree tmp[LIFECYCLE_NR], *c;
> +	struct percpu_counter tmp_pc[LIFECYCLE_NR], *pc;
> +	u64 t0;
> +	int i;
> +
> +	if (bench_wait_go(t->sh))
> +		return 0;
> +	t0 = ktime_get_ns();
> +	for (i = 0; t->sh->impl == IMPL_PERCPU_COUNTER && i < CHURN_ITER; i++) {
> +		bool pin = pin_period && !(i % pin_period);
> +
> +		pc = pin ? &t->pinned_pc[t->nr_pinned * LIFECYCLE_NR] : tmp_pc;
> +		if (percpu_counter_init_many(pc, 0, GFP_KERNEL, LIFECYCLE_NR))
> +			break;

[Severity: Medium]
Will passing stack-allocated struct percpu_counter arrays (pc in
bench_lifecycle_fn() and tmp_pc in bench_churn_fn()) to
percpu_counter_init_many() trigger a debugobjects WARN_ON(1) when
CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER is enabled?

The call chain is:

  percpu_counter_init_many()
    __percpu_counter_init_many()
      debug_percpu_counter_activate()
        debug_object_init()
          __debug_object_init(..., onstack = 0)
            lookup_object_or_alloc()
              debug_object_is_on_stack()

Because debug_object_init() is called with onstack = 0 while pc and tmp_pc
reside on the kthread stack, debug_object_is_on_stack() will warn that a
non-onstack object is on the stack.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102190708.1287100-1-mathieu.desnoyers@efficios.com?part=10


      reply	other threads:[~2026-11-03 19:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 19:06 [RFC PATCH v23 00/10] Hierarchical Percpu Counters for RSS Mathieu Desnoyers
2026-11-02 19:06 ` [RFC PATCH v23 01/10] lib: introduce hierarchical per-cpu counters Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 02/10] lib: test " Mathieu Desnoyers
2026-11-03 19:07   ` sashiko-bot
2026-11-02 19:07 ` [RFC PATCH v23 03/10] mm: use hierarchical per-cpu counters for the RSS counters Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 04/10] tools/testing/hpcc: add userspace test of hierarchical per-CPU counters Mathieu Desnoyers
2026-11-03 19:07   ` sashiko-bot
2026-11-02 19:07 ` [RFC PATCH v23 05/10] mm: report the approximate RSS in the rss_stat tracepoint Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 06/10] lib: percpu_counter_tree: add lazy tree activation Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 07/10] mm: keep the RSS counters of single-threaded processes exact Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 08/10] lib: percpu_counter_tree: add the arity boot parameter Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 09/10] mm: add the rss_stat_batch " Mathieu Desnoyers
2026-11-02 19:07 ` [RFC PATCH v23 10/10] lib: add a benchmark of hierarchical per-cpu counters Mathieu Desnoyers
2026-11-03 19:07   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-195892@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aboorvad@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=brauner@kernel.org \
    --cc=bsegall@google.com \
    --cc=christian.koenig@amd.com \
    --cc=cl@gentwo.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=dennis@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=liumartin@google.com \
    --cc=ljs@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mgorman@suse.de \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=mjguzik@gmail.com \
    --cc=objecting@objecting.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=richard.weiyang@gmail.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=sweettea-kernel@dorminy.me \
    --cc=tj@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vschneid@redhat.com \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox