{"id":815103,"url":"http://patchwork.ozlabs.org/api/1.2/patches/815103/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-8-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-8-edumazet@google.com>","list_archive_url":null,"date":"2017-09-18T19:07:33","name":"[net-next,7/7] ipv4: speedup ipv6 tunnels dismantle","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"6cfda8135b00bd40b21f793e6f503437513ffe96","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-8-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/815103/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815103/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=\"SF4rk8Gb\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwwWW18G4z9s7G\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 05:08:07 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751394AbdIRTH5 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 15:07:57 -0400","from mail-pf0-f175.google.com ([209.85.192.175]:44850 \"EHLO\n\tmail-pf0-f175.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751372AbdIRTHz (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 15:07:55 -0400","by mail-pf0-f175.google.com with SMTP id e1so716125pfk.1\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 12:07:54 -0700 (PDT)","from localhost ([2620:15c:2cb:201:1d19:43e0:8828:6785])\n\tby smtp.gmail.com with ESMTPSA id\n\tu12sm167738pfg.146.2017.09.18.12.07.53\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tMon, 18 Sep 2017 12:07:53 -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=LvQp3sLLPb87nv5TATLuZb0Kn2dymaiMUW8rhPrttYc=;\n\tb=SF4rk8Gbp0urs/OogkAMNGXHBsRhJ8gOHVe1hum/6Xz9fIxrJONQgOWuv33voQiKFu\n\tkCRBUs3x40DsZdCbxJn7R9pB23PPIpsDFQrqKI9Hlzp7I0W0K0j+JIZyPPovOOTYuUVn\n\t3ocLFqfCO5rsDHXmQWKyKjOXg4Q96TZAl+CHJVHpFQnS7naN7Cy70Bvx/lsFvQ6HHL5A\n\tJM/GWClVS228SDzRfrqKP/zOPUn0mt0b+p3rjrpZoI41uZNEb6W9+soU+g9jOt05wPAB\n\tP8K0mSGup97lhl4Wsrr7CQ+gNql2TpvfplXoh6CjBqahcmlrDDU67qr+MB07ONhl8lKO\n\tNurg==","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=LvQp3sLLPb87nv5TATLuZb0Kn2dymaiMUW8rhPrttYc=;\n\tb=otWJeWEhC8jfSxPHYm5la1oshLGErMb5WxwDu3QHLlFrcPZpgkpQNu0RBfXMN8zuf6\n\tY0EvrbkKGDjH7TyKm3Ux4mpisjpN64ruHjGSxohQq1jmh44MSJoRhVFU3Px5jkwQcPQF\n\trnfNOLB0r3LgUHgrxoOgG5HBB3nupK+R2mWGAqk4ygwFlQ35toYcH5OjMm7h/5/GzrNy\n\tfLVhVBsKRJ3c9AYOCBnfwTZvQV35tGY8b9D5bw3OFAS5w328fDqUgjs1zHwnL/xcsSWG\n\tRsCAb3ac5vmjTG+p5dHnWdGwna92xcv1YqTQLA5TiQzNgyabtHoBQL+vz50D2zImQtI3\n\t8lMw==","X-Gm-Message-State":"AHPjjUgXZic8Lnw6pu4bSjE9SiGhwnllAmQoUrIX1JnynlyxzY+n7N/n\n\txtxSsMBqmP5wFLrTKFz3QQ==","X-Google-Smtp-Source":"AOwi7QAQX21LIIiH4g/j7R6Dg9VxPAJFomSRaG9zAUN5GH1evgMZKDsqZUhIjm3+JFhQG/YxJI38VA==","X-Received":"by 10.99.160.2 with SMTP id r2mr19399748pge.158.1505761674195;\n\tMon, 18 Sep 2017 12:07:54 -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 7/7] ipv4: speedup ipv6 tunnels dismantle","Date":"Mon, 18 Sep 2017 12:07:33 -0700","Message-Id":"<20170918190733.26272-8-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        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     | 13 ++++++++++---\n net/ipv4/ip_vti.c        |  7 +++----\n net/ipv4/ipip.c          |  7 +++----\n 5 files changed, 27 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..a85a798b521093b38ff2d73b23eba9f26a6bbf0d 100644\n--- a/net/ipv4/ip_tunnel.c\n+++ b/net/ipv4/ip_tunnel.c\n@@ -1056,21 +1056,28 @@ static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head,\n \t\t\t/* If dev is in the same netns, it has already\n \t\t\t * been added to the list by the previous loop.\n \t\t\t */\n+// TODO use list_empty(&t->dev->unreg_list) in unregister_netdevice_queue ?\n \t\t\tif (!net_eq(dev_net(t->dev), net))\n \t\t\t\tunregister_netdevice_queue(t->dev, 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":["net-next","7/7"]}