BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Satish Kharat" <satishkh@cisco.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH RFC net-next 06/12] net: enic: reserve XDP head and tailroom in RX pages
Date: Wed, 02 Dec 2026 01:16:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-244589@kernel.org> (raw)
In-Reply-To: <20261130-enic-xdp-rfc-p1-20261130-v1-6-3be5458c9118@cisco.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net: enic: unaligned truesize in enic_rq_alloc_buf() misaligns
  skb_shared_info
--

commit cd93cb3238544785656020716a596e6aff1448f8
Author: Satish Kharat <satishkh@cisco.com>

net: enic: reserve XDP head and tailroom in RX pages

This commit adds an xdp_enabled flag to struct enic_rq and reserves XDP
headroom and skb_shared_info tailroom in enic_rq_alloc_buf() when the flag
is set.

> diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c
> index ccbf5c9a21d0f..82ef15296a100 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_rq.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_rq.c
> @@ -273,13 +274,17 @@ int enic_rq_alloc_buf(struct vnic_rq *rq)
>  	struct net_device *netdev = enic->netdev;
>  	struct enic_rq *erq = &enic->rq[rq->index];
>  	struct enic_rq_stats *rqstats = &erq->stats;
> +	unsigned int headroom = erq->xdp_enabled ? ENIC_XDP_HEADROOM : 0;
>  	unsigned int offset = 0;
>  	unsigned int len = netdev->mtu + VLAN_ETH_HLEN;
>  	unsigned int os_buf_index = 0;
>  	dma_addr_t dma_addr;
>  	struct vnic_rq_buf *buf = rq->to_use;
>  	struct page *page;
> -	unsigned int truesize = len;
> +	unsigned int truesize = len + headroom;
> +
> +	if (erq->xdp_enabled)
> +		truesize += ENIC_XDP_TAILROOM;
>  
>  	if (buf->os_buf) {
>  		enic_queue_rq_desc(rq, buf->os_buf, os_buf_index, buf->dma_addr,
> @@ -293,9 +298,9 @@ int enic_rq_alloc_buf(struct vnic_rq *rq)
>  		rqstats->pp_alloc_fail++;
>  		return -ENOMEM;
>  	}
> -	buf->offset = offset;
> +	buf->offset = offset + headroom;
>  	buf->truesize = truesize;

[Severity: High]
Does leaving truesize unaligned misalign struct skb_shared_info when
page_pool_dev_alloc() allocates multiple fragments per page?

With VLAN_ETH_HLEN (18 bytes), len + headroom + ENIC_XDP_TAILROOM is only
2-byte aligned for standard MTUs (or 1-byte aligned for odd MTUs).  When a
page holds more than one fragment, page_pool_alloc_netmem() passes *size
by value to page_pool_alloc_frag_netmem() and leaves the caller's truesize
unchanged for non-terminal fragments:

include/net/page_pool/helpers.h:page_pool_alloc_netmem() {
    ...
	netmem = page_pool_alloc_frag_netmem(pool, offset, *size, gfp);
	if (unlikely(!netmem))
		return 0;

	/* There is very likely not enough space for another fragment, so append
	 * the remaining size to the current fragment to avoid truesize
	 * underestimate problem.
	 */
	if (pool->frag_offset + *size > max_size) {
		*size = max_size - *offset;
		pool->frag_offset = max_size;
	}
    ...
}

When buf->truesize is later passed to xdp_init_buff() as frame_sz,
xdp_data_hard_end() and xdp_get_shared_info_from_buff() place
struct skb_shared_info at an unaligned address, causing misaligned atomic
and pointer accesses.  Aligning truesize with SKB_DATA_ALIGN() before
calling page_pool_dev_alloc() would keep the end of the frame aligned.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-enic-xdp-rfc-p1-20261130-v1-0-3be5458c9118@cisco.com?part=6

  reply	other threads:[~2026-12-02  1:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  1:15 [PATCH RFC net-next 00/12] enic: add native XDP and AF_XDP support Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 01/12] net: enic: bound skb TX rollback to current packet Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 02/12] net: enic: tag work queue descriptor ownership Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 03/12] net: enic: gate native XDP on mixed RQ descriptor capability Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 04/12] net: enic: expose per-queue XDP and AF_XDP counters Satish Kharat
2026-12-02  1:16   ` sashiko-bot
2026-12-01  1:15 ` [PATCH RFC net-next 05/12] net: enic: complete XDP frames by WQ descriptor ownership Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 06/12] net: enic: reserve XDP head and tailroom in RX pages Satish Kharat
2026-12-02  1:16   ` sashiko-bot [this message]
2026-12-01  1:15 ` [PATCH RFC net-next 07/12] net: enic: publish partial receive descriptor batches Satish Kharat
2026-12-02  1:16   ` sashiko-bot
2026-12-01  1:15 ` [PATCH RFC net-next 08/12] net: enic: add native XDP RX, TX, and redirect Satish Kharat
2026-12-02  1:16   ` sashiko-bot
2026-12-01  1:15 ` [PATCH RFC net-next 09/12] net: enic: batch AF_XDP TX completions by pool Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 10/12] net: enic: add AF_XDP zero-copy RX and TX Satish Kharat
2026-12-02  1:16   ` sashiko-bot
2026-12-01  1:15 ` [PATCH RFC net-next 11/12] selftests/xsk: exercise XDP detach with bound socket Satish Kharat
2026-12-01  1:15 ` [PATCH RFC net-next 12/12] net: enic: count XDP and AF_XDP TX in queue statistics Satish Kharat

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=sashiko-outbox-244589@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=satishkh@cisco.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox