From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C589C4338F for ; Mon, 9 Aug 2021 20:14:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E49561004 for ; Mon, 9 Aug 2021 20:14:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0E49561004 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OOWfHIRg9PpScvB0Qo1ugHBeGwoTypQtaEbb3Pbvk9M=; b=qq6NvDJZIm6HJI RSDg0qaApSI22txfs+Lb7Zypp/2ZMUVP9VzxwcrTxWVsydwedG2587O4FV1RuTjFGqKSLrOiVYbFK vEM7MpujEaBgD6U3JzzgjCtTFKg3vFDXBAL4TWHuMmPBbY6lcqzAhhC7ud1qt/PyNp0ezijOClGV2 +t7lh8L5pBDefQ062nkUn7+awbgDQTyPZZ0L8Z2EHSpOQ6s0mmvhTlfyBSTKPlCIntzDmPRj3ASuG hraApFZK9+Ao7hpqSQajSMtHKbBF9yXTIHzQICcKzqS37FwZuXiNoXwJBxOJktkSqgXfqhct46gmP 5STWR1aPCU9rBE9UNCdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDBcm-001urQ-Pp; Mon, 09 Aug 2021 20:11:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDBck-001ur4-Cp for linux-arm-kernel@bombadil.infradead.org; Mon, 09 Aug 2021 20:11:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1ThHp3QfplaW/8yVJ6PCrJAracDEEWmNmsy6zZ7Fui8=; b=EAOQGl02fzyB4OnIOnLOKjDo0R ZcST7ludDz53avaKobi+JqG9cshxAYj77O/GDuu/M99FIPSJGA/esCgzSgl8TQuwwIgA+C1ZwdJWl B3nbfTyE4/VCUosoOYpXHHQe+wBd1BbFDFeFf1v1ZvA61UNMSihWSQ09K5Aq2VQqqoT4rP034Ruil q3HcRKN/eizmzZ7ErpcmzJB0sUOUangrMVPBcnoh14r3VH/hb4AaISDK4fssAtdUxMr9oRbDkZa94 Sxj3mziP+yrGF+DzFkUyiReBPYz6HPYHm40KPJO0EYqekhLFz8EQViY5Q42GyxrqV1FXwjifSt76t qCyUVR0A==; Received: from [179.97.37.151] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDBcg-007Kaz-Ld; Mon, 09 Aug 2021 20:11:47 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 14A8C403F2; Mon, 9 Aug 2021 17:11:44 -0300 (-03) Date: Mon, 9 Aug 2021 17:11:44 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: Peter Zijlstra , Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Will Deacon , Russell King , Catalin Marinas , Mathieu Poirier , Suzuki K Poulose , Mike Leach , John Garry , Andi Kleen , Riccardo Mancini , Jin Yao , Li Huafei , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo Subject: Re: [PATCH v1 1/3] perf env: Track kernel 64-bit mode in environment Message-ID: References: <20210809112727.596876-1-leo.yan@linaro.org> <20210809112727.596876-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210809112727.596876-2-leo.yan@linaro.org> X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > Signed-off-by: Leo Yan > --- > 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel