Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: drv-net: limit RPS test CPUs to supported range

The _get_unused_cpus() function can return CPU numbers >= 16, which
exceeds RPS_MAX_CPUS in toeplitz.c. When this happens, the test fails
with a cryptic message:

# Exception| Traceback (most recent call last):
# Exception| File "/tmp/cur/linux/tools/testing/selftests/net/lib/py/ksft.py", line 319, in ksft_run
# Exception| func(*args)
# Exception| File "/tmp/cur/linux/tools/testing/selftests/drivers/net/hw/toeplitz.py", line 189, in test
# Exception| with bkg(" ".join(rx_cmd), ksft_ready=True, exit_wait=True) as rx_proc:
# Exception| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Exception| File "/tmp/cur/linux/tools/testing/selftests/net/lib/py/utils.py", line 124, in __init__
# Exception| super().__init__(comm, background=True,
# Exception| File "/tmp/cur/linux/tools/testing/selftests/net/lib/py/utils.py", line 77, in __init__
# Exception| raise Exception("Did not receive ready message")
# Exception| Exception: Did not receive ready message

Rename _get_unused_cpus() to _get_unused_rps_cpus() and cap the CPU
search range to RPS_MAX_CPUS.

Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260210093110.1935149-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Gal Pressman and committed by
Jakub Kicinski
ed6788c5 10ec0fc0

+10 -7
+10 -7
tools/testing/selftests/drivers/net/hw/toeplitz.py
··· 19 19 20 20 # "define" for the ID of the Toeplitz hash function 21 21 ETH_RSS_HASH_TOP = 1 22 + # Must match RPS_MAX_CPUS in toeplitz.c 23 + RPS_MAX_CPUS = 16 22 24 23 25 24 26 def _check_rps_and_rfs_not_configured(cfg): ··· 69 67 return cpus 70 68 71 69 72 - def _get_unused_cpus(cfg, count=2): 70 + def _get_unused_rps_cpus(cfg, count=2): 73 71 """ 74 - Get CPUs that are not used by Rx queues. 75 - Returns a list of at least 'count' CPU numbers. 72 + Get CPUs that are not used by Rx queues for RPS. 73 + Returns a list of at least 'count' CPU numbers within 74 + the RPS_MAX_CPUS supported range. 76 75 """ 77 76 78 77 # Get CPUs used by Rx queues 79 78 rx_cpus = set(_get_irq_cpus(cfg)) 80 79 81 - # Get total number of CPUs 82 - num_cpus = os.cpu_count() 80 + # Get total number of CPUs, capped by RPS_MAX_CPUS 81 + num_cpus = min(os.cpu_count(), RPS_MAX_CPUS) 83 82 84 83 # Find unused CPUs 85 84 unused_cpus = [cpu for cpu in range(num_cpus) if cpu not in rx_cpus] 86 85 87 86 if len(unused_cpus) < count: 88 - raise KsftSkipEx(f"Need at {count} CPUs not used by Rx queues, found {len(unused_cpus)}") 87 + raise KsftSkipEx(f"Need at least {count} CPUs in range 0..{num_cpus - 1} not used by Rx queues, found {len(unused_cpus)}") 89 88 90 89 return unused_cpus[:count] 91 90 ··· 184 181 ksft_pr(f"RSS using CPUs: {irq_cpus}") 185 182 elif grp == "rps": 186 183 # Get CPUs not used by Rx queues and configure them for RPS 187 - rps_cpus = _get_unused_cpus(cfg, count=2) 184 + rps_cpus = _get_unused_rps_cpus(cfg, count=2) 188 185 rps_mask = _configure_rps(cfg, rps_cpus) 189 186 defer(_configure_rps, cfg, []) 190 187 rx_cmd += ["-r", rps_mask]