Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Jemmy Wong <jemmywong512@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Cc: Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	Stanislav Fomichev <sdf.kernel@gmail.com>,
	Samiullah Khawaja <skhawaja@google.com>,
	Hangbin Liu <liuhangbin@gmail.com>,
	Krishna Kumar <krikku@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/rps: consolidate RPS dispatch into netif_rps() helpers
Date: Fri, 10 Jul 2026 11:59:07 +0200	[thread overview]
Message-ID: <e53482b8-4e1d-4a04-929c-f5cb443ba59d@redhat.com> (raw)
In-Reply-To: <20260702152830.39065-1-jemmywong512@gmail.com>

On 7/2/26 5:28 PM, Jemmy Wong wrote:
> From: "Jemmy Wong" <jemmywong512@gmail.com>
> 
> The RPS steering logic in netif_rx_internal(), netif_receive_skb_internal()
> and netif_receive_skb_list_internal() was open-coded three times, each with
> its own #ifdef CONFIG_RPS block and manual rcu_read_lock()/unlock() pairs.
> 
> Factor it into two helpers, netif_rps() for the single-skb path and
> netif_rps_list() for the list path, and switch the callers to
> guard(rcu)/scoped_guard(rcu). 

Please be aware of:

https://elixir.bootlin.com/linux/v7.1.2/source/Documentation/process/maintainer-netdev.rst#L400

> @@ -5695,33 +5727,20 @@ EXPORT_SYMBOL_GPL(do_xdp_generic);
> 
>  static int netif_rx_internal(struct sk_buff *skb)
>  {
> -	int ret;
> +	int ret = NET_RX_UNHANDLED;
> +	unsigned int qtail;
> 
>  	net_timestamp_check(READ_ONCE(net_hotdata.tstamp_prequeue), skb);
> 
>  	trace_netif_rx(skb);
> 
> -#ifdef CONFIG_RPS
> -	if (static_branch_unlikely(&rps_needed)) {
> -		struct rps_dev_flow voidflow, *rflow = &voidflow;
> -		int cpu;
> -
> -		rcu_read_lock();
> -
> -		cpu = get_rps_cpu(skb->dev, skb, &rflow);
> -		if (cpu < 0)
> -			cpu = smp_processor_id();
> +	scoped_guard(rcu)
> +		ret = netif_rps(skb);
> +	if (ret != NET_RX_UNHANDLED)
> +		return ret;

This function is performance critical and RCU lock is not a no-op. I
*think* this will add an unneeded rcp barrier when RPS is compile
enabled and `static_branch_unlikely(&rps_needed)` evaluate to false.

At very least you should prove that the generated code is no worse than
the current one.

/P


      parent reply	other threads:[~2026-07-10  9:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 15:28 [PATCH] net/rps: consolidate RPS dispatch into netif_rps() helpers Jemmy Wong
2026-07-07 15:48 ` [RESEND PATCH] net/core: " Jemmy Wong
2026-07-10  9:59 ` Paolo Abeni [this message]

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=e53482b8-4e1d-4a04-929c-f5cb443ba59d@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jemmywong512@gmail.com \
    --cc=krikku@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf.kernel@gmail.com \
    --cc=skhawaja@google.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