From: David Laight <david.laight.linux@gmail.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
intel-wired-lan@lists.osuosl.org,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Simon Horman <horms@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
Natalia Wochtman <natalia.wochtman@intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH iwl-next v3 04/10] ixgbevf: branch prediction and cleanup
Date: Wed, 4 Mar 2026 21:35:20 +0000 [thread overview]
Message-ID: <20260304213520.17e16331@pumpkin> (raw)
In-Reply-To: <20260304160345.1340940-5-larysa.zaremba@intel.com>
On Wed, 4 Mar 2026 17:03:36 +0100
Larysa Zaremba <larysa.zaremba@intel.com> wrote:
> Add likely/unlikely markers for better branch prediction. While touching
> some functions, cleanup the code a little bit.
>
> This patch is not supposed to make any logic changes aside from making
> total_rx_bytes and total_rx_packets more correlated.
>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 29 +++++++++----------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> index 5a270dd2c7aa..4619f2bea1ab 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> @@ -570,7 +570,7 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
> u16 ntu = rx_ring->next_to_use;
>
> /* nothing to do or no valid netdev defined */
> - if (!cleaned_count || !rx_ring->netdev)
> + if (unlikely(!cleaned_count || !rx_ring->netdev))
> return;
>
> rx_desc = IXGBEVF_RX_DESC(rx_ring, ntu);
> @@ -586,7 +586,7 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
>
> rx_desc++;
> ntu++;
> - if (unlikely(ntu == rx_ring->count)) {
> + if (unlikely(ntu == fq.count)) {
> rx_desc = IXGBEVF_RX_DESC(rx_ring, 0);
> ntu = 0;
> }
> @@ -823,7 +823,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
>
> rx_desc = IXGBEVF_RX_DESC(rx_ring, rx_ring->next_to_clean);
> size = le16_to_cpu(rx_desc->wb.upper.length);
> - if (!size)
> + if (unlikely(!size))
> break;
>
> /* This memory barrier is needed to keep us from reading
> @@ -855,7 +855,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
> }
>
> /* exit if we failed to retrieve a buffer */
> - if (!xdp_res && !skb) {
> + if (unlikely(!xdp_res && !skb)) {
I'd check that generates something sensible.
Using unlikely on multi-term conditionals doesn't always do
something sensible.
David
> rx_ring->rx_stats.alloc_rx_buff_failed++;
> break;
> }
> @@ -867,21 +867,19 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
> continue;
>
> /* verify the packet layout is correct */
> - if (xdp_res || ixgbevf_cleanup_headers(rx_ring, rx_desc, skb)) {
> + if (xdp_res ||
> + unlikely(ixgbevf_cleanup_headers(rx_ring, rx_desc, skb))) {
> skb = NULL;
> continue;
> }
>
> - /* probably a little skewed due to removing CRC */
> - total_rx_bytes += skb->len;
> -
> /* Workaround hardware that can't do proper VEPA multicast
> * source pruning.
> */
> - if ((skb->pkt_type == PACKET_BROADCAST ||
> - skb->pkt_type == PACKET_MULTICAST) &&
> - ether_addr_equal(rx_ring->netdev->dev_addr,
> - eth_hdr(skb)->h_source)) {
> + if (unlikely((skb->pkt_type == PACKET_BROADCAST ||
> + skb->pkt_type == PACKET_MULTICAST) &&
> + ether_addr_equal(rx_ring->netdev->dev_addr,
> + eth_hdr(skb)->h_source))) {
> dev_kfree_skb_irq(skb);
> continue;
> }
> @@ -889,13 +887,14 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
> /* populate checksum, VLAN, and protocol */
> ixgbevf_process_skb_fields(rx_ring, rx_desc, skb);
>
> + /* probably a little skewed due to removing CRC */
> + total_rx_bytes += skb->len;
> + total_rx_packets++;
> +
> ixgbevf_rx_skb(q_vector, skb);
>
> /* reset skb pointer */
> skb = NULL;
> -
> - /* update budget accounting */
> - total_rx_packets++;
> }
>
> /* place incomplete frames back on ring for completion */
next prev parent reply other threads:[~2026-03-04 21:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 16:03 [PATCH iwl-next v3 00/10] libeth and full XDP for ixgbevf Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 01/10] ixgbevf: remove legacy Rx Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 02/10] ixgbevf: do not share pages between packets Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 03/10] ixgbevf: use libeth in Rx processing Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 04/10] ixgbevf: branch prediction and cleanup Larysa Zaremba
2026-03-04 21:35 ` David Laight [this message]
2026-03-04 16:03 ` [PATCH iwl-next v3 05/10] ixgbevf: support XDP multi-buffer on Rx path Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 06/10] ixgbevf: XDP_TX in multi-buffer through libeth Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 07/10] ixgbevf: support XDP_REDIRECT and .ndo_xdp_xmit Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 08/10] ixgbevf: add pseudo header split Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 09/10] ixgbevf: reconfigure page pool when reallocating buffers Larysa Zaremba
2026-03-04 16:03 ` [PATCH iwl-next v3 10/10] ixgbevf: allow changing MTU when XDP program is attached Larysa Zaremba
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=20260304213520.17e16331@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=aleksander.lobakin@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=natalia.wochtman@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
/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