[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRGMAHj3MUndBEUq@kernel.org>
Date: Mon, 9 Aug 2021 17:11:44 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Leo Yan <leo.yan@...aro.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Will Deacon <will@...nel.org>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
John Garry <john.garry@...wei.com>,
Andi Kleen <ak@...ux.intel.com>,
Riccardo Mancini <rickyman7@...il.com>,
Jin Yao <yao.jin@...ux.intel.com>,
Li Huafei <lihuafei1@...wei.com>, coresight@...ts.linaro.org,
linux-arm-kernel@...ts.infradead.org,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: Re: [PATCH v1 1/3] perf env: Track kernel 64-bit mode in environment
Em Mon, Aug 09, 2021 at 07:27:25PM +0800, Leo Yan escreveu:
> It's useful to know that the kernel is running in 32-bit or 64-bit
> mode. E.g. We can decide if perf tool is running in compat mode
> based on the info.
>
> This patch adds an item "kernel_is_64_bit" into session's environment
> structure perf_env, its value is initialized based on the architecture
> string.
Thanks, applied.
- Arnaldo
> Suggested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> Signed-off-by: Leo Yan <leo.yan@...aro.org>
> ---
> tools/perf/util/env.c | 24 +++++++++++++++++++++++-
> tools/perf/util/env.h | 3 +++
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
> index ab341050be46..8f7ff0035c41 100644
> --- a/tools/perf/util/env.c
> +++ b/tools/perf/util/env.c
> @@ -219,13 +219,35 @@ void perf_env__exit(struct perf_env *env)
> zfree(&env->hybrid_cpc_nodes);
> }
>
> -void perf_env__init(struct perf_env *env __maybe_unused)
> +void perf_env__init(struct perf_env *env)
> {
> #ifdef HAVE_LIBBPF_SUPPORT
> env->bpf_progs.infos = RB_ROOT;
> env->bpf_progs.btfs = RB_ROOT;
> init_rwsem(&env->bpf_progs.lock);
> #endif
> + env->kernel_is_64_bit = -1;
> +}
> +
> +static void perf_env__init_kernel_mode(struct perf_env *env)
> +{
> + const char *arch = perf_env__raw_arch(env);
> +
> + if (!strncmp(arch, "x86_64", 6) || !strncmp(arch, "aarch64", 7) ||
> + !strncmp(arch, "arm64", 5) || !strncmp(arch, "mips64", 6) ||
> + !strncmp(arch, "parisc64", 8) || !strncmp(arch, "riscv64", 7) ||
> + !strncmp(arch, "s390x", 5) || !strncmp(arch, "sparc64", 7))
> + env->kernel_is_64_bit = 1;
> + else
> + env->kernel_is_64_bit = 0;
> +}
> +
> +int perf_env__kernel_is_64_bit(struct perf_env *env)
> +{
> + if (env->kernel_is_64_bit == -1)
> + perf_env__init_kernel_mode(env);
> +
> + return env->kernel_is_64_bit;
> }
>
> int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
> diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
> index 6824a7423a2d..1f5175820a05 100644
> --- a/tools/perf/util/env.h
> +++ b/tools/perf/util/env.h
> @@ -61,6 +61,7 @@ struct perf_env {
> unsigned long long total_mem;
> unsigned int msr_pmu_type;
> unsigned int max_branches;
> + int kernel_is_64_bit;
>
> int nr_cmdline;
> int nr_sibling_cores;
> @@ -143,6 +144,8 @@ extern struct perf_env perf_env;
>
> void perf_env__exit(struct perf_env *env);
>
> +int perf_env__kernel_is_64_bit(struct perf_env *env);
> +
> int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
>
> int perf_env__read_cpuid(struct perf_env *env);
> --
> 2.25.1
>
--
- Arnaldo
Powered by blists - more mailing lists