History

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.

Magnus Karlsson committed 5 years ago

Commit 092fde01 parent 41003dd1 file · +2 −0Browse files

Unified · Split

samples/bpf/xdpsock_user.c+2−0
@@ -1275,6 +1275,8 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size) · 1274 unmodified lines
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++) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t