Skip to content

Commit 092fde0

Browse files
magnus-karlssonborkmann
authored andcommitted
samples/bpf: Fix possible hang in xdpsock with multiple threads
Fix a possible hang in xdpsock that can occur when using multiple threads. In this case, one or more of the threads might get stuck in the while-loop in tx_only after the user has signaled the main thread to stop execution. In this case, no more Tx packets will be sent, so a thread might get stuck in the aforementioned while-loop. Fix this by introducing a test inside the while-loop to check if the benchmark has been terminated. If so, return from the function. Fixes: cd9e72b ("samples/bpf: xdpsock: Add option to specify batch size") Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20201210163407.22066-1-magnus.karlsson@gmail.com
1 parent 41003dd commit 092fde0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎samples/bpf/xdpsock_user.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,8 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
12751275
while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) <
12761276
batch_size) {
12771277
complete_tx_only(xsk, batch_size);
1278+
if (benchmark_done)
1279+
return;
12781280
}
12791281

12801282
for (i = 0; i < batch_size; i++) {

0 commit comments

Comments
 (0)