{"id":815102,"url":"http://patchwork.ozlabs.org/api/1.2/patches/815102/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-7-edumazet@google.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20170918190733.26272-7-edumazet@google.com>","list_archive_url":null,"date":"2017-09-18T19:07:32","name":"[net-next,6/7] ipv6: speedup ipv6 tunnels dismantle","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"91aeb3e12d0c22a898f4aacbad814159bc214459","submitter":{"id":13357,"url":"http://patchwork.ozlabs.org/api/1.2/people/13357/?format=json","name":"Eric Dumazet","email":"edumazet@google.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-7-edumazet@google.com/mbox/","series":[{"id":3713,"url":"http://patchwork.ozlabs.org/api/1.2/series/3713/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3713","date":"2017-09-18T19:07:26","name":"net: speedup netns create/delete time","version":1,"mbox":"http://patchwork.ozlabs.org/series/3713/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815102/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815102/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=\"vKzKN0cs\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwwWN656Pz9s81\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 05:08:00 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751411AbdIRTH7 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 15:07:59 -0400","from mail-pf0-f176.google.com ([209.85.192.176]:46090 \"EHLO\n\tmail-pf0-f176.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751302AbdIRTHu (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 15:07:50 -0400","by mail-pf0-f176.google.com with SMTP id e199so713192pfh.3\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 12:07:50 -0700 (PDT)","from localhost ([2620:15c:2cb:201:1d19:43e0:8828:6785])\n\tby smtp.gmail.com with ESMTPSA id\n\tu20sm119570pfh.171.2017.09.18.12.07.49\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tMon, 18 Sep 2017 12:07:49 -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=COUHFUArzfrvB7FD0hZyfHzYLAi3PufRxFnIrMcrrmA=;\n\tb=vKzKN0cssnYM11meN1pCKBvxNw8mDcrf4+TnGC3vIShJ3rSynLyFWVkTX4FS2KZFmu\n\tMag/ioNmKxk2akc4l2Nt19ikKK+EIkO5LN84iNny0Hu24vkG7NWt29zhIXczDTsmDFYp\n\taxFuib4n2weZJMidydHp8bZm20JEI1TGxO+hwPNglfq7dBQLMQywLMgpKwr6Z/QP2G4M\n\teuHv20Hs2CyMaC/qjRdBCBZGNTyhpvvSgsWw43+6qhdFuA0H4+uR7xhO8OWOU21oTQtO\n\tR7IG0OpiPAw6LwBDq06pOg50c+z6fRjg2YT7jkyiXaYGUyb5tpJX+An4prIVNRBRHxvI\n\t/PMg==","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=COUHFUArzfrvB7FD0hZyfHzYLAi3PufRxFnIrMcrrmA=;\n\tb=RclalgefTkU2b7hkvWAptbagB/70vw3JonhwhhESpKflnY54twaoaF2IckNOYLMBxL\n\tKIQQuTsPWWCIRec/om4syKZfEvo6Ow8DOGQYbK/4NaOWp+NcDNwdTiGxJSzX4+VDyduj\n\to33GGw9xhhghPc3k/0MbwAz80l09lhbwpkyxSzMsnStRsBk/x49VGICCXgiUgfqYJmx9\n\ts6ePZWe5zooGD77SB7UDobm0ZcIsgMcJCnjbhQ4XplY2tJJSxDH5BQQ3VV0oLBQ4146Y\n\tonAyfWtHLkdsjE1ATOWrnbvq0MUGHGvQ4F/YLsA0TIgfWQ61KCbmyUlD8BBRCmEW6wte\n\thn8w==","X-Gm-Message-State":"AHPjjUgzIGwjIRGAKN6rRTnodqeNP36G+psnjeSBnci8yJNnFmVAEJhy\n\tDfivE64sOkvqMM7k","X-Google-Smtp-Source":"ADKCNb790t/MViHmMpc5ko3PdPLC7tjFverwTiGxBHLIcaNSqhULMD77ajCGP6XI4lNA4eN7HvA7hQ==","X-Received":"by 10.84.151.68 with SMTP id i62mr25452158pli.179.1505761669744; \n\tMon, 18 Sep 2017 12:07:49 -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 net-next 6/7] ipv6: speedup ipv6 tunnels dismantle","Date":"Mon, 18 Sep 2017 12:07:32 -0700","Message-Id":"<20170918190733.26272-7-edumazet@google.com>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170918190733.26272-1-edumazet@google.com>","References":"<20170918190733.26272-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        110    267   5504    1    2 : tunables    8    4    0 : slabdata    110    267      0\n\nreal    3m25.292s\nuser    0m0.644s\nsys     0m40.153s\n\nAfter patch:\n\n$ time ./add_del_unshare.sh\nnet_namespace        126    282   5504    1    2 : tunables    8    4    0 : slabdata    126    282      0\n\nreal\t1m38.965s\nuser\t0m0.688s\nsys\t0m37.017s\n\nSigned-off-by: Eric Dumazet <edumazet@google.com>\n---\n net/ipv6/ip6_gre.c    |  8 +++++---\n net/ipv6/ip6_tunnel.c | 20 +++++++++++---------\n net/ipv6/ip6_vti.c    | 23 ++++++++++++++---------\n net/ipv6/sit.c        |  9 ++++++---\n 4 files changed, 36 insertions(+), 24 deletions(-)","diff":"diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c\nindex b7a72d40933441f835708f55e2d8af371661a5fb..c82d41ef25e283ff92b1eed1f8b927c9d7b8f333 100644\n--- a/net/ipv6/ip6_gre.c\n+++ b/net/ipv6/ip6_gre.c\n@@ -1155,19 +1155,21 @@ static int __net_init ip6gre_init_net(struct net *net)\n \treturn err;\n }\n \n-static void __net_exit ip6gre_exit_net(struct net *net)\n+static void __net_exit ip6gre_exit_batch_net(struct list_head *net_list)\n {\n+\tstruct net *net;\n \tLIST_HEAD(list);\n \n \trtnl_lock();\n-\tip6gre_destroy_tunnels(net, &list);\n+\tlist_for_each_entry(net, net_list, exit_list)\n+\t\tip6gre_destroy_tunnels(net, &list);\n \tunregister_netdevice_many(&list);\n \trtnl_unlock();\n }\n \n static struct pernet_operations ip6gre_net_ops = {\n \t.init = ip6gre_init_net,\n-\t.exit = ip6gre_exit_net,\n+\t.exit_batch = ip6gre_exit_batch_net,\n \t.id   = &ip6gre_net_id,\n \t.size = sizeof(struct ip6gre_net),\n };\ndiff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c\nindex ae73164559d5c4d7f2650ae63c56d76dc93b165c..3d6df489b39f00014f330340927c4d11a64911c2 100644\n--- a/net/ipv6/ip6_tunnel.c\n+++ b/net/ipv6/ip6_tunnel.c\n@@ -2167,17 +2167,16 @@ static struct xfrm6_tunnel ip6ip6_handler __read_mostly = {\n \t.priority\t=\t1,\n };\n \n-static void __net_exit ip6_tnl_destroy_tunnels(struct net *net)\n+static void __net_exit ip6_tnl_destroy_tunnels(struct net *net, struct list_head *list)\n {\n \tstruct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);\n \tstruct net_device *dev, *aux;\n \tint h;\n \tstruct ip6_tnl *t;\n-\tLIST_HEAD(list);\n \n \tfor_each_netdev_safe(net, dev, aux)\n \t\tif (dev->rtnl_link_ops == &ip6_link_ops)\n-\t\t\tunregister_netdevice_queue(dev, &list);\n+\t\t\tunregister_netdevice_queue(dev, list);\n \n \tfor (h = 0; h < IP6_TUNNEL_HASH_SIZE; h++) {\n \t\tt = rtnl_dereference(ip6n->tnls_r_l[h]);\n@@ -2186,12 +2185,10 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct net *net)\n \t\t\t * been added to the list by the previous loop.\n \t\t\t */\n \t\t\tif (!net_eq(dev_net(t->dev), net))\n-\t\t\t\tunregister_netdevice_queue(t->dev, &list);\n+\t\t\t\tunregister_netdevice_queue(t->dev, list);\n \t\t\tt = rtnl_dereference(t->next);\n \t\t}\n \t}\n-\n-\tunregister_netdevice_many(&list);\n }\n \n static int __net_init ip6_tnl_init_net(struct net *net)\n@@ -2235,16 +2232,21 @@ static int __net_init ip6_tnl_init_net(struct net *net)\n \treturn err;\n }\n \n-static void __net_exit ip6_tnl_exit_net(struct net *net)\n+static void __net_exit ip6_tnl_exit_batch_net(struct list_head *net_list)\n {\n+\tstruct net *net;\n+\tLIST_HEAD(list);\n+\n \trtnl_lock();\n-\tip6_tnl_destroy_tunnels(net);\n+\tlist_for_each_entry(net, net_list, exit_list)\n+\t\tip6_tnl_destroy_tunnels(net, &list);\n+\tunregister_netdevice_many(&list);\n \trtnl_unlock();\n }\n \n static struct pernet_operations ip6_tnl_net_ops = {\n \t.init = ip6_tnl_init_net,\n-\t.exit = ip6_tnl_exit_net,\n+\t.exit_batch = ip6_tnl_exit_batch_net,\n \t.id   = &ip6_tnl_net_id,\n \t.size = sizeof(struct ip6_tnl_net),\n };\ndiff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c\nindex 79444a4bfd6d245b66a7edcefe2b5b32801bf2c0..714914d1bb987c46cc98817903ec7bcc367a1b2d 100644\n--- a/net/ipv6/ip6_vti.c\n+++ b/net/ipv6/ip6_vti.c\n@@ -1052,23 +1052,22 @@ static struct rtnl_link_ops vti6_link_ops __read_mostly = {\n \t.get_link_net\t= ip6_tnl_get_link_net,\n };\n \n-static void __net_exit vti6_destroy_tunnels(struct vti6_net *ip6n)\n+static void __net_exit vti6_destroy_tunnels(struct vti6_net *ip6n,\n+\t\t\t\t\t    struct list_head *list)\n {\n \tint h;\n \tstruct ip6_tnl *t;\n-\tLIST_HEAD(list);\n \n \tfor (h = 0; h < IP6_VTI_HASH_SIZE; h++) {\n \t\tt = rtnl_dereference(ip6n->tnls_r_l[h]);\n \t\twhile (t) {\n-\t\t\tunregister_netdevice_queue(t->dev, &list);\n+\t\t\tunregister_netdevice_queue(t->dev, list);\n \t\t\tt = rtnl_dereference(t->next);\n \t\t}\n \t}\n \n \tt = rtnl_dereference(ip6n->tnls_wc[0]);\n-\tunregister_netdevice_queue(t->dev, &list);\n-\tunregister_netdevice_many(&list);\n+\tunregister_netdevice_queue(t->dev, list);\n }\n \n static int __net_init vti6_init_net(struct net *net)\n@@ -1108,18 +1107,24 @@ static int __net_init vti6_init_net(struct net *net)\n \treturn err;\n }\n \n-static void __net_exit vti6_exit_net(struct net *net)\n+static void __net_exit vti6_exit_batch_net(struct list_head *net_list)\n {\n-\tstruct vti6_net *ip6n = net_generic(net, vti6_net_id);\n+\tstruct vti6_net *ip6n;\n+\tstruct net *net;\n+\tLIST_HEAD(list);\n \n \trtnl_lock();\n-\tvti6_destroy_tunnels(ip6n);\n+\tlist_for_each_entry(net, net_list, exit_list) {\n+\t\tip6n = net_generic(net, vti6_net_id);\n+\t\tvti6_destroy_tunnels(ip6n, &list);\n+\t}\n+\tunregister_netdevice_many(&list);\n \trtnl_unlock();\n }\n \n static struct pernet_operations vti6_net_ops = {\n \t.init = vti6_init_net,\n-\t.exit = vti6_exit_net,\n+\t.exit_batch = vti6_exit_batch_net,\n \t.id   = &vti6_net_id,\n \t.size = sizeof(struct vti6_net),\n };\ndiff --git a/net/ipv6/sit.c b/net/ipv6/sit.c\nindex ac912bb217471c048df3b76aa3d7b82886221dc1..a799f525861487ad5b822ab62cdc90f6ca06762f 100644\n--- a/net/ipv6/sit.c\n+++ b/net/ipv6/sit.c\n@@ -1848,19 +1848,22 @@ static int __net_init sit_init_net(struct net *net)\n \treturn err;\n }\n \n-static void __net_exit sit_exit_net(struct net *net)\n+static void __net_exit sit_exit_batch_net(struct list_head *net_list)\n {\n \tLIST_HEAD(list);\n+\tstruct net *net;\n \n \trtnl_lock();\n-\tsit_destroy_tunnels(net, &list);\n+\tlist_for_each_entry(net, net_list, exit_list)\n+\t\tsit_destroy_tunnels(net, &list);\n+\n \tunregister_netdevice_many(&list);\n \trtnl_unlock();\n }\n \n static struct pernet_operations sit_net_ops = {\n \t.init = sit_init_net,\n-\t.exit = sit_exit_net,\n+\t.exit_batch = sit_exit_batch_net,\n \t.id   = &sit_net_id,\n \t.size = sizeof(struct sit_net),\n };\n","prefixes":["net-next","6/7"]}