From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ve1eur01on0137.outbound.protection.outlook.com ([104.47.1.137]:49376 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752478AbeBSJ7B (ORCPT ); Mon, 19 Feb 2018 04:59:01 -0500 Subject: [PATCH 3/3] net: Queue net_cleanup_work only if there is first net added From: Kirill Tkhai To: davem@davemloft.net, nicolas.dichtel@6wind.com, vyasevic@redhat.com, ktkhai@virtuozzo.com, paulmck@linux.vnet.ibm.com, vyasevich@gmail.com, mark.rutland@arm.com, gregkh@linuxfoundation.org, leonro@mellanox.com, avagin@virtuozzo.com, fw@strlen.de, roman.kapl@sysgo.com, netdev@vger.kernel.org Date: Mon, 19 Feb 2018 12:58:54 +0300 Message-ID: <151903433442.8021.12730991801718645322.stgit@localhost.localdomain> In-Reply-To: <151903409491.8021.11032992295248447417.stgit@localhost.localdomain> References: <151903409491.8021.11032992295248447417.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: When llist_add() returns false, cleanup_net() hasn't made its llist_del_all(), while the work has already been scheduled by the first queuer. So, we may skip queue_work() in this case. Signed-off-by: Kirill Tkhai --- net/core/net_namespace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index abf8a46e94e2..27a55236ad64 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -582,8 +582,8 @@ static DECLARE_WORK(net_cleanup_work, cleanup_net); void __put_net(struct net *net) { /* Cleanup the network namespace in process context */ - llist_add(&net->cleanup_list, &cleanup_list); - queue_work(netns_wq, &net_cleanup_work); + if (llist_add(&net->cleanup_list, &cleanup_list)) + queue_work(netns_wq, &net_cleanup_work); } EXPORT_SYMBOL_GPL(__put_net);