* [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5
@ 2019-10-03 1:41 Paul E. McKenney
2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck
` (9 more replies)
0 siblings, 10 replies; 54+ messages in thread
From: Paul E. McKenney @ 2019-10-03 1:41 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
edumazet, fweisbec, oleg, joel
Hello!
This series replaces uses of rcu_swap_protected() with rcu_replace().
A later patch will remove rcu_swap_protected().
1. Upgrade rcu_swap_protected() to rcu_replace().
2-9. Replace calls to rcu_swap_protected() with rcu_replace().
Thanx, Paul
------------------------------------------------------------------------
arch/x86/kvm/pmu.c | 4 ++--
drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +-
drivers/scsi/scsi.c | 4 ++--
drivers/scsi/scsi_sysfs.c | 8 ++++----
fs/afs/vl_list.c | 4 ++--
include/linux/rcupdate.h | 18 ++++++++++++++++++
kernel/bpf/cgroup.c | 4 ++--
net/core/dev.c | 4 ++--
net/core/sock_reuseport.c | 4 ++--
net/netfilter/nf_tables_api.c | 5 +++--
net/sched/act_api.c | 2 +-
net/sched/act_csum.c | 4 ++--
net/sched/act_ct.c | 2 +-
net/sched/act_ctinfo.c | 4 ++--
net/sched/act_ife.c | 2 +-
net/sched/act_mirred.c | 4 ++--
net/sched/act_mpls.c | 2 +-
net/sched/act_police.c | 6 +++---
net/sched/act_skbedit.c | 4 ++--
net/sched/act_tunnel_key.c | 4 ++--
net/sched/act_vlan.c | 2 +-
21 files changed, 56 insertions(+), 37 deletions(-)
^ permalink raw reply [flat|nested] 54+ messages in thread* [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney @ 2019-10-03 1:43 ` paulmck 2019-10-03 8:39 ` David Howells 2019-10-03 16:35 ` Mathieu Desnoyers 2019-10-03 1:43 ` [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck ` (8 subsequent siblings) 9 siblings, 2 replies; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen From: "Paul E. McKenney" <paulmck@kernel.org> Although the rcu_swap_protected() macro follows the example of swap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces an rcu_replace() that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses of rcu_swap_protected() are updated to instead use rcu_replace(), rcu_swap_protected() will be removed. Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Bart Van Assche <bart.vanassche@wdc.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Shane M Seymour <shane.seymour@hpe.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> --- include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 75a2ede..3b73287 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -383,6 +383,24 @@ do { \ } while (0) /** + * rcu_replace() - replace an RCU pointer, returning its old value + * @rcu_ptr: RCU pointer, whose old value is returned + * @ptr: regular pointer + * @c: the lockdep conditions under which the dereference will take place + * + * Perform a replacement, where @rcu_ptr is an RCU-annotated + * pointer and @c is the lockdep argument that is passed to the + * rcu_dereference_protected() call used to read that pointer. The old + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. + */ +#define rcu_replace(rcu_ptr, ptr, c) \ +({ \ + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ + rcu_assign_pointer((rcu_ptr), (ptr)); \ + __tmp; \ +}) + +/** * rcu_swap_protected() - swap an RCU and a regular pointer * @rcu_ptr: RCU pointer * @ptr: regular pointer -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck @ 2019-10-03 8:39 ` David Howells 2019-10-03 13:08 ` Steven Rostedt 2019-10-03 16:35 ` Mathieu Desnoyers 1 sibling, 1 reply; 54+ messages in thread From: David Howells @ 2019-10-03 8:39 UTC (permalink / raw) To: paulmck Cc: dhowells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, edumazet, fweisbec, oleg, joel, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen paulmck@kernel.org wrote: > +#define rcu_replace(rcu_ptr, ptr, c) \ > +({ \ > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > + __tmp; \ > +}) Does it make sense to actually use xchg() if that's supported by the arch? David ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 8:39 ` David Howells @ 2019-10-03 13:08 ` Steven Rostedt 2019-10-03 13:33 ` Paul E. McKenney 2019-10-03 16:31 ` Mathieu Desnoyers 0 siblings, 2 replies; 54+ messages in thread From: Steven Rostedt @ 2019-10-03 13:08 UTC (permalink / raw) To: David Howells Cc: paulmck, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, edumazet, fweisbec, oleg, joel, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <dhowells@redhat.com> wrote: > paulmck@kernel.org wrote: > > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > +({ \ > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > + __tmp; \ > > +}) > > Does it make sense to actually use xchg() if that's supported by the arch? > Hmm, is there really any arch that doesn't support xchg()? It would be very hard to do any kind of atomic operations without it. cmpxchg() is the one that I understand is optional by the arch. -- Steve ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 13:08 ` Steven Rostedt @ 2019-10-03 13:33 ` Paul E. McKenney 2019-10-03 13:41 ` Peter Zijlstra 2019-10-03 14:01 ` Joel Fernandes 2019-10-03 16:31 ` Mathieu Desnoyers 1 sibling, 2 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-03 13:33 UTC (permalink / raw) To: Steven Rostedt Cc: David Howells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, edumazet, fweisbec, oleg, joel, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, Oct 03, 2019 at 09:08:50AM -0400, Steven Rostedt wrote: > On Thu, 03 Oct 2019 09:39:17 +0100 > David Howells <dhowells@redhat.com> wrote: > > > paulmck@kernel.org wrote: > > > > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > > +({ \ > > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > > + __tmp; \ > > > +}) > > > > Does it make sense to actually use xchg() if that's supported by the arch? Historically, xchg() has been quite a bit slower than a pair of assignment statements, in part due to the strong memory ordering guaranteed by xchg(). Has that changed? If so, then, agreed, it might make sense to use xchg(). > Hmm, is there really any arch that doesn't support xchg()? It would be > very hard to do any kind of atomic operations without it. > > cmpxchg() is the one that I understand is optional by the arch. To your point, even the old Sequent Symmetry platforms supported xchg() back in the late 1980s and early 1990s, but only the later versions (with 80486 and later) supported cmpxchg(). Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 13:33 ` Paul E. McKenney @ 2019-10-03 13:41 ` Peter Zijlstra 2019-10-03 13:58 ` Paul E. McKenney 2019-10-03 14:01 ` Joel Fernandes 1 sibling, 1 reply; 54+ messages in thread From: Peter Zijlstra @ 2019-10-03 13:41 UTC (permalink / raw) To: Paul E. McKenney Cc: Steven Rostedt, David Howells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, edumazet, fweisbec, oleg, joel, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, Oct 03, 2019 at 06:33:15AM -0700, Paul E. McKenney wrote: > On Thu, Oct 03, 2019 at 09:08:50AM -0400, Steven Rostedt wrote: > > On Thu, 03 Oct 2019 09:39:17 +0100 > > David Howells <dhowells@redhat.com> wrote: > > > > > paulmck@kernel.org wrote: > > > > > > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > > > +({ \ > > > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > > > + __tmp; \ > > > > +}) > > > > > > Does it make sense to actually use xchg() if that's supported by the arch? > > Historically, xchg() has been quite a bit slower than a pair of assignment > statements, in part due to the strong memory ordering guaranteed by > xchg(). Has that changed? If so, then, agreed, it might make sense to > use xchg(). Nope, still the case. xchg() is an atomic op with full ordering. ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 13:41 ` Peter Zijlstra @ 2019-10-03 13:58 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-03 13:58 UTC (permalink / raw) To: Peter Zijlstra Cc: Steven Rostedt, David Howells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, edumazet, fweisbec, oleg, joel, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, Oct 03, 2019 at 03:41:31PM +0200, Peter Zijlstra wrote: > On Thu, Oct 03, 2019 at 06:33:15AM -0700, Paul E. McKenney wrote: > > On Thu, Oct 03, 2019 at 09:08:50AM -0400, Steven Rostedt wrote: > > > On Thu, 03 Oct 2019 09:39:17 +0100 > > > David Howells <dhowells@redhat.com> wrote: > > > > > > > paulmck@kernel.org wrote: > > > > > > > > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > > > > +({ \ > > > > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > > > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > > > > + __tmp; \ > > > > > +}) > > > > > > > > Does it make sense to actually use xchg() if that's supported by the arch? > > > > Historically, xchg() has been quite a bit slower than a pair of assignment > > statements, in part due to the strong memory ordering guaranteed by > > xchg(). Has that changed? If so, then, agreed, it might make sense to > > use xchg(). > > Nope, still the case. xchg() is an atomic op with full ordering. OK, let's stick with the pair of assignments, then. ;-) Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 13:33 ` Paul E. McKenney 2019-10-03 13:41 ` Peter Zijlstra @ 2019-10-03 14:01 ` Joel Fernandes 1 sibling, 0 replies; 54+ messages in thread From: Joel Fernandes @ 2019-10-03 14:01 UTC (permalink / raw) To: Paul E. McKenney Cc: Steven Rostedt, David Howells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, edumazet, fweisbec, oleg, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, Oct 03, 2019 at 06:33:15AM -0700, Paul E. McKenney wrote: > On Thu, Oct 03, 2019 at 09:08:50AM -0400, Steven Rostedt wrote: > > On Thu, 03 Oct 2019 09:39:17 +0100 > > David Howells <dhowells@redhat.com> wrote: > > > > > paulmck@kernel.org wrote: > > > > > > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > > > +({ \ > > > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > > > + __tmp; \ > > > > +}) > > > > > > Does it make sense to actually use xchg() if that's supported by the arch? > > Historically, xchg() has been quite a bit slower than a pair of assignment > statements, in part due to the strong memory ordering guaranteed by > xchg(). Has that changed? If so, then, agreed, it might make sense to > use xchg(). For the kfree_rcu() performance testing I was working on recently, replacing xchg() with a pair of assignment statements in the code being tested provided a great performance increase (on x86). thanks, - Joel ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 13:08 ` Steven Rostedt 2019-10-03 13:33 ` Paul E. McKenney @ 2019-10-03 16:31 ` Mathieu Desnoyers 2019-10-03 18:05 ` Peter Zijlstra 1 sibling, 1 reply; 54+ messages in thread From: Mathieu Desnoyers @ 2019-10-03 16:31 UTC (permalink / raw) To: rostedt Cc: David Howells, paulmck, rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen ----- On Oct 3, 2019, at 9:08 AM, rostedt rostedt@goodmis.org wrote: > On Thu, 03 Oct 2019 09:39:17 +0100 > David Howells <dhowells@redhat.com> wrote: > >> paulmck@kernel.org wrote: >> >> > +#define rcu_replace(rcu_ptr, ptr, c) \ >> > +({ \ >> > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ >> > + rcu_assign_pointer((rcu_ptr), (ptr)); \ >> > + __tmp; \ >> > +}) >> >> Does it make sense to actually use xchg() if that's supported by the arch? >> > > Hmm, is there really any arch that doesn't support xchg()? It would be > very hard to do any kind of atomic operations without it. > > cmpxchg() is the one that I understand is optional by the arch. I remember going through all kernel arch headers myself and introduce irq-off-based xchg and cmpxchg generic implementations for all UP architectures lacking cmpxchg/xchg instructions. We might want to consider simply using xchg() here. FWIW, the API exposed by the Userspace RCU project (liburcu) for this is: rcu_xchg_pointer() Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 16:31 ` Mathieu Desnoyers @ 2019-10-03 18:05 ` Peter Zijlstra 0 siblings, 0 replies; 54+ messages in thread From: Peter Zijlstra @ 2019-10-03 18:05 UTC (permalink / raw) To: Mathieu Desnoyers Cc: rostedt, David Howells, paulmck, rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen On Thu, Oct 03, 2019 at 12:31:38PM -0400, Mathieu Desnoyers wrote: > We might want to consider simply using xchg() here. As stated elsewhere, xchg() is an atomic op with full ordering, IOW it is stupid expensive for what needs to be done. ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck 2019-10-03 8:39 ` David Howells @ 2019-10-03 16:35 ` Mathieu Desnoyers 2019-10-03 16:52 ` Paul E. McKenney 1 sibling, 1 reply; 54+ messages in thread From: Mathieu Desnoyers @ 2019-10-03 16:35 UTC (permalink / raw) To: paulmck Cc: rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, rostedt, David Howells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin ----- On Oct 2, 2019, at 9:43 PM, paulmck paulmck@kernel.org wrote: > From: "Paul E. McKenney" <paulmck@kernel.org> > > Although the rcu_swap_protected() macro follows the example of swap(), > the interactions with RCU make its update of its argument somewhat > counter-intuitive. This commit therefore introduces an rcu_replace() > that returns the old value of the RCU pointer instead of doing the > argument update. Once all the uses of rcu_swap_protected() are updated > to instead use rcu_replace(), rcu_swap_protected() will be removed. We expose the rcu_xchg_pointer() API in liburcu (Userspace RCU) project. Any reason for not going that way and keep the kernel and user-space RCU APIs alike ? It's of course fine if they diverge, but we might want to at least consider if using the same API name would be OK. Thanks, Mathieu > > Link: > https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Bart Van Assche <bart.vanassche@wdc.com> > Cc: Christoph Hellwig <hch@lst.de> > Cc: Hannes Reinecke <hare@suse.de> > Cc: Johannes Thumshirn <jthumshirn@suse.de> > Cc: Shane M Seymour <shane.seymour@hpe.com> > Cc: Martin K. Petersen <martin.petersen@oracle.com> > --- > include/linux/rcupdate.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 75a2ede..3b73287 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -383,6 +383,24 @@ do { \ > } while (0) > > /** > + * rcu_replace() - replace an RCU pointer, returning its old value > + * @rcu_ptr: RCU pointer, whose old value is returned > + * @ptr: regular pointer > + * @c: the lockdep conditions under which the dereference will take place > + * > + * Perform a replacement, where @rcu_ptr is an RCU-annotated > + * pointer and @c is the lockdep argument that is passed to the > + * rcu_dereference_protected() call used to read that pointer. The old > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. > + */ > +#define rcu_replace(rcu_ptr, ptr, c) \ > +({ \ > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > + __tmp; \ > +}) > + > +/** > * rcu_swap_protected() - swap an RCU and a regular pointer > * @rcu_ptr: RCU pointer > * @ptr: regular pointer > -- > 2.9.5 -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 16:35 ` Mathieu Desnoyers @ 2019-10-03 16:52 ` Paul E. McKenney 2019-10-03 17:21 ` Mathieu Desnoyers 0 siblings, 1 reply; 54+ messages in thread From: Paul E. McKenney @ 2019-10-03 16:52 UTC (permalink / raw) To: Mathieu Desnoyers Cc: rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, rostedt, David Howells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin On Thu, Oct 03, 2019 at 12:35:30PM -0400, Mathieu Desnoyers wrote: > ----- On Oct 2, 2019, at 9:43 PM, paulmck paulmck@kernel.org wrote: > > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > Although the rcu_swap_protected() macro follows the example of swap(), > > the interactions with RCU make its update of its argument somewhat > > counter-intuitive. This commit therefore introduces an rcu_replace() > > that returns the old value of the RCU pointer instead of doing the > > argument update. Once all the uses of rcu_swap_protected() are updated > > to instead use rcu_replace(), rcu_swap_protected() will be removed. > > We expose the rcu_xchg_pointer() API in liburcu (Userspace RCU) project. > Any reason for not going that way and keep the kernel and user-space RCU > APIs alike ? > > It's of course fine if they diverge, but we might want to at least consider > if using the same API name would be OK. Different semantics. An rcu_xchg_pointer() allows concurrent updates, and rcu_replace() does not. But yes, if someone needs the concurrent updates, rcu_xchg_pointer() would certainly be my choice for the name. Thanx, Paul > Thanks, > > Mathieu > > > > > > Link: > > https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Bart Van Assche <bart.vanassche@wdc.com> > > Cc: Christoph Hellwig <hch@lst.de> > > Cc: Hannes Reinecke <hare@suse.de> > > Cc: Johannes Thumshirn <jthumshirn@suse.de> > > Cc: Shane M Seymour <shane.seymour@hpe.com> > > Cc: Martin K. Petersen <martin.petersen@oracle.com> > > --- > > include/linux/rcupdate.h | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > > index 75a2ede..3b73287 100644 > > --- a/include/linux/rcupdate.h > > +++ b/include/linux/rcupdate.h > > @@ -383,6 +383,24 @@ do { \ > > } while (0) > > > > /** > > + * rcu_replace() - replace an RCU pointer, returning its old value > > + * @rcu_ptr: RCU pointer, whose old value is returned > > + * @ptr: regular pointer > > + * @c: the lockdep conditions under which the dereference will take place > > + * > > + * Perform a replacement, where @rcu_ptr is an RCU-annotated > > + * pointer and @c is the lockdep argument that is passed to the > > + * rcu_dereference_protected() call used to read that pointer. The old > > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. > > + */ > > +#define rcu_replace(rcu_ptr, ptr, c) \ > > +({ \ > > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > > + __tmp; \ > > +}) > > + > > +/** > > * rcu_swap_protected() - swap an RCU and a regular pointer > > * @rcu_ptr: RCU pointer > > * @ptr: regular pointer > > -- > > 2.9.5 > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 16:52 ` Paul E. McKenney @ 2019-10-03 17:21 ` Mathieu Desnoyers 2019-10-03 19:09 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: Mathieu Desnoyers @ 2019-10-03 17:21 UTC (permalink / raw) To: paulmck Cc: rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, rostedt, David Howells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin ----- On Oct 3, 2019, at 12:52 PM, paulmck paulmck@kernel.org wrote: > On Thu, Oct 03, 2019 at 12:35:30PM -0400, Mathieu Desnoyers wrote: >> ----- On Oct 2, 2019, at 9:43 PM, paulmck paulmck@kernel.org wrote: >> >> > From: "Paul E. McKenney" <paulmck@kernel.org> >> > >> > Although the rcu_swap_protected() macro follows the example of swap(), >> > the interactions with RCU make its update of its argument somewhat >> > counter-intuitive. This commit therefore introduces an rcu_replace() >> > that returns the old value of the RCU pointer instead of doing the >> > argument update. Once all the uses of rcu_swap_protected() are updated >> > to instead use rcu_replace(), rcu_swap_protected() will be removed. >> >> We expose the rcu_xchg_pointer() API in liburcu (Userspace RCU) project. >> Any reason for not going that way and keep the kernel and user-space RCU >> APIs alike ? >> >> It's of course fine if they diverge, but we might want to at least consider >> if using the same API name would be OK. > > Different semantics. An rcu_xchg_pointer() allows concurrent updates, > and rcu_replace() does not. > > But yes, if someone needs the concurrent updates, rcu_xchg_pointer() > would certainly be my choice for the name. Then considering that its assignment counterpart is "rcu_assign_pointer()" (and not "rcu_assign()"), would "rcu_replace_pointer()" be less ambiguous about its intended use ? Thanks, Mathieu > > Thanx, Paul > >> Thanks, >> >> Mathieu >> >> >> > >> > Link: >> > https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ >> > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> >> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> >> > Cc: Bart Van Assche <bart.vanassche@wdc.com> >> > Cc: Christoph Hellwig <hch@lst.de> >> > Cc: Hannes Reinecke <hare@suse.de> >> > Cc: Johannes Thumshirn <jthumshirn@suse.de> >> > Cc: Shane M Seymour <shane.seymour@hpe.com> >> > Cc: Martin K. Petersen <martin.petersen@oracle.com> >> > --- >> > include/linux/rcupdate.h | 18 ++++++++++++++++++ >> > 1 file changed, 18 insertions(+) >> > >> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h >> > index 75a2ede..3b73287 100644 >> > --- a/include/linux/rcupdate.h >> > +++ b/include/linux/rcupdate.h >> > @@ -383,6 +383,24 @@ do { \ >> > } while (0) >> > >> > /** >> > + * rcu_replace() - replace an RCU pointer, returning its old value >> > + * @rcu_ptr: RCU pointer, whose old value is returned >> > + * @ptr: regular pointer >> > + * @c: the lockdep conditions under which the dereference will take place >> > + * >> > + * Perform a replacement, where @rcu_ptr is an RCU-annotated >> > + * pointer and @c is the lockdep argument that is passed to the >> > + * rcu_dereference_protected() call used to read that pointer. The old >> > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. >> > + */ >> > +#define rcu_replace(rcu_ptr, ptr, c) \ >> > +({ \ >> > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ >> > + rcu_assign_pointer((rcu_ptr), (ptr)); \ >> > + __tmp; \ >> > +}) >> > + >> > +/** >> > * rcu_swap_protected() - swap an RCU and a regular pointer >> > * @rcu_ptr: RCU pointer >> > * @ptr: regular pointer >> > -- >> > 2.9.5 >> >> -- >> Mathieu Desnoyers >> EfficiOS Inc. > > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 17:21 ` Mathieu Desnoyers @ 2019-10-03 19:09 ` Paul E. McKenney 2019-10-03 19:14 ` Mathieu Desnoyers 0 siblings, 1 reply; 54+ messages in thread From: Paul E. McKenney @ 2019-10-03 19:09 UTC (permalink / raw) To: Mathieu Desnoyers Cc: rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, rostedt, David Howells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin On Thu, Oct 03, 2019 at 01:21:14PM -0400, Mathieu Desnoyers wrote: > ----- On Oct 3, 2019, at 12:52 PM, paulmck paulmck@kernel.org wrote: > > > On Thu, Oct 03, 2019 at 12:35:30PM -0400, Mathieu Desnoyers wrote: > >> ----- On Oct 2, 2019, at 9:43 PM, paulmck paulmck@kernel.org wrote: > >> > >> > From: "Paul E. McKenney" <paulmck@kernel.org> > >> > > >> > Although the rcu_swap_protected() macro follows the example of swap(), > >> > the interactions with RCU make its update of its argument somewhat > >> > counter-intuitive. This commit therefore introduces an rcu_replace() > >> > that returns the old value of the RCU pointer instead of doing the > >> > argument update. Once all the uses of rcu_swap_protected() are updated > >> > to instead use rcu_replace(), rcu_swap_protected() will be removed. > >> > >> We expose the rcu_xchg_pointer() API in liburcu (Userspace RCU) project. > >> Any reason for not going that way and keep the kernel and user-space RCU > >> APIs alike ? > >> > >> It's of course fine if they diverge, but we might want to at least consider > >> if using the same API name would be OK. > > > > Different semantics. An rcu_xchg_pointer() allows concurrent updates, > > and rcu_replace() does not. > > > > But yes, if someone needs the concurrent updates, rcu_xchg_pointer() > > would certainly be my choice for the name. > > Then considering that its assignment counterpart is "rcu_assign_pointer()" > (and not "rcu_assign()"), would "rcu_replace_pointer()" be less ambiguous > about its intended use ? The sequence was rcu_swap_protected() -> rcu_swap() -> rcu_replace(). Because that rcu_replace(), unlike rcu_swap_protected(), returns a value, the shorter name is valuable. Maybe we should have used rcu_assign() instead of rcu_assign_pointer(), but there is no point in that sort of change at this late date! Thanx, Paul > Thanks, > > Mathieu > > > > > > Thanx, Paul > > > >> Thanks, > >> > >> Mathieu > >> > >> > >> > > >> > Link: > >> > https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > >> > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > >> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > >> > Cc: Bart Van Assche <bart.vanassche@wdc.com> > >> > Cc: Christoph Hellwig <hch@lst.de> > >> > Cc: Hannes Reinecke <hare@suse.de> > >> > Cc: Johannes Thumshirn <jthumshirn@suse.de> > >> > Cc: Shane M Seymour <shane.seymour@hpe.com> > >> > Cc: Martin K. Petersen <martin.petersen@oracle.com> > >> > --- > >> > include/linux/rcupdate.h | 18 ++++++++++++++++++ > >> > 1 file changed, 18 insertions(+) > >> > > >> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > >> > index 75a2ede..3b73287 100644 > >> > --- a/include/linux/rcupdate.h > >> > +++ b/include/linux/rcupdate.h > >> > @@ -383,6 +383,24 @@ do { \ > >> > } while (0) > >> > > >> > /** > >> > + * rcu_replace() - replace an RCU pointer, returning its old value > >> > + * @rcu_ptr: RCU pointer, whose old value is returned > >> > + * @ptr: regular pointer > >> > + * @c: the lockdep conditions under which the dereference will take place > >> > + * > >> > + * Perform a replacement, where @rcu_ptr is an RCU-annotated > >> > + * pointer and @c is the lockdep argument that is passed to the > >> > + * rcu_dereference_protected() call used to read that pointer. The old > >> > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. > >> > + */ > >> > +#define rcu_replace(rcu_ptr, ptr, c) \ > >> > +({ \ > >> > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ > >> > + rcu_assign_pointer((rcu_ptr), (ptr)); \ > >> > + __tmp; \ > >> > +}) > >> > + > >> > +/** > >> > * rcu_swap_protected() - swap an RCU and a regular pointer > >> > * @rcu_ptr: RCU pointer > >> > * @ptr: regular pointer > >> > -- > >> > 2.9.5 > >> > >> -- > >> Mathieu Desnoyers > >> EfficiOS Inc. > > > http://www.efficios.com > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-03 19:09 ` Paul E. McKenney @ 2019-10-03 19:14 ` Mathieu Desnoyers 0 siblings, 0 replies; 54+ messages in thread From: Mathieu Desnoyers @ 2019-10-03 19:14 UTC (permalink / raw) To: paulmck Cc: rcu, linux-kernel, Ingo Molnar, Lai Jiangshan, dipankar, Andrew Morton, Josh Triplett, Thomas Gleixner, Peter Zijlstra, rostedt, David Howells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Google, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin ----- On Oct 3, 2019, at 3:09 PM, paulmck paulmck@kernel.org wrote: > On Thu, Oct 03, 2019 at 01:21:14PM -0400, Mathieu Desnoyers wrote: >> ----- On Oct 3, 2019, at 12:52 PM, paulmck paulmck@kernel.org wrote: >> >> > On Thu, Oct 03, 2019 at 12:35:30PM -0400, Mathieu Desnoyers wrote: >> >> ----- On Oct 2, 2019, at 9:43 PM, paulmck paulmck@kernel.org wrote: >> >> >> >> > From: "Paul E. McKenney" <paulmck@kernel.org> >> >> > >> >> > Although the rcu_swap_protected() macro follows the example of swap(), >> >> > the interactions with RCU make its update of its argument somewhat >> >> > counter-intuitive. This commit therefore introduces an rcu_replace() >> >> > that returns the old value of the RCU pointer instead of doing the >> >> > argument update. Once all the uses of rcu_swap_protected() are updated >> >> > to instead use rcu_replace(), rcu_swap_protected() will be removed. >> >> >> >> We expose the rcu_xchg_pointer() API in liburcu (Userspace RCU) project. >> >> Any reason for not going that way and keep the kernel and user-space RCU >> >> APIs alike ? >> >> >> >> It's of course fine if they diverge, but we might want to at least consider >> >> if using the same API name would be OK. >> > >> > Different semantics. An rcu_xchg_pointer() allows concurrent updates, >> > and rcu_replace() does not. >> > >> > But yes, if someone needs the concurrent updates, rcu_xchg_pointer() >> > would certainly be my choice for the name. >> >> Then considering that its assignment counterpart is "rcu_assign_pointer()" >> (and not "rcu_assign()"), would "rcu_replace_pointer()" be less ambiguous >> about its intended use ? > > The sequence was rcu_swap_protected() -> rcu_swap() -> rcu_replace(). > Because that rcu_replace(), unlike rcu_swap_protected(), returns a > value, the shorter name is valuable. > > Maybe we should have used rcu_assign() instead of rcu_assign_pointer(), > but there is no point in that sort of change at this late date! I agree that having both the "rcu_" prefix and the "_pointer" suffix is somewhat redundant. Indeed it's not a worthwhile change for a pre-existing API, but it is welcome for a new API. Thanks! Mathieu > > Thanx, Paul > >> Thanks, >> >> Mathieu >> >> >> > >> > Thanx, Paul >> > >> >> Thanks, >> >> >> >> Mathieu >> >> >> >> >> >> > >> >> > Link: >> >> > https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ >> >> > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> >> >> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> >> >> > Cc: Bart Van Assche <bart.vanassche@wdc.com> >> >> > Cc: Christoph Hellwig <hch@lst.de> >> >> > Cc: Hannes Reinecke <hare@suse.de> >> >> > Cc: Johannes Thumshirn <jthumshirn@suse.de> >> >> > Cc: Shane M Seymour <shane.seymour@hpe.com> >> >> > Cc: Martin K. Petersen <martin.petersen@oracle.com> >> >> > --- >> >> > include/linux/rcupdate.h | 18 ++++++++++++++++++ >> >> > 1 file changed, 18 insertions(+) >> >> > >> >> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h >> >> > index 75a2ede..3b73287 100644 >> >> > --- a/include/linux/rcupdate.h >> >> > +++ b/include/linux/rcupdate.h >> >> > @@ -383,6 +383,24 @@ do { \ >> >> > } while (0) >> >> > >> >> > /** >> >> > + * rcu_replace() - replace an RCU pointer, returning its old value >> >> > + * @rcu_ptr: RCU pointer, whose old value is returned >> >> > + * @ptr: regular pointer >> >> > + * @c: the lockdep conditions under which the dereference will take place >> >> > + * >> >> > + * Perform a replacement, where @rcu_ptr is an RCU-annotated >> >> > + * pointer and @c is the lockdep argument that is passed to the >> >> > + * rcu_dereference_protected() call used to read that pointer. The old >> >> > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. >> >> > + */ >> >> > +#define rcu_replace(rcu_ptr, ptr, c) \ >> >> > +({ \ >> >> > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ >> >> > + rcu_assign_pointer((rcu_ptr), (ptr)); \ >> >> > + __tmp; \ >> >> > +}) >> >> > + >> >> > +/** >> >> > * rcu_swap_protected() - swap an RCU and a regular pointer >> >> > * @rcu_ptr: RCU pointer >> >> > * @ptr: regular pointer >> >> > -- >> >> > 2.9.5 >> >> >> >> -- >> >> Mathieu Desnoyers >> >> EfficiOS Inc. >> > > http://www.efficios.com >> >> -- >> Mathieu Desnoyers >> EfficiOS Inc. > > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-03 10:14 ` Paolo Bonzini 2019-10-03 1:43 ` [PATCH tip/core/rcu 3/9] drivers/gpu: " paulmck ` (7 subsequent siblings) 9 siblings, 1 reply; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Paolo Bonzini, Radim Krčmář, Ingo Molnar, Borislav Petkov, H. Peter Anvin, x86, kvm From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: <x86@kernel.org> Cc: <kvm@vger.kernel.org> --- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index 46875bb..4c37266 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -416,8 +416,8 @@ int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) *filter = tmp; mutex_lock(&kvm->lock); - rcu_swap_protected(kvm->arch.pmu_event_filter, filter, - mutex_is_locked(&kvm->lock)); + filter = rcu_replace(kvm->arch.pmu_event_filter, filter, + mutex_is_locked(&kvm->lock)); mutex_unlock(&kvm->lock); synchronize_srcu_expedited(&kvm->srcu); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck @ 2019-10-03 10:14 ` Paolo Bonzini 2019-10-05 16:11 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: Paolo Bonzini @ 2019-10-03 10:14 UTC (permalink / raw) To: paulmck, rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Radim Krčmář, Ingo Molnar, Borislav Petkov, H. Peter Anvin, x86, kvm On 03/10/19 03:43, paulmck@kernel.org wrote: > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: "Radim Krčmář" <rkrcmar@redhat.com> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Borislav Petkov <bp@alien8.de> > Cc: "H. Peter Anvin" <hpa@zytor.com> > Cc: <x86@kernel.org> > Cc: <kvm@vger.kernel.org> > --- > arch/x86/kvm/pmu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index 46875bb..4c37266 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -416,8 +416,8 @@ int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) > *filter = tmp; > > mutex_lock(&kvm->lock); > - rcu_swap_protected(kvm->arch.pmu_event_filter, filter, > - mutex_is_locked(&kvm->lock)); > + filter = rcu_replace(kvm->arch.pmu_event_filter, filter, > + mutex_is_locked(&kvm->lock)); > mutex_unlock(&kvm->lock); > > synchronize_srcu_expedited(&kvm->srcu); > Should go without saying, but Acked-by: Paolo Bonzini <pbonzini@redhat.com> Paolo ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 10:14 ` Paolo Bonzini @ 2019-10-05 16:11 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-05 16:11 UTC (permalink / raw) To: Paolo Bonzini Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Radim Krčmář, Ingo Molnar, Borislav Petkov, H. Peter Anvin, x86, kvm On Thu, Oct 03, 2019 at 12:14:32PM +0200, Paolo Bonzini wrote: > On 03/10/19 03:43, paulmck@kernel.org wrote: > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Paolo Bonzini <pbonzini@redhat.com> > > Cc: "Radim Krčmář" <rkrcmar@redhat.com> > > Cc: Thomas Gleixner <tglx@linutronix.de> > > Cc: Ingo Molnar <mingo@redhat.com> > > Cc: Borislav Petkov <bp@alien8.de> > > Cc: "H. Peter Anvin" <hpa@zytor.com> > > Cc: <x86@kernel.org> > > Cc: <kvm@vger.kernel.org> > > --- > > arch/x86/kvm/pmu.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > > index 46875bb..4c37266 100644 > > --- a/arch/x86/kvm/pmu.c > > +++ b/arch/x86/kvm/pmu.c > > @@ -416,8 +416,8 @@ int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) > > *filter = tmp; > > > > mutex_lock(&kvm->lock); > > - rcu_swap_protected(kvm->arch.pmu_event_filter, filter, > > - mutex_is_locked(&kvm->lock)); > > + filter = rcu_replace(kvm->arch.pmu_event_filter, filter, > > + mutex_is_locked(&kvm->lock)); > > mutex_unlock(&kvm->lock); > > > > synchronize_srcu_expedited(&kvm->srcu); > > > > Should go without saying, but > > Acked-by: Paolo Bonzini <pbonzini@redhat.com> It never goes without saying! ;-) Applied, thank you! Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 3/9] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck 2019-10-03 1:43 ` [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-03 1:43 ` [PATCH tip/core/rcu 4/9] drivers/scsi: " paulmck ` (6 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter, Chris Wilson, Tvrtko Ursulin, intel-gfx, dri-devel From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: <intel-gfx@lists.freedesktop.org> Cc: <dri-devel@lists.freedesktop.org> --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 1cdfe05..c5c22c4 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -1629,7 +1629,7 @@ set_engines(struct i915_gem_context *ctx, i915_gem_context_set_user_engines(ctx); else i915_gem_context_clear_user_engines(ctx); - rcu_swap_protected(ctx->engines, set.engines, 1); + set.engines = rcu_replace(ctx->engines, set.engines, 1); mutex_unlock(&ctx->engines_mutex); call_rcu(&set.engines->rcu, free_engines_rcu); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (2 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 3/9] drivers/gpu: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-04 2:09 ` Martin K. Petersen 2019-10-03 1:43 ` [PATCH tip/core/rcu 5/9] fs/afs: " paulmck ` (5 subsequent siblings) 9 siblings, 1 reply; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, James E.J. Bottomley, Martin K. Petersen, linux-scsi From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: <linux-scsi@vger.kernel.org> Cc: <linux-kernel@vger.kernel.org> --- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 1f5b5c8..6a38d4a 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -434,8 +434,8 @@ static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page, return; mutex_lock(&sdev->inquiry_mutex); - rcu_swap_protected(*sdev_vpd_buf, vpd_buf, - lockdep_is_held(&sdev->inquiry_mutex)); + vpd_buf = rcu_replace(*sdev_vpd_buf, vpd_buf, + lockdep_is_held(&sdev->inquiry_mutex)); mutex_unlock(&sdev->inquiry_mutex); if (vpd_buf) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 64c96c7..8d17779 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -466,10 +466,10 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) sdev->request_queue = NULL; mutex_lock(&sdev->inquiry_mutex); - rcu_swap_protected(sdev->vpd_pg80, vpd_pg80, - lockdep_is_held(&sdev->inquiry_mutex)); - rcu_swap_protected(sdev->vpd_pg83, vpd_pg83, - lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pg80 = rcu_replace(sdev->vpd_pg80, vpd_pg80, + lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pg83 = rcu_replace(sdev->vpd_pg83, vpd_pg83, + lockdep_is_held(&sdev->inquiry_mutex)); mutex_unlock(&sdev->inquiry_mutex); if (vpd_pg83) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 4/9] drivers/scsi: " paulmck @ 2019-10-04 2:09 ` Martin K. Petersen 2019-10-05 16:06 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: Martin K. Petersen @ 2019-10-04 2:09 UTC (permalink / raw) To: paulmck Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, James E.J. Bottomley, Martin K. Petersen, linux-scsi Paul, No objections from me. > + vpd_pg80 = rcu_replace(sdev->vpd_pg80, vpd_pg80, > + lockdep_is_held(&sdev->inquiry_mutex)); > + vpd_pg83 = rcu_replace(sdev->vpd_pg83, vpd_pg83, > + lockdep_is_held(&sdev->inquiry_mutex)); Just a heads-up that we have added a couple of additional VPD pages so my 5.5 tree will need additional calls to be updated to rcu_replace(). -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace() 2019-10-04 2:09 ` Martin K. Petersen @ 2019-10-05 16:06 ` Paul E. McKenney 2019-10-10 2:36 ` Martin K. Petersen 0 siblings, 1 reply; 54+ messages in thread From: Paul E. McKenney @ 2019-10-05 16:06 UTC (permalink / raw) To: Martin K. Petersen Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, James E.J. Bottomley, linux-scsi On Thu, Oct 03, 2019 at 10:09:31PM -0400, Martin K. Petersen wrote: > > Paul, > > No objections from me. Thank you, Martin! I have applied your Acked-by, but please let me know if that over-interprets your "No objections" above. > > + vpd_pg80 = rcu_replace(sdev->vpd_pg80, vpd_pg80, > > + lockdep_is_held(&sdev->inquiry_mutex)); > > + vpd_pg83 = rcu_replace(sdev->vpd_pg83, vpd_pg83, > > + lockdep_is_held(&sdev->inquiry_mutex)); > > Just a heads-up that we have added a couple of additional VPD pages so > my 5.5 tree will need additional calls to be updated to rcu_replace(). I do not intend to actually remove rcu_swap_protected() until 5.6 for exactly this sort of thing. My plan is to take another pass through the tree after 5.5 comes out, and these will be caught at that time. Does that work for you? Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace() 2019-10-05 16:06 ` Paul E. McKenney @ 2019-10-10 2:36 ` Martin K. Petersen 0 siblings, 0 replies; 54+ messages in thread From: Martin K. Petersen @ 2019-10-10 2:36 UTC (permalink / raw) To: Paul E. McKenney Cc: Martin K. Petersen, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, James E.J. Bottomley, linux-scsi Paul, > I do not intend to actually remove rcu_swap_protected() until 5.6 for > exactly this sort of thing. My plan is to take another pass through > the tree after 5.5 comes out, and these will be caught at that time. > > Does that work for you? Yep, that's great. Thanks! -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 5/9] fs/afs: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (3 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 4/9] drivers/scsi: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-03 8:38 ` David Howells 2019-10-03 1:43 ` [PATCH tip/core/rcu 6/9] bpf/cgroup: " paulmck ` (4 subsequent siblings) 9 siblings, 1 reply; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, linux-afs From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: David Howells <dhowells@redhat.com> Cc: <linux-afs@lists.infradead.org> Cc: <linux-kernel@vger.kernel.org> --- fs/afs/vl_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 21eb0c0..e594598 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -279,8 +279,8 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, struct afs_addr_list *old = addrs; write_lock(&server->lock); - rcu_swap_protected(server->addresses, old, - lockdep_is_held(&server->lock)); + old = rcu_replace(server->addresses, old, + lockdep_is_held(&server->lock)); write_unlock(&server->lock); afs_put_addrlist(old); } -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 5/9] fs/afs: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 5/9] fs/afs: " paulmck @ 2019-10-03 8:38 ` David Howells 2019-10-05 16:10 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: David Howells @ 2019-10-03 8:38 UTC (permalink / raw) To: paulmck Cc: dhowells, rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, edumazet, fweisbec, oleg, joel, linux-afs paulmck@kernel.org wrote: > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). Yay! > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: David Howells <dhowells@redhat.com> > Cc: <linux-afs@lists.infradead.org> > Cc: <linux-kernel@vger.kernel.org> Acked-by: David Howells <dhowells@redhat.com> ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 5/9] fs/afs: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 8:38 ` David Howells @ 2019-10-05 16:10 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-05 16:10 UTC (permalink / raw) To: David Howells Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, edumazet, fweisbec, oleg, joel, linux-afs On Thu, Oct 03, 2019 at 09:38:14AM +0100, David Howells wrote: > paulmck@kernel.org wrote: > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > Yay! > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: David Howells <dhowells@redhat.com> > > Cc: <linux-afs@lists.infradead.org> > > Cc: <linux-kernel@vger.kernel.org> > > Acked-by: David Howells <dhowells@redhat.com> Applied, thank you David! Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (4 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 5/9] fs/afs: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-03 17:21 ` Andrii Nakryiko 2019-10-03 1:43 ` [PATCH tip/core/rcu 7/9] net/core: " paulmck ` (3 subsequent siblings) 9 siblings, 1 reply; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, netdev, bpf From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Song Liu <songliubraving@fb.com> Cc: Yonghong Song <yhs@fb.com> Cc: <netdev@vger.kernel.org> Cc: <bpf@vger.kernel.org> --- kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index ddd8add..06a0657 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -180,8 +180,8 @@ static void activate_effective_progs(struct cgroup *cgrp, enum bpf_attach_type type, struct bpf_prog_array *old_array) { - rcu_swap_protected(cgrp->bpf.effective[type], old_array, - lockdep_is_held(&cgroup_mutex)); + old_array = rcu_replace(cgrp->bpf.effective[type], old_array, + lockdep_is_held(&cgroup_mutex)); /* free prog array after grace period, since __cgroup_bpf_run_*() * might be still walking the array */ -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 6/9] bpf/cgroup: " paulmck @ 2019-10-03 17:21 ` Andrii Nakryiko 2019-10-03 20:58 ` Song Liu 0 siblings, 1 reply; 54+ messages in thread From: Andrii Nakryiko @ 2019-10-03 17:21 UTC (permalink / raw) To: paulmck Cc: rcu, open list, Ingo Molnar, jiangshanlai, dipankar, Andrew Morton, mathieu.desnoyers, josh, Thomas Gleixner, Peter Ziljstra, Steven Rostedt, dhowells, Eric Dumazet, fweisbec, oleg, Joel Fernandes, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, Networking, bpf On Wed, Oct 2, 2019 at 6:45 PM <paulmck@kernel.org> wrote: > > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Alexei Starovoitov <ast@kernel.org> > Cc: Daniel Borkmann <daniel@iogearbox.net> > Cc: Martin KaFai Lau <kafai@fb.com> > Cc: Song Liu <songliubraving@fb.com> > Cc: Yonghong Song <yhs@fb.com> > Cc: <netdev@vger.kernel.org> > Cc: <bpf@vger.kernel.org> > --- Acked-by: Andrii Nakryiko <andriin@fb.com> > kernel/bpf/cgroup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c > index ddd8add..06a0657 100644 > --- a/kernel/bpf/cgroup.c > +++ b/kernel/bpf/cgroup.c > @@ -180,8 +180,8 @@ static void activate_effective_progs(struct cgroup *cgrp, > enum bpf_attach_type type, > struct bpf_prog_array *old_array) > { > - rcu_swap_protected(cgrp->bpf.effective[type], old_array, > - lockdep_is_held(&cgroup_mutex)); > + old_array = rcu_replace(cgrp->bpf.effective[type], old_array, > + lockdep_is_held(&cgroup_mutex)); > /* free prog array after grace period, since __cgroup_bpf_run_*() > * might be still walking the array > */ > -- > 2.9.5 > ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 17:21 ` Andrii Nakryiko @ 2019-10-03 20:58 ` Song Liu 2019-10-05 16:11 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: Song Liu @ 2019-10-03 20:58 UTC (permalink / raw) To: Andrii Nakryiko Cc: paulmck, rcu, open list, Ingo Molnar, jiangshanlai, dipankar, Andrew Morton, mathieu.desnoyers, josh, Thomas Gleixner, Peter Ziljstra, Steven Rostedt, dhowells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, Networking, bpf On Thu, Oct 3, 2019 at 10:43 AM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote: > > On Wed, Oct 2, 2019 at 6:45 PM <paulmck@kernel.org> wrote: > > > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Alexei Starovoitov <ast@kernel.org> > > Cc: Daniel Borkmann <daniel@iogearbox.net> > > Cc: Martin KaFai Lau <kafai@fb.com> > > Cc: Song Liu <songliubraving@fb.com> > > Cc: Yonghong Song <yhs@fb.com> > > Cc: <netdev@vger.kernel.org> > > Cc: <bpf@vger.kernel.org> > > --- > > Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Song Liu <songliubraving@fb.com> ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 20:58 ` Song Liu @ 2019-10-05 16:11 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-05 16:11 UTC (permalink / raw) To: Song Liu Cc: Andrii Nakryiko, rcu, open list, Ingo Molnar, jiangshanlai, dipankar, Andrew Morton, mathieu.desnoyers, josh, Thomas Gleixner, Peter Ziljstra, Steven Rostedt, dhowells, Eric Dumazet, fweisbec, Oleg Nesterov, Joel Fernandes, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, Networking, bpf On Thu, Oct 03, 2019 at 01:58:13PM -0700, Song Liu wrote: > On Thu, Oct 3, 2019 at 10:43 AM Andrii Nakryiko > <andrii.nakryiko@gmail.com> wrote: > > > > On Wed, Oct 2, 2019 at 6:45 PM <paulmck@kernel.org> wrote: > > > > > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > > > This commit replaces the use of rcu_swap_protected() with the more > > > intuitively appealing rcu_replace() as a step towards removing > > > rcu_swap_protected(). > > > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > > Cc: Alexei Starovoitov <ast@kernel.org> > > > Cc: Daniel Borkmann <daniel@iogearbox.net> > > > Cc: Martin KaFai Lau <kafai@fb.com> > > > Cc: Song Liu <songliubraving@fb.com> > > > Cc: Yonghong Song <yhs@fb.com> > > > Cc: <netdev@vger.kernel.org> > > > Cc: <bpf@vger.kernel.org> > > > --- > > > > Acked-by: Andrii Nakryiko <andriin@fb.com> > > Acked-by: Song Liu <songliubraving@fb.com> Applied, thank you both! Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 7/9] net/core: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (5 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 6/9] bpf/cgroup: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-03 1:43 ` [PATCH tip/core/rcu 8/9] net/netfilter: " paulmck ` (2 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, David S. Miller, Jiri Pirko, Ido Schimmel, Petr Machata, Paolo Abeni, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Eric Dumazet <edumazet@google.com> Cc: Ido Schimmel <idosch@mellanox.com> Cc: Petr Machata <petrm@mellanox.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: <netdev@vger.kernel.org> --- net/core/dev.c | 4 ++-- net/core/sock_reuseport.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index bf3ed41..41f6936 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1288,8 +1288,8 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len) } mutex_lock(&ifalias_mutex); - rcu_swap_protected(dev->ifalias, new_alias, - mutex_is_locked(&ifalias_mutex)); + new_alias = rcu_replace(dev->ifalias, new_alias, + mutex_is_locked(&ifalias_mutex)); mutex_unlock(&ifalias_mutex); if (new_alias) diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c index f3ceec9..805287b 100644 --- a/net/core/sock_reuseport.c +++ b/net/core/sock_reuseport.c @@ -356,8 +356,8 @@ int reuseport_detach_prog(struct sock *sk) spin_lock_bh(&reuseport_lock); reuse = rcu_dereference_protected(sk->sk_reuseport_cb, lockdep_is_held(&reuseport_lock)); - rcu_swap_protected(reuse->prog, old_prog, - lockdep_is_held(&reuseport_lock)); + old_prog = rcu_replace(reuse->prog, old_prog, + lockdep_is_held(&reuseport_lock)); spin_unlock_bh(&reuseport_lock); if (!old_prog) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 8/9] net/netfilter: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (6 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 7/9] net/core: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-08 14:16 ` Pablo Neira Ayuso 2019-10-03 1:43 ` [PATCH tip/core/rcu 9/9] net/sched: " paulmck 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 9 siblings, 1 reply; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal, David S. Miller, netfilter-devel, coreteam, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Cc: Jozsef Kadlecsik <kadlec@netfilter.org> Cc: Florian Westphal <fw@strlen.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: <netfilter-devel@vger.kernel.org> Cc: <coreteam@netfilter.org> Cc: <netdev@vger.kernel.org> --- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index d481f9b..8499baf 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1461,8 +1461,9 @@ static void nft_chain_stats_replace(struct nft_trans *trans) if (!nft_trans_chain_stats(trans)) return; - rcu_swap_protected(chain->stats, nft_trans_chain_stats(trans), - lockdep_commit_lock_is_held(trans->ctx.net)); + nft_trans_chain_stats(trans) = + rcu_replace(chain->stats, nft_trans_chain_stats(trans), + lockdep_commit_lock_is_held(trans->ctx.net)); if (!nft_trans_chain_stats(trans)) static_branch_inc(&nft_counters_enabled); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 8/9] net/netfilter: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:43 ` [PATCH tip/core/rcu 8/9] net/netfilter: " paulmck @ 2019-10-08 14:16 ` Pablo Neira Ayuso 2019-10-09 15:36 ` Paul E. McKenney 0 siblings, 1 reply; 54+ messages in thread From: Pablo Neira Ayuso @ 2019-10-08 14:16 UTC (permalink / raw) To: paulmck Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Jozsef Kadlecsik, Florian Westphal, David S. Miller, netfilter-devel, coreteam, netdev On Wed, Oct 02, 2019 at 06:43:09PM -0700, paulmck@kernel.org wrote: > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Pablo Neira Ayuso <pablo@netfilter.org> > Cc: Jozsef Kadlecsik <kadlec@netfilter.org> > Cc: Florian Westphal <fw@strlen.de> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: <netfilter-devel@vger.kernel.org> > Cc: <coreteam@netfilter.org> > Cc: <netdev@vger.kernel.org> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> > --- > net/netfilter/nf_tables_api.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index d481f9b..8499baf 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c > @@ -1461,8 +1461,9 @@ static void nft_chain_stats_replace(struct nft_trans *trans) > if (!nft_trans_chain_stats(trans)) > return; > > - rcu_swap_protected(chain->stats, nft_trans_chain_stats(trans), > - lockdep_commit_lock_is_held(trans->ctx.net)); > + nft_trans_chain_stats(trans) = > + rcu_replace(chain->stats, nft_trans_chain_stats(trans), > + lockdep_commit_lock_is_held(trans->ctx.net)); > > if (!nft_trans_chain_stats(trans)) > static_branch_inc(&nft_counters_enabled); > -- > 2.9.5 > ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 8/9] net/netfilter: Replace rcu_swap_protected() with rcu_replace() 2019-10-08 14:16 ` Pablo Neira Ayuso @ 2019-10-09 15:36 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-09 15:36 UTC (permalink / raw) To: Pablo Neira Ayuso Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Jozsef Kadlecsik, Florian Westphal, David S. Miller, netfilter-devel, coreteam, netdev On Tue, Oct 08, 2019 at 04:16:11PM +0200, Pablo Neira Ayuso wrote: > On Wed, Oct 02, 2019 at 06:43:09PM -0700, paulmck@kernel.org wrote: > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Pablo Neira Ayuso <pablo@netfilter.org> > > Cc: Jozsef Kadlecsik <kadlec@netfilter.org> > > Cc: Florian Westphal <fw@strlen.de> > > Cc: "David S. Miller" <davem@davemloft.net> > > Cc: <netfilter-devel@vger.kernel.org> > > Cc: <coreteam@netfilter.org> > > Cc: <netdev@vger.kernel.org> > > Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> Applied, thank you! Thanx, Paul > > --- > > net/netfilter/nf_tables_api.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > > index d481f9b..8499baf 100644 > > --- a/net/netfilter/nf_tables_api.c > > +++ b/net/netfilter/nf_tables_api.c > > @@ -1461,8 +1461,9 @@ static void nft_chain_stats_replace(struct nft_trans *trans) > > if (!nft_trans_chain_stats(trans)) > > return; > > > > - rcu_swap_protected(chain->stats, nft_trans_chain_stats(trans), > > - lockdep_commit_lock_is_held(trans->ctx.net)); > > + nft_trans_chain_stats(trans) = > > + rcu_replace(chain->stats, nft_trans_chain_stats(trans), > > + lockdep_commit_lock_is_held(trans->ctx.net)); > > > > if (!nft_trans_chain_stats(trans)) > > static_branch_inc(&nft_counters_enabled); > > -- > > 2.9.5 > > ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 9/9] net/sched: Replace rcu_swap_protected() with rcu_replace() 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (7 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 8/9] net/netfilter: " paulmck @ 2019-10-03 1:43 ` paulmck 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-03 1:43 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Jiri Pirko <jiri@resnulli.us> Cc: "David S. Miller" <davem@davemloft.net> Cc: <netdev@vger.kernel.org> Cc: <linux-kernel@vger.kernel.org> --- net/sched/act_api.c | 2 +- net/sched/act_csum.c | 4 ++-- net/sched/act_ct.c | 2 +- net/sched/act_ctinfo.c | 4 ++-- net/sched/act_ife.c | 2 +- net/sched/act_mirred.c | 4 ++-- net/sched/act_mpls.c | 2 +- net/sched/act_police.c | 6 +++--- net/sched/act_skbedit.c | 4 ++-- net/sched/act_tunnel_key.c | 4 ++-- net/sched/act_vlan.c | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 2558f00..1ab810c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -88,7 +88,7 @@ struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action, struct tcf_chain *goto_chain) { a->tcfa_action = action; - rcu_swap_protected(a->goto_chain, goto_chain, 1); + goto_chain = rcu_replace(a->goto_chain, goto_chain, 1); return goto_chain; } EXPORT_SYMBOL(tcf_action_set_ctrlact); diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index d3cfad8..ced5fe6 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -101,8 +101,8 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, spin_lock_bh(&p->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(p->params, params_new, - lockdep_is_held(&p->tcf_lock)); + params_new = rcu_replace(p->params, params_new, + lockdep_is_held(&p->tcf_lock)); spin_unlock_bh(&p->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index fcc4602..500e874 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -722,7 +722,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, spin_lock_bh(&c->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(c->params, params, lockdep_is_held(&c->tcf_lock)); + params = rcu_replace(c->params, params, lockdep_is_held(&c->tcf_lock)); spin_unlock_bh(&c->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 0dbcfd1..e6ea270 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -257,8 +257,8 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, spin_lock_bh(&ci->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, actparm->action, goto_ch); - rcu_swap_protected(ci->params, cp_new, - lockdep_is_held(&ci->tcf_lock)); + cp_new = rcu_replace(ci->params, cp_new, + lockdep_is_held(&ci->tcf_lock)); spin_unlock_bh(&ci->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 3a31e24..a6a60b8 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -594,7 +594,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, spin_lock_bh(&ife->tcf_lock); /* protected by tcf_lock when modifying existing action */ goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(ife->params, p, 1); + p = rcu_replace(ife->params, p, 1); if (exists) spin_unlock_bh(&ife->tcf_lock); diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 9ce073a..1ed5d7e 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -178,8 +178,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, goto put_chain; } mac_header_xmit = dev_is_mac_header_xmit(dev); - rcu_swap_protected(m->tcfm_dev, dev, - lockdep_is_held(&m->tcf_lock)); + dev = rcu_replace(m->tcfm_dev, dev, + lockdep_is_held(&m->tcf_lock)); if (dev) dev_put(dev); m->tcfm_mac_header_xmit = mac_header_xmit; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index e168df0..cea8771 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -258,7 +258,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, spin_lock_bh(&m->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(m->mpls_p, p, lockdep_is_held(&m->tcf_lock)); + p = rcu_replace(m->mpls_p, p, lockdep_is_held(&m->tcf_lock)); spin_unlock_bh(&m->tcf_lock); if (goto_ch) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 89c04c5..02a4bc9c 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -191,9 +191,9 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, police->tcfp_ptoks = new->tcfp_mtu_ptoks; spin_unlock_bh(&police->tcfp_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(police->params, - new, - lockdep_is_held(&police->tcf_lock)); + new = rcu_replace(police->params, + new, + lockdep_is_held(&police->tcf_lock)); spin_unlock_bh(&police->tcf_lock); if (goto_ch) diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index 6a8d333..6c4bd47 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -206,8 +206,8 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, spin_lock_bh(&d->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(d->params, params_new, - lockdep_is_held(&d->tcf_lock)); + params_new = rcu_replace(d->params, params_new, + lockdep_is_held(&d->tcf_lock)); spin_unlock_bh(&d->tcf_lock); if (params_new) kfree_rcu(params_new, rcu); diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 2f83a79..7130da8 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -381,8 +381,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, spin_lock_bh(&t->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(t->params, params_new, - lockdep_is_held(&t->tcf_lock)); + params_new = rcu_replace(t->params, params_new, + lockdep_is_held(&t->tcf_lock)); spin_unlock_bh(&t->tcf_lock); tunnel_key_release_params(params_new); if (goto_ch) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 08aaf71..402c9ea 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -220,7 +220,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, spin_lock_bh(&v->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); + p = rcu_replace(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); spin_unlock_bh(&v->tcf_lock); if (goto_ch) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (8 preceding siblings ...) 2019-10-03 1:43 ` [PATCH tip/core/rcu 9/9] net/sched: " paulmck @ 2019-10-22 19:11 ` Paul E. McKenney 2019-10-22 19:12 ` [PATCH tip/core/rcu 01/10] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck ` (9 more replies) 9 siblings, 10 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-22 19:11 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel Hello! This series replaces uses of rcu_swap_protected() with rcu_replace(). A later patch will remove rcu_swap_protected(). 1. Upgrade rcu_swap_protected() to rcu_replace(). 2-10. Replace calls to rcu_swap_protected() with rcu_replace(). Changes from v1: o Added security/safesetid patch. o Changed the name from rcu_replace() to rcu_replace_pointer() based on feedback from Ingo Molnar. Thanx, Paul ------------------------------------------------------------------------ arch/x86/kvm/pmu.c | 4 ++-- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 8 ++++---- fs/afs/vl_list.c | 4 ++-- include/linux/rcupdate.h | 18 ++++++++++++++++++ kernel/bpf/cgroup.c | 4 ++-- net/core/dev.c | 4 ++-- net/core/sock_reuseport.c | 4 ++-- net/netfilter/nf_tables_api.c | 5 +++-- net/sched/act_api.c | 2 +- net/sched/act_csum.c | 4 ++-- net/sched/act_ct.c | 3 ++- net/sched/act_ctinfo.c | 4 ++-- net/sched/act_ife.c | 2 +- net/sched/act_mirred.c | 4 ++-- net/sched/act_mpls.c | 2 +- net/sched/act_police.c | 6 +++--- net/sched/act_sample.c | 4 ++-- net/sched/act_skbedit.c | 4 ++-- net/sched/act_tunnel_key.c | 4 ++-- net/sched/act_vlan.c | 2 +- security/safesetid/securityfs.c | 4 ++-- 23 files changed, 61 insertions(+), 41 deletions(-) ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 01/10] rcu: Upgrade rcu_swap_protected() to rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 02/10] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck ` (8 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Bart Van Assche, Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn, Shane M Seymour, Martin K . Petersen From: "Paul E. McKenney" <paulmck@kernel.org> Although the rcu_swap_protected() macro follows the example of swap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces an rcu_replace() that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses of rcu_swap_protected() are updated to instead use rcu_replace(), rcu_swap_protected() will be removed. Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Bart Van Assche <bart.vanassche@wdc.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Shane M Seymour <shane.seymour@hpe.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> --- include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 75a2ede..185dd97 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -383,6 +383,24 @@ do { \ } while (0) /** + * rcu_replace_pointer() - replace an RCU pointer, returning its old value + * @rcu_ptr: RCU pointer, whose old value is returned + * @ptr: regular pointer + * @c: the lockdep conditions under which the dereference will take place + * + * Perform a replacement, where @rcu_ptr is an RCU-annotated + * pointer and @c is the lockdep argument that is passed to the + * rcu_dereference_protected() call used to read that pointer. The old + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. + */ +#define rcu_replace_pointer(rcu_ptr, ptr, c) \ +({ \ + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ + rcu_assign_pointer((rcu_ptr), (ptr)); \ + __tmp; \ +}) + +/** * rcu_swap_protected() - swap an RCU and a regular pointer * @rcu_ptr: RCU pointer * @ptr: regular pointer -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 02/10] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 2019-10-22 19:12 ` [PATCH tip/core/rcu 01/10] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` paulmck ` (7 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Radim Krčmář, Ingo Molnar, Borislav Petkov, H. Peter Anvin, x86, kvm From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: <x86@kernel.org> Cc: <kvm@vger.kernel.org> --- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index 46875bb..5ddb05a 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -416,8 +416,8 @@ int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) *filter = tmp; mutex_lock(&kvm->lock); - rcu_swap_protected(kvm->arch.pmu_event_filter, filter, - mutex_is_locked(&kvm->lock)); + filter = rcu_replace_pointer(kvm->arch.pmu_event_filter, filter, + mutex_is_locked(&kvm->lock)); mutex_unlock(&kvm->lock); synchronize_srcu_expedited(&kvm->srcu); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 02/10] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck ` (8 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter, Chris Wilson, Tvrtko Ursulin, intel-gfx, dri-devel From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: <intel-gfx@lists.freedesktop.org> Cc: <dri-devel@lists.freedesktop.org> --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 1cdfe05..3f3e803 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -1629,7 +1629,7 @@ set_engines(struct i915_gem_context *ctx, i915_gem_context_set_user_engines(ctx); else i915_gem_context_clear_user_engines(ctx); - rcu_swap_protected(ctx->engines, set.engines, 1); + set.engines = rcu_replace_pointer(ctx->engines, set.engines, 1); mutex_unlock(&ctx->engines_mutex); call_rcu(&set.engines->rcu, free_engines_rcu); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-22 19:12 ` paulmck 0 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: peterz, fweisbec, jiangshanlai, dri-devel, oleg, dhowells, edumazet, joel, mingo, David Airlie, dipankar, Paul E. McKenney, intel-gfx, josh, mathieu.desnoyers, rostedt, Rodrigo Vivi, tglx, Tvrtko Ursulin, linux-kernel, akpm From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: <intel-gfx@lists.freedesktop.org> Cc: <dri-devel@lists.freedesktop.org> --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 1cdfe05..3f3e803 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -1629,7 +1629,7 @@ set_engines(struct i915_gem_context *ctx, i915_gem_context_set_user_engines(ctx); else i915_gem_context_clear_user_engines(ctx); - rcu_swap_protected(ctx->engines, set.engines, 1); + set.engines = rcu_replace_pointer(ctx->engines, set.engines, 1); mutex_unlock(&ctx->engines_mutex); call_rcu(&set.engines->rcu, free_engines_rcu); -- 2.9.5 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:12 ` paulmck (?) (?) @ 2019-10-28 12:57 ` Joonas Lahtinen -1 siblings, 0 replies; 54+ messages in thread From: Joonas Lahtinen @ 2019-10-28 12:57 UTC (permalink / raw) To: paulmck, rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jani Nikula, Rodrigo Vivi, David Airlie, Daniel Vetter, Chris Wilson, Tvrtko Ursulin, intel-gfx, dri-devel Quoting paulmck@kernel.org (2019-10-22 22:12:08) > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Jani Nikula <jani.nikula@linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Cc: <intel-gfx@lists.freedesktop.org> > Cc: <dri-devel@lists.freedesktop.org> "drm/i915:" preferred as the subject prefix for increased specificity. Let me know which tree you end up merging with. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [Intel-gfx] [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 12:57 ` Joonas Lahtinen 0 siblings, 0 replies; 54+ messages in thread From: Joonas Lahtinen @ 2019-10-28 12:57 UTC (permalink / raw) To: paulmck, rcu Cc: peterz, fweisbec, jiangshanlai, dri-devel, oleg, dhowells, edumazet, joel, mingo, David Airlie, dipankar, Paul E. McKenney, intel-gfx, josh, mathieu.desnoyers, rostedt, tglx, linux-kernel, akpm Quoting paulmck@kernel.org (2019-10-22 22:12:08) > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Jani Nikula <jani.nikula@linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Cc: <intel-gfx@lists.freedesktop.org> > Cc: <dri-devel@lists.freedesktop.org> "drm/i915:" preferred as the subject prefix for increased specificity. Let me know which tree you end up merging with. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 12:57 ` Joonas Lahtinen 0 siblings, 0 replies; 54+ messages in thread From: Joonas Lahtinen @ 2019-10-28 12:57 UTC (permalink / raw) To: paulmck, rcu Cc: peterz, fweisbec, jiangshanlai, dri-devel, oleg, dhowells, edumazet, joel, mingo, David Airlie, dipankar, Paul E. McKenney, intel-gfx, josh, mathieu.desnoyers, rostedt, Rodrigo Vivi, tglx, Tvrtko Ursulin, linux-kernel, akpm Quoting paulmck@kernel.org (2019-10-22 22:12:08) > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Jani Nikula <jani.nikula@linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Cc: <intel-gfx@lists.freedesktop.org> > Cc: <dri-devel@lists.freedesktop.org> "drm/i915:" preferred as the subject prefix for increased specificity. Let me know which tree you end up merging with. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 12:57 ` Joonas Lahtinen 0 siblings, 0 replies; 54+ messages in thread From: Joonas Lahtinen @ 2019-10-28 12:57 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jani Nikula, Rodrigo Vivi, David Airlie, Daniel Vetter, Chris Wilson, Tvrtko Ursulin, intel-gfx, dri-devel Quoting paulmck@kernel.org (2019-10-22 22:12:08) > From: "Paul E. McKenney" <paulmck@kernel.org> > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Jani Nikula <jani.nikula@linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Cc: <intel-gfx@lists.freedesktop.org> > Cc: <dri-devel@lists.freedesktop.org> "drm/i915:" preferred as the subject prefix for increased specificity. Let me know which tree you end up merging with. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 13:40 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-28 13:40 UTC (permalink / raw) To: Joonas Lahtinen Cc: rcu, linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Jani Nikula, Rodrigo Vivi, David Airlie, Daniel Vetter, Chris Wilson, Tvrtko Ursulin, intel-gfx, dri-devel On Mon, Oct 28, 2019 at 02:57:26PM +0200, Joonas Lahtinen wrote: > Quoting paulmck@kernel.org (2019-10-22 22:12:08) > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Jani Nikula <jani.nikula@linux.intel.com> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > > Cc: David Airlie <airlied@linux.ie> > > Cc: Daniel Vetter <daniel@ffwll.ch> > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > > Cc: <intel-gfx@lists.freedesktop.org> > > Cc: <dri-devel@lists.freedesktop.org> > > "drm/i915:" preferred as the subject prefix for increased specificity. "drm/i915" it is! > Let me know which tree you end up merging with. I expect to be sending a pull request for inclusion into the -tip tree in a day or three. > Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Applied, thank you! Thanx, Paul ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [Intel-gfx] [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 13:40 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-28 13:40 UTC (permalink / raw) To: Joonas Lahtinen Cc: peterz, fweisbec, jiangshanlai, dri-devel, oleg, dhowells, edumazet, joel, mingo, David Airlie, dipankar, intel-gfx, josh, rcu, mathieu.desnoyers, rostedt, tglx, linux-kernel, akpm On Mon, Oct 28, 2019 at 02:57:26PM +0200, Joonas Lahtinen wrote: > Quoting paulmck@kernel.org (2019-10-22 22:12:08) > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Jani Nikula <jani.nikula@linux.intel.com> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > > Cc: David Airlie <airlied@linux.ie> > > Cc: Daniel Vetter <daniel@ffwll.ch> > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > > Cc: <intel-gfx@lists.freedesktop.org> > > Cc: <dri-devel@lists.freedesktop.org> > > "drm/i915:" preferred as the subject prefix for increased specificity. "drm/i915" it is! > Let me know which tree you end up merging with. I expect to be sending a pull request for inclusion into the -tip tree in a day or three. > Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Applied, thank you! Thanx, Paul _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace() @ 2019-10-28 13:40 ` Paul E. McKenney 0 siblings, 0 replies; 54+ messages in thread From: Paul E. McKenney @ 2019-10-28 13:40 UTC (permalink / raw) To: Joonas Lahtinen Cc: peterz, fweisbec, jiangshanlai, dri-devel, oleg, dhowells, edumazet, joel, mingo, David Airlie, dipankar, intel-gfx, josh, rcu, mathieu.desnoyers, rostedt, Rodrigo Vivi, tglx, Tvrtko Ursulin, linux-kernel, akpm On Mon, Oct 28, 2019 at 02:57:26PM +0200, Joonas Lahtinen wrote: > Quoting paulmck@kernel.org (2019-10-22 22:12:08) > > From: "Paul E. McKenney" <paulmck@kernel.org> > > > > This commit replaces the use of rcu_swap_protected() with the more > > intuitively appealing rcu_replace() as a step towards removing > > rcu_swap_protected(). > > > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org> > > [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Jani Nikula <jani.nikula@linux.intel.com> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> > > Cc: David Airlie <airlied@linux.ie> > > Cc: Daniel Vetter <daniel@ffwll.ch> > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > > Cc: <intel-gfx@lists.freedesktop.org> > > Cc: <dri-devel@lists.freedesktop.org> > > "drm/i915:" preferred as the subject prefix for increased specificity. "drm/i915" it is! > Let me know which tree you end up merging with. I expect to be sending a pull request for inclusion into the -tip tree in a day or three. > Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Applied, thank you! Thanx, Paul _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 04/10] drivers/scsi: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (2 preceding siblings ...) 2019-10-22 19:12 ` paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 05/10] fs/afs: " paulmck ` (5 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, James E.J. Bottomley, linux-scsi From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: <linux-scsi@vger.kernel.org> Cc: <linux-kernel@vger.kernel.org> --- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 1f5b5c8..7a1b6c7 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -434,8 +434,8 @@ static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page, return; mutex_lock(&sdev->inquiry_mutex); - rcu_swap_protected(*sdev_vpd_buf, vpd_buf, - lockdep_is_held(&sdev->inquiry_mutex)); + vpd_buf = rcu_replace_pointer(*sdev_vpd_buf, vpd_buf, + lockdep_is_held(&sdev->inquiry_mutex)); mutex_unlock(&sdev->inquiry_mutex); if (vpd_buf) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 64c96c7..5adfcab 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -466,10 +466,10 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) sdev->request_queue = NULL; mutex_lock(&sdev->inquiry_mutex); - rcu_swap_protected(sdev->vpd_pg80, vpd_pg80, - lockdep_is_held(&sdev->inquiry_mutex)); - rcu_swap_protected(sdev->vpd_pg83, vpd_pg83, - lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pg80 = rcu_replace_pointer(sdev->vpd_pg80, vpd_pg80, + lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pg83 = rcu_replace_pointer(sdev->vpd_pg83, vpd_pg83, + lockdep_is_held(&sdev->inquiry_mutex)); mutex_unlock(&sdev->inquiry_mutex); if (vpd_pg83) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 05/10] fs/afs: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (3 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 04/10] drivers/scsi: " paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 06/10] bpf/cgroup: " paulmck ` (4 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, linux-afs From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: David Howells <dhowells@redhat.com> Cc: <linux-afs@lists.infradead.org> Cc: <linux-kernel@vger.kernel.org> --- fs/afs/vl_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 21eb0c0..8fea54e 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -279,8 +279,8 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, struct afs_addr_list *old = addrs; write_lock(&server->lock); - rcu_swap_protected(server->addresses, old, - lockdep_is_held(&server->lock)); + old = rcu_replace_pointer(server->addresses, old, + lockdep_is_held(&server->lock)); write_unlock(&server->lock); afs_put_addrlist(old); } -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 06/10] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (4 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 05/10] fs/afs: " paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 07/10] net/core: " paulmck ` (3 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Yonghong Song, netdev, bpf From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Song Liu <songliubraving@fb.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Yonghong Song <yhs@fb.com> Cc: <netdev@vger.kernel.org> Cc: <bpf@vger.kernel.org> --- kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index ddd8add..c684cf4 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -180,8 +180,8 @@ static void activate_effective_progs(struct cgroup *cgrp, enum bpf_attach_type type, struct bpf_prog_array *old_array) { - rcu_swap_protected(cgrp->bpf.effective[type], old_array, - lockdep_is_held(&cgroup_mutex)); + old_array = rcu_replace_pointer(cgrp->bpf.effective[type], old_array, + lockdep_is_held(&cgroup_mutex)); /* free prog array after grace period, since __cgroup_bpf_run_*() * might be still walking the array */ -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 07/10] net/core: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (5 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 06/10] bpf/cgroup: " paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 08/10] net/netfilter: " paulmck ` (2 subsequent siblings) 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, David S. Miller, Jiri Pirko, Ido Schimmel, Petr Machata, Paolo Abeni, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Eric Dumazet <edumazet@google.com> Cc: Ido Schimmel <idosch@mellanox.com> Cc: Petr Machata <petrm@mellanox.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: <netdev@vger.kernel.org> --- net/core/dev.c | 4 ++-- net/core/sock_reuseport.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index bf3ed41..c5d8882 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1288,8 +1288,8 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len) } mutex_lock(&ifalias_mutex); - rcu_swap_protected(dev->ifalias, new_alias, - mutex_is_locked(&ifalias_mutex)); + new_alias = rcu_replace_pointer(dev->ifalias, new_alias, + mutex_is_locked(&ifalias_mutex)); mutex_unlock(&ifalias_mutex); if (new_alias) diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c index f3ceec9..f19f179 100644 --- a/net/core/sock_reuseport.c +++ b/net/core/sock_reuseport.c @@ -356,8 +356,8 @@ int reuseport_detach_prog(struct sock *sk) spin_lock_bh(&reuseport_lock); reuse = rcu_dereference_protected(sk->sk_reuseport_cb, lockdep_is_held(&reuseport_lock)); - rcu_swap_protected(reuse->prog, old_prog, - lockdep_is_held(&reuseport_lock)); + old_prog = rcu_replace_pointer(reuse->prog, old_prog, + lockdep_is_held(&reuseport_lock)); spin_unlock_bh(&reuseport_lock); if (!old_prog) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 08/10] net/netfilter: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (6 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 07/10] net/core: " paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 09/10] net/sched: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 10/10] security/safesetid: " paulmck 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jozsef Kadlecsik, Florian Westphal, David S. Miller, netfilter-devel, coreteam, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> Cc: Jozsef Kadlecsik <kadlec@netfilter.org> Cc: Florian Westphal <fw@strlen.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: <netfilter-devel@vger.kernel.org> Cc: <coreteam@netfilter.org> Cc: <netdev@vger.kernel.org> --- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index d481f9b..3379974 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1461,8 +1461,9 @@ static void nft_chain_stats_replace(struct nft_trans *trans) if (!nft_trans_chain_stats(trans)) return; - rcu_swap_protected(chain->stats, nft_trans_chain_stats(trans), - lockdep_commit_lock_is_held(trans->ctx.net)); + nft_trans_chain_stats(trans) = + rcu_replace_pointer(chain->stats, nft_trans_chain_stats(trans), + lockdep_commit_lock_is_held(trans->ctx.net)); if (!nft_trans_chain_stats(trans)) static_branch_inc(&nft_counters_enabled); -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 09/10] net/sched: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (7 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 08/10] net/netfilter: " paulmck @ 2019-10-22 19:12 ` paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 10/10] security/safesetid: " paulmck 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller, netdev From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Jiri Pirko <jiri@resnulli.us> Cc: "David S. Miller" <davem@davemloft.net> Cc: <netdev@vger.kernel.org> Cc: <linux-kernel@vger.kernel.org> --- net/sched/act_api.c | 2 +- net/sched/act_csum.c | 4 ++-- net/sched/act_ct.c | 3 ++- net/sched/act_ctinfo.c | 4 ++-- net/sched/act_ife.c | 2 +- net/sched/act_mirred.c | 4 ++-- net/sched/act_mpls.c | 2 +- net/sched/act_police.c | 6 +++--- net/sched/act_sample.c | 4 ++-- net/sched/act_skbedit.c | 4 ++-- net/sched/act_tunnel_key.c | 4 ++-- net/sched/act_vlan.c | 2 +- 12 files changed, 21 insertions(+), 20 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 2558f00..3d51573 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -88,7 +88,7 @@ struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action, struct tcf_chain *goto_chain) { a->tcfa_action = action; - rcu_swap_protected(a->goto_chain, goto_chain, 1); + goto_chain = rcu_replace_pointer(a->goto_chain, goto_chain, 1); return goto_chain; } EXPORT_SYMBOL(tcf_action_set_ctrlact); diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index d3cfad8..87dddba 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -101,8 +101,8 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, spin_lock_bh(&p->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(p->params, params_new, - lockdep_is_held(&p->tcf_lock)); + params_new = rcu_replace_pointer(p->params, params_new, + lockdep_is_held(&p->tcf_lock)); spin_unlock_bh(&p->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index fcc4602..2d5ab23 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -722,7 +722,8 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, spin_lock_bh(&c->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(c->params, params, lockdep_is_held(&c->tcf_lock)); + params = rcu_replace_pointer(c->params, params, + lockdep_is_held(&c->tcf_lock)); spin_unlock_bh(&c->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 0dbcfd1..c599818 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -257,8 +257,8 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, spin_lock_bh(&ci->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, actparm->action, goto_ch); - rcu_swap_protected(ci->params, cp_new, - lockdep_is_held(&ci->tcf_lock)); + cp_new = rcu_replace_pointer(ci->params, cp_new, + lockdep_is_held(&ci->tcf_lock)); spin_unlock_bh(&ci->tcf_lock); if (goto_ch) diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 3a31e24..2ea2e16 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -594,7 +594,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, spin_lock_bh(&ife->tcf_lock); /* protected by tcf_lock when modifying existing action */ goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(ife->params, p, 1); + p = rcu_replace_pointer(ife->params, p, 1); if (exists) spin_unlock_bh(&ife->tcf_lock); diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 9ce073a..0c2f737 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -178,8 +178,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, goto put_chain; } mac_header_xmit = dev_is_mac_header_xmit(dev); - rcu_swap_protected(m->tcfm_dev, dev, - lockdep_is_held(&m->tcf_lock)); + dev = rcu_replace_pointer(m->tcfm_dev, dev, + lockdep_is_held(&m->tcf_lock)); if (dev) dev_put(dev); m->tcfm_mac_header_xmit = mac_header_xmit; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index e168df0..5b3031c 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -258,7 +258,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, spin_lock_bh(&m->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(m->mpls_p, p, lockdep_is_held(&m->tcf_lock)); + p = rcu_replace_pointer(m->mpls_p, p, lockdep_is_held(&m->tcf_lock)); spin_unlock_bh(&m->tcf_lock); if (goto_ch) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 89c04c5..caa91cf 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -191,9 +191,9 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, police->tcfp_ptoks = new->tcfp_mtu_ptoks; spin_unlock_bh(&police->tcfp_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(police->params, - new, - lockdep_is_held(&police->tcf_lock)); + new = rcu_replace_pointer(police->params, + new, + lockdep_is_held(&police->tcf_lock)); spin_unlock_bh(&police->tcf_lock); if (goto_ch) diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 514456a..4deeaf2 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -102,8 +102,8 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); s->rate = rate; s->psample_group_num = psample_group_num; - rcu_swap_protected(s->psample_group, psample_group, - lockdep_is_held(&s->tcf_lock)); + psample_group = rcu_replace_pointer(s->psample_group, psample_group, + lockdep_is_held(&s->tcf_lock)); if (tb[TCA_SAMPLE_TRUNC_SIZE]) { s->truncate = true; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index 6a8d333..c38cc39 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -206,8 +206,8 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, spin_lock_bh(&d->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(d->params, params_new, - lockdep_is_held(&d->tcf_lock)); + params_new = rcu_replace_pointer(d->params, params_new, + lockdep_is_held(&d->tcf_lock)); spin_unlock_bh(&d->tcf_lock); if (params_new) kfree_rcu(params_new, rcu); diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 2f83a79..20d7ca4 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -381,8 +381,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, spin_lock_bh(&t->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(t->params, params_new, - lockdep_is_held(&t->tcf_lock)); + params_new = rcu_replace_pointer(t->params, params_new, + lockdep_is_held(&t->tcf_lock)); spin_unlock_bh(&t->tcf_lock); tunnel_key_release_params(params_new); if (goto_ch) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 08aaf71..7aca1f0 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -220,7 +220,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, spin_lock_bh(&v->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); - rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); + p = rcu_replace_pointer(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); spin_unlock_bh(&v->tcf_lock); if (goto_ch) -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH tip/core/rcu 10/10] security/safesetid: Replace rcu_swap_protected() with rcu_replace() 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney ` (8 preceding siblings ...) 2019-10-22 19:12 ` [PATCH tip/core/rcu 09/10] net/sched: " paulmck @ 2019-10-22 19:12 ` paulmck 9 siblings, 0 replies; 54+ messages in thread From: paulmck @ 2019-10-22 19:12 UTC (permalink / raw) To: rcu Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg, joel, Paul E. McKenney, Micah Morton, James Morris, Serge E. Hallyn, linux-security-module From: "Paul E. McKenney" <paulmck@kernel.org> This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected(). Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Reported-by: Reported-by: kbuild test robot <lkp@intel.com> [ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Micah Morton <mortonm@chromium.org> Cc: James Morris <jmorris@namei.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: <linux-security-module@vger.kernel.org> --- security/safesetid/securityfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c index 74a13d4..f8bc574 100644 --- a/security/safesetid/securityfs.c +++ b/security/safesetid/securityfs.c @@ -179,8 +179,8 @@ static ssize_t handle_policy_update(struct file *file, * doesn't currently exist, just use a spinlock for now. */ mutex_lock(&policy_update_lock); - rcu_swap_protected(safesetid_setuid_rules, pol, - lockdep_is_held(&policy_update_lock)); + pol = rcu_replace_pointer(safesetid_setuid_rules, pol, + lockdep_is_held(&policy_update_lock)); mutex_unlock(&policy_update_lock); err = len; -- 2.9.5 ^ permalink raw reply related [flat|nested] 54+ messages in thread
end of thread, other threads:[~2019-10-28 15:29 UTC | newest] Thread overview: 54+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-10-03 1:41 [PATCH tip/core/rcu 0/9] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck 2019-10-03 8:39 ` David Howells 2019-10-03 13:08 ` Steven Rostedt 2019-10-03 13:33 ` Paul E. McKenney 2019-10-03 13:41 ` Peter Zijlstra 2019-10-03 13:58 ` Paul E. McKenney 2019-10-03 14:01 ` Joel Fernandes 2019-10-03 16:31 ` Mathieu Desnoyers 2019-10-03 18:05 ` Peter Zijlstra 2019-10-03 16:35 ` Mathieu Desnoyers 2019-10-03 16:52 ` Paul E. McKenney 2019-10-03 17:21 ` Mathieu Desnoyers 2019-10-03 19:09 ` Paul E. McKenney 2019-10-03 19:14 ` Mathieu Desnoyers 2019-10-03 1:43 ` [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck 2019-10-03 10:14 ` Paolo Bonzini 2019-10-05 16:11 ` Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 3/9] drivers/gpu: " paulmck 2019-10-03 1:43 ` [PATCH tip/core/rcu 4/9] drivers/scsi: " paulmck 2019-10-04 2:09 ` Martin K. Petersen 2019-10-05 16:06 ` Paul E. McKenney 2019-10-10 2:36 ` Martin K. Petersen 2019-10-03 1:43 ` [PATCH tip/core/rcu 5/9] fs/afs: " paulmck 2019-10-03 8:38 ` David Howells 2019-10-05 16:10 ` Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 6/9] bpf/cgroup: " paulmck 2019-10-03 17:21 ` Andrii Nakryiko 2019-10-03 20:58 ` Song Liu 2019-10-05 16:11 ` Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 7/9] net/core: " paulmck 2019-10-03 1:43 ` [PATCH tip/core/rcu 8/9] net/netfilter: " paulmck 2019-10-08 14:16 ` Pablo Neira Ayuso 2019-10-09 15:36 ` Paul E. McKenney 2019-10-03 1:43 ` [PATCH tip/core/rcu 9/9] net/sched: " paulmck 2019-10-22 19:11 ` [PATCH v2 tip/core/rcu 0/10] Replace rcu_swap_protected() for v5.5 Paul E. McKenney 2019-10-22 19:12 ` [PATCH tip/core/rcu 01/10] rcu: Upgrade rcu_swap_protected() to rcu_replace() paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 02/10] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace() paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 03/10] drivers/gpu: " paulmck 2019-10-22 19:12 ` paulmck 2019-10-28 12:57 ` Joonas Lahtinen 2019-10-28 12:57 ` [Intel-gfx] " Joonas Lahtinen 2019-10-28 12:57 ` Joonas Lahtinen 2019-10-28 12:57 ` Joonas Lahtinen 2019-10-28 13:40 ` Paul E. McKenney 2019-10-28 13:40 ` [Intel-gfx] " Paul E. McKenney 2019-10-28 13:40 ` Paul E. McKenney 2019-10-22 19:12 ` [PATCH tip/core/rcu 04/10] drivers/scsi: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 05/10] fs/afs: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 06/10] bpf/cgroup: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 07/10] net/core: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 08/10] net/netfilter: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 09/10] net/sched: " paulmck 2019-10-22 19:12 ` [PATCH tip/core/rcu 10/10] security/safesetid: " paulmck
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.