From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: [RFC Patch net-next 3/4] net_sched: use RCU for tc actions traverse Date: Thu, 9 Jan 2014 10:19:52 -0800 Message-ID: <1389291593-2494-4-git-send-email-xiyou.wangcong@gmail.com> References: <1389291593-2494-1-git-send-email-xiyou.wangcong@gmail.com> Cc: Cong Wang , John Fastabend , Eric Dumazet , "David S. Miller" , Jamal Hadi Salim To: netdev@vger.kernel.org Return-path: Received: from mail-pa0-f44.google.com ([209.85.220.44]:56198 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754878AbaAISUN (ORCPT ); Thu, 9 Jan 2014 13:20:13 -0500 Received: by mail-pa0-f44.google.com with SMTP id fa1so3638797pad.31 for ; Thu, 09 Jan 2014 10:20:13 -0800 (PST) In-Reply-To: <1389291593-2494-1-git-send-email-xiyou.wangcong@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Cc: John Fastabend Cc: Eric Dumazet Cc: David S. Miller Cc: Jamal Hadi Salim Signed-off-by: Cong Wang --- net/sched/act_api.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index f63e146..e3c655e 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -351,7 +351,7 @@ int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, ret = TC_ACT_OK; goto exec_done; } - list_for_each_entry(a, actions, list) { + list_for_each_entry_rcu(a, actions, list) { repeat: ret = a->ops->act(skb, a, res); if (TC_MUNGED & skb->tc_verd) { @@ -372,11 +372,13 @@ EXPORT_SYMBOL(tcf_action_exec); void tcf_action_destroy(struct list_head *actions, int bind) { struct tc_action *a, *tmp; + LIST_HEAD(list); + list_splice_init_rcu(actions, &list, synchronize_rcu); - list_for_each_entry_safe(a, tmp, actions, list) { + list_for_each_entry_safe(a, tmp, &list, list) { if (a->ops->cleanup(a, bind) == ACT_P_DELETED) module_put(a->ops->owner); - list_del(&a->list); + list_del_rcu(&a->list); kfree(a); } } @@ -420,7 +422,7 @@ tcf_action_dump(struct sk_buff *skb, struct list_head *actions, int bind, int re int err = -EINVAL; struct nlattr *nest; - list_for_each_entry(a, actions, list) { + list_for_each_entry_rcu(a, actions, list) { nest = nla_nest_start(skb, a->order); if (nest == NULL) goto nla_put_failure; @@ -542,7 +544,7 @@ int tcf_action_init(struct net *net, struct nlattr *nla, goto err; } act->order = i; - list_add_tail(&act->list, actions); + list_add_tail_rcu(&act->list, actions); } return 0; -- 1.8.3.1