Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 02:53:43PM -0500, Mathieu Desnoyers wrote: > On 2024-03-07 14:47, Paul E. McKenney wrote: > > On Thu, Mar 07, 2024 at 08:53:05AM -0500, Mathieu Desnoyers wrote: > > > On 2024-03-06 22:37, Paul E. McKenney wrote: > > > > On Wed, Mar 06, 2024 at 10:06:21PM -0500, Mathieu

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 02:09:00PM -0800, Linus Torvalds wrote: > On Thu, 7 Mar 2024 at 13:40, Julia Lawall wrote: > > > > I tried the following: > > > > @@ > > expression x; > > @@ > > > > *WRITE_ONCE(x,<+...READ_ONCE(x)...+>) > > > > This gave a number of results, shown below. Let me know if

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 06:52:14PM -0500, Joel Fernandes wrote: > On Thu, Mar 7, 2024 at 6:48 PM Joel Fernandes (Google) > wrote: > > > > In the synchronize_rcu() common case, we will have less than > > SR_MAX_USERS_WAKE_FROM_GP number of users per GP. Waking up the kworker > > is pointless just

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-07 Thread Joel Fernandes
On Thu, Mar 7, 2024 at 6:48 PM Joel Fernandes (Google) wrote: > > In the synchronize_rcu() common case, we will have less than > SR_MAX_USERS_WAKE_FROM_GP number of users per GP. Waking up the kworker > is pointless just to free the last injected wait head since at that point, > all the users

[PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-07 Thread Joel Fernandes (Google)
In the synchronize_rcu() common case, we will have less than SR_MAX_USERS_WAKE_FROM_GP number of users per GP. Waking up the kworker is pointless just to free the last injected wait head since at that point, all the users have already been awakened. Introduce a new counter to track this and

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Linus Torvalds
On Thu, 7 Mar 2024 at 13:40, Julia Lawall wrote: > > I tried the following: > > @@ > expression x; > @@ > > *WRITE_ONCE(x,<+...READ_ONCE(x)...+>) > > This gave a number of results, shown below. Let me know if some of them > are undesirable. Well, all the ones you list do look like garbage.

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Julia Lawall
On Thu, 7 Mar 2024, Paul E. McKenney wrote: > On Thu, Mar 07, 2024 at 12:00:44PM -0800, Linus Torvalds wrote: > > On Thu, 7 Mar 2024 at 11:47, Paul E. McKenney wrote: > > > > > > > - The per-thread counter (Thread-Local Storage) incremented by a single > > > > thread, read by various

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 12:00:44PM -0800, Linus Torvalds wrote: > On Thu, 7 Mar 2024 at 11:47, Paul E. McKenney wrote: > > > > > - The per-thread counter (Thread-Local Storage) incremented by a single > > > thread, read by various threads concurrently, is a good target > > > for

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Linus Torvalds
On Thu, 7 Mar 2024 at 11:47, Paul E. McKenney wrote: > > > - The per-thread counter (Thread-Local Storage) incremented by a single > > thread, read by various threads concurrently, is a good target > > for WRITE_ONCE()/READ_ONCE() pairing. This is actually what we do in > > various liburcu

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Mathieu Desnoyers
On 2024-03-07 14:47, Paul E. McKenney wrote: On Thu, Mar 07, 2024 at 08:53:05AM -0500, Mathieu Desnoyers wrote: On 2024-03-06 22:37, Paul E. McKenney wrote: On Wed, Mar 06, 2024 at 10:06:21PM -0500, Mathieu Desnoyers wrote: [...] As far as the WRITE_ONCE(x, READ_ONCE(x) + 1) pattern is

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 08:53:05AM -0500, Mathieu Desnoyers wrote: > On 2024-03-06 22:37, Paul E. McKenney wrote: > > On Wed, Mar 06, 2024 at 10:06:21PM -0500, Mathieu Desnoyers wrote: > [...] > > > > > As far as the WRITE_ONCE(x, READ_ONCE(x) + 1) pattern > > > is concerned, the only valid

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 06:54:38PM +, Russell King (Oracle) wrote: > On Thu, Mar 07, 2024 at 09:45:36AM -0800, Paul E. McKenney wrote: > > > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > > > index 3431c0553f45..6875e2c5dd50 100644 > > > --- a/arch/arm/kernel/smp.c > > > +++

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 12:44:39AM -0500, Joel Fernandes wrote: > > > On 3/6/2024 10:37 PM, Paul E. McKenney wrote: > > On Wed, Mar 06, 2024 at 10:06:21PM -0500, Mathieu Desnoyers wrote: > >> On 2024-03-06 21:43, Linus Torvalds wrote: > >> [...] > >>> > >>> Honestly, this all makes me think that

Re: [PATCH] net: raise RCU qs after each threaded NAPI poll

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 01:52:15PM -0500, Steven Rostedt wrote: > On Thu, 7 Mar 2024 16:57:33 + > Mark Rutland wrote: > > > * Use rcu_tasks_trace to synchronize updates? > > Yes. I think I wanted both. The above to make sure it covers all cases > where something could be preempted, and a

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Russell King (Oracle)
On Thu, Mar 07, 2024 at 09:45:36AM -0800, Paul E. McKenney wrote: > > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > > index 3431c0553f45..6875e2c5dd50 100644 > > --- a/arch/arm/kernel/smp.c > > +++ b/arch/arm/kernel/smp.c > > @@ -319,7 +319,14 @@ void __noreturn

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Boqun Feng
[Cc Frederic] On Thu, Mar 07, 2024 at 05:09:51PM +0100, Stefan Wiehler wrote: > With CONFIG_PROVE_RCU_LIST=y and by executing > > $ echo 0 > /sys/devices/system/cpu/cpu1/online > > one can trigger the following Lockdep-RCU splat on ARM: > > = > WARNING:

Re: [PATCH] net: raise RCU qs after each threaded NAPI poll

2024-03-07 Thread Steven Rostedt
On Thu, 7 Mar 2024 16:57:33 + Mark Rutland wrote: > * Use rcu_tasks_trace to synchronize updates? Yes. I think I wanted both. The above to make sure it covers all cases where something could be preempted, and a case for those covered when RCU isn't watching (which always has preemption

Re: [PATCH] net: raise RCU qs after each threaded NAPI poll

2024-03-07 Thread Mark Rutland
On Thu, Mar 07, 2024 at 04:57:33PM +, Mark Rutland wrote: > On Mon, Mar 04, 2024 at 04:16:01AM -0500, Joel Fernandes wrote: > > On 3/2/2024 8:01 PM, Joel Fernandes wrote: > > Case 1: For !CONFIG_DYNAMIC_FTRACE update of ftrace_trace_function > > > > This config is itself expected to be slow.

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 09:45:36AM -0800, Paul E. McKenney wrote: > On Thu, Mar 07, 2024 at 05:09:51PM +0100, Stefan Wiehler wrote: > > With CONFIG_PROVE_RCU_LIST=y and by executing > > > > $ echo 0 > /sys/devices/system/cpu/cpu1/online > > > > one can trigger the following Lockdep-RCU splat

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Paul E. McKenney
On Thu, Mar 07, 2024 at 05:09:51PM +0100, Stefan Wiehler wrote: > With CONFIG_PROVE_RCU_LIST=y and by executing > > $ echo 0 > /sys/devices/system/cpu/cpu1/online > > one can trigger the following Lockdep-RCU splat on ARM: > > = > WARNING: suspicious RCU usage

Re: [PATCH] net: raise RCU qs after each threaded NAPI poll

2024-03-07 Thread Mark Rutland
Hi Joel, Paul, Steve, On Mon, Mar 04, 2024 at 04:16:01AM -0500, Joel Fernandes wrote: > Hi Paul, > > On 3/2/2024 8:01 PM, Joel Fernandes wrote: > >> As you noted, one thing that Ankur's series changes is that preemption > >> can occur anywhere that it is not specifically disabled in kernels > >>

[PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-07 Thread Stefan Wiehler
With CONFIG_PROVE_RCU_LIST=y and by executing $ echo 0 > /sys/devices/system/cpu/cpu1/online one can trigger the following Lockdep-RCU splat on ARM: = WARNING: suspicious RCU usage 6.8.0-rc7-1-g0db1d0ed8958 #10 Not tainted -

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Steven Rostedt
On Thu, 7 Mar 2024 08:20:59 -0500 Steven Rostedt wrote: > When a write happens, it looks to see if the smallest watermark is hit, > if so, calls irqwork to wakeup all the waiters. > > The waiters will wake up, check to see if a signal is pending or if the > ring buffer has hit the watermark the

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Mathieu Desnoyers
On 2024-03-06 22:37, Paul E. McKenney wrote: On Wed, Mar 06, 2024 at 10:06:21PM -0500, Mathieu Desnoyers wrote: [...] As far as the WRITE_ONCE(x, READ_ONCE(x) + 1) pattern is concerned, the only valid use-case I can think of is split counters or RCU implementations where there is a single

Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug

2024-03-07 Thread Steven Rostedt
On Wed, 6 Mar 2024 12:06:00 -0800 Linus Torvalds wrote: > On Wed, 6 Mar 2024 at 11:45, Steven Rostedt wrote: > > > > Here's the back story. I received the following patch: > > > > > > https://lore.kernel.org/all/tencent_ba1473492bc618b473864561ea3ab1418...@qq.com/ > > > > I didn't like it.

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Joel Fernandes
On 3/7/2024 7:57 AM, Uladzislau Rezki wrote: > On Wed, Mar 06, 2024 at 05:31:31PM -0500, Joel Fernandes wrote: >> >> >> On 3/5/2024 2:57 PM, Uladzislau Rezki (Sony) wrote: >>> Fix a below race by not releasing a wait-head from the >>> GP-kthread as it can lead for reusing it whereas a worker

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Uladzislau Rezki
On Wed, Mar 06, 2024 at 05:31:31PM -0500, Joel Fernandes wrote: > > > On 3/5/2024 2:57 PM, Uladzislau Rezki (Sony) wrote: > > Fix a below race by not releasing a wait-head from the > > GP-kthread as it can lead for reusing it whereas a worker > > can still access it thus execute newly added

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Uladzislau Rezki
On Thu, Mar 07, 2024 at 02:09:38AM -0500, Joel Fernandes wrote: > > > On 3/7/2024 1:21 AM, Joel Fernandes wrote: > > > > > > On 3/6/2024 5:31 PM, Joel Fernandes wrote: > >> > >> > >> On 3/5/2024 2:57 PM, Uladzislau Rezki (Sony) wrote: > >>> Fix a below race by not releasing a wait-head from

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Uladzislau Rezki
On Thu, Mar 07, 2024 at 01:21:50AM -0500, Joel Fernandes wrote: > > > On 3/6/2024 5:31 PM, Joel Fernandes wrote: > > > > > > On 3/5/2024 2:57 PM, Uladzislau Rezki (Sony) wrote: > >> Fix a below race by not releasing a wait-head from the > >> GP-kthread as it can lead for reusing it whereas a

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Uladzislau Rezki
On Wed, Mar 06, 2024 at 05:44:04PM -0500, Joel Fernandes wrote: > On Wed, Mar 6, 2024 at 5:31 PM Joel Fernandes wrote: > > > > > > > > On 3/5/2024 2:57 PM, Uladzislau Rezki (Sony) wrote: > > > Fix a below race by not releasing a wait-head from the > > > GP-kthread as it can lead for reusing it

Re: [PATCH 1/2] rcu: Do not release a wait-head from a GP kthread

2024-03-07 Thread Uladzislau Rezki
On Thu, Mar 07, 2024 at 01:04:25AM +0100, Frederic Weisbecker wrote: > Le Tue, Mar 05, 2024 at 08:57:19PM +0100, Uladzislau Rezki (Sony) a écrit : > > Fix a below race by not releasing a wait-head from the > > GP-kthread as it can lead for reusing it whereas a worker > > can still access it thus

Re: [PATCH 2/2] rcu: Allocate WQ with WQ_MEM_RECLAIM bit set

2024-03-07 Thread Uladzislau Rezki
On Wed, Mar 06, 2024 at 12:57:25PM -0500, Joel Fernandes wrote: > > > On 3/6/2024 6:56 AM, Uladzislau Rezki wrote: > > On Wed, Mar 06, 2024 at 10:15:44AM +0800, Z qiang wrote: > >>> > >>> synchronize_rcu() users have to be processed regardless > >>> of memory pressure so our private WQ needs to