Skip to content

Commit 94d864b

Browse files
magnus-karlssonkernel-patches-bot
authored andcommitted
From: Magnus Karlsson <[email protected]>
Add a quiet option (-Q) that disables the statistics print outs of xdpsock. This is good to have when measuring 0% loss rate performance as it will be quite terrible if the application uses printfs. Signed-off-by: Magnus Karlsson <[email protected]> --- samples/bpf/xdpsock_user.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
1 parent 3502242 commit 94d864b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

samples/bpf/xdpsock_user.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static int opt_pkt_count;
7878
static u16 opt_pkt_size = MIN_PKT_SIZE;
7979
static u32 opt_pkt_fill_pattern = 0x12345678;
8080
static bool opt_extra_stats;
81+
static bool opt_quiet;
8182
static int opt_poll;
8283
static int opt_interval = 1;
8384
static u32 opt_xdp_bind_flags = XDP_USE_NEED_WAKEUP;
@@ -718,6 +719,7 @@ static struct option long_options[] = {
718719
{"tx-pkt-size", required_argument, 0, 's'},
719720
{"tx-pkt-pattern", required_argument, 0, 'P'},
720721
{"extra-stats", no_argument, 0, 'x'},
722+
{"quiet", no_argument, 0, 'Q'},
721723
{0, 0, 0, 0}
722724
};
723725

@@ -753,6 +755,7 @@ static void usage(const char *prog)
753755
" Min size: %d, Max size %d.\n"
754756
" -P, --tx-pkt-pattern=nPacket fill pattern. Default: 0x%x\n"
755757
" -x, --extra-stats Display extra statistics.\n"
758+
" -Q, --quiet Do not display any stats.\n"
756759
"\n";
757760
fprintf(stderr, str, prog, XSK_UMEM__DEFAULT_FRAME_SIZE,
758761
opt_batch_size, MIN_PKT_SIZE, MIN_PKT_SIZE,
@@ -768,7 +771,7 @@ static void parse_command_line(int argc, char **argv)
768771
opterr = 0;
769772

770773
for (;;) {
771-
c = getopt_long(argc, argv, "Frtli:q:pSNn:czf:muMd:b:C:s:P:x",
774+
c = getopt_long(argc, argv, "Frtli:q:pSNn:czf:muMd:b:C:s:P:xQ",
772775
long_options, &option_index);
773776
if (c == -1)
774777
break;
@@ -852,6 +855,9 @@ static void parse_command_line(int argc, char **argv)
852855
case 'x':
853856
opt_extra_stats = 1;
854857
break;
858+
case 'Q':
859+
opt_quiet = 1;
860+
break;
855861
default:
856862
usage(basename(argv[0]));
857863
}
@@ -1286,9 +1292,11 @@ int main(int argc, char **argv)
12861292

12871293
setlocale(LC_ALL, "");
12881294

1289-
ret = pthread_create(&pt, NULL, poller, NULL);
1290-
if (ret)
1291-
exit_with_error(ret);
1295+
if (!opt_quiet) {
1296+
ret = pthread_create(&pt, NULL, poller, NULL);
1297+
if (ret)
1298+
exit_with_error(ret);
1299+
}
12921300

12931301
prev_time = get_nsecs();
12941302
start_time = prev_time;
@@ -1302,7 +1310,8 @@ int main(int argc, char **argv)
13021310

13031311
benchmark_done = true;
13041312

1305-
pthread_join(pt, NULL);
1313+
if (!opt_quiet)
1314+
pthread_join(pt, NULL);
13061315

13071316
xdpsock_cleanup();
13081317

0 commit comments

Comments
 (0)