Replace rcu_swap_protected() for v5.5
Subsystems (16)
Paul E. McKenney
maintainercover Replace rcu_swap_protected() for v5.5
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(-)
[email protected]
maintainerPATCH 1/9 rcu: Upgrade rcu_swap_protected() to rcu_replace()
From: "Paul E. McKenney" <[email protected]>
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.
--- include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/linux/rcupdate.h +18 -0
@@ -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
Signature · 1 line
2.9.5
David Howells
maintainerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines · [email protected] wrote:
include/linux/rcupdate.h +6
-0+#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
Steven Rostedt
reviewerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 11 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines · [email protected] wrote:
include/linux/rcupdate.h +6
-0+#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
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
[email protected] wrote:
Quoted 8 lines
Quoted 8 lines
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines
include/linux/rcupdate.h +6
-0+#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().
Quoted 4 lines
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
Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 15 lines · Paul E. McKenney
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
[email protected] wrote:
Quoted 8 lines
Quoted 8 lines
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines
include/linux/rcupdate.h +6
-0+#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?
Quoted 4 lines
Historically,
xchg()has been quite a bit slower than a pair of assignment statements, in part due to the strong memory ordering guaranteed byxchg(). Has that changed? If so, then, agreed, it might make sense to usexchg().
Nope, still the case. xchg() is an atomic op with full ordering.
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 16 lines · Peter Zijlstra
Quoted 15 lines · Paul E. McKenney
Quoted 13 lines · Steven Rostedt
Quoted 10 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines · [email protected] wrote:
include/linux/rcupdate.h +6
-0+#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?
Quoted 6 lines
Quoted 4 lines
Historically,
xchg()has been quite a bit slower than a pair of assignment statements, in part due to the strong memory ordering guaranteed byxchg(). Has that changed? If so, then, agreed, it might make sense to usexchg().Nope, still the case.
xchg()is an atomic op with full ordering.
OK, let's stick with the pair of assignments, then. ;-)
Thanx, Paul
Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
In reply to Paul E. McKenneyQuoted 15 lines · Paul E. McKenney
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
[email protected] wrote:
Quoted 8 lines
Quoted 8 lines
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines
include/linux/rcupdate.h +6
-0+#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?
Quoted 4 lines
Historically,
xchg()has been quite a bit slower than a pair of assignment statements, in part due to the strong memory ordering guaranteed byxchg(). Has that changed? If so, then, agreed, it might make sense to usexchg().
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
Mathieu Desnoyers
reviewerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
In reply to Steven RostedtQuoted 15 lines · ----- On Oct 3, 2019, at 9:08 AM, rostedt [email protected] wrote:
Quoted 11 lines · On Thu, 03 Oct 2019 09:39:17 +0100 David Howells <[email protected]> wrote:
include/linux/rcupdate.h do { \ · line 401
Quoted 6 lines · [email protected] wrote:
include/linux/rcupdate.h +6
-0+#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?
Quoted 4 lines
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
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 1 line · Mathieu Desnoyers
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.
Mathieu Desnoyers
reviewerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
In reply to [email protected]Quoted 8 lines · ----- On Oct 2, 2019, at 9:43 PM, paulmck [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
Although the
rcu_swap_protected()macro follows the example ofswap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces anrcu_replace()that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses ofrcu_swap_protected()are updated to instead usercu_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
Quoted 46 lines
Link:
https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/Reported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Shane M Seymour <[email protected]>Cc Martin K. Petersen <[email protected]>---
include/linux/rcupdate.h| 18 ++++++++++++++++++1 file changed, 18 insertions(+)include/linux/rcupdate.h +18
-1@@ -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
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 11 lines · Mathieu Desnoyers
Quoted 8 lines · ----- On Oct 2, 2019, at 9:43 PM, paulmck [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
Although the
rcu_swap_protected()macro follows the example ofswap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces anrcu_replace()that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses ofrcu_swap_protected()are updated to instead usercu_replace(),rcu_swap_protected()will be removed.
Quoted 6 lines
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
Quoted 56 lines
Thanks,
Mathieu
Quoted 46 lines
Link:
https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/Reported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Shane M Seymour <[email protected]>Cc Martin K. Petersen <[email protected]>---
include/linux/rcupdate.h| 18 ++++++++++++++++++1 file changed, 18 insertions(+)include/linux/rcupdate.h +18
-1@@ -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
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Mathieu Desnoyers
reviewerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 16 lines · ----- On Oct 3, 2019, at 12:52 PM, paulmck [email protected] wrote:
Quoted 15 lines · Mathieu Desnoyers
Quoted 8 lines · ----- On Oct 2, 2019, at 9:43 PM, paulmck [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
Although the
rcu_swap_protected()macro follows the example ofswap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces anrcu_replace()that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses ofrcu_swap_protected()are updated to instead usercu_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 ?
Quoted 8 lines
Quoted 2 lines
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, andrcu_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
Quoted 59 lines
Thanx, Paul
Quoted 56 lines
Thanks,
Mathieu
Quoted 45 lines
Link:
https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/Reported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Shane M Seymour <[email protected]>Cc Martin K. Petersen <[email protected]>---
include/linux/rcupdate.h| 18 ++++++++++++++++++1 file changed, 18 insertions(+)include/linux/rcupdate.h +18
-1@@ -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 -- Quoted 1 line
2.9.5
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 24 lines · Mathieu Desnoyers
Quoted 22 lines · ----- On Oct 3, 2019, at 12:52 PM, paulmck [email protected] wrote:
Quoted 11 lines · Mathieu Desnoyers
Quoted 8 lines · ----- On Oct 2, 2019, at 9:43 PM, paulmck [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
Although the
rcu_swap_protected()macro follows the example ofswap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces anrcu_replace()that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses ofrcu_swap_protected()are updated to instead usercu_replace(),rcu_swap_protected()will be removed.Quoted 6 lines
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, andrcu_replace()does not.
Quoted 6 lines
Quoted 2 lines
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
Quoted 69 lines
Thanks,
Mathieu
Quoted 59 lines
Thanx, Paul
Quoted 56 lines
Thanks,
Mathieu
Quoted 45 lines
Link:
https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/Reported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Shane M Seymour <[email protected]>Cc Martin K. Petersen <[email protected]>---
include/linux/rcupdate.h| 18 ++++++++++++++++++1 file changed, 18 insertions(+)include/linux/rcupdate.h +18
-1@@ -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 -- Quoted 1 line
2.9.5
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.comSignature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Mathieu Desnoyers
reviewerRe: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace()
Quoted 32 lines · ----- On Oct 3, 2019, at 3:09 PM, paulmck [email protected] wrote:
Quoted 24 lines · Mathieu Desnoyers
Quoted 22 lines · ----- On Oct 3, 2019, at 12:52 PM, paulmck [email protected] wrote:
Quoted 11 lines · Mathieu Desnoyers
Quoted 8 lines · ----- On Oct 2, 2019, at 9:43 PM, paulmck [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
Although the
rcu_swap_protected()macro follows the example ofswap(), the interactions with RCU make its update of its argument somewhat counter-intuitive. This commit therefore introduces anrcu_replace()that returns the old value of the RCU pointer instead of doing the argument update. Once all the uses ofrcu_swap_protected()are updated to instead usercu_replace(),rcu_swap_protected()will be removed.Quoted 6 lines
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, andrcu_replace()does not.Quoted 6 lines
Quoted 2 lines
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 ?
Quoted 6 lines
The sequence was
rcu_swap_protected()->rcu_swap()->rcu_replace(). Because thatrcu_replace(), unlikercu_swap_protected(), returns a value, the shorter name is valuable.Maybe we should have used
rcu_assign()instead ofrcu_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
Quoted 72 lines
Thanx, Paul
Quoted 69 lines
Thanks,
Mathieu
Quoted 59 lines
Thanx, Paul
Quoted 56 lines
Thanks,
Mathieu
Quoted 45 lines
Link:
https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/Reported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Shane M Seymour <[email protected]>Cc Martin K. Petersen <[email protected]>---
include/linux/rcupdate.h| 18 ++++++++++++++++++1 file changed, 18 insertions(+)include/linux/rcupdate.h +18
-1@@ -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 -- Quoted 1 line
2.9.5
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
[email protected]
maintainerPATCH 2/9 x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/pmu.c +2 -2
@@ -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);
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace()
Quoted 27 lines · On 03/10/19 03:43, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Paolo Bonzini <[email protected]>Cc "Radim Krčmář" <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc <[email protected]>Cc <[email protected]>--- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kvm/pmu.c +0
-0
arch/x86/kvm/pmu.c int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) · line 423
Quoted 10 lines
arch/x86/kvm/pmu.c +2
-2@@ -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
Paolo
Re: [PATCH tip/core/rcu 2/9] x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace()
Quoted 36 lines · Paolo Bonzini
Quoted 35 lines · On 03/10/19 03:43, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Paolo Bonzini <[email protected]>Cc "Radim Krčmář" <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc <[email protected]>Cc <[email protected]>--- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kvm/pmu.c +2
-2@@ -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);
Quoted 6 lines
arch/x86/kvm/pmu.c int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp) · line 423
Quoted 2 lines
arch/x86/kvm/pmu.c +0
-0synchronize_srcu_expedited (&kvm->srcu);Should go without saying, but
Acked-by Paolo Bonzini <[email protected]>
It never goes without saying! ;-)
Applied, thank you!
Thanx, Paul
[email protected]
maintainerPATCH 3/9 drivers/gpu: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -1
@@ -1629,7 +1629,7 @@ set_engines(struct i915_gem_context *ctx,i915_gem_context_set_user_engines (ctx); elsei915_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);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/9 drivers/scsi: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/scsi.c +2 -2
@@ -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)
drivers/scsi/scsi_sysfs.c +4 -4
@@ -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)
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace()
Paul,
No objections from me.
drivers/scsi/scsi_sysfs.c static void scsi_device_dev_release_usercontext(struct work_struct *work) · line 472
Quoted 4 lines
drivers/scsi/scsi_sysfs.c +4
-0+ 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().
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace()
Quoted 4 lines · Martin K. Petersen
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.
Quoted 7 lines
drivers/scsi/scsi_sysfs.c static void scsi_device_dev_release_usercontext(struct work_struct *work) · line 472
Quoted 4 lines
drivers/scsi/scsi_sysfs.c +4
-0+ 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
Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace()
Paul,
Quoted 5 lines
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!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
[email protected]
maintainerPATCH 5/9 fs/afs: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- fs/afs/vl_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/vl_list.c +2 -2
@@ -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); }
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 5/9] fs/afs: Replace rcu_swap_protected() with rcu_replace()
Quoted 3 lines · [email protected] wrote:
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().
Yay!
Quoted 6 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc David Howells <[email protected]>Cc <[email protected]>Cc <[email protected]>
Re: [PATCH tip/core/rcu 5/9] fs/afs: Replace rcu_swap_protected() with rcu_replace()
Quoted 8 lines · David Howells
Quoted 3 lines · [email protected] wrote:
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Yay!
Quoted 8 lines
Quoted 6 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc David Howells <[email protected]>Cc <[email protected]>Cc <[email protected]>Acked-by David Howells <[email protected]>
Applied, thank you David!
Thanx, Paul
[email protected]
maintainerPATCH 6/9 bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/cgroup.c +2 -2
@@ -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 */
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()
Quoted 17 lines · On Wed, Oct 2, 2019 at 6:45 PM <[email protected]> wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc <[email protected]>Cc <[email protected]>
Quoted 1 line
---
Quoted 21 lines
kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/bpf/cgroup.c +2
-3@@ -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
Song Liu
Acked-byRe: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()
Quoted 21 lines · Andrii Nakryiko
Quoted 17 lines · On Wed, Oct 2, 2019 at 6:45 PM <[email protected]> wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc <[email protected]>Cc <[email protected]>Quoted 1 line
---
Quoted 1 line
Acked-by Andrii Nakryiko <[email protected]>
Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()
Quoted 23 lines · Song Liu
Quoted 21 lines · Andrii Nakryiko
Quoted 18 lines · On Wed, Oct 2, 2019 at 6:45 PM <[email protected]> wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc <[email protected]>Cc <[email protected]>---
Quoted 3 lines
Quoted 1 line
Acked-by Andrii Nakryiko <[email protected]>Acked-by Song Liu <[email protected]>
Applied, thank you both!
Thanx, Paul
[email protected]
maintainerPATCH 7/9 net/core: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- net/core/dev.c | 4 ++-- net/core/sock_reuseport.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
net/core/dev.c +2 -2
@@ -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)
net/core/sock_reuseport.c +2 -2
@@ -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)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/9 net/netfilter: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +3 -2
@@ -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);
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 8/9] net/netfilter: Replace rcu_swap_protected() with rcu_replace()
Quoted 6 lines · On Wed, Oct 02, 2019 at 06:43:09PM -0700, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().
Quoted 10 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Cc Jozsef Kadlecsik <[email protected]>Cc Florian Westphal <[email protected]>Cc "David S. Miller" <[email protected]>Cc <[email protected]>Cc <[email protected]>Cc <[email protected]>
Quoted 23 lines
--- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/netfilter/nf_tables_api.c +3
-2@@ -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);Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 8/9] net/netfilter: Replace rcu_swap_protected() with rcu_replace()
Quoted 18 lines · Pablo Neira Ayuso
Quoted 6 lines · On Wed, Oct 02, 2019 at 06:43:09PM -0700, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Quoted 10 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Cc Jozsef Kadlecsik <[email protected]>Cc Florian Westphal <[email protected]>Cc "David S. Miller" <[email protected]>Cc <[email protected]>Cc <[email protected]>Cc <[email protected]>
Quoted 1 line
Applied, thank you!
Thanx, Paul
Quoted 23 lines
Quoted 23 lines
--- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/netfilter/nf_tables_api.c +3
-2@@ -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);Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/9 net/sched: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- 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(-)
net/sched/act_api.c +1 -1
@@ -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);
net/sched/act_csum.c +2 -2
@@ -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)
net/sched/act_ct.c +1 -1
@@ -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)
net/sched/act_ctinfo.c +2 -2
@@ -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)
net/sched/act_ife.c +1 -1
@@ -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);
net/sched/act_mirred.c +2 -2
@@ -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;
net/sched/act_mpls.c +1 -1
@@ -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)
net/sched/act_police.c +3 -3
@@ -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)
net/sched/act_skbedit.c +2 -2
@@ -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);
net/sched/act_tunnel_key.c +2 -2
@@ -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)
net/sched/act_vlan.c +1 -1
@@ -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)
Signature · 1 line
2.9.5
Paul E. McKenney
maintainerv2 cover Replace rcu_swap_protected() for v5.5
In reply to Paul E. McKenneyHello!
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(-)
[email protected]
maintainerPATCH v2 1/10 rcu: Upgrade rcu_swap_protected() to rcu_replace()
From: "Paul E. McKenney" <[email protected]>
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.
--- include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/linux/rcupdate.h +18 -0
@@ -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
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 2/10 x86/kvm/pmu: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/pmu.c +2 -2
@@ -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);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 3/10 drivers/gpu: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -1
@@ -1629,7 +1629,7 @@ set_engines(struct i915_gem_context *ctx,i915_gem_context_set_user_engines (ctx); elsei915_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);
Signature · 6 lines
2.9.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace()
Quoting [email protected] (2019-10-22 22:12:08)
Quoted 6 lines
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().
Quoted 13 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>[ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ]Signed-off-by Paul E. McKenney <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc <[email protected]>Cc <[email protected]>
"drm/i915:" preferred as the subject prefix for increased specificity.
Let me know which tree you end up merging with.
Regards, Joonas
Re: [PATCH tip/core/rcu 03/10] drivers/gpu: Replace rcu_swap_protected() with rcu_replace()
Quoted 21 lines · Joonas Lahtinen
Quoting [email protected] (2019-10-22 22:12:08)
Quoted 6 lines
From: "Paul E. McKenney" <[email protected]>
This commit replaces the use of
rcu_swap_protected()with the more intuitively appealingrcu_replace()as a step towards removingrcu_swap_protected().Quoted 13 lines
Link https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ open hereReported-by Linus Torvalds <[email protected]>[ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ]Signed-off-by Paul E. McKenney <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc <[email protected]>Cc <[email protected]>
Quoted 1 line
"drm/i915:" preferred as the subject prefix for increased specificity.
"drm/i915" it is!
Quoted 1 line
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.
Quoted 1 line
Reviewed-by Joonas Lahtinen <[email protected]>
Applied, thank you!
Thanx, Paul
[email protected]
maintainerPATCH v2 4/10 drivers/scsi: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/scsi.c +2 -2
@@ -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)
drivers/scsi/scsi_sysfs.c +4 -4
@@ -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)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 5/10 fs/afs: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- fs/afs/vl_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/vl_list.c +2 -2
@@ -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); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 6/10 bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/cgroup.c +2 -2
@@ -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 */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 7/10 net/core: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- net/core/dev.c | 4 ++-- net/core/sock_reuseport.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
net/core/dev.c +2 -2
@@ -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)
net/core/sock_reuseport.c +2 -2
@@ -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)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 8/10 net/netfilter: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- net/netfilter/nf_tables_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +3 -2
@@ -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);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 9/10 net/sched: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- 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(-)
net/sched/act_api.c +1 -1
@@ -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);
net/sched/act_csum.c +2 -2
@@ -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)
net/sched/act_ct.c +2 -1
@@ -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)
net/sched/act_ctinfo.c +2 -2
@@ -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)
net/sched/act_ife.c +1 -1
@@ -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);
net/sched/act_mirred.c +2 -2
@@ -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;
net/sched/act_mpls.c +1 -1
@@ -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)
net/sched/act_police.c +3 -3
@@ -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)
net/sched/act_sample.c +2 -2
@@ -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;
net/sched/act_skbedit.c +2 -2
@@ -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);
net/sched/act_tunnel_key.c +2 -2
@@ -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)
net/sched/act_vlan.c +1 -1
@@ -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)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH v2 10/10 security/safesetid: Replace rcu_swap_protected() with rcu_replace()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit replaces the use of rcu_swap_protected() with the more intuitively appealing rcu_replace() as a step towards removing rcu_swap_protected().
--- security/safesetid/securityfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/safesetid/securityfs.c +2 -2
@@ -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;
Signature · 1 line
2.9.5