login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
May
»
10
Re: mmotm 2010-04-28 - RCU whinges
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Paul E. McKenney
Subject:
Re: mmotm 2010-04-28 - RCU whinges
Date: Monday, May 10, 2010 - 8:57 am
On Mon, May 10, 2010 at 05:40:58PM +0200, Patrick McHardy wrote:
quoted text
> David Miller wrote: > > From: Eric Dumazet <eric.dumazet@gmail.com> > > Date: Mon, 03 May 2010 07:43:56 +0200 > > > >> Le lundi 03 mai 2010 à 07:41 +0200, Eric Dumazet a écrit : > >> > >>> Oops scratch that, I'll resend a correct version. > >>> > >>> > >> Sorry, patch _is_ fine, I had one brain collapse when re-reading it, I > >> thought a different mutex was in use in one of the functions. > > > > Ok, Patrick please review, thanks. > > Actually we don't need the rcu_dereference() calls at all since > registration and unregistration are protected by the mutexes.
The best approach in that case is rcu_dereference_protected() listing the lock that must be held. Of course, your code, so your choice. Thanx, Paul
quoted text
> I queued this patch in nf-next, the only reason why I haven't > submitted it yet is that I was unable to get git to cleanly export > only the proper set of patches meant for -next due to a few merges, > it insists on including 5 patches already merged upstream. If you > don't mind ignoring the first 5 patches in the series, I'll send a > pull request tonight. > >
quoted text
> commit ed86308f6179d8fa6151c2d0f652aad0091548e2 > Author: Patrick McHardy <kaber@trash.net> > Date: Fri Apr 9 16:42:15 2010 +0200 > > netfilter: remove invalid rcu_dereference() calls > > The CONFIG_PROVE_RCU option discovered a few invalid uses of > rcu_dereference() in netfilter. In all these cases, the code code > intends to check whether a pointer is already assigned when > performing registration or whether the assigned pointer matches > when performing unregistration. The entire registration/ > unregistration is protected by a mutex, so we don't need the > rcu_dereference() calls. > > Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu> > Tested-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu> > Signed-off-by: Patrick McHardy <kaber@trash.net> > > diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c > index d5a9bcd..849614a 100644 > --- a/net/netfilter/nf_conntrack_ecache.c > +++ b/net/netfilter/nf_conntrack_ecache.c > @@ -81,11 +81,9 @@ EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events); > int nf_conntrack_register_notifier(struct nf_ct_event_notifier *new) > { > int ret = 0; > - struct nf_ct_event_notifier *notify; > > mutex_lock(&nf_ct_ecache_mutex); > - notify = rcu_dereference(nf_conntrack_event_cb); > - if (notify != NULL) { > + if (nf_conntrack_event_cb != NULL) { > ret = -EBUSY; > goto out_unlock; > } > @@ -101,11 +99,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_register_notifier); > > void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *new) > { > - struct nf_ct_event_notifier *notify; > - > mutex_lock(&nf_ct_ecache_mutex); > - notify = rcu_dereference(nf_conntrack_event_cb); > - BUG_ON(notify != new); > + BUG_ON(nf_conntrack_event_cb != new); > rcu_assign_pointer(nf_conntrack_event_cb, NULL); > mutex_unlock(&nf_ct_ecache_mutex); > } > @@ -114,11 +109,9 @@ EXPORT_SYMBOL_GPL(nf_conntrack_unregister_notifier); > int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *new) > { > int ret = 0; > - struct nf_exp_event_notifier *notify; > > mutex_lock(&nf_ct_ecache_mutex); > - notify = rcu_dereference(nf_expect_event_cb); > - if (notify != NULL) { > + if (nf_expect_event_cb != NULL) { > ret = -EBUSY; > goto out_unlock; > } > @@ -134,11 +127,8 @@ EXPORT_SYMBOL_GPL(nf_ct_expect_register_notifier); > > void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *new) > { > - struct nf_exp_event_notifier *notify; > - > mutex_lock(&nf_ct_ecache_mutex); > - notify = rcu_dereference(nf_expect_event_cb); > - BUG_ON(notify != new); > + BUG_ON(nf_expect_event_cb != new); > rcu_assign_pointer(nf_expect_event_cb, NULL); > mutex_unlock(&nf_ct_ecache_mutex); > } > diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c > index 015725a..908f599 100644 > --- a/net/netfilter/nf_log.c > +++ b/net/netfilter/nf_log.c > @@ -35,7 +35,6 @@ static struct nf_logger *__find_logger(int pf, const char *str_logger) > /* return EEXIST if the same logger is registred, 0 on success. */ > int nf_log_register(u_int8_t pf, struct nf_logger *logger) > { > - const struct nf_logger *llog; > int i; > > if (pf >= ARRAY_SIZE(nf_loggers)) > @@ -52,8 +51,7 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger) > } else { > /* register at end of list to honor first register win */ > list_add_tail(&logger->list[pf], &nf_loggers_l[pf]); > - llog = rcu_dereference(nf_loggers[pf]); > - if (llog == NULL) > + if (nf_loggers[pf] == NULL) > rcu_assign_pointer(nf_loggers[pf], logger); > } > > @@ -65,13 +63,11 @@ EXPORT_SYMBOL(nf_log_register); > > void nf_log_unregister(struct nf_logger *logger) > { > - const struct nf_logger *c_logger; > int i; > > mutex_lock(&nf_log_mutex); > for (i = 0; i < ARRAY_SIZE(nf_loggers); i++) { > - c_logger = rcu_dereference(nf_loggers[i]); > - if (c_logger == logger) > + if (nf_loggers[i] == logger) > rcu_assign_pointer(nf_loggers[i], NULL); > list_del(&logger->list[i]); > }
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
mmotm 2010-04-28-16-53 uploaded
, akpm
, (Wed Apr 28, 4:53 pm)
Re: mmotm 2010-04-28-16-53 uploaded
, Valdis.Kletnieks
, (Thu Apr 29, 2:32 pm)
Re: mmotm 2010-04-28-16-53 uploaded
, Andrew Morton
, (Thu Apr 29, 2:53 pm)
Re: mmotm 2010-04-28-16-53 uploaded
, Andrew Morton
, (Thu Apr 29, 3:00 pm)
Re: mmotm 2010-04-28-16-53 uploaded
, Lee Schermerhorn
, (Fri Apr 30, 5:11 am)
Re: mmotm 2010-04-28-16-53 uploaded
, Lee Schermerhorn
, (Fri Apr 30, 11:02 am)
Re: mmotm 2010-04-28-16-53 uploaded
, Valdis.Kletnieks
, (Fri Apr 30, 11:47 am)
Re: mmotm 2010-04-28-16-53 uploaded
, Lee Schermerhorn
, (Fri Apr 30, 12:05 pm)
mmotm 2010-04-28 - nouveau driver issues
, Valdis.Kletnieks
, (Sun May 2, 10:38 am)
mmotm 2010-04-28 - RCU whinges
, Valdis.Kletnieks
, (Sun May 2, 10:46 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Sun May 2, 10:38 pm)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Sun May 2, 10:41 pm)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Sun May 2, 10:43 pm)
Re: mmotm 2010-04-28 - RCU whinges
, David Miller
, (Sun May 2, 10:55 pm)
Re: mmotm 2010-04-28 - RCU whinges
, Valdis.Kletnieks
, (Mon May 3, 7:30 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Mon May 3, 7:48 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Mon May 3, 7:58 am)
Re: mmotm 2010-04-28 - RCU whinges
, Valdis.Kletnieks
, (Mon May 3, 8:29 am)
Re: mmotm 2010-04-28 - RCU whinges
, Paul E. McKenney
, (Mon May 3, 8:43 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Mon May 3, 9:14 am)
Re: mmotm 2010-04-28 - RCU whinges
, Paul E. McKenney
, (Mon May 3, 11:16 am)
[PATCH net-next-2.6] net: if6_get_next() fix
, Eric Dumazet
, (Mon May 3, 12:46 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, David Miller
, (Mon May 3, 1:09 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, Eric Dumazet
, (Mon May 3, 1:13 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, David Miller
, (Mon May 3, 1:24 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, Eric Dumazet
, (Mon May 3, 1:50 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, David Miller
, (Mon May 3, 3:17 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, Paul E. McKenney
, (Mon May 3, 3:48 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, Paul E. McKenney
, (Mon May 3, 3:52 pm)
Re: [PATCH net-next-2.6] net: if6_get_next() fix
, David Miller
, (Mon May 3, 3:54 pm)
Re: mmotm 2010-04-28 - RCU whinges
, Patrick McHardy
, (Mon May 10, 8:40 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Mon May 10, 8:56 am)
Re: mmotm 2010-04-28 - RCU whinges
, Eric Dumazet
, (Mon May 10, 8:57 am)
Re: mmotm 2010-04-28 - RCU whinges
, Paul E. McKenney
, (Mon May 10, 8:57 am)
Re: mmotm 2010-04-28 - RCU whinges
, Patrick McHardy
, (Mon May 10, 9:03 am)
Re: mmotm 2010-04-28 - RCU whinges
, Patrick McHardy
, (Mon May 10, 9:04 am)
Re: mmotm 2010-04-28 - RCU whinges
, David Miller
, (Mon May 10, 9:12 am)
Re: mmotm 2010-04-28 - RCU whinges
, Patrick McHardy
, (Mon May 10, 9:27 am)
Re: mmotm 2010-04-28 - RCU whinges
, Patrick McHardy
, (Mon May 10, 9:53 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
David Howells
[PATCH] KEYS: Use the variable 'key' in keyctl_describe_key()
Greg Kroah-Hartman
[PATCH 17/36] sysdev: detect multiple driver registrations
Dave Jones
Re: OT: character encodings (was: Linux 2.6.20-rc4)
Sam Ravnborg
Re: [PATCH] kbuild: fix make V=1
Nick Piggin
Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
git
:
Stephen R. van den Berg
Re: [RFC] origin link for cherry-pick and revert
Junio C Hamano
Re: [PATCH 1/2] Teach git-describe to display distances from tags.
Johannes Schindelin
Re: [PATCH 2/2] git-svn: support fetch with autocrlf on
Dan Chokola
Re: how do you "force a pull"?
Junio C Hamano
Re: [PATCH 6/6] Teach core object handling functions about gitlinks
linux-netdev
:
Jan Engelhardt
[PATCH 1/3] net: tcp: make hybla selectable as default congestion module
Jarek Poplawski
Re: [PATCH] flush_work_sync vs. flush_scheduled_work Re: [PATCH] PHYLIB: IRQ event...
Lennert Buytenhek
Re: Distributed Switch Architecture(DSA)
Daniel Schaffrath
Re: tcp bw in 2.6
Matt Mackall
Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference
git-commits-head
:
Linux Kernel Mailing List
ipv6: fix an oops when force unload ipv6 module
Linux Kernel Mailing List
tracing: protect reader of cmdline output
Linux Kernel Mailing List
kconfig: recalc symbol value before showing search results
Linux Kernel Mailing List
KVM: VMX: Clear CR4.VMXE in hardware_disable
Linux Kernel Mailing List
USB: set correct configuration in probe of ti_usb_3410_5052
openbsd-misc
:
Claudio Jeker
Re: Vlan Tag on Vlan Tag (l2tunneling)
Josh Grosse
ssh/sshd challenge-response seems to have stopped working in -current
Pieter Verberne
File collision while using pkg_add
Tomas Bodzar
bsd: uvm_mapent_alloc: out of static map entries
Community First Financial
Teacher A+ Loan
Colocation donated by:
Syndicate