lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2e8c01a3-4ad7-4c4b-a697-acebdf7db8ad@paulmck-laptop>
Date: Tue, 3 Sep 2024 15:10:47 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: rcu@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
	Kernel Team <kernel-team@...a.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Alexei Starovoitov <ast@...nel.org>,
	Andrii Nakryiko <andrii@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Kent Overstreet <kent.overstreet@...ux.dev>,
	bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH rcu 07/11] srcu: Add srcu_read_lock_lite() and
 srcu_read_unlock_lite()

On Tue, Sep 03, 2024 at 12:45:23PM -0700, Alexei Starovoitov wrote:
> On Tue, Sep 3, 2024 at 9:33 AM Paul E. McKenney <paulmck@...nel.org> wrote:
> >
> > diff --git a/include/linux/srcu.h b/include/linux/srcu.h
> > index 84daaa33ea0ab..4ba96e2cfa405 100644
> > --- a/include/linux/srcu.h
> > +++ b/include/linux/srcu.h
> ...
> 
> > +static inline int srcu_read_lock_lite(struct srcu_struct *ssp) __acquires(ssp)
> > +{
> > +       int retval;
> > +
> > +       srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_LITE);
> > +       retval = __srcu_read_lock_lite(ssp);
> > +       rcu_try_lock_acquire(&ssp->dep_map);
> > +       return retval;
> > +}
> 
> ...
> 
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index 602b4b8c4b891..bab888e86b9bb 100644
> > --- a/kernel/rcu/srcutree.c
> > +++ b/kernel/rcu/srcutree.c
> > +int __srcu_read_lock_lite(struct srcu_struct *ssp)
> > +{
> > +       int idx;
> > +
> > +       RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_lite().");
> > +       idx = READ_ONCE(ssp->srcu_idx) & 0x1;
> > +       this_cpu_inc(ssp->sda->srcu_lock_count[idx].counter); /* Y */
> > +       barrier(); /* Avoid leaking the critical section. */
> > +       return idx;
> > +}
> > +EXPORT_SYMBOL_GPL(__srcu_read_lock_lite);
> 
> The use cases where smp_mb() penalty is noticeable probably will notice
> the cost of extra call too.
> Can the main part be in srcu.h as well to make it truly "lite" ?
> Otherwise we'd have to rely on compilers doing LTO which may or may not happen.

I vaguely recall #include issues for old-times srcu_read_lock() and
srcu_read_unlock(), but I will try it and see what happens.

In the meantime, if you are too curious for your own good...  ;-)

One way to check the performance is to work in the other direction.  For
example, add ndelay(10) or similar to the current srcu_read_lock_lite()
implementation and seeing if this is visible at the system level.

							Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ