From patchwork Sat Oct 16 08:49:03 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: 12563327 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 274DFC4332F for ; Sat, 16 Oct 2021 08:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B30560EC0 for ; Sat, 16 Oct 2021 08:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243876AbhJPIvd (ORCPT ); Sat, 16 Oct 2021 04:51:33 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:55088 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239889AbhJPIv3 (ORCPT ); Sat, 16 Oct 2021 04:51:29 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1634374160; 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=yT4LQKypoYY1sKemdKiMLaN9Yxk5PY1d95laAk6+74s=; b=Nu5M/lYslGw85Rlp494Tt9RkoyPGRMu9cDop2q1Tyu6j1Cq+LWe7CnPr6det+3QQ0eU9yr Y/pUZ4wnG8PQVgrE825N3bTvvJzPe7rzP1Q5iRATNXRhWYIhARsMxtAdPLAhxNt1amwlmM 399Acv6vyjOHAYfDD18rB6H96QTl3iJWBUL/d45a7dyp/Qk3cYykef4VS6Jbb5tsRPpEMi y/tF7RpZRmpttO1uARXmEs0uQOMjnpnbPp7a/+tFoL47ymg0ntZcEqwMYbG6bB3QcC5UHN JnxZuIlRUjdeQ0XEX6+9aTELkVQpOT01VsZdwLRhiHE9y35sU9V+ni87+0Lgrw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1634374160; 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=yT4LQKypoYY1sKemdKiMLaN9Yxk5PY1d95laAk6+74s=; b=KvhTIr4+QrrRqMSqTwhLHGzEATCgIXRAze5TwSIaaTnO826tvg3n/k4BhcSdZjFalI/Ogi fwI7jsqnunEtcJBw== To: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "Ahmed S. Darwish" , Eric Dumazet , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 2/9] gen_stats: Add gnet_stats_add_queue(). Date: Sat, 16 Oct 2021 10:49:03 +0200 Message-Id: <20211016084910.4029084-3-bigeasy@linutronix.de> In-Reply-To: <20211016084910.4029084-1-bigeasy@linutronix.de> References: <20211016084910.4029084-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 This function will replace __gnet_stats_copy_queue(). It reads all arguments and adds them into the passed gnet_stats_queue argument. In contrast to __gnet_stats_copy_queue() it also copies the qlen member. Signed-off-by: Sebastian Andrzej Siewior --- include/net/gen_stats.h | 3 +++ net/core/gen_stats.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h index 25740d004bdb0..148f0ba85f25a 100644 --- a/include/net/gen_stats.h +++ b/include/net/gen_stats.h @@ -62,6 +62,9 @@ int gnet_stats_copy_queue(struct gnet_dump *d, void __gnet_stats_copy_queue(struct gnet_stats_queue *qstats, const struct gnet_stats_queue __percpu *cpu_q, const struct gnet_stats_queue *q, __u32 qlen); +void gnet_stats_add_queue(struct gnet_stats_queue *qstats, + const struct gnet_stats_queue __percpu *cpu_q, + const struct gnet_stats_queue *q); int gnet_stats_copy_app(struct gnet_dump *d, void *st, int len); int gnet_stats_finish_copy(struct gnet_dump *d); diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c index 25d7c0989b83f..26c020a7ead49 100644 --- a/net/core/gen_stats.c +++ b/net/core/gen_stats.c @@ -321,6 +321,38 @@ void __gnet_stats_copy_queue(struct gnet_stats_queue *qstats, } EXPORT_SYMBOL(__gnet_stats_copy_queue); +static void gnet_stats_add_queue_cpu(struct gnet_stats_queue *qstats, + const struct gnet_stats_queue __percpu *q) +{ + int i; + + for_each_possible_cpu(i) { + const struct gnet_stats_queue *qcpu = per_cpu_ptr(q, i); + + qstats->qlen += qcpu->backlog; + qstats->backlog += qcpu->backlog; + qstats->drops += qcpu->drops; + qstats->requeues += qcpu->requeues; + qstats->overlimits += qcpu->overlimits; + } +} + +void gnet_stats_add_queue(struct gnet_stats_queue *qstats, + const struct gnet_stats_queue __percpu *cpu, + const struct gnet_stats_queue *q) +{ + if (cpu) { + gnet_stats_add_queue_cpu(qstats, cpu); + } else { + qstats->qlen += q->qlen; + qstats->backlog += q->backlog; + qstats->drops += q->drops; + qstats->requeues += q->requeues; + qstats->overlimits += q->overlimits; + } +} +EXPORT_SYMBOL(gnet_stats_add_queue); + /** * gnet_stats_copy_queue - copy queue statistics into statistics TLV * @d: dumping handle