From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlad Buslov Subject: [PATCH net-next 09/13] net: sched: extend tcf_block with rcu Date: Thu, 6 Sep 2018 10:58:58 +0300 Message-ID: <1536220742-25650-10-git-send-email-vladbu@mellanox.com> References: <1536220742-25650-1-git-send-email-vladbu@mellanox.com> Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, stephen@networkplumber.org, ktkhai@virtuozzo.com, paulmck@linux.vnet.ibm.com, nicolas.dichtel@6wind.com, leon@kernel.org, gregkh@linuxfoundation.org, mark.rutland@arm.com, fw@strlen.de, dsahern@gmail.com, lucien.xin@gmail.com, jakub.kicinski@netronome.com, christian.brauner@ubuntu.com, jbenc@redhat.com, Vlad Buslov To: netdev@vger.kernel.org Return-path: Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:45990 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728097AbeIFMd3 (ORCPT ); Thu, 6 Sep 2018 08:33:29 -0400 In-Reply-To: <1536220742-25650-1-git-send-email-vladbu@mellanox.com> Sender: netdev-owner@vger.kernel.org List-ID: Extend tcf_block with rcu to allow safe deallocation when it is accessed concurrently. Signed-off-by: Vlad Buslov Acked-by: Jiri Pirko --- include/net/sch_generic.h | 1 + net/sched/cls_api.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 825e2bf6c5c3..2b87b47c49f6 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -357,6 +357,7 @@ struct tcf_block { struct tcf_chain *chain; struct list_head filter_chain_list; } chain0; + struct rcu_head rcu; }; static inline void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index f11da74dd339..502b2da8a885 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -241,7 +241,7 @@ static void tcf_chain_destroy(struct tcf_chain *chain) block->chain0.chain = NULL; kfree(chain); if (list_empty(&block->chain_list) && !refcount_read(&block->refcnt)) - kfree(block); + kfree_rcu(block, rcu); } static void tcf_chain_hold(struct tcf_chain *chain) @@ -785,7 +785,7 @@ int tcf_block_attach_ext(struct tcf_block **p_block, struct Qdisc *q, if (tcf_block_shared(block)) tcf_block_remove(block, net); err_block_insert: - kfree(block); + kfree_rcu(block, rcu); } else { refcount_dec(&block->refcnt); } @@ -841,7 +841,7 @@ void tcf_block_detach_ext(struct tcf_block *block, struct Qdisc *q, tcf_block_offload_unbind(block, q, ei); if (free_block) - kfree(block); + kfree_rcu(block, rcu); else tcf_block_put_all_chains(block); } else { -- 2.7.5