net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC
authorJesper Dangaard Brouer <hawk@kernel.org>
Wed, 16 Jul 2025 16:26:53 +0000 (18:26 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 18 Jul 2025 23:59:05 +0000 (16:59 -0700)
commita6f190630d070173897a7e98a30188b7638ba0a1
tree72e6fadd557f4929f49bca1fff592c1d34be0e3f
parent8b7ab8eb52b51a7058edf0035e47b281f9fc9a19
net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC

Add a new SKB drop reason (SKB_DROP_REASON_PFMEMALLOC) to track packets
dropped due to memory pressure. In production environments, we've observed
memory exhaustion reported by memory layer stack traces, but these drops
were not properly tracked in the SKB drop reason infrastructure.

While most network code paths now properly report pfmemalloc drops, some
protocol-specific socket implementations still use sk_filter() without
drop reason tracking:
- Bluetooth L2CAP sockets
- CAIF sockets
- IUCV sockets
- Netlink sockets
- SCTP sockets
- Unix domain sockets

These remaining cases represent less common paths and could be converted
in a follow-up patch if needed. The current implementation provides
significantly improved observability into memory pressure events in the
network stack, especially for key protocols like TCP and UDP, helping to
diagnose problems in production environments.

Reported-by: Matt Fleming <mfleming@cloudflare.com>
Signed-off-by: Jesper Dangaard Brouer <hawk@kernel.org>
Link: https://patch.msgid.link/175268316579.2407873.11634752355644843509.stgit@firesoul
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
12 files changed:
drivers/net/tun.c
include/linux/filter.h
include/net/dropreason-core.h
include/net/tcp.h
net/core/dev.c
net/core/filter.c
net/core/sock.c
net/ipv4/tcp_ipv4.c
net/ipv4/udp.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/rose/rose_in.c