|
Gary Lin |
1698bd |
From: Magnus Karlsson <magnus.karlsson@intel.com>
|
|
Gary Lin |
1698bd |
Date: Thu, 10 Dec 2020 17:34:07 +0100
|
|
Gary Lin |
1698bd |
Subject: samples/bpf: Fix possible hang in xdpsock with multiple threads
|
|
Gary Lin |
1698bd |
Patch-mainline: v5.11-rc1
|
|
Gary Lin |
1698bd |
Git-commit: 092fde0f863b72b67c4d6dc03844f5658fc00a35
|
|
Gary Lin |
1698bd |
References: bsc#1155518
|
|
Gary Lin |
1698bd |
|
|
Gary Lin |
1698bd |
Fix a possible hang in xdpsock that can occur when using multiple
|
|
Gary Lin |
1698bd |
threads. In this case, one or more of the threads might get stuck in
|
|
Gary Lin |
1698bd |
the while-loop in tx_only after the user has signaled the main thread
|
|
Gary Lin |
1698bd |
to stop execution. In this case, no more Tx packets will be sent, so a
|
|
Gary Lin |
1698bd |
thread might get stuck in the aforementioned while-loop. Fix this by
|
|
Gary Lin |
1698bd |
introducing a test inside the while-loop to check if the benchmark has
|
|
Gary Lin |
1698bd |
been terminated. If so, return from the function.
|
|
Gary Lin |
1698bd |
|
|
Gary Lin |
1698bd |
Fixes: cd9e72b6f210 ("samples/bpf: xdpsock: Add option to specify batch size")
|
|
Gary Lin |
1698bd |
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
|
|
Gary Lin |
1698bd |
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
|
|
Gary Lin |
1698bd |
Link: https://lore.kernel.org/bpf/20201210163407.22066-1-magnus.karlsson@gmail.com
|
|
Gary Lin |
1698bd |
Acked-by: Gary Lin <glin@suse.com>
|
|
Gary Lin |
1698bd |
---
|
|
Gary Lin |
1698bd |
samples/bpf/xdpsock_user.c | 2 ++
|
|
Gary Lin |
1698bd |
1 file changed, 2 insertions(+)
|
|
Gary Lin |
1698bd |
|
|
Gary Lin |
1698bd |
--- a/samples/bpf/xdpsock_user.c
|
|
Gary Lin |
1698bd |
+++ b/samples/bpf/xdpsock_user.c
|
|
Gary Lin |
1698bd |
@@ -929,6 +929,8 @@ static void tx_only(struct xsk_socket_in
|
|
Gary Lin |
1698bd |
while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) <
|
|
Gary Lin |
1698bd |
batch_size) {
|
|
Gary Lin |
1698bd |
complete_tx_only(xsk, batch_size);
|
|
Gary Lin |
1698bd |
+ if (benchmark_done)
|
|
Gary Lin |
1698bd |
+ return;
|
|
Gary Lin |
1698bd |
}
|
|
Gary Lin |
1698bd |
|
|
Gary Lin |
1698bd |
for (i = 0; i < batch_size; i++) {
|