Patchwork [-next] vxlan: using kfree_rcu() to simplify the code

login
register
mail settings
Submitter Wei Yongjun
Date July 17, 2013, 5:29 a.m.
Message ID <CAPgLHd89R4FkKq1tCyuL9WWRXgsCb7ZpGGsw3yiPn1Ht5X61Vw@mail.gmail.com>
Download mbox | patch
Permalink /patch/259597/
State Deferred
Delegated to: David Miller
Headers show

Comments

Wei Yongjun - July 17, 2013, 5:29 a.m.
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/net/vxlan.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)


--
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
David Miller - July 17, 2013, 6:01 a.m.
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Wed, 17 Jul 2013 13:29:58 +0800

> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> The callback function of call_rcu() just calls a kfree(), so we
> can use kfree_rcu() instead of call_rcu() + callback function.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

net-next is not open yet, please resubmit this when I announce here
on netdev that the net-next tree is open for submissions.

Thank you.
--
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

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 227b54a..d6fc046 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -498,12 +498,6 @@  static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 	return 0;
 }
 
-static void vxlan_fdb_free_rdst(struct rcu_head *head)
-{
-	struct vxlan_rdst *rd = container_of(head, struct vxlan_rdst, rcu);
-	kfree(rd);
-}
-
 static void vxlan_fdb_free(struct rcu_head *head)
 {
 	struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu);
@@ -643,7 +637,7 @@  static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 	 */
 	if (rd && !list_is_singular(&f->remotes)) {
 		list_del_rcu(&rd->list);
-		call_rcu(&rd->rcu, vxlan_fdb_free_rdst);
+		kfree_rcu(rd, rcu);
 		goto out;
 	}