[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGZ25_gUxziOoNZp@lore-desk>
Date: Thu, 3 Jul 2025 14:26:15 +0200
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Jesper Dangaard Brouer <hawk@...nel.org>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <borkmann@...earbox.net>,
Eric Dumazet <eric.dumazet@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>, sdf@...ichev.me,
kernel-team@...udflare.com, arthur@...hurfabre.com,
jakub@...udflare.com
Subject: Re: [PATCH bpf-next V2 3/7] net: xdp: Add kfuncs to store hw
metadata in xdp_buff
>
> On 02/07/2025 16.58, Jesper Dangaard Brouer wrote:
> > From: Lorenzo Bianconi<lorenzo@...nel.org>
> >
> > Introduce the following kfuncs to store hw metadata provided by the NIC
> > into the xdp_buff struct:
> >
> > - rx-hash: bpf_xdp_store_rx_hash
> > - rx-vlan: bpf_xdp_store_rx_vlan
> > - rx-hw-ts: bpf_xdp_store_rx_ts
> >
> > Signed-off-by: Lorenzo Bianconi<lorenzo@...nel.org>
> > Signed-off-by: Jesper Dangaard Brouer<hawk@...nel.org>
> > ---
> > include/net/xdp.h | 5 +++++
> > net/core/xdp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 50 insertions(+)
> >
> > diff --git a/net/core/xdp.c b/net/core/xdp.c
> > index bd3110fc7ef8..1ffba57714ea 100644
> > --- a/net/core/xdp.c
> > +++ b/net/core/xdp.c
> > @@ -963,12 +963,57 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
> [...]
> > +__bpf_kfunc int bpf_xdp_store_rx_ts(struct xdp_md *ctx, u64 ts)
> > +{
> > + struct xdp_buff *xdp = (struct xdp_buff *)ctx;
> > + struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
> > + struct skb_shared_hwtstamps *shwt = &sinfo->hwtstamps;
> > +
> > + shwt->hwtstamp = ts;
>
> Here we are storing into the SKB shared_info struct. This is located at
> the SKB data tail. Thus, this will very likely cause a cache-miss.
>
> What about storing it into xdp->rx_meta and then starting a prefetch for
> shared_info? (and updating patch-4 that moved it into SKB)
ack, I am fine with it. I can address it in v3.
Regards,
Lorenzo
>
> (Reviewers should be aware that writing into the xdp_frame headroom
> (xdp->rx_meta) likely isn't a cache-miss, because all drivers does a
> prefetchw for this memory prior to running BPF-prog).
>
>
> > + xdp->flags |= XDP_FLAGS_META_RX_TS;
> > +
> > + return 0;
> > +}
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists