lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL+tcoBpUg=ggf6nQpYeZyAcMbXobuJtyUdN98G1HpcuUqFZ+w@mail.gmail.com>
Date: Mon, 17 Nov 2025 16:41:20 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>, 
	Kuniyuki Iwashima <kuniyu@...gle.com>, netdev@...r.kernel.org, eric.dumazet@...il.com, 
	Maciej Fijalkowski <maciej.fijalkowski@...el.com>
Subject: Re: [PATCH v3 net-next 3/3] net: use napi_skb_cache even in process context

On Mon, Nov 17, 2025 at 9:07 AM Jason Xing <kerneljasonxing@...il.com> wrote:
>
> On Mon, Nov 17, 2025 at 4:27 AM Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > This is a followup of commit e20dfbad8aab ("net: fix napi_consume_skb()
> > with alien skbs").
> >
> > Now the per-cpu napi_skb_cache is populated from TX completion path,
> > we can make use of this cache, especially for cpus not used
> > from a driver NAPI poll (primary user of napi_cache).
> >
> > We can use the napi_skb_cache only if current context is not from hard irq.
> >
> > With this patch, I consistently reach 130 Mpps on my UDP tx stress test
> > and reduce SLUB spinlock contention to smaller values.
> >
> > Note there is still some SLUB contention for skb->head allocations.
> >
> > I had to tune /sys/kernel/slab/skbuff_small_head/cpu_partial
> > and /sys/kernel/slab/skbuff_small_head/min_partial depending
> > on the platform taxonomy.
> >
> > Signed-off-by: Eric Dumazet <edumazet@...gle.com>
>
> Reviewed-by: Jason Xing <kerneljasonxing@...il.com>
>
> Thanks for working on this. Previously I was thinking about this as
> well since it affects the hot path for xsk (please see
> __xsk_generic_xmit()->xsk_build_skb()->sock_alloc_send_pskb()). But I
> wasn't aware of the benefits between disabling irq and allocating
> memory. AFAIK, I once removed an enabling/disabling irq pair and saw a
> minor improvement as this commit[1] says. Would you share your
> invaluable experience with us in this case?
>
> In the meantime, I will do more rounds of experiments to see how they perform.

Tested-by: Jason Xing <kerneljasonxing@...il.com>
Done! I managed to see an improvement. The pps number goes from
1,458,644 to 1,647,235 by running [2].

But sadly the news is that the previous commit [3] leads to a huge
decrease in af_xdp from 1,980,000 to 1,458,644. With commit [3]
applied, I observed and found xdpsock always allocated the skb on cpu
0 but the napi poll triggered skb_attempt_defer_free() on another
call[4], which affected the final results.

[2]
taskset -c 0 ./xdpsock -i enp2s0f1 -q 1 -t -S -s 64

[3]
commit e20dfbad8aab2b7c72571ae3c3e2e646d6b04cb7
Author: Eric Dumazet <edumazet@...gle.com>
Date:   Thu Nov 6 20:29:34 2025 +0000

    net: fix napi_consume_skb() with alien skbs

    There is a lack of NUMA awareness and more generally lack
    of slab caches affinity on TX completion path.

[4]
@c[
    skb_attempt_defer_free+1
    ixgbe_clean_tx_irq+723
    ixgbe_poll+119
    __napi_poll+48
, ksoftirqd/24]: 1964731

@c[
    kick_defer_list_purge+1
    napi_consume_skb+333
    ixgbe_clean_tx_irq+723
    ixgbe_poll+119
, 34, swapper/34]: 123779

Thanks,
Jason

>
> [1]
> commit 30ed05adca4a05c50594384cff18910858dd1d35
> Author: Jason Xing <kernelxing@...cent.com>
> Date:   Thu Oct 30 08:06:46 2025 +0800
>
>     xsk: use a smaller new lock for shared pool case
>
>     - Split cq_lock into two smaller locks: cq_prod_lock and
>       cq_cached_prod_lock
>     - Avoid disabling/enabling interrupts in the hot xmit path
>
> Thanks,
> Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ