From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, ast@kernel.org,
daniel@iogearbox.net, lorenzo@kernel.org, toke@redhat.com,
john.fastabend@gmail.com, sdf@fomichev.me,
michael.chan@broadcom.com, anthony.l.nguyen@intel.com,
przemyslaw.kitszel@intel.com, marcin.s.wojtas@gmail.com,
tariqt@nvidia.com, mbloch@nvidia.com, eperezma@redhat.com
Subject: Re: [RFC] xdp: pass flags to xdp_update_skb_shared_info() directly
Date: Wed, 13 Aug 2025 10:43:21 +0200 [thread overview]
Message-ID: <2ba29c9f-a44f-4be6-bd3a-eb9cdb34ac8a@kernel.org> (raw)
In-Reply-To: <46470d2b-4828-48ad-a94e-9d874de1b2fc@intel.com>
On 12/08/2025 18.48, Alexander Lobakin wrote:
> From: Jakub Kicinski <kuba@kernel.org>
> Date: Tue, 12 Aug 2025 09:15:28 -0700
>
>> xdp_update_skb_shared_info() needs to update skb state which
>> was maintained in xdp_buff / frame. Pass full flags into it,
>> instead of breaking it out bit by bit. We will need to add
>> a bit for unreadable frags (even tho XDP doesn't support
>> those the driver paths may be common), at which point almost
>> all call sites would become:
>>
>> xdp_update_skb_shared_info(skb, num_frags,
>> sinfo->xdp_frags_size,
>> MY_PAGE_SIZE * num_frags,
>> xdp_buff_is_frag_pfmemalloc(xdp),
>> xdp_buff_is_frag_unreadable(xdp));
>
> Yeah I think this doesn't make sense, it just doesn't scale. We can make
> more flags in future and adding a new argument for each is not a good
> idea, even if more drivers would switch to generic
> xdp_build_skb_from_buff().
>
I agree. And good reminder that some driver have already switched to the
generic xdp_build_skb_from_buff().
>>
>> Keep a helper for accessing the flags, in case we need to
>> transform them somehow in the future (e.g. to cover up xdp_buff
>> vs xdp_frame differences).
>>
>> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>> ---
>> Does anyone prefer the current form of the API, or can we change
>> as prosposed?
>>
I like the proposed change.
The only thing that confuses me was that the u32 flags is named
"skb_flags" and not "xdp_flags".
@@ -314,7 +313,7 @@
static inline void
xdp_update_skb_shared_info(struct sk_buff *skb, u8 nr_frags,
unsigned int size, unsigned int truesize,
- bool pfmemalloc)
+ u32 skb_flags)
>> Bonus question: while Im messing with this API could I rename
>> xdp_update_skb_shared_info()? Maybe to xdp_update_skb_state() ?
>> Not sure why the function name has "shared_info" when most of
>> what it updates is skb fields.
>
> I can only suspect that the author decided to name it this way due to
> that it's only used when xdp_buff has frags (and frags are in shinfo).
> But I agree it's not the best choice. xdp_update_skb_state() sounds fine
> to me, but given that it's all about frags, maybe something like
> xdp_update_skb_frags_info/state() or so?
>
Yes, function is only used when skb_shared_info have already been touched.
Performance wise it can be expensive to touch the cache-line for
skb_shared_info, so the code carefully checks xdp_buff_has_frags() (flag
XDP_FLAGS_HAS_FRAGS) before deref of skb_shared_info memory area.
Calling it xdp_update_skb_state() seems misleading. As Olek says, this
is about updating the "skb_frags". The original intent is that
xdp_buff/xdp_frame is using same skb_shared_info area as SKB, and when
transitioning to a "full" SKB then we need to do some adjustments.
(Looking at function code, it is of-cause confusing that it doesn't
touch sinfo->frags[] array, but that is because we don't need to, as
non-linear XDP and SKB have same layout.).
--Jesper
>>
>> CC: ast@kernel.org
>> CC: daniel@iogearbox.net
>> CC: hawk@kernel.org
>> CC: lorenzo@kernel.org
>> CC: toke@redhat.com
>> CC: john.fastabend@gmail.com
>> CC: sdf@fomichev.me
>> CC: michael.chan@broadcom.com
>> CC: anthony.l.nguyen@intel.com
>> CC: przemyslaw.kitszel@intel.com
>> CC: marcin.s.wojtas@gmail.com
>> CC: tariqt@nvidia.com
>> CC: mbloch@nvidia.com
>> CC: eperezma@redhat.com
>> CC: bpf@vger.kernel.org
>> ---
>> include/net/xdp.h | 21 +++++++++----------
>> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 2 +-
>> drivers/net/ethernet/intel/i40e/i40e_txrx.c | 4 ++--
>> drivers/net/ethernet/intel/ice/ice_txrx.c | 4 ++--
>> drivers/net/ethernet/marvell/mvneta.c | 2 +-
>> .../net/ethernet/mellanox/mlx5/core/en_rx.c | 7 +++----
>> drivers/net/virtio_net.c | 2 +-
>> net/core/xdp.c | 11 +++++-----
>> 8 files changed, 26 insertions(+), 27 deletions(-)
next prev parent reply other threads:[~2025-08-13 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 16:15 [RFC] xdp: pass flags to xdp_update_skb_shared_info() directly Jakub Kicinski
2025-08-12 16:17 ` Jakub Kicinski
2025-08-12 16:48 ` Alexander Lobakin
2025-08-13 8:43 ` Jesper Dangaard Brouer [this message]
2025-08-13 21:44 ` Jakub Kicinski
2025-08-14 8:11 ` Jesper Dangaard Brouer
2025-08-13 7:25 ` Lorenzo Bianconi
2025-08-13 11:06 ` Toke Høiland-Jørgensen
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=2ba29c9f-a44f-4be6-bd3a-eb9cdb34ac8a@kernel.org \
--to=hawk@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eperezma@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=marcin.s.wojtas@gmail.com \
--cc=mbloch@nvidia.com \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=tariqt@nvidia.com \
--cc=toke@redhat.com \
/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.