🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4910

Re: [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring

#4910
From: "Daniel Zahka"
Date: Mon, 19 Oct 2026 13:04
44 lines
10456 bytes
On Fri Oct 16, 2026 at 6:09 PM EDT, Sebastian Andrzej Siewior wrote:
> On 2026-10-12 05:04:34 [-0700], Daniel Zahka wrote:
>> Keep packet, byte and drop counters on each Tx work, Tx completion, and
>> Rx completion queue. Report them to the core via the rtnl_link_stats64
>> interface.
>> 
>> Rx completion queues also count errors. Frames the device marked with an
>> uncorrectable error are counted as errors, and frames that fail for any
>> other reason are counted as drops.
>> 
>> All packets cleaned from the TWQ during mpnic_flush() are counted as
>> drops, though completions for some of them may have been DMA'd into
>> the completion ring between the time mpnic_poll() last ran and before
>> mpnic_wait_all_queues_idle() returns. This is done for code simplicity.
>> 
>> An RCU approach is used because ndo_get_stats64 is not called with the
>> instance lock.
>
> Why do you have the two mpnic_base_stats and fold the stats into into
> it? My guess would be that on stop the counters are reset and you want
> to preserve the stats.
>

Not sure I understand. I think you are asking about two things:

1. Why have two mpnic_base_stats?

To avoid a separate heap allocation that can fail. Handling an
allocation failure in the ndo_stop path when doing the aggregation into
the base stats is tricky.

2. Why split stats into base stats and per queue stats, and why reset
the per queue counts when the device transitions down?

This is the way the stats in netdev.yaml are exposed depending on the
'scope' request attribute. My reading of the relevant kernel docs is
that the per queue counters are counting events for the current live
queue, so it makes sense to reset them and fold those counts into the
base stats when the interface is transitioned down.

>> Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
>
> Sebastian
Technical Details
Message-ID: <DM8U47F4MNK3.2V54CCQ9YTNBY@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348520-linux-kernel-netdev=dewy.ru
References: <20261012-mpnic-counters3-v2-0-8afba81c2d5a@gmail.com> <20261012-mpnic-counters3-v2-1-8afba81c2d5a@gmail.com> <20261016220930.i32JEcqe@linutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348520-linux-kernel-netdev=dewy.ru
From: daniel.zahka@gmail.com ("Daniel Zahka")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and
 drops per ring
Date: Mon, 19 Oct 2026 09:04:38 -0400
Organization: Usenet Network
Message-ID: <DM8U47F4MNK3.2V54CCQ9YTNBY@gmail.com>
References: <20261012-mpnic-counters3-v2-0-8afba81c2d5a@gmail.com>
 <20261012-mpnic-counters3-v2-1-8afba81c2d5a@gmail.com>
 <20261016220930.i32JEcqe@linutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3607509"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:etq65MhPg9d8412aaKILmMRynms= sha256:gsAydp3rQUlC7Yk6S2rzNz2YnTsI4UWf2ZD3xn93kcw=
	sha1:59K6D4595jr7JwF23U2yTEFQk18= sha256:GlJypsXrExvn0PglX5n/KNRdVQVNnJ+qM4X66Icti/Y=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 600EA1109E8; Mon, 19 Oct 2026 16:05:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Zqbj4Xiq_CLB;
	Mon, 19 Oct 2026 16:05:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-348520-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id D8EBC1109A8; Mon, 19 Oct 2026 16:04:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sto.lore.kernel.org (Postfix) with ESMTP id 966A5603E58; Mon, 19 Oct 2026 13:04:43 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D71224F3ED6;
	Mon, 19 Oct 2026 13:04:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zw2Ro5NT"
X-Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91AA4EA38C
	for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 13:04:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792415082; cv=none; b=Ag5OfIBebOI7XLiW4dIrxhZ6HeVYDzJcekj9VM4I3DvffM67lOJMaviLYX9C01vWmvnPL2xoQJeQVP4ZNYL26YFjOqLRoQiqUHx2y0ngGO4g8TAPsNxExGRbuZREhDpkY+/OjZVnWbFWFwdvdHVOog+KNGO/XYFKVB7z2hnHteY=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792415082; c=relaxed/simple;
	bh=ypi3osWI8gP8xyKWXAity7kWnhHwA/VpXlB9i/wvPi4=;
	h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From:
	 References:In-Reply-To; b=PwB1MAFMSrWZOeisqkWEsB/dR2WMHMq2nTdrYHEdmdjV5Po/+03V1BHxbSEv8T9T18faIO6sJEQFFOiglq9kFtQaufYNSoj4B0g0g1InCl584a+vJmhQgYTUx5MFWVj+7f6YU6Q7/hMip5hMyhdwD9de11TWrMyk67RM92sUO0I=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zw2Ro5NT; arc=none smtp.client-ip=209.85.222.170
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-930c0f9c1b1so207376085a.1
        for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 06:04:40 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792415080; x=1793019880; darn=vger.kernel.org;
        h=in-reply-to:references:from:subject:cc:to:message-id:date
         :content-type:content-transfer-encoding:mime-version:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=ypi3osWI8gP8xyKWXAity7kWnhHwA/VpXlB9i/wvPi4=;
        b=Zw2Ro5NTFeqeRpPaUDiAoqDBBEVA4vrR/egIYDXbODNDfzxRKXaLD1RJK11z0W2Nfo
         v4ChuE6+1Sfi4K+VMqUl/ZYJB0btqAXli5pJHKqFcJ5+/uVwztEMPyj+J7yGeSc02FBk
         C6CLlRLhQJl0jM8HTwn917o5vL1wfF9ZSDi+dhXi+InmnwfjUMcBIiA70sapE8VxKTcE
         fF9GSx6VUK6IsUY0dHiKY4mYq2w+na9GwH3Hpjy1mWZGcO69wec5JKb27RNOnTs3sqsM
         01rhQF+lRKg5rrHh7r063fn0ukbU+Iv3/sufzKGp/PEF1gaM6y90GfQ/oOuPO+W+XT/y
         jCvQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792415080; x=1793019880;
        h=in-reply-to:references:from:subject:cc:to:message-id:date
         :content-type:content-transfer-encoding:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=ypi3osWI8gP8xyKWXAity7kWnhHwA/VpXlB9i/wvPi4=;
        b=jMQnOSKRlObeEfJtGNxDZDU40Z8WcsH3ItTaMnQP2rwcQ23ZMNhpkksNUaEIJna1my
         JkAw/GNZQ3MGc0DLFI2gAKIw7b2IOPs6X95qR4gjXW6FZ/oBhAKElLhG+d1hcFnEhgyn
         NwApnWIlqAlrtBnc+sY+HoMketC9k89BKyZJQgwFEfTHWsBTvr+Zo26zEeZva6RaRKez
         dFxhyeVaJkRdBW9lK2DGofsY4dlseSluy/DXguO+8j4ZG5QeQtj56O3mfuxJzD9Vc0mS
         95NO3d44E3YnC1UE//xk6s9DUEouHDWH9Ck/ppVuLM64KnljiM37iioDDgLa/B84TGQ8
         J6QA==
X-Forwarded-Encrypted: i=1; AKwUvByRqnO3KZkIJunR/FsFHbEsPqJ6giLKNvS50ndxNJuTs8XSde90deMD3cp42EBx/AGMGLuzxwc=@vger.kernel.org
X-Gm-Message-State: AFq9FYLza26FZ2lzIlEZGvlrRFEYRWkBY/RoUiQt4egy5T3ey06SiBnT
	2MG7GJSKyjJfuEoPjRLYt/LAwyu5sxvsumfHD/mmsPj+kabLnTIDaRcf
X-Gm-Gg: AYBFou1I+e7JGOf8nmDzhzsBpcpSWNyCC1Cd8VM1Y07rIMZBZpA1rVFWSbT6rvyDtNi
	m4xyZgix5GVcRJH3aSztYrQ6Ki0WtZ963XSODYOY7Q8+Kg4KKh8FH2v00MmjHLNYYhTrzouY/VW
	A8M/bo9cJIHD9XVgoWn/WWUEnldyX4GCaVcgVsouqIB9gPixtn/FG/f/zYslCaFnuASoIUHClLv
	+EYgkOpJf+66IjLxHJVB2CEtEm8GoU9tRgbJdfZnGr3kfpYYR+VVW5KIzKESFAnoKOMyT4YEH0a
	3pw5f6Z8L2UejsoiEV8uyog3m3TLKPl4AFLvN0Se/FUKJhJkmZotpaofyrVVBT30fBQdtx0zkLT
	SUHcCuYoSk5zrycv2WJccfWUWHjc087MExfEWrgHSrBCI9WrNMOzUQ9tCqH63E++4TLzue8k+Ns
	v8f63TPnCjdgK440PWQ1oi+m7cjWfUvTSIAJaqvSBfjG0ir9IHHPPSNmybd1+lVUMTdWeLPd5JC
	qs=
X-Received: by 2002:a05:620a:7119:b0:93e:fc4e:c490 with SMTP id af79cd13be357-93f29cf1c9bmr1378673385a.15.1792415079619;
        Mon, 19 Oct 2026 06:04:39 -0700 (PDT)
X-Received: from localhost ([2600:4040:9399:4000:e553:72e5:7d37:c7ef])
        by smtp.gmail.com with ESMTPSA id af79cd13be357-93f3cb855a0sm328418385a.4.2026.10.19.06.04.38
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Mon, 19 Oct 2026 06:04:39 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-Cc: "Alexander Duyck" <alexanderduyck@fb.com>, "Jakub Kicinski"
 <kuba@kernel.org>, <kernel-team@meta.com>, "Andrew Lunn"
 <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, "Paolo
 Abeni" <pabeni@redhat.com>, "Alexei Starovoitov" <ast@kernel.org>, "Daniel
 Borkmann" <daniel@iogearbox.net>, "Jesper Dangaard Brouer"
 <hawk@kernel.org>, "John Fastabend" <john.fastabend@gmail.com>, "Stanislav
 Fomichev" <sdf@fomichev.me>, "Eric Dumazet" <edumazet@kernel.org>,
 <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
 <bpf@vger.kernel.org>
X-Mailer: aerc 0.21.0-threadmapfix
X-In-Reply-To: <20261016220930.i32JEcqe@linutronix.de>