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 15841C07E99 for ; Mon, 12 Jul 2021 18:16:20 +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 CEC09610CB for ; Mon, 12 Jul 2021 18:16:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEC09610CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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=rBGE5mP0CD1+ilaofqm2wb2K9/wuFEQsgdxE69gwqqg=; b=xRheQUQ8gVmojC 8HqryufEYPzuIkxhOzv4NTFCRqJZhNTvw8l1wgt1klZ9JVfHvE7gTwyKVXXAcIWYxCZ4W4Qrcv1Ro IUXABkvjSCCzoqsIrVjVkrODkskptuWYeA5OeFV9szv1S3uD23eOS9i8DXYaMvSFO3ENQs7UPnDCp 3rXxzSqOQm53Ykd4aK1aEGLaIrERKA/hPCInhRZiYRJaJBCD+4V/xK6xwzIikrDxBYOnAiGY1TGo4 +xyqycL8LYEGY6pDProxd14RMS+/4OK8K9QKOermu1qlUEDx37D+Ag4GQqWEWMOZRZGAFo239ujrX HvxXdN+erawUb0JKMFEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m30SB-0088jA-CE; Mon, 12 Jul 2021 18:14:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m30S8-0088im-Vj for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Jul 2021 18:14:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=YbLKP+jpQ10RhYfc/vjxAYLluWThCZNWYM9mMscKD1w=; b=cERmVIUjrZXplN5UtLEDWeCusI 8GQqP2IjaNZ/21618DQxprSiGkIhgZ0rJA/oEMB9O1ncsFQIW9fUsJKgPZ2HVWpivvdf8WnZ+vsRB 7tP6ZTZALGarN07edzcz+jklc1+9mg7aSQlCMbAYudQ4YprE2VTOykRA0pR79aF8WQn4CqAazj0xt YnFv1iXNMS+kRu3L0X9NLbhLk9eYigfoT+KQWBHNfdhAMVlnY4Z/CteJWBCG5I25I1TfObG6lLeh+ 6QVQZdf3/gsnaC99tmlV2xvv8n58fzTnjCK8Xfr7LksOQWg/4S2KbKfdWdTFeCl7s9uK7F5XlbXZG 2JiBaUAA==; Received: from [177.35.17.230] (helo=quaco.ghostprotocols.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m30Rx-000IsU-Li; Mon, 12 Jul 2021 18:14:40 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 28339403F2; Mon, 12 Jul 2021 15:14:35 -0300 (-03) Date: Mon, 12 Jul 2021 15:14:35 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 10/11] perf env: Set flag for kernel is 64-bit mode Message-ID: References: <20210711104105.505728-1-leo.yan@linaro.org> <20210711104105.505728-11-leo.yan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210711104105.505728-11-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 Sun, Jul 11, 2021 at 06:41:04PM +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 > from this info. > > This patch adds a global variable "kernel_is_64_bit", it's initialized > when a session setups environment, its value is decided by checking the > architecture string. > > Signed-off-by: Leo Yan > --- > tools/perf/util/env.c | 17 ++++++++++++++++- > tools/perf/util/env.h | 1 + > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c > index ebc5e9ad35db..345635a2e842 100644 > --- a/tools/perf/util/env.c > +++ b/tools/perf/util/env.c > @@ -11,6 +11,7 @@ > #include > #include > > +int kernel_is_64_bit; > struct perf_env perf_env; Why can't this be in 'struct perf_env'? - Arnaldo > #ifdef HAVE_LIBBPF_SUPPORT > @@ -172,6 +173,19 @@ static void perf_env__purge_bpf(struct perf_env *env __maybe_unused) > } > #endif // HAVE_LIBBPF_SUPPORT > > +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)) > + kernel_is_64_bit = 1; > + else > + kernel_is_64_bit = 0; > +} > + > void perf_env__exit(struct perf_env *env) > { > int i; > @@ -217,13 +231,14 @@ 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 > + perf_env__init_kernel_mode(env); > } > > 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..cc989ff49740 100644 > --- a/tools/perf/util/env.h > +++ b/tools/perf/util/env.h > @@ -139,6 +139,7 @@ enum perf_compress_type { > struct bpf_prog_info_node; > struct btf_node; > > +extern int kernel_is_64_bit; > extern struct perf_env perf_env; > > void perf_env__exit(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