{"id":815100,"url":"http://patchwork.ozlabs.org/api/1.2/patches/815100/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-6-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-6-edumazet@google.com>","list_archive_url":null,"date":"2017-09-18T19:07:31","name":"[net-next,5/7] tcp: batch tcp_net_metrics_exit","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"26e0df817b9851de0d8653e0eb78127d1634d786","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-6-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/815100/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815100/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=\"Sd9W4qmk\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwwWK695zz9s7p\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 05:07:57 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751353AbdIRTHv (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 15:07:51 -0400","from mail-pg0-f42.google.com ([74.125.83.42]:46819 \"EHLO\n\tmail-pg0-f42.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751024AbdIRTHt (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 15:07:49 -0400","by mail-pg0-f42.google.com with SMTP id i130so659156pgc.3\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 12:07:48 -0700 (PDT)","from localhost ([2620:15c:2cb:201:1d19:43e0:8828:6785])\n\tby smtp.gmail.com with ESMTPSA id\n\th10sm161980pgn.73.2017.09.18.12.07.47\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tMon, 18 Sep 2017 12:07:47 -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=fD2eZz0RGu0ESHFUZTkrn1B+ZlO2UcSoclDfSo4DGSs=;\n\tb=Sd9W4qmkfovW3nBA6TLhBI7JVQG88jZdc9Go6vjPciGXmuOCmcTFoXyRMiFHZPQ4ir\n\tuW+L8SSf7SohGOYcNuyuil+l7j3eBWN47jM77d0+S0VKaL5U32PJwj4VYeIfeJlUXnci\n\tehTK4DFrxaUyfXkpyZsDBzBnWhszB96r04QDrtov62L+DAW5tCkwnZ/QhoRUt8uOrnqh\n\t/2jK1x+jnxf41CFtpbgx6Hc5NrAvpb1uPywUHgiZ+4Mpm2Kdlm9j4ZLrdgs9cnTUx3yY\n\tPxvt2j1bAtwLvN0wjQ7ixodUTvWTHNwj55ePqPggr6sb4GNmGTVRLtrgzIAj/G0vahCS\n\tTxlg==","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=fD2eZz0RGu0ESHFUZTkrn1B+ZlO2UcSoclDfSo4DGSs=;\n\tb=XD3Idj2QYM0/ZJbQvUC1g2tZS5ZASDs3SIEf0opt8ncF/3UCwbcH42ODI/QIlGR1M7\n\tbOM2bTmfVtmjP7Hp6EbR6o0eDwOwujewRqLdCMpC7HU+W3PiDi69U7A28zJ4MOjbwdnu\n\t9olfKQzUK0SOSxo5bt+yWKCRRb7nL0bEVmJzafczjEsYo1u+C87zejrhEon7fBuG5luV\n\ti1MeE5cYZ+L+JL0iQeu160X4xyOKn+VRnSe0WB1tTS2Rdekctmmx8RmlVucDf7g1vB74\n\tqkcpksD6naRFIsqmNyZ9OQ4BJqMcIpYbPMjLh89FJ9NxaCMJKDtgQh53hDP9TmfmP0Zw\n\tzu1A==","X-Gm-Message-State":"AHPjjUhK8awhxXmFcA8lMruwJZiu46mMo0c44Zbx3IAQ4Jh3azi2AXit\n\tXRI/DfRoQbEcSRAh","X-Google-Smtp-Source":"AOwi7QDxThoWC+tFDg50ORCbQSjNBv3agu13VAMGXWQuWGGPWdyURW8iphVkDpH9MbwBXQHa32WV2A==","X-Received":"by 10.98.147.137 with SMTP id r9mr20128820pfk.161.1505761668021; \n\tMon, 18 Sep 2017 12:07:48 -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 5/7] tcp: batch tcp_net_metrics_exit","Date":"Mon, 18 Sep 2017 12:07:31 -0700","Message-Id":"<20170918190733.26272-6-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":"When dealing with a list of dismantling netns, we can scan\ntcp_metrics once, saving cpu cycles.\n\nSigned-off-by: Eric Dumazet <edumazet@google.com>\n---\n net/ipv4/tcp_metrics.c | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)","diff":"diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c\nindex 102b2c90bb807d3a88d31b59324baf72cf901cdf..0ab78abc811bef0388089befed672e3d4ee9d881 100644\n--- a/net/ipv4/tcp_metrics.c\n+++ b/net/ipv4/tcp_metrics.c\n@@ -892,10 +892,14 @@ static void tcp_metrics_flush_all(struct net *net)\n \n \tfor (row = 0; row < max_rows; row++, hb++) {\n \t\tstruct tcp_metrics_block __rcu **pp;\n+\t\tbool match;\n+\n \t\tspin_lock_bh(&tcp_metrics_lock);\n \t\tpp = &hb->chain;\n \t\tfor (tm = deref_locked(*pp); tm; tm = deref_locked(*pp)) {\n-\t\t\tif (net_eq(tm_net(tm), net)) {\n+\t\t\tmatch = net ? net_eq(tm_net(tm), net) :\n+\t\t\t\t!atomic_read(&tm_net(tm)->count);\n+\t\t\tif (match) {\n \t\t\t\t*pp = tm->tcpm_next;\n \t\t\t\tkfree_rcu(tm, rcu_head);\n \t\t\t} else {\n@@ -1018,14 +1022,14 @@ static int __net_init tcp_net_metrics_init(struct net *net)\n \treturn 0;\n }\n \n-static void __net_exit tcp_net_metrics_exit(struct net *net)\n+static void __net_exit tcp_net_metrics_exit_batch(struct list_head *net_exit_list)\n {\n-\ttcp_metrics_flush_all(net);\n+\ttcp_metrics_flush_all(NULL);\n }\n \n static __net_initdata struct pernet_operations tcp_net_metrics_ops = {\n-\t.init\t=\ttcp_net_metrics_init,\n-\t.exit\t=\ttcp_net_metrics_exit,\n+\t.init\t\t=\ttcp_net_metrics_init,\n+\t.exit_batch\t=\ttcp_net_metrics_exit_batch,\n };\n \n void __init tcp_metrics_init(void)\n","prefixes":["net-next","5/7"]}