Merge tag 'iommu-fixes-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / tools / perf / perf.c
index 97e2628..27f94b0 100644 (file)
@@ -1,4 +1,3 @@
-// SPDX-License-Identifier: GPL-2.0
 /*
  * perf.c
  *
@@ -8,8 +7,12 @@
  * perf top, perf record, perf report, etc.) are started.
  */
 #include "builtin.h"
+#include "perf.h"
 
+#include "util/build-id.h"
+#include "util/cache.h"
 #include "util/env.h"
+#include <internal/lib.h> // page_size
 #include <subcmd/exec-cmd.h>
 #include "util/config.h"
 #include <subcmd/run-command.h>
 #include "util/bpf-loader.h"
 #include "util/debug.h"
 #include "util/event.h"
+#include "util/util.h" // usage()
+#include "ui/ui.h"
+#include "perf-sys.h"
 #include <api/fs/fs.h>
 #include <api/fs/tracing_path.h>
+#include <perf/core.h>
 #include <errno.h>
 #include <pthread.h>
 #include <signal.h>
@@ -29,6 +36,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <linux/kernel.h>
+#include <linux/string.h>
 #include <linux/zalloc.h>
 
 const char perf_usage_string[] =
@@ -422,6 +430,12 @@ void pthread__unblock_sigwinch(void)
        pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 }
 
+static int libperf_print(enum libperf_print_level level,
+                        const char *fmt, va_list ap)
+{
+       return eprintf(level, verbose, fmt, ap);
+}
+
 int main(int argc, const char **argv)
 {
        int err;
@@ -432,8 +446,7 @@ int main(int argc, const char **argv)
        exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
        pager_init(PERF_PAGER_ENVIRONMENT);
 
-       /* The page_size is placed in util object. */
-       page_size = sysconf(_SC_PAGE_SIZE);
+       libperf_init(libperf_print);
 
        cmd = extract_argv0_path(argv[0]);
        if (!cmd)
@@ -441,6 +454,9 @@ int main(int argc, const char **argv)
 
        srandom(time(NULL));
 
+       /* Setting $PERF_CONFIG makes perf read _only_ the given config file. */
+       config_exclusive_filename = getenv("PERF_CONFIG");
+
        err = perf_config(perf_default_config, NULL);
        if (err)
                return err;