public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: davem@davemloft.net, yoshfuji@linux-ipv6.org,
	edumazet@google.com, yanhaishuang@cmss.chinamobile.com,
	nikolay@cumulusnetworks.com, yotamg@mellanox.com,
	soheil@google.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, lkp@intel.com
Subject: Re: [PATCH net-next v3 0/5] Rework ip_ra_chain protection
Date: Thu, 22 Mar 2018 12:49:57 +0300	[thread overview]
Message-ID: <abdaca1a-260d-3abe-db94-3e37b5cd06ec@virtuozzo.com> (raw)
In-Reply-To: <152171176936.18202.11912079579606814167.stgit@localhost.localdomain>

On 22.03.2018 12:44, Kirill Tkhai wrote:
> 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).
> 
> 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
> 
> ---
> v3: Change patches order: [2/5] and [3/5].
> v2: Fix sparse warning [4/5], as reported by kbuild test robot.
> 
> ---
> 
> Kirill Tkhai (5):
>       net: Revert "ipv4: get rid of ip_ra_lock"
>       net: Move IP_ROUTER_ALERT out of lock_sock(sk)
>       net: Revert "ipv4: fix a deadlock in ip_ra_control"
>       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 <ktkhai@virtuozzo.com>

JFI: I used the below program to test:

#define _GNU_SOURCE
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <linux/mroute.h>
#include <sched.h>

int main()
{
        int sk, v, i = 0;

        if (unshare(CLONE_NEWNET)) {
                perror("unshare");
                return 1;
        }
        sk = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
        if (sk < 0) {
                perror("socket");
                return 1;
        }
        for (i = 0; i < 3; i++)
                fork();

        while (1) {
                setsockopt(sk, IPPROTO_IP, MRT_INIT, (void *)&v, sizeof(v));
                setsockopt(sk, IPPROTO_IP, MRT_DONE, (void *)&v, sizeof(v));
                v = (i++)%2;
                setsockopt(sk, IPPROTO_IP, IP_ROUTER_ALERT, (void *)&v, sizeof(v));
        }

        return 0;
}

  parent reply	other threads:[~2018-03-22  9:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22  9:44 [PATCH net-next v3 0/5] Rework ip_ra_chain protection Kirill Tkhai
2018-03-22  9:45 ` [PATCH net-next v3 1/5] net: Revert "ipv4: get rid of ip_ra_lock" Kirill Tkhai
2018-03-22  9:45 ` [PATCH net-next v3 2/5] net: Move IP_ROUTER_ALERT out of lock_sock(sk) Kirill Tkhai
2018-03-22  9:45 ` [PATCH net-next v3 3/5] net: Revert "ipv4: fix a deadlock in ip_ra_control" Kirill Tkhai
2018-03-22  9:45 ` [PATCH net-next v3 4/5] net: Make ip_ra_chain per struct net Kirill Tkhai
2018-03-22  9:45 ` [PATCH net-next v3 5/5] net: Replace ip_ra_lock with per-net mutex Kirill Tkhai
2018-03-22  9:49 ` Kirill Tkhai [this message]
2018-03-22 19:14 ` [PATCH net-next v3 0/5] Rework ip_ra_chain protection David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abdaca1a-260d-3abe-db94-3e37b5cd06ec@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=andreyknvl@google.com \
    --cc=avagin@virtuozzo.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=ebiederm@xmission.com \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roman.kapl@sysgo.com \
    --cc=soheil@google.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yanhaishuang@cmss.chinamobile.com \
    --cc=yoshfuji@linux-ipv6.org \
    --cc=yotamg@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox