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:
Jiri Olsa
2019-08-06 15:25:25 +02:00
committed by Arnaldo Carvalho de Melo
parent d5a99483de
commit 20f2be1d48
28 changed files with 36 additions and 25 deletions

View File

@@ -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>

View File

@@ -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"

View File

@@ -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"

View File

@@ -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>

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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;

View File

@@ -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,