All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Jakub Kicinski <kuba@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: Wed, 16 Jul 2025 11:26:24 +0200	[thread overview]
Message-ID: <d0c8c1ce-5bb2-45f5-9d7f-fac734dcfe31@kernel.org> (raw)
In-Reply-To: <20250707174346.2211c46a@kernel.org>



On 08/07/2025 02.43, Jakub Kicinski wrote:
> 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?
> 

Good catch, yes the brackets are unnecessary, will remove in V5.

>> @@ -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 like it, this is a good description, thanks! :-)

> 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))

Agreed, will fix in V5.

> 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
> 

Sure I will adjust code.

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

--Jesper

      reply	other threads:[~2025-07-16  9:26 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
2025-07-16  9:26   ` Jesper Dangaard Brouer [this message]

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=d0c8c1ce-5bb2-45f5-9d7f-fac734dcfe31@kernel.org \
    --to=hawk@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.