hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/tools/perf/builtin-bench.c
....@@ -11,20 +11,22 @@
1111 * Available benchmark collection list:
1212 *
1313 * sched ... scheduler and IPC performance
14
+ * syscall ... System call performance
1415 * mem ... memory access performance
1516 * numa ... NUMA scheduling and MM performance
1617 * futex ... Futex performance
18
+ * epoll ... Event poll performance
1719 */
18
-#include "perf.h"
19
-#include "util/util.h"
2020 #include <subcmd/parse-options.h>
2121 #include "builtin.h"
2222 #include "bench/bench.h"
2323
24
+#include <locale.h>
2425 #include <stdio.h>
2526 #include <stdlib.h>
2627 #include <string.h>
2728 #include <sys/prctl.h>
29
+#include <linux/zalloc.h>
2830
2931 typedef int (*bench_fn_t)(int argc, const char **argv);
3032
....@@ -49,9 +51,16 @@
4951 { NULL, NULL, NULL }
5052 };
5153
54
+static struct bench syscall_benchmarks[] = {
55
+ { "basic", "Benchmark for basic getppid(2) calls", bench_syscall_basic },
56
+ { "all", "Run all syscall benchmarks", NULL },
57
+ { NULL, NULL, NULL },
58
+};
59
+
5260 static struct bench mem_benchmarks[] = {
5361 { "memcpy", "Benchmark for memcpy() functions", bench_mem_memcpy },
5462 { "memset", "Benchmark for memset() functions", bench_mem_memset },
63
+ { "find_bit", "Benchmark for find_bit() functions", bench_mem_find_bit },
5564 { "all", "Run all memory access benchmarks", NULL },
5665 { NULL, NULL, NULL }
5766 };
....@@ -67,6 +76,22 @@
6776 { NULL, NULL, NULL }
6877 };
6978
79
+#ifdef HAVE_EVENTFD_SUPPORT
80
+static struct bench epoll_benchmarks[] = {
81
+ { "wait", "Benchmark epoll concurrent epoll_waits", bench_epoll_wait },
82
+ { "ctl", "Benchmark epoll concurrent epoll_ctls", bench_epoll_ctl },
83
+ { "all", "Run all futex benchmarks", NULL },
84
+ { NULL, NULL, NULL }
85
+};
86
+#endif // HAVE_EVENTFD_SUPPORT
87
+
88
+static struct bench internals_benchmarks[] = {
89
+ { "synthesize", "Benchmark perf event synthesis", bench_synthesize },
90
+ { "kallsyms-parse", "Benchmark kallsyms parsing", bench_kallsyms_parse },
91
+ { "inject-build-id", "Benchmark build-id injection", bench_inject_build_id },
92
+ { NULL, NULL, NULL }
93
+};
94
+
7095 struct collection {
7196 const char *name;
7297 const char *summary;
....@@ -75,11 +100,16 @@
75100
76101 static struct collection collections[] = {
77102 { "sched", "Scheduler and IPC benchmarks", sched_benchmarks },
103
+ { "syscall", "System call benchmarks", syscall_benchmarks },
78104 { "mem", "Memory access benchmarks", mem_benchmarks },
79105 #ifdef HAVE_LIBNUMA_SUPPORT
80106 { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks },
81107 #endif
82108 {"futex", "Futex stressing benchmarks", futex_benchmarks },
109
+#ifdef HAVE_EVENTFD_SUPPORT
110
+ {"epoll", "Epoll stressing benchmarks", epoll_benchmarks },
111
+#endif
112
+ { "internals", "Perf-internals benchmarks", internals_benchmarks },
83113 { "all", "All benchmarks", NULL },
84114 { NULL, NULL, NULL }
85115 };
....@@ -196,7 +226,6 @@
196226 if (!bench->fn)
197227 break;
198228 printf("# Running %s/%s benchmark...\n", coll->name, bench->name);
199
- fflush(stdout);
200229
201230 argv[1] = bench->name;
202231 run_bench(coll->name, bench->name, bench->fn, 1, argv);
....@@ -216,6 +245,10 @@
216245 {
217246 struct collection *coll;
218247 int ret = 0;
248
+
249
+ /* Unbuffered output */
250
+ setvbuf(stdout, NULL, _IONBF, 0);
251
+ setlocale(LC_ALL, "");
219252
220253 if (argc < 2) {
221254 /* No collection specified. */
....@@ -270,7 +303,6 @@
270303
271304 if (bench_format == BENCH_FORMAT_DEFAULT)
272305 printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name);
273
- fflush(stdout);
274306 ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1);
275307 goto end;
276308 }