hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/perf/perf.c
....@@ -1,4 +1,3 @@
1
-// SPDX-License-Identifier: GPL-2.0
21 /*
32 * perf.c
43 *
....@@ -8,8 +7,12 @@
87 * perf top, perf record, perf report, etc.) are started.
98 */
109 #include "builtin.h"
10
+#include "perf.h"
1111
12
+#include "util/build-id.h"
13
+#include "util/cache.h"
1214 #include "util/env.h"
15
+#include <internal/lib.h> // page_size
1316 #include <subcmd/exec-cmd.h>
1417 #include "util/config.h"
1518 #include <subcmd/run-command.h>
....@@ -18,8 +21,12 @@
1821 #include "util/bpf-loader.h"
1922 #include "util/debug.h"
2023 #include "util/event.h"
24
+#include "util/util.h" // usage()
25
+#include "ui/ui.h"
26
+#include "perf-sys.h"
2127 #include <api/fs/fs.h>
2228 #include <api/fs/tracing_path.h>
29
+#include <perf/core.h>
2330 #include <errno.h>
2431 #include <pthread.h>
2532 #include <signal.h>
....@@ -29,6 +36,8 @@
2936 #include <sys/stat.h>
3037 #include <unistd.h>
3138 #include <linux/kernel.h>
39
+#include <linux/string.h>
40
+#include <linux/zalloc.h>
3241
3342 const char perf_usage_string[] =
3443 "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
....@@ -298,6 +307,7 @@
298307 use_pager = 1;
299308 commit_pager_choice();
300309
310
+ perf_env__init(&perf_env);
301311 perf_env__set_cmdline(&perf_env, argc, argv);
302312 status = p->fn(argc, argv);
303313 perf_config__exit();
....@@ -420,6 +430,12 @@
420430 pthread_sigmask(SIG_UNBLOCK, &set, NULL);
421431 }
422432
433
+static int libperf_print(enum libperf_print_level level,
434
+ const char *fmt, va_list ap)
435
+{
436
+ return veprintf(level, verbose, fmt, ap);
437
+}
438
+
423439 int main(int argc, const char **argv)
424440 {
425441 int err;
....@@ -430,8 +446,7 @@
430446 exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
431447 pager_init(PERF_PAGER_ENVIRONMENT);
432448
433
- /* The page_size is placed in util object. */
434
- page_size = sysconf(_SC_PAGE_SIZE);
449
+ libperf_init(libperf_print);
435450
436451 cmd = extract_argv0_path(argv[0]);
437452 if (!cmd)