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

selftests: Add napi threaded busy poll test in `busy_poller`

Add testcase to run busy poll test with threaded napi busy poll enabled.

Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Martin Karsten <mkarsten@uwaterloo.ca>
Tested-by: Martin Karsten <mkarsten@uwaterloo.ca>
Link: https://patch.msgid.link/20251028203007.575686-3-skhawaja@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Samiullah Khawaja and committed by
Jakub Kicinski
add3c132 c18d4b19

+36 -4
+23 -1
tools/testing/selftests/net/busy_poll_test.sh
··· 27 27 GRO_FLUSH_TIMEOUT=50000 28 28 SUSPEND_TIMEOUT=20000000 29 29 30 + NAPI_THREADED_MODE_BUSY_POLL=2 31 + 30 32 setup_ns() 31 33 { 32 34 set -e ··· 64 62 test_busypoll() 65 63 { 66 64 suspend_value=${1:-0} 65 + napi_threaded_value=${2:-0} 66 + prefer_busy_poll_value=${3:-$PREFER_BUSY_POLL} 67 + 67 68 tmp_file=$(mktemp) 68 69 out_file=$(mktemp) 69 70 ··· 78 73 -b${SERVER_IP} \ 79 74 -m${MAX_EVENTS} \ 80 75 -u${BUSY_POLL_USECS} \ 81 - -P${PREFER_BUSY_POLL} \ 76 + -P${prefer_busy_poll_value} \ 82 77 -g${BUSY_POLL_BUDGET} \ 83 78 -i${NSIM_SV_IFIDX} \ 84 79 -s${suspend_value} \ 80 + -t${napi_threaded_value} \ 85 81 -o${out_file}& 86 82 87 83 wait_local_port_listen nssv ${SERVER_PORT} tcp ··· 111 105 test_busypoll_with_suspend() 112 106 { 113 107 test_busypoll ${SUSPEND_TIMEOUT} 108 + 109 + return $? 110 + } 111 + 112 + test_busypoll_with_napi_threaded() 113 + { 114 + # Only enable napi threaded poll. Set suspend timeout and prefer busy 115 + # poll to 0. 116 + test_busypoll 0 ${NAPI_THREADED_MODE_BUSY_POLL} 0 114 117 115 118 return $? 116 119 } ··· 165 150 test_busypoll_with_suspend 166 151 if [ $? -ne 0 ]; then 167 152 echo "test_busypoll_with_suspend failed" 153 + cleanup_ns 154 + exit 1 155 + fi 156 + 157 + test_busypoll_with_napi_threaded 158 + if [ $? -ne 0 ]; then 159 + echo "test_busypoll_with_napi_threaded failed" 168 160 cleanup_ns 169 161 exit 1 170 162 fi
+13 -3
tools/testing/selftests/net/busy_poller.c
··· 65 65 static uint16_t cfg_busy_poll_budget; 66 66 static uint8_t cfg_prefer_busy_poll; 67 67 68 - /* IRQ params */ 68 + /* NAPI params */ 69 69 static uint32_t cfg_defer_hard_irqs; 70 70 static uint64_t cfg_gro_flush_timeout; 71 71 static uint64_t cfg_irq_suspend_timeout; 72 + static enum netdev_napi_threaded cfg_napi_threaded_poll = NETDEV_NAPI_THREADED_DISABLED; 72 73 73 74 static void usage(const char *filepath) 74 75 { 75 76 error(1, 0, 76 - "Usage: %s -p<port> -b<addr> -m<max_events> -u<busy_poll_usecs> -P<prefer_busy_poll> -g<busy_poll_budget> -o<outfile> -d<defer_hard_irqs> -r<gro_flush_timeout> -s<irq_suspend_timeout> -i<ifindex>", 77 + "Usage: %s -p<port> -b<addr> -m<max_events> -u<busy_poll_usecs> -P<prefer_busy_poll> -g<busy_poll_budget> -o<outfile> -d<defer_hard_irqs> -r<gro_flush_timeout> -s<irq_suspend_timeout> -t<napi_threaded_poll> -i<ifindex>", 77 78 filepath); 78 79 } 79 80 ··· 87 86 if (argc <= 1) 88 87 usage(argv[0]); 89 88 90 - while ((c = getopt(argc, argv, "p:m:b:u:P:g:o:d:r:s:i:")) != -1) { 89 + while ((c = getopt(argc, argv, "p:m:b:u:P:g:o:d:r:s:i:t:")) != -1) { 91 90 /* most options take integer values, except o and b, so reduce 92 91 * code duplication a bit for the common case by calling 93 92 * strtoull here and leave bounds checking and casting per ··· 169 168 170 169 cfg_ifindex = (int)tmp; 171 170 break; 171 + case 't': 172 + if (tmp > 2) 173 + error(1, ERANGE, "napi threaded poll value must be 0-2"); 174 + 175 + cfg_napi_threaded_poll = (enum netdev_napi_threaded)tmp; 176 + break; 172 177 } 173 178 } 174 179 ··· 253 246 cfg_gro_flush_timeout); 254 247 netdev_napi_set_req_set_irq_suspend_timeout(set_req, 255 248 cfg_irq_suspend_timeout); 249 + 250 + if (cfg_napi_threaded_poll) 251 + netdev_napi_set_req_set_threaded(set_req, cfg_napi_threaded_poll); 256 252 257 253 if (netdev_napi_set(ys, set_req)) 258 254 error(1, 0, "can't set NAPI params: %s\n", yerr.msg);