netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	danielj@nvidia.com, mst@redhat.com, amritha.nambiar@intel.com,
	michael.chan@broadcom.com, Jakub Kicinski <kuba@kernel.org>
Subject: [RFC net-next 2/3] netdev: add queue stat for alloc failures
Date: Thu, 22 Feb 2024 14:36:28 -0800	[thread overview]
Message-ID: <20240222223629.158254-3-kuba@kernel.org> (raw)
In-Reply-To: <20240222223629.158254-1-kuba@kernel.org>

Rx alloc failures are commonly counted by drivers.
Support reporting those via netdev-genl queue stats.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 Documentation/netlink/specs/netdev.yaml | 7 +++++++
 include/net/netdev_queues.h             | 2 ++
 include/uapi/linux/netdev.h             | 1 +
 net/core/netdev-genl.c                  | 3 ++-
 tools/include/uapi/linux/netdev.h       | 1 +
 5 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index eea41e9de98c..ea7b3b72b212 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -328,6 +328,13 @@ name: netdev
         name: tx-bytes
         doc: Successfully sent bytes, see `tx-packets`.
         type: uint
+      -
+        name: rx-alloc-fail
+        doc: |
+          Number of times skb or buffer allocation failed on the Rx datapath.
+          Allocation failure may, or may not result in a packet drop, depending
+          on driver implementation and whether system recovers quickly.
+        type: uint
 
 operations:
   list:
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index d633347eeda5..1ec408585373 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -4,9 +4,11 @@
 
 #include <linux/netdevice.h>
 
+/* See the netdev.yaml spec for definition of each statistic */
 struct netdev_queue_stats_rx {
 	u64 bytes;
 	u64 packets;
+	u64 alloc_fail;
 };
 
 struct netdev_queue_stats_tx {
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index c6a5e4b03828..ec65790c2c6c 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -146,6 +146,7 @@ enum {
 	NETDEV_A_STATS_RX_BYTES,
 	NETDEV_A_STATS_TX_PACKETS,
 	NETDEV_A_STATS_TX_BYTES,
+	NETDEV_A_STATS_RX_ALLOC_FAIL,
 
 	__NETDEV_A_STATS_MAX,
 	NETDEV_A_STATS_MAX = (__NETDEV_A_STATS_MAX - 1)
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index fe4e9bc5436a..7976c112c447 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -498,7 +498,8 @@ static int
 netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)
 {
 	if (netdev_stat_put(rsp, NETDEV_A_STATS_RX_PACKETS, rx->packets) ||
-	    netdev_stat_put(rsp, NETDEV_A_STATS_RX_BYTES, rx->bytes))
+	    netdev_stat_put(rsp, NETDEV_A_STATS_RX_BYTES, rx->bytes) ||
+	    netdev_stat_put(rsp, NETDEV_A_STATS_RX_ALLOC_FAIL, rx->alloc_fail))
 		return -EMSGSIZE;
 	return 0;
 }
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index c6a5e4b03828..ec65790c2c6c 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -146,6 +146,7 @@ enum {
 	NETDEV_A_STATS_RX_BYTES,
 	NETDEV_A_STATS_TX_PACKETS,
 	NETDEV_A_STATS_TX_BYTES,
+	NETDEV_A_STATS_RX_ALLOC_FAIL,
 
 	__NETDEV_A_STATS_MAX,
 	NETDEV_A_STATS_MAX = (__NETDEV_A_STATS_MAX - 1)
-- 
2.43.2


  parent reply	other threads:[~2024-02-22 22:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 22:36 [RFC net-next 0/3] netdev: add per-queue statistics Jakub Kicinski
2024-02-22 22:36 ` [RFC net-next 1/3] " Jakub Kicinski
2024-02-23  0:23   ` Nambiar, Amritha
2024-02-23  1:37     ` Jakub Kicinski
2024-02-23 20:40       ` Nambiar, Amritha
2024-02-23  0:29   ` Nambiar, Amritha
2024-02-23  1:44     ` Jakub Kicinski
2024-02-23  4:32       ` Stanislav Fomichev
2024-02-23  9:22         ` Vadim Fedorenko
2024-02-23 20:51       ` Nambiar, Amritha
2024-02-24  0:13         ` Jakub Kicinski
2024-02-26 19:42           ` Nambiar, Amritha
2024-02-22 22:36 ` Jakub Kicinski [this message]
2024-02-22 22:36 ` [RFC net-next 3/3] eth: bnxt: support " Jakub Kicinski
2024-02-23  0:29   ` Nambiar, Amritha
2024-02-23  1:33     ` Jakub Kicinski
2024-02-23 20:42       ` Nambiar, Amritha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240222223629.158254-3-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=amritha.nambiar@intel.com \
    --cc=danielj@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=michael.chan@broadcom.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).