{"id":815942,"url":"http://patchwork.ozlabs.org/api/patches/815942/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170919232709.14690-6-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-6-edumazet@google.com>","list_archive_url":null,"date":"2017-09-19T23:27:07","name":"[v2,net-next,5/7] tcp: batch tcp_net_metrics_exit","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"26e0df817b9851de0d8653e0eb78127d1634d786","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-6-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/815942/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815942/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=\"ppWvqJwo\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxfDJ1D8Jz9sPr\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 20 Sep 2017 09:27:28 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751746AbdISX10 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 19:27:26 -0400","from mail-pf0-f177.google.com ([209.85.192.177]:57339 \"EHLO\n\tmail-pf0-f177.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751728AbdISX1X (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 19:27:23 -0400","by mail-pf0-f177.google.com with SMTP id g65so591007pfe.13\n\tfor <netdev@vger.kernel.org>; Tue, 19 Sep 2017 16:27:23 -0700 (PDT)","from localhost ([2620:15c:2cb:201:58bc:17b0:6372:1d5f])\n\tby smtp.gmail.com with ESMTPSA id\n\tf3sm6942414pfd.82.2017.09.19.16.27.22\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tTue, 19 Sep 2017 16:27:22 -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=ppWvqJwo8bcl6FHiWNNsQdTGmF0rAD4qXBNQa7t1D72A8TswhotXEcB1S81wQPzGxR\n\tzMujn7Hy9U7+k9liGXl040oxd2nEA1fNufh6Z9/7WCqZvaOfhId3qFGefMTupuBifHGp\n\tOG0oRo/+4WGYkVCLVaWlc/o5US3fEOsdZSIqeNCjr0C0STzzwqF3a5CGW+FkWEWs47Q1\n\tL4+5sAJZOeIgylyKBG9lj70le9F37HDfHHpVCTIU1EsMSy1GNoMPwNQfAVxokuLs4pz1\n\tIHi6BED3/nqoTtzr9sImFpduRZMPGuhnkvMi4jiRHvgoG5fA4S5OYS4+SrJzAXpyJ/53\n\tmGXw==","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=a1rKD4fE6foyr8y0LvaUWSrs2M+4K7nnld6/NCBC498flMtLgo9L/mnv0Upz1FeCPg\n\tHv+b7Xfd5tVEjI5D4KpRxqfzcy5LdjmMhN0asKkx2aDrhT8gGb51ToEXxoVNs2ccfcgL\n\t8krMALSJ6GAovLoA2E7YMtfoO1KsGQ0F9RwwnOIYdO0J24ubSJg5WTPy0CWDChhiSsph\n\tMWEoS7W6Tmf0z5FwcergBVvOarY9EMBOOrzJlLgzMXH6bM7JUo0RVL0z38SKbpx2Z8EF\n\tqCgw6k++pPBEYvrgMnDX7WNJR3/wbin8jCmJ1AMN4RfV+kTkGQ9i+ldkkQXr9baiCLDs\n\tKtlg==","X-Gm-Message-State":"AHPjjUjXuB2FIQ3Btrwoyg0713dd70nm8vOiQD4fsiLjKF/G0MgVnAl/\n\tkaa5/eR94IxhJHq/DGxAwkMxYQ==","X-Google-Smtp-Source":"AOwi7QDWR2Jyi75Zjh3dUpd3XWTlC6Hhu4tmWHYmifF7jzfh6mte2F84beSKlnVk3KwBtwB2HZWxjQ==","X-Received":"by 10.99.186.81 with SMTP id l17mr247755pgu.170.1505863642978;\n\tTue, 19 Sep 2017 16:27:22 -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 5/7] tcp: batch tcp_net_metrics_exit","Date":"Tue, 19 Sep 2017 16:27:07 -0700","Message-Id":"<20170919232709.14690-6-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":"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":["v2","net-next","5/7"]}