[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190923191036.GB13508@kernel.org>
Date: Mon, 23 Sep 2019 16:10:36 -0300
From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To: Jiri Olsa <jolsa@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>
Subject: Re: [PATCH 32/73] libperf: Move page_size into libperf
Em Fri, Sep 13, 2019 at 03:23:14PM +0200, Jiri Olsa escreveu:
> We need page_size in libperf, so moving it in there.
> Adding libperf_init as a global libperf init functon.
>
> Link: http://lkml.kernel.org/n/tip-g6auuaej31nsusuevuhcgxli@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> tools/perf/lib/core.c | 7 +++++++
> tools/perf/lib/include/internal/lib.h | 2 ++
> tools/perf/lib/include/perf/core.h | 1 +
> tools/perf/lib/lib.c | 2 ++
> tools/perf/lib/libperf.map | 1 +
> tools/perf/perf.c | 4 ++--
> tools/perf/util/util.h | 2 --
you forgot to remove it from tools/perf/util/util.c, I did it, and also
added internal/lib.h to the places that use page_size, after this I'll
remove that include from util/util.h, that header has to die :-)
- Arnaldo
> 7 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/lib/core.c b/tools/perf/lib/core.c
> index 29d5e3348718..6689d593c2d1 100644
> --- a/tools/perf/lib/core.c
> +++ b/tools/perf/lib/core.c
> @@ -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);
> +}
> diff --git a/tools/perf/lib/include/internal/lib.h b/tools/perf/lib/include/internal/lib.h
> index 0b56f1201dc9..9168b7d2a7e1 100644
> --- a/tools/perf/lib/include/internal/lib.h
> +++ b/tools/perf/lib/include/internal/lib.h
> @@ -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);
>
> diff --git a/tools/perf/lib/include/perf/core.h b/tools/perf/lib/include/perf/core.h
> index c341a7b2c874..ba2f4e76a3e2 100644
> --- a/tools/perf/lib/include/perf/core.h
> +++ b/tools/perf/lib/include/perf/core.h
> @@ -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 */
> diff --git a/tools/perf/lib/lib.c b/tools/perf/lib/lib.c
> index 2a81819c3b8c..18658931fc71 100644
> --- a/tools/perf/lib/lib.c
> +++ b/tools/perf/lib/lib.c
> @@ -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;
> diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map
> index dc4d66363bc4..3fbf050b5add 100644
> --- a/tools/perf/lib/libperf.map
> +++ b/tools/perf/lib/libperf.map
> @@ -1,5 +1,6 @@
> LIBPERF_0.0.1 {
> global:
> + libperf_init;
> libperf_set_print;
> perf_cpu_map__dummy_new;
> perf_cpu_map__get;
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 1193b923e801..ead18b712d6c 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -25,6 +25,7 @@
> #include "perf-sys.h"
> #include <api/fs/fs.h>
> #include <api/fs/tracing_path.h>
> +#include <internal/lib.h>
> #include <errno.h>
> #include <pthread.h>
> #include <signal.h>
> @@ -438,8 +439,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)
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 45a5c6f20197..d6ae394e67c4 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -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,
> --
> 2.21.0
--
- Arnaldo
Powered by blists - more mailing lists