Commit 32da0f00 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

net: rtnl: introduce rcu_replace_pointer_rtnl

Introduce the rcu_replace_pointer_rtnl helper to lockdep check rtnl lock
rcu replacements, alongside the already existing helpers.

This is a quality of life helper so instead of using:
   rcu_replace_pointer(rp, p, lockdep_rtnl_is_held())
   .. or the open coded..
   rtnl_dereference() / rcu_assign_pointer()
   .. or the lazy check version ..
   rcu_replace_pointer(rp, p, 1)
Use:
   rcu_replace_pointer_rtnl(rp, p)
Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarVictor Nogueira <victor@mojatatu.com>
Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 54f4c257
...@@ -79,6 +79,18 @@ static inline bool lockdep_rtnl_is_held(void) ...@@ -79,6 +79,18 @@ static inline bool lockdep_rtnl_is_held(void)
#define rtnl_dereference(p) \ #define rtnl_dereference(p) \
rcu_dereference_protected(p, lockdep_rtnl_is_held()) rcu_dereference_protected(p, lockdep_rtnl_is_held())
/**
* rcu_replace_pointer_rtnl - replace an RCU pointer under rtnl_lock, returning
* its old value
* @rp: RCU pointer, whose value is returned
* @p: regular pointer
*
* Perform a replacement under rtnl_lock, where @rp is an RCU-annotated
* pointer. The old value of @rp is returned, and @rp is set to @p
*/
#define rcu_replace_pointer_rtnl(rp, p) \
rcu_replace_pointer(rp, p, lockdep_rtnl_is_held())
static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev) static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
{ {
return rtnl_dereference(dev->ingress_queue); return rtnl_dereference(dev->ingress_queue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment