* [PATCH -next] net/hsr: using kfree_rcu() to simplify the code
@ 2013-12-16 6:05 Wei Yongjun
2013-12-17 0:56 ` Arvid Brodin
2013-12-17 21:32 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2013-12-16 6:05 UTC (permalink / raw)
To: davem, Arvid.Brodin; +Cc: yongjun_wei, netdev
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/hsr/hsr_framereg.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 003f5bb..a758963 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -127,11 +127,6 @@ int hsr_create_self_node(struct list_head *self_node_db,
return 0;
}
-static void node_entry_reclaim(struct rcu_head *rh)
-{
- kfree(container_of(rh, struct node_entry, rcu_head));
-}
-
/* Add/merge node to the database of nodes. 'skb' must contain an HSR
* supervision frame.
@@ -175,7 +170,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
if (node && !ether_addr_equal(node->MacAddressA, hsr_sp->MacAddressA)) {
/* Node has changed its AddrA, frame was received from SlaveB */
list_del_rcu(&node->mac_list);
- call_rcu(&node->rcu_head, node_entry_reclaim);
+ kfree_rcu(node, rcu_head);
node = NULL;
}
@@ -183,7 +178,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
!ether_addr_equal(node->MacAddressB, hsr_ethsup->ethhdr.h_source)) {
/* Cables have been swapped */
list_del_rcu(&node->mac_list);
- call_rcu(&node->rcu_head, node_entry_reclaim);
+ kfree_rcu(node, rcu_head);
node = NULL;
}
@@ -192,7 +187,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
!ether_addr_equal(node->MacAddressA, hsr_ethsup->ethhdr.h_source)) {
/* Cables have been swapped */
list_del_rcu(&node->mac_list);
- call_rcu(&node->rcu_head, node_entry_reclaim);
+ kfree_rcu(node, rcu_head);
node = NULL;
}
@@ -416,7 +411,7 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
hsr_nl_nodedown(hsr_priv, node->MacAddressA);
list_del_rcu(&node->mac_list);
/* Note that we need to free this entry later: */
- call_rcu(&node->rcu_head, node_entry_reclaim);
+ kfree_rcu(node, rcu_head);
}
}
rcu_read_unlock();
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] net/hsr: using kfree_rcu() to simplify the code
2013-12-16 6:05 [PATCH -next] net/hsr: using kfree_rcu() to simplify the code Wei Yongjun
@ 2013-12-17 0:56 ` Arvid Brodin
2013-12-17 21:32 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Arvid Brodin @ 2013-12-17 0:56 UTC (permalink / raw)
To: Wei Yongjun, davem; +Cc: yongjun_wei, netdev
Looks good to me, feel free to add
Acked-by: Arvid Brodin <arvid.brodin@alten.se>
Nice to have others look at the code! :)
On 2013-12-16 07:05, Wei Yongjun wrote:
> 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/hsr/hsr_framereg.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
> index 003f5bb..a758963 100644
> --- a/net/hsr/hsr_framereg.c
> +++ b/net/hsr/hsr_framereg.c
> @@ -127,11 +127,6 @@ int hsr_create_self_node(struct list_head *self_node_db,
> return 0;
> }
>
> -static void node_entry_reclaim(struct rcu_head *rh)
> -{
> - kfree(container_of(rh, struct node_entry, rcu_head));
> -}
> -
>
> /* Add/merge node to the database of nodes. 'skb' must contain an HSR
> * supervision frame.
> @@ -175,7 +170,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
> if (node && !ether_addr_equal(node->MacAddressA, hsr_sp->MacAddressA)) {
> /* Node has changed its AddrA, frame was received from SlaveB */
> list_del_rcu(&node->mac_list);
> - call_rcu(&node->rcu_head, node_entry_reclaim);
> + kfree_rcu(node, rcu_head);
> node = NULL;
> }
>
> @@ -183,7 +178,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
> !ether_addr_equal(node->MacAddressB, hsr_ethsup->ethhdr.h_source)) {
> /* Cables have been swapped */
> list_del_rcu(&node->mac_list);
> - call_rcu(&node->rcu_head, node_entry_reclaim);
> + kfree_rcu(node, rcu_head);
> node = NULL;
> }
>
> @@ -192,7 +187,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
> !ether_addr_equal(node->MacAddressA, hsr_ethsup->ethhdr.h_source)) {
> /* Cables have been swapped */
> list_del_rcu(&node->mac_list);
> - call_rcu(&node->rcu_head, node_entry_reclaim);
> + kfree_rcu(node, rcu_head);
> node = NULL;
> }
>
> @@ -416,7 +411,7 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
> hsr_nl_nodedown(hsr_priv, node->MacAddressA);
> list_del_rcu(&node->mac_list);
> /* Note that we need to free this entry later: */
> - call_rcu(&node->rcu_head, node_entry_reclaim);
> + kfree_rcu(node, rcu_head);
> }
> }
> rcu_read_unlock();
>
--
Arvid Brodin | Consultant (Linux)
P: +46-8-56254286 | M: +46-70-9714286
ALTEN | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden
arvid.brodin@alten.se | www.alten.se/en/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] net/hsr: using kfree_rcu() to simplify the code
2013-12-16 6:05 [PATCH -next] net/hsr: using kfree_rcu() to simplify the code Wei Yongjun
2013-12-17 0:56 ` Arvid Brodin
@ 2013-12-17 21:32 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-12-17 21:32 UTC (permalink / raw)
To: weiyj.lk; +Cc: Arvid.Brodin, yongjun_wei, netdev
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Mon, 16 Dec 2013 14:05:50 +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>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-17 21:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-16 6:05 [PATCH -next] net/hsr: using kfree_rcu() to simplify the code Wei Yongjun
2013-12-17 0:56 ` Arvid Brodin
2013-12-17 21:32 ` 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).