Re: [RESEND PATCH] net/core: consolidate RPS dispatch into netif_rps() helpers
From: Jemmy Wong
Date: Tue Jul 21 2026 - 12:08:45 EST
> On Jul 21, 2026, at 7:25 AM, Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Tue, 7 Jul 2026 23:48:55 +0800 Jemmy Wong wrote:
>> 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). A new internal NET_RX_UNHANDLED sentinel lets
>> a helper report "RPS did not take this skb" so the caller falls back to the
>> local enqueue / __netif_receive_skb() path; it never escapes to callers.
>>
>> netif_rps_list() keeps the early static_branch_unlikely(&rps_needed) bail
>> out so the list is not needlessly walked and re-spliced when RPS is
>> compiled in but disabled.
>>
>> No functional change intended.
>
> You haven't read Paolo's reply, please go away.
Hi Jakub,
Apologies for the confusion — I am new to the netdev subsystem and
may have handled the process incorrectly.
I did read Paolo's reply and sent v2 [1] the following day to address
his two concerns:
1. Dropped guard()/scoped_guard() in favour of explicit
rcu_read_lock()/rcu_read_unlock() per the cleanup.h guidance [2].
2. Moved the RCU section inside the static_branch_unlikely() check so
the hot path (!rps_needed) acquires no lock. Verified with objdump
and bloat-o-meter that the fast path is instruction-identical to base.
I should have replied here first before posting v2 — apologies for
that process mistake.
After re-reading the maintainer-netdev.rst guide I also noticed:
- v2 subject is missing the target tree prefix (should be
"[PATCH net-next v2]").
- The patch is a standalone refactoring with no functional change,
which the guide discourages [3]. If it does not carry enough value
on its own, I am happy to drop it or fold it into a future
functional change.
[1] https://lore.kernel.org/all/20260711121009.76842-1-jemmywong512@xxxxxxxxx/
[2] https://elixir.bootlin.com/linux/v7.1.2/source/Documentation/process/maintainer-netdev.rst#L400
[3] https://elixir.bootlin.com/linux/v7.1.2/source/Documentation/process/maintainer-netdev.rst#L416
Thanks,
Jemmy Wong