From: Boqun Feng <boqun@kernel.org>
To: Kunwu Chan <kunwu.chan@gmail.com>
Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com,
will@kernel.org, peterz@infradead.org, npiggin@gmail.com,
dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr,
paulmck@kernel.org, corbet@lwn.net, mingo@redhat.com,
dave@stgolabs.net, josh@joshtriplett.org, frederic@kernel.org,
neeraj.upadhyay@kernel.org, urezki@gmail.com, akiyks@gmail.com,
dlustig@nvidia.com, joelagnelf@nvidia.com,
skhan@linuxfoundation.org, rdunlap@infradead.org,
longman@redhat.com, rostedt@goodmis.org,
mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
qiang.zhang@linux.dev, include@grrlz.net,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
lkmm@lists.linux.dev, linux-doc@vger.kernel.org,
rcu@vger.kernel.org, lianux.mm@gmail.com
Subject: Re: [RFC/WIP PATCH 3/4] rcuscale: add hazptr scale type
Date: Tue, 22 Sep 2026 09:55:25 +0200 [thread overview]
Message-ID: <arI0bexTH7CL66Dc@MacBook-0RXW5> (raw)
In-Reply-To: <20260922070950.4173245-4-kunwu.chan@gmail.com>
On Tue, Sep 22, 2026 at 03:09:49PM +0800, Kunwu Chan wrote:
> Add hazptr reader and synchronize operations so that synchronize
> latency can be measured alongside RCU and SRCU.
>
> The read side acquires the hazard pointer in readlock() and holds
> it until readunlock(), matching the RCU/SRCU reader model. The
> address of a static object serves as the synchronize target, which
> is stable and never reclaimed. Both normal and expedited sync map
> to hazptr_synchronize(), since hazptr has no expedited concept.
>
> Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
> ---
> kernel/rcu/rcuscale.c | 65 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
> index 1097ec15879c..072ddf9526c3 100644
> --- a/kernel/rcu/rcuscale.c
> +++ b/kernel/rcu/rcuscale.c
> @@ -39,6 +39,7 @@
> #include <linux/torture.h>
> #include <linux/vmalloc.h>
> #include <linux/rcupdate_trace.h>
> +#include <linux/hazptr.h>
> #include <linux/sched/debug.h>
>
> #include "rcu.h"
> @@ -418,6 +419,66 @@ static struct rcu_scale_ops tasks_tracing_ops = {
>
> #endif // #else // #ifdef CONFIG_TASKS_TRACE_RCU
>
> +#if IS_ENABLED(CONFIG_HAZPTR_TORTURE_TEST)
> +
> +static int hazptr_scale_obj; /* Stable, non-NULL, never reclaimed. */
You can probaly make hazptr_scale_obj an arrary, and let an updater
either randomly or round-robin select an object to wait, it'll reflect
better to a real world workload.
> +static void *hazptr_scale_ptr = &hazptr_scale_obj;
> +
> +struct hazptr_scale_state {
> + struct hazptr_ctx ctx;
> + void *addr;
> +};
> +static DEFINE_PER_CPU(struct hazptr_scale_state, hazptr_scale_state);
> +
> +static int hazptr_scale_read_lock(void)
> +{
> + struct hazptr_scale_state *state = this_cpu_ptr(&hazptr_scale_state);
> +
> + preempt_disable();
I think you can drop the preempt_disable() and preempt_enable() below,
since the new hazptr_acquire()/hazptr_release() work without them (i.e.
the hazptr acquisition no longer requires preemption disable).
Regards,
Boqun
> + state->addr = hazptr_acquire(&state->ctx, &hazptr_scale_ptr);
> + return 0;
> +}
> +
> +static void hazptr_scale_read_unlock(int idx)
> +{
> + struct hazptr_scale_state *state = this_cpu_ptr(&hazptr_scale_state);
> +
> + udelay(10);
> + hazptr_release(&state->ctx, state->addr);
> + preempt_enable();
> +}
> +
> +static unsigned long hazptr_scale_completed(void)
> +{
> + return 0;
> +}
> +
> +static void hazptr_scale_sync(void)
> +{
> + hazptr_synchronize(hazptr_scale_ptr);
> +}
> +
> +static void hazptr_scale_sync_exp(void)
> +{
> + hazptr_synchronize(hazptr_scale_ptr);
> +}
> +
> +static struct rcu_scale_ops hazptr_scale_ops = {
> + .ptype = 0,
> + .readlock = hazptr_scale_read_lock,
> + .readunlock = hazptr_scale_read_unlock,
> + .get_gp_seq = hazptr_scale_completed,
> + .gp_diff = NULL,
> + .sync = hazptr_scale_sync,
> + .exp_sync = hazptr_scale_sync_exp,
> + .name = "hazptr",
> +};
> +
> +#define HAZPTR_SCALE_OPS &hazptr_scale_ops,
> +#else
> +#define HAZPTR_SCALE_OPS
> +#endif
> +
> static unsigned long rcuscale_seq_diff(unsigned long new, unsigned long old)
> {
> if (!cur_ops->gp_diff)
> @@ -1110,7 +1171,9 @@ rcu_scale_init(void)
> long i;
> long j;
> static struct rcu_scale_ops *scale_ops[] = {
> - &rcu_ops, &srcu_ops, &srcud_ops, TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS
> + &rcu_ops, &srcu_ops, &srcud_ops,
> + TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS
> + HAZPTR_SCALE_OPS
> };
>
> if (!torture_init_begin(scale_type, verbose))
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-09-22 7:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 7:09 [RFC/WIP PATCH 0/4] hazptr: add shared scan path and lockdep use case Kunwu Chan
2026-09-22 7:09 ` [RFC/WIP PATCH 1/4] hazptr: add shared-scan kthread Kunwu Chan
2026-09-22 8:28 ` Boqun Feng
2026-09-22 8:44 ` Lian Wang
2026-09-23 3:16 ` KunWu Chan
2026-09-22 7:09 ` [RFC/WIP PATCH 2/4] locking/lockdep: use hazptr to wait for dynamic key lookups Kunwu Chan
2026-09-22 8:51 ` Boqun Feng
2026-09-23 4:15 ` KunWu Chan
2026-09-22 7:09 ` [RFC/WIP PATCH 3/4] rcuscale: add hazptr scale type Kunwu Chan
2026-09-22 7:55 ` Boqun Feng [this message]
2026-09-23 4:40 ` KunWu Chan
2026-09-22 7:09 ` [RFC/WIP PATCH 4/4] Documentation/litmus-tests: add hazptr acquire-before-scan test Kunwu Chan
2026-09-22 7:48 ` [RFC/WIP PATCH 0/4] hazptr: add shared scan path and lockdep use case Boqun Feng
2026-09-22 9:55 ` KunWu Chan
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=arI0bexTH7CL66Dc@MacBook-0RXW5 \
--to=boqun@kernel.org \
--cc=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=frederic@kernel.org \
--cc=include@grrlz.net \
--cc=j.alglave@ucl.ac.uk \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=kunwu.chan@gmail.com \
--cc=lianux.mm@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkmm@lists.linux.dev \
--cc=longman@redhat.com \
--cc=luc.maranget@inria.fr \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=skhan@linuxfoundation.org \
--cc=stern@rowland.harvard.edu \
--cc=urezki@gmail.com \
--cc=will@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.