From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-he1eur01on0096.outbound.protection.outlook.com ([104.47.0.96]:39552 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752034AbeCONUF (ORCPT ); Thu, 15 Mar 2018 09:20:05 -0400 Subject: [PATCH net-next 0/5] Rework ip_ra_chain protection From: Kirill Tkhai To: davem@davemloft.net, yoshfuji@linux-ipv6.org, edumazet@google.com, yanhaishuang@cmss.chinamobile.com, nikolay@cumulusnetworks.com, yotamg@mellanox.com, soheil@google.com, ktkhai@virtuozzo.com, avagin@virtuozzo.com, nicolas.dichtel@6wind.com, ebiederm@xmission.com, fw@strlen.de, roman.kapl@sysgo.com, netdev@vger.kernel.org, xiyou.wangcong@gmail.com, dvyukov@google.com, andreyknvl@google.com Date: Thu, 15 Mar 2018 16:19:55 +0300 Message-ID: <152111892326.30586.3742839588131331286.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: Commit 1215e51edad1 "ipv4: fix a deadlock in ip_ra_control" made rtnl_lock() be used in raw_close(). This function is called on every RAW socket destruction, so that rtnl_mutex is taken every time. This scales very sadly. I observe cleanup_net() spending a lot of time in rtnl_lock() and raw_close() is one of the biggest rtnl user (since we have percpu net->ipv4.icmp_sk). Another problem is that commit does not explain actual call path mrtsock_destruct() takes sk lock and the way to deadlock. But there is no sk lock taking is visible in mrtsock_destruct(). So, it is a question does we need it at all. This patchset reworks the locking: reverts the problem commit and its descendant, and introduces rtnl-independent locking. This may have a continuation, and someone may work on killing rtnl_lock() in mrtsock_destruct() in the future. Thanks, Kirill --- Kirill Tkhai (5): net: Revert "ipv4: get rid of ip_ra_lock" net: Revert "ipv4: fix a deadlock in ip_ra_control" net: Move IP_ROUTER_ALERT out of lock_sock(sk) net: Make ip_ra_chain per struct net net: Replace ip_ra_lock with per-net mutex include/net/ip.h | 13 +++++++++++-- include/net/netns/ipv4.h | 2 ++ net/core/net_namespace.c | 1 + net/ipv4/ip_input.c | 5 ++--- net/ipv4/ip_sockglue.c | 34 +++++++++++++--------------------- net/ipv4/ipmr.c | 11 +++++++++-- net/ipv4/raw.c | 2 -- 7 files changed, 38 insertions(+), 30 deletions(-) -- Signed-off-by: Kirill Tkhai