Re: [PATCH net-next v3 05/12] net: add METADATA_PSP dst to carry a psp association on an skb

From: Todd Bert Freed

Date: Thu Dec 03 2026 - 16:44:43 EST


> Performance thoughts. These two functions (__dev_queue_xmit and
> sk_validate_xmit_skb) are in the hotpath. The static key is globally for
> all netdevs. My worry is that packets that doesn't care about PSP has to
> touch more cachelines during ptr chasing. Cheaper, less instrusive
> (flag?) per-skb check possible? (Or proof that it doesn't matter! ;-))

Good idea. There is already a per-skb flag for this. Whenever a
METADATA_PSP dst is attached, skb->decrypted is also set. In v4
I will have the lookup test skb->decrypted before looking at the dst.
And skb->decrypted is in the same cacheline as mac_header, which
__dev_queue_xmit() always writes, so that check is cheap.

In sk_validate_xmit_skb(), only packets of a socket with its own device
offload (kTLS, PSP), or packets marked decrypted, look at their dst.

I measured this on x86_64 (AMD EPYC 9D64) with CX7. One thread
sending 64 byte non-PSP UDP packets, using perf stat on the
sending CPU. To turn the static key on, I created a psp encap action
which no filter uses, so it never runs. For the key off, I created a gact
action instead. Alternating between the two, avg instructions per
packet,

without the series 6768
with v4 series, static key off 6765
with v4 series, static key on 6771

I suppose we could add another bit, psp_decrypted, so that kTLS
does not need to look at the dst on these paths. What do you
think?

-Todd