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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJCRksMjpKzpNFNXR4ZggnuLN4yTmBbFCr5YW33bbwSwQ@mail.gmail.com>
Date: Tue, 3 Sep 2024 12:45:23 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: "Paul E. McKenney" <paulmck@...nel.org>
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 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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ