From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Jiebin Sun <jiebin.sun@intel.com>
Cc: akpm@linux-foundation.org, dennis@kernel.org, tj@kernel.org,
cl@gentwo.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
clrkwllms@kernel.org, rostedt@goodmis.org,
linux-rt-devel@lists.linux.dev, tim.c.chen@linux.intel.com,
tianyou.li@intel.com, wangyang.guo@intel.com
Subject: Re: [PATCH] lib/percpu_counter: allow concurrent sums with an rwlock
Date: Mon, 16 Nov 2026 08:30:08 +0100 [thread overview]
Message-ID: <20261116073008.PvlRj7Tl@linutronix.de> (raw)
In-Reply-To: <20261116015655.2744577-1-jiebin.sun@intel.com>
On 2026-11-16 09:56:55 [+0800], Jiebin Sun wrote:
> __percpu_counter_sum() holds a raw spinlock while reading the global
> count and per-CPU deltas, serializing concurrent sums of the same
> counter. Since a sum changes neither the global count nor the per-CPU
> deltas, use rwlock_t on !PREEMPT_RT to allow concurrent sums with a
> read lock. Global updates take the write lock. The per-CPU fast path
> remains lockless, so sums keep their existing snapshot semantics.
>
> stress-ng dentry reaches this path through ext4_statfs():
>
> statfs -> ext4_statfs -> __percpu_counter_sum
> -> native_queued_spin_lock_slowpath
>
> Keep the raw spinlock on PREEMPT_RT, where rwlock_t can sleep.
> Global counter updates can run in atomic context and must not sleep.
>
> stress-ng dentry test average throughput change:
>
> +------------------------+------------+--------------------+
> | Case | Unit | Average change (%) |
> +------------------------+------------+--------------------+
> | Dentry, 64 workers | bogo ops/s | +47.34 |
> +------------------------+------------+--------------------+
>
> Dentry ran on ext4 with 64 workers pinned to physical CPUs:
>
> stress-ng --dentry 64 --dentries 4096 --timeout 20s
>
> Suggested-by: Tim Chen <tim.c.chen@linux.intel.com>
> Reviewed-by: Tianyou Li <tianyou.li@intel.com>
> Reviewed-by: Wangyang Guo <wangyang.guo@intel.com>
> Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
It looks okay from RT point of view. Is this limited to this benchmark
or is there a real workload behind this?
Sebastian
prev parent reply other threads:[~2026-11-16 7:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 1:56 Jiebin Sun
2026-11-16 3:16 ` Andrew Morton
2026-11-16 3:44 ` Andrew Morton
2026-11-16 7:41 ` Sebastian Andrzej Siewior
2026-11-16 7:30 ` Sebastian Andrzej Siewior [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=20261116073008.PvlRj7Tl@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=clrkwllms@kernel.org \
--cc=dennis@kernel.org \
--cc=jiebin.sun@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=rostedt@goodmis.org \
--cc=tianyou.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=tj@kernel.org \
--cc=wangyang.guo@intel.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
all inboxes | Powered by JetHome®