From patchwork Thu Oct 7 17:49:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12542493 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B29EC43217 for ; Thu, 7 Oct 2021 17:51:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6484B61248 for ; Thu, 7 Oct 2021 17:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243063AbhJGRxN (ORCPT ); Thu, 7 Oct 2021 13:53:13 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:38506 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243383AbhJGRxG (ORCPT ); Thu, 7 Oct 2021 13:53:06 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1633629068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOMWDoD1SdKXS/QHNB7RZQwaZoX8OvnSfKd24MnYn+M=; b=yvBf6Q7eADeluCZtE/HRvDGSw/D2mFcxgO+4Sop7TD3hgln+vwAH6MqSpNH0bn4rXnWqqf AMkCEHmLD4Gg92M4XhYp/fOXKBvN0WZSMAKWjQdHnvuK7597SeNcHHOStyuA0guGUK+KNx FX6OFGEe+3tKpmC2WwY2+RiTRM3Kv+BTh22MzrfIzhJzVSthJEGN/vuprfIT8hJ5IkQs0d 6+1gYr+FKbb/c4R7P5RpPzQ1S9U/eYZyHE8Jo7DOdzs2bb9CX9IxZcxose6lNaHJdmbk68 4AghMhGxnMu5h9MY9QS3SvQOAd31+qE29FL3atFkngsJJ+8WYc7Gya9OAOC31g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1633629068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOMWDoD1SdKXS/QHNB7RZQwaZoX8OvnSfKd24MnYn+M=; b=wpv8QHlzD47W0dYjeeqtVgqC4LzJNnwZeSECdcq79P/f9Ww0d+ACtN0m68dBOc1OXeB3J2 fwWdzxJXcUpxlZBg== To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Thomas Gleixner , "Ahmed S. Darwish" , Sebastian Andrzej Siewior Subject: [PATCH net-next 2/4] gen_stats: Add instead Set the value in __gnet_stats_copy_basic(). Date: Thu, 7 Oct 2021 19:49:58 +0200 Message-Id: <20211007175000.2334713-3-bigeasy@linutronix.de> In-Reply-To: <20211007175000.2334713-1-bigeasy@linutronix.de> References: <20211007175000.2334713-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since day one __gnet_stats_copy_basic() always assigned the value to the bstats argument overwriting the previous value. Based on review there are five users of that function as of today: - est_fetch_counters(), ___gnet_stats_copy_basic() memsets() bstats to zero, single invocation. - mq_dump(), mqprio_dump(), mqprio_dump_class_stats() memsets() bstats to zero, multiple invocation but does not use the function due to !qdisc_is_percpu_stats(). It will probably simplify in percpu stats case if the value would be added and not just stored. Signed-off-by: Sebastian Andrzej Siewior --- net/core/gen_stats.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c index e491b083b3485..e12e544a7ab0f 100644 --- a/net/core/gen_stats.c +++ b/net/core/gen_stats.c @@ -143,6 +143,8 @@ __gnet_stats_copy_basic(const seqcount_t *running, struct gnet_stats_basic_packed *b) { unsigned int seq; + __u64 bytes = 0; + __u64 packets = 0; if (cpu) { __gnet_stats_copy_basic_cpu(bstats, cpu); @@ -151,9 +153,12 @@ __gnet_stats_copy_basic(const seqcount_t *running, do { if (running) seq = read_seqcount_begin(running); - bstats->bytes = b->bytes; - bstats->packets = b->packets; + bytes = b->bytes; + packets = b->packets; } while (running && read_seqcount_retry(running, seq)); + + bstats->bytes += bytes; + bstats->packets += packets; } EXPORT_SYMBOL(__gnet_stats_copy_basic);