libperf: Move 'page_size' global variable to libperf
We need the 'page_size' variable in libperf, so move it there. Add a libperf_init() as a global libperf init function to obtain this value via sysconf() at tool start. Committer notes: Add internal/lib.h to tools/perf/ files using 'page_size', sometimes replacing util.h with it if that was the only reason for having util.h included. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lore.kernel.org/lkml/20190913132355.21634-33-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d5a99483de
commit
20f2be1d48
|
@ -25,7 +25,7 @@
|
|||
#include "../../util/evsel.h"
|
||||
#include "../../util/pmu.h"
|
||||
#include "../../util/cs-etm.h"
|
||||
#include "../../util/util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "../../util/session.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "../../util/evsel.h"
|
||||
#include "../../util/evlist.h"
|
||||
#include "../../util/session.h"
|
||||
#include "../../util/util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "../../util/pmu.h"
|
||||
#include "../../util/debug.h"
|
||||
#include "../../util/auxtrace.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "machine.h"
|
||||
#include "api/fs/fs.h"
|
||||
#include "debug.h"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "evlist.h"
|
||||
#include "evsel.h"
|
||||
#include "arch-tests.h"
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "tests/tests.h"
|
||||
#include "cloexec.h"
|
||||
#include "event.h"
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "arch-tests.h"
|
||||
|
||||
static u64 rdpmc(unsigned int counter)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "../../util/tsc.h"
|
||||
#include "../../util/auxtrace.h"
|
||||
#include "../../util/intel-bts.h"
|
||||
#include "../../util/util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#define KiB(x) ((x) * 1024)
|
||||
#define MiB(x) ((x) * 1024 * 1024)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "../../util/record.h"
|
||||
#include "../../util/target.h"
|
||||
#include "../../util/tsc.h"
|
||||
#include "../../util/util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "../../util/intel-pt.h"
|
||||
|
||||
#define KiB(x) ((x) * 1024)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../util/util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "../../util/machine.h"
|
||||
#include "../../util/map.h"
|
||||
#include "../../util/symbol.h"
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <perf/core.h>
|
||||
#include <internal/lib.h>
|
||||
#include "internal.h"
|
||||
|
||||
static int __base_pr(enum libperf_print_level level, const char *format,
|
||||
|
@ -32,3 +34,8 @@ void libperf_print(enum libperf_print_level level, const char *format, ...)
|
|||
__libperf_pr(level, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void libperf_init(void)
|
||||
{
|
||||
page_size = sysconf(_SC_PAGE_SIZE);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
extern unsigned int page_size;
|
||||
|
||||
ssize_t readn(int fd, void *buf, size_t n);
|
||||
ssize_t writen(int fd, const void *buf, size_t n);
|
||||
|
||||
|
|
|
@ -18,5 +18,6 @@ typedef int (*libperf_print_fn_t)(enum libperf_print_level level,
|
|||
const char *, va_list ap);
|
||||
|
||||
LIBPERF_API void libperf_set_print(libperf_print_fn_t fn);
|
||||
LIBPERF_API void libperf_init(void);
|
||||
|
||||
#endif /* __LIBPERF_CORE_H */
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <internal/lib.h>
|
||||
|
||||
unsigned int page_size;
|
||||
|
||||
static ssize_t ion(bool is_read, int fd, void *buf, size_t n)
|
||||
{
|
||||
void *buf_start = buf;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
LIBPERF_0.0.1 {
|
||||
global:
|
||||
libperf_init;
|
||||
libperf_set_print;
|
||||
perf_cpu_map__dummy_new;
|
||||
perf_cpu_map__get;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#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>
|
||||
|
@ -20,11 +21,12 @@
|
|||
#include "util/bpf-loader.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/event.h"
|
||||
#include "util/util.h" // page_size, usage()
|
||||
#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>
|
||||
|
@ -438,8 +440,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();
|
||||
|
||||
cmd = extract_argv0_path(argv[0]);
|
||||
if (!cmd)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "symbol.h"
|
||||
#include "util/synthetic-events.h"
|
||||
#include "thread.h"
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#define THREADS 4
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "dso.h"
|
||||
#include "map.h"
|
||||
#include "symbol.h"
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "tests.h"
|
||||
#include "debug.h"
|
||||
#include "machine.h"
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "intel-bts.h"
|
||||
#include "arm-spe.h"
|
||||
#include "s390-cpumsf.h"
|
||||
#include "util.h" // page_size
|
||||
#include "util/mmap.h"
|
||||
|
||||
#include <linux/ctype.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "evsel.h"
|
||||
#include "debug.h"
|
||||
#include "units.h"
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
#include "../perf.h"
|
||||
#include "asm/bug.h"
|
||||
#include "bpf-event.h"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "tool.h"
|
||||
#include "time-utils.h"
|
||||
#include "units.h"
|
||||
#include "util.h" // page_size, perf_exe()
|
||||
#include "util/util.h" // perf_exe()
|
||||
#include "cputopo.h"
|
||||
#include "bpf-event.h"
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "linux/hash.h"
|
||||
#include "asm/bug.h"
|
||||
#include "bpf-event.h"
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#include <linux/ctype.h>
|
||||
#include <symbol/kallsyms.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "event.h"
|
||||
#include "mmap.h"
|
||||
#include "../perf.h"
|
||||
#include "util.h" /* page_size */
|
||||
#include <internal/lib.h> /* page_size */
|
||||
|
||||
size_t perf_mmap__mmap_len(struct mmap *map)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "thread_map.h"
|
||||
#include "trace-event.h"
|
||||
#include "mmap.h"
|
||||
#include "util.h"
|
||||
#include <internal/lib.h>
|
||||
#include "../perf-sys.h"
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "thread-stack.h"
|
||||
#include "sample-raw.h"
|
||||
#include "stat.h"
|
||||
#include "util.h"
|
||||
#include "ui/progress.h"
|
||||
#include "../perf.h"
|
||||
#include "arch/common.h"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <string.h>
|
||||
#include "srccode.h"
|
||||
#include "debug.h"
|
||||
#include "util.h" // page_size
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#define MAXSRCCACHE (32*1024*1024)
|
||||
#define MAXSRCFILES 64
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "util/synthetic-events.h"
|
||||
#include "util/target.h"
|
||||
#include "util/time-utils.h"
|
||||
#include "util/util.h"
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
|
@ -26,6 +25,7 @@
|
|||
#include <perf/evsel.h>
|
||||
#include <internal/cpumap.h>
|
||||
#include <perf/cpumap.h>
|
||||
#include <internal/lib.h> // page_size
|
||||
#include <internal/threadmap.h>
|
||||
#include <perf/threadmap.h>
|
||||
#include <symbol/kallsyms.h>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
/*
|
||||
* Copyright (C) 2008,2009, Steven Rostedt <srostedt@redhat.com>
|
||||
*/
|
||||
#include "util.h" // page_size
|
||||
#include <dirent.h>
|
||||
#include <mntent.h>
|
||||
#include <stdio.h>
|
||||
|
@ -19,6 +18,7 @@
|
|||
#include <linux/list.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/zalloc.h>
|
||||
#include <internal/lib.h> // page_size
|
||||
|
||||
#include "trace-event.h"
|
||||
#include <api/fs/tracing_path.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "debug.h"
|
||||
#include "event.h"
|
||||
#include "namespaces.h"
|
||||
#include <internal/lib.h>
|
||||
#include <api/fs/fs.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -41,8 +42,6 @@ void perf_set_multithreaded(void)
|
|||
perf_singlethreaded = false;
|
||||
}
|
||||
|
||||
unsigned int page_size;
|
||||
|
||||
int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH;
|
||||
int sysctl_perf_event_max_contexts_per_stack = PERF_MAX_CONTEXTS_PER_STACK;
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size);
|
|||
|
||||
size_t hex_width(u64 v);
|
||||
|
||||
extern unsigned int page_size;
|
||||
|
||||
int sysctl__max_stack(void);
|
||||
|
||||
int fetch_kernel_version(unsigned int *puint,
|
||||
|
|
Loading…
Reference in New Issue