mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
samples/bpf: Fix possible hang in xdpsock with multiple threads
[ Upstream commit092fde0f86] 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:cd9e72b6f2("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4d0721cb10
commit
81ef603e86
@@ -1250,6 +1250,8 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
|
||||
while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) <
|
||||
batch_size) {
|
||||
complete_tx_only(xsk, batch_size);
|
||||
if (benchmark_done)
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < batch_size; i++) {
|
||||
|
||||
Reference in New Issue
Block a user