From: Eric Dumazet <eric.dumazet@gmail.com>
To: Patrick McHardy <kaber@trash.net>
Cc: David Miller <davem@davemloft.net>,
Ben Greear <greearb@candelatech.com>,
netdev <netdev@vger.kernel.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH net-next-2.6] garp: remove last synchronize_rcu() call
Date: Thu, 12 May 2011 15:29:17 +0200 [thread overview]
Message-ID: <1305206957.3795.21.camel@edumazet-laptop> (raw)
In-Reply-To: <4DC831B0.80107@trash.net>
Le lundi 09 mai 2011 à 20:25 +0200, Patrick McHardy a écrit :
> Am 09.05.2011 15:35, schrieb Eric Dumazet:
> > Speedup vlan dismantling in CONFIG_VLAN_8021Q_GVRP=y cases,
> > by using a call_rcu() to free the memory instead of waiting with
> > expensive synchronize_rcu() [ while RTNL is held ]
> >
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > Cc: Ben Greear <greearb@candelatech.com>
> > Cc: Patrick McHardy <kaber@trash.net>
> > Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > ---
> > Note: I'll take care of using kfree_rcu() when available in net-next-2.6
> >
>
> Looks good to me.
>
Here is a followup on this patch, thanks !
[PATCH net-next-2.6] garp: remove last synchronize_rcu() call
When removing last vlan from a device, garp_uninit_applicant() calls
synchronize_rcu() to make sure no user can still manipulate struct
garp_applicant before we free it.
Use call_rcu() instead, as a step to further net_device dismantle
optimizations.
Add the temporary garp_cleanup_module() function to make sure no pending
call_rcu() are left at module unload time [ this will be removed when
kfree_rcu() is available ]
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ben Greear <greearb@candelatech.com>
---
include/net/garp.h | 1 +
net/802/garp.c | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/net/garp.h b/include/net/garp.h
index 8cabbf08..834d8ad 100644
--- a/include/net/garp.h
+++ b/include/net/garp.h
@@ -104,6 +104,7 @@ struct garp_applicant {
struct sk_buff_head queue;
struct sk_buff *pdu;
struct rb_root gid;
+ struct rcu_head rcu;
};
struct garp_port {
diff --git a/net/802/garp.c b/net/802/garp.c
index 5dbe896..f8300a8 100644
--- a/net/802/garp.c
+++ b/net/802/garp.c
@@ -603,6 +603,11 @@ err1:
}
EXPORT_SYMBOL_GPL(garp_init_applicant);
+static void garp_app_kfree_rcu(struct rcu_head *head)
+{
+ kfree(container_of(head, struct garp_applicant, rcu));
+}
+
void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl)
{
struct garp_port *port = rtnl_dereference(dev->garp_port);
@@ -611,7 +616,6 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
ASSERT_RTNL();
rcu_assign_pointer(port->applicants[appl->type], NULL);
- synchronize_rcu();
/* Delete timer and generate a final TRANSMIT_PDU event to flush out
* all pending messages before the applicant is gone. */
@@ -621,7 +625,7 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
garp_queue_xmit(app);
dev_mc_del(dev, appl->proto.group_address);
- kfree(app);
+ call_rcu(&app->rcu, garp_app_kfree_rcu);
garp_release_port(dev);
}
EXPORT_SYMBOL_GPL(garp_uninit_applicant);
@@ -639,3 +643,9 @@ void garp_unregister_application(struct garp_application *appl)
stp_proto_unregister(&appl->proto);
}
EXPORT_SYMBOL_GPL(garp_unregister_application);
+
+static void __exit garp_cleanup_module(void)
+{
+ rcu_barrier(); /* Wait for completion of call_rcu()'s */
+}
+module_exit(garp_cleanup_module);
next prev parent reply other threads:[~2011-05-12 13:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 13:35 [PATCH net-next-2.6] garp: remove one synchronize_rcu() call Eric Dumazet
2011-05-09 14:40 ` [PATCH net-next-2.6] vlan: remove one synchronize_net() call Eric Dumazet
2011-05-09 17:30 ` Jesse Gross
2011-05-09 18:26 ` Patrick McHardy
2011-05-09 18:42 ` David Miller
2011-05-09 18:25 ` [PATCH net-next-2.6] garp: remove one synchronize_rcu() call Patrick McHardy
2011-05-12 13:29 ` Eric Dumazet [this message]
2011-05-12 21:47 ` [PATCH net-next-2.6] garp: remove last " David Miller
2011-05-09 18:42 ` [PATCH net-next-2.6] garp: remove one " David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1305206957.3795.21.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=greearb@candelatech.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox