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: <CAEXW_YSz8xD4WXO0dOyKC6X7BZeqMD2TOCm0=43=owLjJj=PVA@mail.gmail.com>
Date: Tue, 23 Apr 2024 14:19:34 -0400
From: Joel Fernandes <joel@...lfernandes.org>
To: Lai Jiangshan <jiangshanlai@...il.com>
Cc: linux-kernel@...r.kernel.org, rcu@...r.kernel.org, x86@...nel.org, 
	Lai Jiangshan <jiangshan.ljs@...group.com>, "Paul E. McKenney" <paulmck@...nel.org>, 
	Peter Zijlstra <peterz@...radead.org>, Frederic Weisbecker <frederic@...nel.org>, 
	Neeraj Upadhyay <quic_neeraju@...cinc.com>, Josh Triplett <josh@...htriplett.org>, 
	Boqun Feng <boqun.feng@...il.com>, Steven Rostedt <rostedt@...dmis.org>, 
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Zqiang <qiang.zhang1211@...il.com>
Subject: Re: [PATCH V2 09/11] rcu: Implement PCPU_RCU_PREEMPT_COUNT framework

On Sun, Apr 7, 2024 at 5:04 AM Lai Jiangshan <jiangshanlai@...il.com> wrote:
>
> From: Lai Jiangshan <jiangshan.ljs@...group.com>
>
> When the arch code provides HAVE_PCPU_RCU_PREEMPT_COUNT and the
> corresponding functions, rcu core uses the functions to implement
> rcu_preempt_depth(), special bits, switching and so on.
>
> Cc: "Paul E. McKenney" <paulmck@...nel.org>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Frederic Weisbecker <frederic@...nel.org>
> Signed-off-by: Lai Jiangshan <jiangshan.ljs@...group.com>
> ---
>  include/linux/rcupdate.h | 33 +++++++++++++++++++++++++++++++++
>  kernel/rcu/Kconfig       |  8 ++++++++
>  kernel/rcu/rcu.h         |  4 ++++
>  kernel/rcu/tree_plugin.h |  8 ++++++++
>  4 files changed, 53 insertions(+)
>
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 328667ae8086..e3e5ce44c7dc 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -70,6 +70,8 @@ static inline bool same_state_synchronize_rcu(unsigned long oldstate1, unsigned
>
>  void rcu_read_unlock_special(void);
>
> +#ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT
> +
>  void __rcu_read_lock(void);
>  void __rcu_read_unlock(void);
>
> @@ -81,6 +83,37 @@ void __rcu_read_unlock(void);
>   */
>  #define rcu_preempt_depth() READ_ONCE(current->rcu_read_lock_nesting)
>  #define rcu_preempt_depth_set(val) WRITE_ONCE(current->rcu_read_lock_nesting, (val))
> +#define pcpu_rcu_preempt_special_set() do { } while (0)
> +#define pcpu_rcu_preempt_special_clear() do { } while (0)
> +
> +#else /* #ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT */
> +
> +#include <asm/rcu_preempt.h>
> +
> +static __always_inline void __rcu_read_lock(void)
> +{
> +       pcpu_rcu_preempt_count_add(1);
> +       barrier();
> +}
> +
> +static __always_inline void __rcu_read_unlock(void)
> +{
> +       barrier();
> +       if (unlikely(pcpu_rcu_preempt_count_dec_and_test()))
> +               pcpu_rcu_read_unlock_special();
> +}

Previous code had comments about the barrier(); , can you add back
those comments?

Also there was a compiler barrier in the body of the if() as well?

For reference:

void __rcu_read_unlock(void)
{
        struct task_struct *t = current;

        barrier();  // critical section before exit code.
        if (rcu_preempt_read_exit() == 0) {
                barrier();  // critical-section exit before .s check.
                if (unlikely(READ_ONCE(t->rcu_read_unlock_special.s)))
                        rcu_read_unlock_special(t);
        }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ