diff options
author | Jesse Gross <jesse@nicira.com> | 2011-11-19 19:21:37 -0500 |
---|---|---|
committer | Jesse Gross <jesse@nicira.com> | 2011-12-03 12:35:08 -0500 |
commit | b4e16611c4e1cd98765269c8fdaf43f96baa57b1 (patch) | |
tree | 3ca0f230d24748d51726c7e5bb392529a8d65009 /include/linux/genetlink.h | |
parent | 86b1309c7e411b7c25dc0dc7a092582a4d291044 (diff) |
genetlink: Add rcu_dereference_genl and genl_dereference.
This adds rcu_dereference_genl and genl_dereference, which are genl
variants of the RTNL functions to enforce proper locking with lockdep
and sparse.
Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'include/linux/genetlink.h')
-rw-r--r-- | include/linux/genetlink.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/genetlink.h b/include/linux/genetlink.h index 59311adfb0e0..73c28dea10ae 100644 --- a/include/linux/genetlink.h +++ b/include/linux/genetlink.h | |||
@@ -89,6 +89,27 @@ extern void genl_unlock(void); | |||
89 | extern int lockdep_genl_is_held(void); | 89 | extern int lockdep_genl_is_held(void); |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | /** | ||
93 | * rcu_dereference_genl - rcu_dereference with debug checking | ||
94 | * @p: The pointer to read, prior to dereferencing | ||
95 | * | ||
96 | * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() | ||
97 | * or genl mutex. Note : Please prefer genl_dereference() or rcu_dereference() | ||
98 | */ | ||
99 | #define rcu_dereference_genl(p) \ | ||
100 | rcu_dereference_check(p, lockdep_genl_is_held()) | ||
101 | |||
102 | /** | ||
103 | * genl_dereference - fetch RCU pointer when updates are prevented by genl mutex | ||
104 | * @p: The pointer to read, prior to dereferencing | ||
105 | * | ||
106 | * Return the value of the specified RCU-protected pointer, but omit | ||
107 | * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because | ||
108 | * caller holds genl mutex. | ||
109 | */ | ||
110 | #define genl_dereference(p) \ | ||
111 | rcu_dereference_protected(p, lockdep_genl_is_held()) | ||
112 | |||
92 | #endif /* __KERNEL__ */ | 113 | #endif /* __KERNEL__ */ |
93 | 114 | ||
94 | #endif /* __LINUX_GENERIC_NETLINK_H */ | 115 | #endif /* __LINUX_GENERIC_NETLINK_H */ |