From patchwork Mon Oct 12 08:15:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11831901 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E1A7C43467 for ; Mon, 12 Oct 2020 08:22:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC423208FE for ; Mon, 12 Oct 2020 08:22:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u6vzQZjp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbgJLIWG (ORCPT ); Mon, 12 Oct 2020 04:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbgJLIVx (ORCPT ); Mon, 12 Oct 2020 04:21:53 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AC2C0613CE; Mon, 12 Oct 2020 01:21:52 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id c22so22023367ejx.0; Mon, 12 Oct 2020 01:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=K5p6PQe9PHlb+DeFu3qCLN+dyNKfD6AR/iCNZWeTJCc=; b=u6vzQZjpjUwAoxgsdIvqGoW2wscsD+27fYStwCH0/DAdwWm40pGzmqma6NZfzR2nY4 FraHh5xiK/XNO/MGkH2q10HSSExTebIq4cBbJ5G0a+fA1d5/0R0JL0xHn2iWHdC4cXjh 3zcrCQJXT974X8B2at1b6ft2C7z6Wni/rrcSNWwAS16OOfclGUAxh3qlA5QQYpmDMr5+ SBfTMY55MMCVP6q9lIzHYl9Lf8zxTCzI/ADBY5mYJYrF0q9NQxICntDL6447ROzmLpbJ ccZIbeOlF2Vt9eZEOvuJCUrmFAhAZZYOBEGA6EH4/cDWprQdM7QP/i/4RE/eeApna4oe wlwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=K5p6PQe9PHlb+DeFu3qCLN+dyNKfD6AR/iCNZWeTJCc=; b=a+CpWMryDOscdStr5eHe0d4DCeR1BoG9ICCxBEVVGSSVqVlm4Gb+HvVRuAM9W8Pzc1 csvb/3X+caN624L9Lxg/ICIW4f7kQyb3LcqsoktbXxisbGpdXNjyu4scFFSVPsHE1/Up VZOzrlcp26zjl+T2pm0vuF97LPE0/KAWInI5/a/UDXvX4Qy1K4EwknCv8rPJL697ojLT PZKhPrc98NrvIW1p9BdNQEx6IRP2VVR8OflQfrpPnbh642wctnTu4LxfRhQLh/UNEi95 3xYZc53RBEHUWL15K9MrgRur4f0hj34VVdFEGsZsfebQu4OAeqzRmoheKlFqz8lPbLKg lQ+w== X-Gm-Message-State: AOAM530w87t82TOBZIVbltJIlvE+WnCRPXaHn4Gnzd8CNZ//pD2cNlm2 p2WGsjtnBg7+g0uh+xO3sysqmedW9y5B8g== X-Google-Smtp-Source: ABdhPJzpn3UQ1NZ0j3vtYPuMV0pGk+0sppVmn15F/C759IM7WrJi58wx79UeJABZsLX6vgSyVZ/9pA== X-Received: by 2002:a17:906:ae48:: with SMTP id lf8mr15228828ejb.345.1602490911396; Mon, 12 Oct 2020 01:21:51 -0700 (PDT) Received: from ?IPv6:2003:ea:8f00:6a00:f90c:2907:849f:701c? (p200300ea8f006a00f90c2907849f701c.dip0.t-ipconnect.de. [2003:ea:8f00:6a00:f90c:2907:849f:701c]) by smtp.googlemail.com with ESMTPSA id q27sm10354699ejd.74.2020.10.12.01.21.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Oct 2020 01:21:51 -0700 (PDT) Subject: [PATCH net-next v2 07/12] net: bridge: use new function dev_fetch_sw_netstats From: Heiner Kallweit To: David Miller , Jakub Kicinski , =?utf-8?q?Bj=C3=B8rn_Mork?= , Oliver Neukum , Igor Mitsyanko , Sergey Matyukevich , Kalle Valo , Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Alexey Kuznetsov , Hideaki YOSHIFUJI , Johannes Berg , Pravin B Shelar , Steffen Klassert , Herbert Xu Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org, Linux USB Mailing List , linux-wireless , bridge@lists.linux-foundation.org References: Message-ID: Date: Mon, 12 Oct 2020 10:15:22 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Simplify the code by using new function dev_fetch_sw_netstats(). Signed-off-by: Heiner Kallweit --- net/bridge/br_device.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 9a2fb4aa1..6f742fee8 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -206,27 +206,8 @@ static void br_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct net_bridge *br = netdev_priv(dev); - struct pcpu_sw_netstats tmp, sum = { 0 }; - unsigned int cpu; - - for_each_possible_cpu(cpu) { - unsigned int start; - const struct pcpu_sw_netstats *bstats - = per_cpu_ptr(br->stats, cpu); - do { - start = u64_stats_fetch_begin_irq(&bstats->syncp); - memcpy(&tmp, bstats, sizeof(tmp)); - } while (u64_stats_fetch_retry_irq(&bstats->syncp, start)); - sum.tx_bytes += tmp.tx_bytes; - sum.tx_packets += tmp.tx_packets; - sum.rx_bytes += tmp.rx_bytes; - sum.rx_packets += tmp.rx_packets; - } - stats->tx_bytes = sum.tx_bytes; - stats->tx_packets = sum.tx_packets; - stats->rx_bytes = sum.rx_bytes; - stats->rx_packets = sum.rx_packets; + dev_fetch_sw_netstats(stats, br->stats); } static int br_change_mtu(struct net_device *dev, int new_mtu)