On Tue, May 19, 2026 at 12:56:38PM +0200, Maciej Fijalkowski wrote: > For the main VSI, i40e_set_num_rings_in_vsi() always derives > num_q_vectors from pf->num_lan_msix. At the same time, ethtool -L stores > the user requested channel count in vsi->req_queue_pairs and the queue > setup path uses that value for the effective number of queue pairs. > > This leaves queue and vector counts out of sync after shrinking channel > count via ethtool -L. The active queue configuration is reduced, but the > VSI still keeps the full PF-sized q_vector topology. > > That mismatch breaks reconfiguration flows which rely on vector/NAPI > state matching the effective channel configuration. In particular, > toggling /sys/class/net/<dev>/threaded after reducing the channel count > can hang, and later channel-count changes can fail because VSI reinit > does not rebuild q_vectors to match the new vector count. > > Fix this by making the main VSI num_q_vectors follow the effective > requested channel count, capped by the available MSI-X vectors. Update > i40e_vsi_reinit_setup() to rebuild q_vectors during VSI reinit so the > vector topology is refreshed together with the ring arrays when channel > count changes. > > Keep alloc_queue_pairs unchanged and based on pf->num_lan_qps so the VSI > retains its full queue capacity. > > Selftest napi_threaded.py was originally used when Jakub reported hang > on /sys/class/net/<dev>/threaded toggle. In order to make it pass on > i40e, use persistent NAPI configuration for q_vector NAPIs so NAPI > identity and threaded settings survive q_vector reallocation across > channel-count changes. This is achieved by using netif_napi_add_config() > when configuring q_vectors. > > $ export NETIF=ens259f1np1 > $ sudo -E env PATH="$PATH" > ./tools/testing/selftests/drivers/net/napi_threaded.py > TAP version 13 > 1..3 > ok 1 napi_threaded.napi_init > ok 2 napi_threaded.change_num_queues > ok 3 napi_threaded.enable_dev_threaded_disable_napi_threaded > Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0 > > Reported-by: Jakub Kicinski <[email protected]> > Closes: > https://lore.kernel.org/intel-wired-lan/[email protected]/ > Fixes: d2a69fefd756 ("i40e: Fix changing previously set num_queue_pairs for > PFs") > Reviewed-by: Simon Horman <[email protected]> > Tested-by: Sunitha Mekala <[email protected]> > Signed-off-by: Maciej Fijalkowski <[email protected]> > --- > v3: > - address UAF when ring arrays where freed before q_vector's ring > containers (Sashiko, Jacob) > - remove bool params from alloc/free array routines (Simon) > v2: > - NULL vsi->tx_rings in i40e_vsi_alloc_arrays() (Sashiko)
I notice that there is an AI review of this patch available on sashiko.dev. However, I believe that flags a pre-existing problem that is orthogonal to this patch. o I do no think that review should block progress of this patch but rather be looked at in the context of possible follow-up.
