* [PATCH net-next-2.6] net: introduce rcu_dereference_read_lock_or_rtnl @ 2010-09-07 20:11 Eric Dumazet 2010-09-07 20:49 ` Jarek Poplawski 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2010-09-07 20:11 UTC (permalink / raw) To: David Miller; +Cc: netdev We use rcu_dereference_check(p, rcu_read_lock_held() || lockdep_rtnl_is_held()) several times in network stack. More usages to come too, so its time to create a helper. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> --- include/linux/rtnetlink.h | 12 ++++++++++++ diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 58d4449..5ba48bb 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -745,10 +745,22 @@ extern void rtnl_lock(void); extern void rtnl_unlock(void); extern int rtnl_trylock(void); extern int rtnl_is_locked(void); + #ifdef CONFIG_PROVE_LOCKING extern int lockdep_rtnl_is_held(void); #endif /* #ifdef CONFIG_PROVE_LOCKING */ +/** + * rcu_dereference_read_lock_or_rtnl - rcu_dereference with debug checking + * @p: The pointer to read, prior to dereferencing + * + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() + * or RTNL + */ +#define rcu_dereference_read_lock_or_rtnl(p) \ + rcu_dereference_check(p, rcu_read_lock_held() || \ + lockdep_rtnl_is_held()); + extern void rtnetlink_init(void); extern void __rtnl_unlock(void); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next-2.6] net: introduce rcu_dereference_read_lock_or_rtnl 2010-09-07 20:11 [PATCH net-next-2.6] net: introduce rcu_dereference_read_lock_or_rtnl Eric Dumazet @ 2010-09-07 20:49 ` Jarek Poplawski 2010-09-07 21:07 ` [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl Eric Dumazet 0 siblings, 1 reply; 6+ messages in thread From: Jarek Poplawski @ 2010-09-07 20:49 UTC (permalink / raw) To: Eric Dumazet; +Cc: David Miller, netdev Eric Dumazet wrote, On 09/07/2010 10:11 PM: > We use rcu_dereference_check(p, rcu_read_lock_held() || > lockdep_rtnl_is_held()) several times in network stack. > > More usages to come too, so its time to create a helper. > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> > --- > include/linux/rtnetlink.h | 12 ++++++++++++ > > diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h > index 58d4449..5ba48bb 100644 > --- a/include/linux/rtnetlink.h > +++ b/include/linux/rtnetlink.h > @@ -745,10 +745,22 @@ extern void rtnl_lock(void); > extern void rtnl_unlock(void); > extern int rtnl_trylock(void); > extern int rtnl_is_locked(void); > + > #ifdef CONFIG_PROVE_LOCKING > extern int lockdep_rtnl_is_held(void); > #endif /* #ifdef CONFIG_PROVE_LOCKING */ > > +/** > + * rcu_dereference_read_lock_or_rtnl - rcu_dereference with debug checking > + * @p: The pointer to read, prior to dereferencing > + * > + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() > + * or RTNL > + */ > +#define rcu_dereference_read_lock_or_rtnl(p) My proposal is to shorten the name, and since rcu_read_lock part seems obvious, maybe rcu_dereference_rtnl() only? Jarek P. \ > + rcu_dereference_check(p, rcu_read_lock_held() || \ > + lockdep_rtnl_is_held()); > + > extern void rtnetlink_init(void); > extern void __rtnl_unlock(void); > > > > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl 2010-09-07 20:49 ` Jarek Poplawski @ 2010-09-07 21:07 ` Eric Dumazet 2010-09-08 18:29 ` Ben Hutchings 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2010-09-07 21:07 UTC (permalink / raw) To: Jarek Poplawski; +Cc: David Miller, netdev Le mardi 07 septembre 2010 à 22:49 +0200, Jarek Poplawski a écrit : > Eric Dumazet wrote, On 09/07/2010 10:11 PM: > > > We use rcu_dereference_check(p, rcu_read_lock_held() || > > lockdep_rtnl_is_held()) several times in network stack. > > > > More usages to come too, so its time to create a helper. > > > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> > > --- > > include/linux/rtnetlink.h | 12 ++++++++++++ > > > > diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h > > index 58d4449..5ba48bb 100644 > > --- a/include/linux/rtnetlink.h > > +++ b/include/linux/rtnetlink.h > > @@ -745,10 +745,22 @@ extern void rtnl_lock(void); > > extern void rtnl_unlock(void); > > extern int rtnl_trylock(void); > > extern int rtnl_is_locked(void); > > + > > #ifdef CONFIG_PROVE_LOCKING > > extern int lockdep_rtnl_is_held(void); > > #endif /* #ifdef CONFIG_PROVE_LOCKING */ > > > > +/** > > + * rcu_dereference_read_lock_or_rtnl - rcu_dereference with debug checking > > + * @p: The pointer to read, prior to dereferencing > > + * > > + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() > > + * or RTNL > > + */ > > +#define rcu_dereference_read_lock_or_rtnl(p) > > > My proposal is to shorten the name, and since rcu_read_lock > part seems obvious, maybe rcu_dereference_rtnl() only? Yes, name is absolutely awful, I am very bad at this kind of games :) Thanks ! [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl We use rcu_dereference_check(p, rcu_read_lock_held() || lockdep_rtnl_is_held()) several times in network stack. More usages to come too, so its time to create a helper. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> --- include/linux/rtnetlink.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 58d4449..057a08f 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -749,6 +749,17 @@ extern int rtnl_is_locked(void); extern int lockdep_rtnl_is_held(void); #endif /* #ifdef CONFIG_PROVE_LOCKING */ +/** + * rcu_dereference_rtnl - rcu_dereference with debug checking + * @p: The pointer to read, prior to dereferencing + * + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() + * or RTNL + */ +#define rcu_dereference_rtnl(p) \ + rcu_dereference_check(p, rcu_read_lock_held() || \ + lockdep_rtnl_is_held()); + extern void rtnetlink_init(void); extern void __rtnl_unlock(void); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl 2010-09-07 21:07 ` [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl Eric Dumazet @ 2010-09-08 18:29 ` Ben Hutchings 2010-09-08 18:44 ` Eric Dumazet 0 siblings, 1 reply; 6+ messages in thread From: Ben Hutchings @ 2010-09-08 18:29 UTC (permalink / raw) To: Eric Dumazet; +Cc: Jarek Poplawski, David Miller, netdev On Tue, 2010-09-07 at 23:07 +0200, Eric Dumazet wrote: [...] > +/** > + * rcu_dereference_rtnl - rcu_dereference with debug checking > + * @p: The pointer to read, prior to dereferencing > + * > + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() > + * or RTNL > + */ > +#define rcu_dereference_rtnl(p) \ > + rcu_dereference_check(p, rcu_read_lock_held() || \ > + lockdep_rtnl_is_held()); [...] No semicolon on the end, please. The 'caller' will add that. Ben. -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl 2010-09-08 18:29 ` Ben Hutchings @ 2010-09-08 18:44 ` Eric Dumazet 2010-09-08 21:15 ` David Miller 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2010-09-08 18:44 UTC (permalink / raw) To: Ben Hutchings; +Cc: Jarek Poplawski, David Miller, netdev Le mercredi 08 septembre 2010 à 19:29 +0100, Ben Hutchings a écrit : > No semicolon on the end, please. The 'caller' will add that. Oh definitely, thanks ! [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl We use rcu_dereference_check(p, rcu_read_lock_held() || lockdep_rtnl_is_held()) several times in network stack. More usages to come too, so its time to create a helper. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> --- include/linux/rtnetlink.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 58d4449..263690d 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -749,6 +749,17 @@ extern int rtnl_is_locked(void); extern int lockdep_rtnl_is_held(void); #endif /* #ifdef CONFIG_PROVE_LOCKING */ +/** + * rcu_dereference_rtnl - rcu_dereference with debug checking + * @p: The pointer to read, prior to dereferencing + * + * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() + * or RTNL + */ +#define rcu_dereference_rtnl(p) \ + rcu_dereference_check(p, rcu_read_lock_held() || \ + lockdep_rtnl_is_held()) + extern void rtnetlink_init(void); extern void __rtnl_unlock(void); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl 2010-09-08 18:44 ` Eric Dumazet @ 2010-09-08 21:15 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2010-09-08 21:15 UTC (permalink / raw) To: eric.dumazet; +Cc: bhutchings, jarkao2, netdev From: Eric Dumazet <eric.dumazet@gmail.com> Date: Wed, 08 Sep 2010 20:44:29 +0200 > Le mercredi 08 septembre 2010 à 19:29 +0100, Ben Hutchings a écrit : > >> No semicolon on the end, please. The 'caller' will add that. > > Oh definitely, thanks ! > > [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl > > We use rcu_dereference_check(p, rcu_read_lock_held() || > lockdep_rtnl_is_held()) several times in network stack. > > More usages to come too, so its time to create a helper. > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Applied, thanks Eric. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-08 21:15 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-09-07 20:11 [PATCH net-next-2.6] net: introduce rcu_dereference_read_lock_or_rtnl Eric Dumazet 2010-09-07 20:49 ` Jarek Poplawski 2010-09-07 21:07 ` [PATCH net-next-2.6] net: introduce rcu_dereference_rtnl Eric Dumazet 2010-09-08 18:29 ` Ben Hutchings 2010-09-08 18:44 ` Eric Dumazet 2010-09-08 21:15 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).