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 07/12] net: enic: publish partial receive descriptor batches
Date: Wed, 02 Dec 2026 01:16:19 +0000	[thread overview]
Message-ID: <sashiko-outbox-244590@kernel.org> (raw)
In-Reply-To: <20261130-enic-xdp-rfc-p1-20261130-v1-7-3be5458c9118@cisco.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: enic: vnic_rq_publish_tail() defeats RX posted_index
  MMIO batching
--

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

net: enic: publish partial receive descriptor batches

This commit adds vnic_rq_publish_tail() and calls it at the end of
vnic_rq_fill() and enic_admin_rq_fill() so partial batches of fewer than 16
receive descriptors are published to the device.

> diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethernet/cisco/enic/vnic_rq.h
> index 9fc2090eac447..6c347599d233d 100644
> --- a/drivers/net/ethernet/cisco/enic/vnic_rq.h
> +++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h
> @@ -140,6 +140,19 @@ static inline void vnic_rq_post(struct vnic_rq *rq,
>  	}
>  }
>  
> +static inline void vnic_rq_publish_tail(struct vnic_rq *rq,
> +					struct vnic_rq_buf *first)
> +{
> +	/* A full batch was already published by vnic_rq_post(). */
> +	if (rq->to_use == first ||
> +	    !(rq->to_use->index & VNIC_RQ_RETURN_RATE))
> +		return;
> +
> +	/* Make descriptor contents visible before advancing the device index. */
> +	wmb();
> +	iowrite32(rq->to_use->index, &rq->ctrl->posted_index);
> +}
> +
>  static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count)
>  {
>  	rq->ring.desc_avail += count;
> @@ -181,16 +194,18 @@ static inline void vnic_rq_service(struct vnic_rq *rq,
>  static inline int vnic_rq_fill(struct vnic_rq *rq,
>  	int (*buf_fill)(struct vnic_rq *rq))
>  {
> -	int err;
> +	struct vnic_rq_buf *first = rq->to_use;
> +	int err = 0;
>  
>  	while (vnic_rq_desc_avail(rq) > 0) {
>  
>  		err = (*buf_fill)(rq);
>  		if (err)
> -			return err;
> +			break;
>  	}
>  
> -	return 0;
> +	vnic_rq_publish_tail(rq, first);
> +	return err;
>  }

[Severity: Medium]
Does calling vnic_rq_publish_tail() unconditionally at the end of
vnic_rq_fill() defeat the 16-descriptor posted_index batching in
vnic_rq_post() on the NAPI RX path?

vnic_dev_alloc_desc_ring() aligns ring->desc_count to a multiple of 32 and
initializes ring->desc_avail to ring->desc_count - 1.  When the ring is
completely filled during enic_open(), rq->to_use->index ends at
desc_count - 1 (15 mod 16) and vnic_rq_publish_tail() writes it to
posted_index.

Because vnic_rq_post() still flushes whenever (buf->index & 0xf) == 0, the
very first descriptor refilled on the next NAPI poll wraps buf->index to a
multiple of 16 and triggers an immediate wmb() and iowrite32() for a single
descriptor, and the end of the poll leaves rq->to_use->index unaligned again
so vnic_rq_publish_tail() issues another write.  Every full-budget 64-packet
NAPI poll permanently performs 5 posted_index MMIO writes (batches of 1, 16,
16, 16, and 15) instead of 4, and a 16-packet poll performs 2 writes instead
of 1.

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

  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
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 [this message]
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-244590@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