public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
	"Eric Dumazet" <eric.dumazet@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Toke Høiland-Jørgensen" <toke@toke.dk>,
	kernel-team@cloudflare.com, mfleming@cloudflare.com
Subject: Re: [PATCH net-next V4] net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC
Date: Mon, 7 Jul 2025 17:43:46 -0700	[thread overview]
Message-ID: <20250707174346.2211c46a@kernel.org> (raw)
In-Reply-To: <175146472829.1363787.9293177520571232738.stgit@firesoul>

On Wed, 02 Jul 2025 15:59:19 +0200 Jesper Dangaard Brouer wrote:
> 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

> @@ -1030,10 +1030,8 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
>  	}
>  
>  	if (tfile->socket.sk->sk_filter &&
> -	    sk_filter(tfile->socket.sk, skb)) {
> -		drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
> +	    (sk_filter_reason(tfile->socket.sk, skb, &drop_reason)))

why the outside brackets?

> @@ -591,6 +592,10 @@ enum skb_drop_reason {
>  	 * non conform CAN-XL frame (or device is unable to receive CAN frames)
>  	 */
>  	SKB_DROP_REASON_CANXL_RX_INVALID_FRAME,
> +	/**
> +	 * @SKB_DROP_REASON_PFMEMALLOC: dropped when under memory pressure

I guess kinda, but in practice not very precise?

How about: packet allocated from memory reserve reached a path or
socket not eligible for use of memory reserves.

I could be misremembering the meaning of "memory reserve" TBH.

> +	 */
> +	SKB_DROP_REASON_PFMEMALLOC,
>  	/**
>  	 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
>  	 * shouldn't be used as a real 'reason' - only for tracing code gen

> -	if (unlikely(sk_add_backlog(sk, skb, limit))) {
> +	if (unlikely((err = sk_add_backlog(sk, skb, limit)))) {

I understand the else if () case but here you can simply:

	err = sk_add_backlog(sk, skb, limit);
	if (unlikely(err))

no need to make checkpatch upset.

> @@ -162,7 +163,7 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
>  		rose_frames_acked(sk, nr);
>  		if (ns == rose->vr) {
>  			rose_start_idletimer(sk);
> -			if (sk_filter_trim_cap(sk, skb, ROSE_MIN_LEN) == 0 &&
> +			if (sk_filter_trim_cap(sk, skb, ROSE_MIN_LEN, &dr) == 0 &&

let's switch to negation rather than comparing to 0 while at it?
otherwise we run over 80 chars

>  			    __sock_queue_rcv_skb(sk, skb) == 0) {
>  				rose->vr = (rose->vr + 1) % ROSE_MODULUS;
>  				queued = 1;
-- 
pw-bot: cr

  reply	other threads:[~2025-07-08  0:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 13:59 [PATCH net-next V4] net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC Jesper Dangaard Brouer
2025-07-08  0:43 ` Jakub Kicinski [this message]
2025-07-16  9:26   ` Jesper Dangaard Brouer

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=20250707174346.2211c46a@kernel.org \
    --to=kuba@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=hawk@kernel.org \
    --cc=kernel-team@cloudflare.com \
    --cc=mfleming@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@toke.dk \
    /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