Skip to content

Commit 92f8b1f

Browse files
committed
netdev: add queue stat for alloc failures
Rx alloc failures are commonly counted by drivers. Support reporting those via netdev-genl queue stats. Acked-by: Stanislav Fomichev <[email protected]> Reviewed-by: Amritha Nambiar <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ab63a23 commit 92f8b1f

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

Documentation/netlink/specs/netdev.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ attribute-sets:
328328
name: tx-bytes
329329
doc: Successfully sent bytes, see `tx-packets`.
330330
type: uint
331+
-
332+
name: rx-alloc-fail
333+
doc: |
334+
Number of times skb or buffer allocation failed on the Rx datapath.
335+
Allocation failure may, or may not result in a packet drop, depending
336+
on driver implementation and whether system recovers quickly.
337+
type: uint
331338

332339
operations:
333340
list:

include/net/netdev_queues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
#include <linux/netdevice.h>
66

7+
/* See the netdev.yaml spec for definition of each statistic */
78
struct netdev_queue_stats_rx {
89
u64 bytes;
910
u64 packets;
11+
u64 alloc_fail;
1012
};
1113

1214
struct netdev_queue_stats_tx {

include/uapi/linux/netdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ enum {
145145
NETDEV_A_QSTATS_RX_BYTES,
146146
NETDEV_A_QSTATS_TX_PACKETS,
147147
NETDEV_A_QSTATS_TX_BYTES,
148+
NETDEV_A_QSTATS_RX_ALLOC_FAIL,
148149

149150
__NETDEV_A_QSTATS_MAX,
150151
NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)

net/core/netdev-genl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ static int
488488
netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)
489489
{
490490
if (netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_PACKETS, rx->packets) ||
491-
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_BYTES, rx->bytes))
491+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_BYTES, rx->bytes) ||
492+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_ALLOC_FAIL, rx->alloc_fail))
492493
return -EMSGSIZE;
493494
return 0;
494495
}

tools/include/uapi/linux/netdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ enum {
145145
NETDEV_A_QSTATS_RX_BYTES,
146146
NETDEV_A_QSTATS_TX_PACKETS,
147147
NETDEV_A_QSTATS_TX_BYTES,
148+
NETDEV_A_QSTATS_RX_ALLOC_FAIL,
148149

149150
__NETDEV_A_QSTATS_MAX,
150151
NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)

0 commit comments

Comments
 (0)