{"id":815945,"url":"http://patchwork.ozlabs.org/api/patches/815945/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170919232709.14690-8-edumazet@google.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170919232709.14690-8-edumazet@google.com>","list_archive_url":null,"date":"2017-09-19T23:27:09","name":"[v2,net-next,7/7] ipv4: speedup ipv6 tunnels dismantle","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d0ef3a579a21fe4a6d3fa57d12bbf416c6cc49aa","submitter":{"id":13357,"url":"http://patchwork.ozlabs.org/api/people/13357/?format=json","name":"Eric Dumazet","email":"edumazet@google.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170919232709.14690-8-edumazet@google.com/mbox/","series":[{"id":3987,"url":"http://patchwork.ozlabs.org/api/series/3987/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3987","date":"2017-09-19T23:27:02","name":"net: speedup netns create/delete time","version":2,"mbox":"http://patchwork.ozlabs.org/series/3987/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815945/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815945/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"L3ca9WcX\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxfDR2qLwz9sPt\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 20 Sep 2017 09:27:35 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751763AbdISX1d (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 19:27:33 -0400","from mail-pf0-f179.google.com ([209.85.192.179]:54609 \"EHLO\n\tmail-pf0-f179.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751700AbdISX11 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 19:27:27 -0400","by mail-pf0-f179.google.com with SMTP id d187so594156pfg.11\n\tfor <netdev@vger.kernel.org>; Tue, 19 Sep 2017 16:27:27 -0700 (PDT)","from localhost ([2620:15c:2cb:201:58bc:17b0:6372:1d5f])\n\tby smtp.gmail.com with ESMTPSA id\n\tu12sm7132996pfg.146.2017.09.19.16.27.26\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tTue, 19 Sep 2017 16:27:26 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=google.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=uoTl2pAcI1qfHyi6dPWLNxCGKnjIZWSm+kVcYBS/GPQ=;\n\tb=L3ca9WcXLJxy+rjP6msmu6CleNi/pHk47pp3ooqwlHjwKOI066reIYy6hoqIjvGE62\n\tlQ8T52G8egjitq4zw8K9SDK7EIrFl/r5+miKDRhMHOQPL2PVKdpTGP3nIc0WfULEqg0K\n\tWpwYpZQTJ8ePznIWIQx2AmhZxQyMiCV7FCNWAa3yOoshzgED94tkKHw77GKpplH5qxuu\n\ti0p+LOPix3wjpFQVoJP1G+0IbPzb7nxehTdrcaMDDPdtPy/vEc0TYQvEN7XgYAWaX4Mv\n\tIDkEL9PB1yl8Ie8bA+FkrJBg/W9TtsX6n09M++alJEaTBE0lmRRRn7juP1HOgQLVwIFG\n\tFPew==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=uoTl2pAcI1qfHyi6dPWLNxCGKnjIZWSm+kVcYBS/GPQ=;\n\tb=VDcDD0fCzXnWJGkqSdE01r1vVE0WPGQg7gf/sgY+TofRBYC/ffZFdEDR4s2f5d04RA\n\tPenHAi9fgiC8H5+LKnAs9cn+Y+lGNeyyZef4JOrXkQd6gf7CWRl6AdXzv+BZ+Sgz/I8k\n\tejSrNde5XTOjolp18H5t4sTtE4ap6yiKhtyyuQXryyYwJjq0U+vWhSqWGGg1rHy2TFtZ\n\t/PR3AlscuK0zAfalHmPP4jopYnyZ6UHvHW9NY07AFEeTe1+CrEMHf0hLM1hbyzk42S0V\n\tyz1jrVyfv0FSh8AyrUSCDhxLLUg8YecH6a8xsWNidiLa5Toe/IYH5Wh7DUjpc78zPFDw\n\t+zNw==","X-Gm-Message-State":"AHPjjUjoeVHi4ktgihFvOVbCLWBVU8YIx0032EDLjLnXykv8WenAG3kz\n\tSwdD3GiwhZl0SJPMo68WEwtt7Q==","X-Google-Smtp-Source":"AOwi7QDRDVxY9XOt4hG4F9mR7eOwcIyKnOud0qEgGG7kOClNmcitULywoynUtK9clc85s9yrYXMBnw==","X-Received":"by 10.98.155.220 with SMTP id e89mr257039pfk.120.1505863646865; \n\tTue, 19 Sep 2017 16:27:26 -0700 (PDT)","From":"Eric Dumazet <edumazet@google.com>","To":"\"David S . Miller\" <davem@davemloft.net>","Cc":"netdev <netdev@vger.kernel.org>,\n\t\"Eric W . Biederman\" <ebiederm@xmission.com>,\n\tEric Dumazet <edumazet@google.com>, Eric Dumazet <eric.dumazet@gmail.com>","Subject":"[PATCH v2 net-next 7/7] ipv4: speedup ipv6 tunnels dismantle","Date":"Tue, 19 Sep 2017 16:27:09 -0700","Message-Id":"<20170919232709.14690-8-edumazet@google.com>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170919232709.14690-1-edumazet@google.com>","References":"<20170919232709.14690-1-edumazet@google.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Implement exit_batch() method to dismantle more devices\nper round.\n\n(rtnl_lock() ...\n unregister_netdevice_many() ...\n rtnl_unlock())\n\nTested:\n$ cat add_del_unshare.sh\nfor i in `seq 1 40`\ndo\n (for j in `seq 1 100` ; do unshare -n /bin/true >/dev/null ; done) &\ndone\nwait ; grep net_namespace /proc/slabinfo\n\nBefore patch :\n$ time ./add_del_unshare.sh\nnet_namespace        126    282   5504    1    2 : tunables    8    4    0 : slabdata    126    282      0\n\nreal    1m38.965s\nuser    0m0.688s\nsys     0m37.017s\n\nAfter patch:\n$ time ./add_del_unshare.sh\nnet_namespace        135    291   5504    1    2 : tunables    8    4    0 : slabdata    135    291      0\n\nreal\t0m22.117s\nuser\t0m0.728s\nsys\t0m35.328s\n\nSigned-off-by: Eric Dumazet <edumazet@google.com>\n---\n include/net/ip_tunnels.h |  3 ++-\n net/ipv4/ip_gre.c        | 22 +++++++++-------------\n net/ipv4/ip_tunnel.c     | 12 +++++++++---\n net/ipv4/ip_vti.c        |  7 +++----\n net/ipv4/ipip.c          |  7 +++----\n 5 files changed, 26 insertions(+), 25 deletions(-)","diff":"diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h\nindex 992652856fe8c7c1032e0f5f92ce7ee5aa0119da..b41a1e057fcec9d6e4c5a0c1cafd1f1d537ccd53 100644\n--- a/include/net/ip_tunnels.h\n+++ b/include/net/ip_tunnels.h\n@@ -258,7 +258,8 @@ int ip_tunnel_get_iflink(const struct net_device *dev);\n int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id,\n \t\t       struct rtnl_link_ops *ops, char *devname);\n \n-void ip_tunnel_delete_net(struct ip_tunnel_net *itn, struct rtnl_link_ops *ops);\n+void ip_tunnel_delete_nets(struct list_head *list_net, unsigned int id,\n+\t\t\t   struct rtnl_link_ops *ops);\n \n void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t    const struct iphdr *tnl_params, const u8 protocol);\ndiff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c\nindex 0162fb955b33abf18514cbfd482e72a0ebce6e48..9cee986ac6b8ed04ff95e193fe1e8e60e74d84a9 100644\n--- a/net/ipv4/ip_gre.c\n+++ b/net/ipv4/ip_gre.c\n@@ -1013,15 +1013,14 @@ static int __net_init ipgre_init_net(struct net *net)\n \treturn ip_tunnel_init_net(net, ipgre_net_id, &ipgre_link_ops, NULL);\n }\n \n-static void __net_exit ipgre_exit_net(struct net *net)\n+static void __net_exit ipgre_exit_batch_net(struct list_head *list_net)\n {\n-\tstruct ip_tunnel_net *itn = net_generic(net, ipgre_net_id);\n-\tip_tunnel_delete_net(itn, &ipgre_link_ops);\n+\tip_tunnel_delete_nets(list_net, ipgre_net_id, &ipgre_link_ops);\n }\n \n static struct pernet_operations ipgre_net_ops = {\n \t.init = ipgre_init_net,\n-\t.exit = ipgre_exit_net,\n+\t.exit_batch = ipgre_exit_batch_net,\n \t.id   = &ipgre_net_id,\n \t.size = sizeof(struct ip_tunnel_net),\n };\n@@ -1540,15 +1539,14 @@ static int __net_init ipgre_tap_init_net(struct net *net)\n \treturn ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, \"gretap0\");\n }\n \n-static void __net_exit ipgre_tap_exit_net(struct net *net)\n+static void __net_exit ipgre_tap_exit_batch_net(struct list_head *list_net)\n {\n-\tstruct ip_tunnel_net *itn = net_generic(net, gre_tap_net_id);\n-\tip_tunnel_delete_net(itn, &ipgre_tap_ops);\n+\tip_tunnel_delete_nets(list_net, gre_tap_net_id, &ipgre_tap_ops);\n }\n \n static struct pernet_operations ipgre_tap_net_ops = {\n \t.init = ipgre_tap_init_net,\n-\t.exit = ipgre_tap_exit_net,\n+\t.exit_batch = ipgre_tap_exit_batch_net,\n \t.id   = &gre_tap_net_id,\n \t.size = sizeof(struct ip_tunnel_net),\n };\n@@ -1559,16 +1557,14 @@ static int __net_init erspan_init_net(struct net *net)\n \t\t\t\t  &erspan_link_ops, \"erspan0\");\n }\n \n-static void __net_exit erspan_exit_net(struct net *net)\n+static void __net_exit erspan_exit_batch_net(struct list_head *net_list)\n {\n-\tstruct ip_tunnel_net *itn = net_generic(net, erspan_net_id);\n-\n-\tip_tunnel_delete_net(itn, &erspan_link_ops);\n+\tip_tunnel_delete_nets(net_list, erspan_net_id, &erspan_link_ops);\n }\n \n static struct pernet_operations erspan_net_ops = {\n \t.init = erspan_init_net,\n-\t.exit = erspan_exit_net,\n+\t.exit_batch = erspan_exit_batch_net,\n \t.id   = &erspan_net_id,\n \t.size = sizeof(struct ip_tunnel_net),\n };\ndiff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c\nindex e9805ad664ac24c3405ad015cfaab89dc1c95279..fe6fee728ce49d01b55aa478698e1a3bcf9a3bdb 100644\n--- a/net/ipv4/ip_tunnel.c\n+++ b/net/ipv4/ip_tunnel.c\n@@ -1061,16 +1061,22 @@ static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head,\n \t}\n }\n \n-void ip_tunnel_delete_net(struct ip_tunnel_net *itn, struct rtnl_link_ops *ops)\n+void ip_tunnel_delete_nets(struct list_head *net_list, unsigned int id,\n+\t\t\t   struct rtnl_link_ops *ops)\n {\n+\tstruct ip_tunnel_net *itn;\n+\tstruct net *net;\n \tLIST_HEAD(list);\n \n \trtnl_lock();\n-\tip_tunnel_destroy(itn, &list, ops);\n+\tlist_for_each_entry(net, net_list, exit_list) {\n+\t\titn = net_generic(net, id);\n+\t\tip_tunnel_destroy(itn, &list, ops);\n+\t}\n \tunregister_netdevice_many(&list);\n \trtnl_unlock();\n }\n-EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);\n+EXPORT_SYMBOL_GPL(ip_tunnel_delete_nets);\n \n int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],\n \t\t      struct ip_tunnel_parm *p, __u32 fwmark)\ndiff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c\nindex 5ed63d25095062d44dacfd291e227290d24ea0ed..02d70ca99db16f2a50e3e179a05e74b535865f46 100644\n--- a/net/ipv4/ip_vti.c\n+++ b/net/ipv4/ip_vti.c\n@@ -452,15 +452,14 @@ static int __net_init vti_init_net(struct net *net)\n \treturn 0;\n }\n \n-static void __net_exit vti_exit_net(struct net *net)\n+static void __net_exit vti_exit_batch_net(struct list_head *list_net)\n {\n-\tstruct ip_tunnel_net *itn = net_generic(net, vti_net_id);\n-\tip_tunnel_delete_net(itn, &vti_link_ops);\n+\tip_tunnel_delete_nets(list_net, vti_net_id, &vti_link_ops);\n }\n \n static struct pernet_operations vti_net_ops = {\n \t.init = vti_init_net,\n-\t.exit = vti_exit_net,\n+\t.exit_batch = vti_exit_batch_net,\n \t.id   = &vti_net_id,\n \t.size = sizeof(struct ip_tunnel_net),\n };\ndiff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c\nindex fb1ad22b5e292d5669c70b5640ad3207c353c6bb..1e47818e38c766a3dab63dfa6bfa9610fa9550ac 100644\n--- a/net/ipv4/ipip.c\n+++ b/net/ipv4/ipip.c\n@@ -634,15 +634,14 @@ static int __net_init ipip_init_net(struct net *net)\n \treturn ip_tunnel_init_net(net, ipip_net_id, &ipip_link_ops, \"tunl0\");\n }\n \n-static void __net_exit ipip_exit_net(struct net *net)\n+static void __net_exit ipip_exit_batch_net(struct list_head *list_net)\n {\n-\tstruct ip_tunnel_net *itn = net_generic(net, ipip_net_id);\n-\tip_tunnel_delete_net(itn, &ipip_link_ops);\n+\tip_tunnel_delete_nets(list_net, ipip_net_id, &ipip_link_ops);\n }\n \n static struct pernet_operations ipip_net_ops = {\n \t.init = ipip_init_net,\n-\t.exit = ipip_exit_net,\n+\t.exit_batch = ipip_exit_batch_net,\n \t.id   = &ipip_net_id,\n \t.size = sizeof(struct ip_tunnel_net),\n };\n","prefixes":["v2","net-next","7/7"]}