From patchwork Fri Mar 3 20:10:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 64077 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp608660wrd; Fri, 3 Mar 2023 12:17:19 -0800 (PST) X-Google-Smtp-Source: AK7set9YttA+fEQov04xhQQrAILlVMKOanXtVBpBHsSmRzLOKHm6brmW5HoCdxnEOR87ZdlDR2zz X-Received: by 2002:aa7:9782:0:b0:5d6:3d96:4777 with SMTP id o2-20020aa79782000000b005d63d964777mr2905037pfp.24.1677874638696; Fri, 03 Mar 2023 12:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677874638; cv=none; d=google.com; s=arc-20160816; b=qNictFm8v3OQAxMYiwUWt24VKHQGD509BPViXC5FkxOGDpr5o9H4X4kujf2tl7Lx15 plqsShHVh68ERs6raTEqKFFyxZrS1pBaRuaQHqtt4sKwjkdY93JE0Xn7t1eirpivsD3S J7kvGIFdywit+wa7WT1ExmqVSNn5Ad4oHcZdEqYtjp3Fw8kpyNQp1kaGvTdrdsve7cMv LphOY+QwRx48Vudab4Cl0IagdMydJ2hZR3bIXOkSif/NVeWR9qkRC5Pz9aD9kBVXwq6m v1C+ji9WjwDdDRfKnRrE++cd1tqUmL2IxCGyAxOLsR6siPFwY0lM/ea4fHlzGxtny6o6 J0Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=oojyChBAVcO0GmxTrlVcHAV9nUppObiNwYBSluckznU=; b=QjfUaVcejD9B7+IKOY8oQ2gRR+RJkTSMJiWIBiBAb1DOFu9yCWXYGudFF5rNxlKG0Y 9W+n9IBuKJ5ju2R9pJ0dponJLej6TGVkNautxTwRZ8HtnJ5Xik0I4hwVq/93i1v6y42o c9lcBXrNZLUsyKFeMfm/DcmEt73fwUONQHwOSmD1UvEb538zFJLqQTrXhaj3MYVwvHRO 7mH+HK3eqUBiEvgxZIFoRo79YN+TNipn2iOs9crIgqMRhYywY2r6g3FgdpDbN+duSS7K EEk9BOxi9IsRYr7inq8fG4oaBag75jwbSGksH1QmWE11z4D2+8Gl48L3JEjx0sA3DFVW XahQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FXqApEMd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u131-20020a627989000000b005a8d4f27a2esi3142803pfc.50.2023.03.03.12.17.05; Fri, 03 Mar 2023 12:17:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FXqApEMd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjCCUKN (ORCPT + 99 others); Fri, 3 Mar 2023 15:10:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbjCCUKL (ORCPT ); Fri, 3 Mar 2023 15:10:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C54B11169 for ; Fri, 3 Mar 2023 12:10:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC55B618D7 for ; Fri, 3 Mar 2023 20:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0445CC433EF; Fri, 3 Mar 2023 20:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677874209; bh=X4akq66e0gZRvEvk52d1rWM5GurogB2/V8coehvNc0I=; h=Date:From:To:Cc:Subject:From; b=FXqApEMdwMw3QQFtPhe4PcOettLioseLX1AS39OBtCN0xgZ9j2UcnOwvS6XfH+D7C y9Nig+CkTxGyE/a62dVcAPyyvORXJTh+UVitULcFWn2oz8qxdSJCBy0tkjH4zSYaWB 3iEZpqYe3wqoPZaHbDE4ySpQSxMltjTkJGqerU9m4hXJnrJSHC8gMfV9zT3VmNGgLM 9Vh3DsXZkI90kAS/iLk0krWY2N/8D2OTll4rfFBSFx7vyaxZ515eFOaHz/BeqNjkU7 T3d+gOe9VtIK7ZrBRz8iICEcIn8gSKq6/85EDKkLrxcdVWip/4R8yjt9ylNfGlOmrD /32dxxFFKgHmg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5C4D14049F; Fri, 3 Mar 2023 17:10:06 -0300 (-03) Date: Fri, 3 Mar 2023 17:10:06 -0300 From: Arnaldo Carvalho de Melo To: linux-kernel@vger.kernel.org Cc: Adrian Hunter , Ian Rogers , Jiri Olsa , Mike Leach , Namhyung Kim , Suzuki K Poulose Subject: [PATCH 1/1 fyi] tools headers: Sync linux/coresight-pmu.h with the kernel sources Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759379077210186998?= X-GMAIL-MSGID: =?utf-8?q?1759379077210186998?= tldr; Just FYI, I'm carrying this on the perf tools tree. - Arnaldo Full explanation: There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model. The way these headers are used in perf are not restricted to just including them to compile something. There are sometimes used in scripts that convert defines into string tables, etc, so some change may break one of these scripts, or new MSRs may use some different #define pattern, etc. E.g.: $ ls -1 tools/perf/trace/beauty/*.sh | head -5 tools/perf/trace/beauty/arch_errno_names.sh tools/perf/trace/beauty/drm_ioctl.sh tools/perf/trace/beauty/fadvise.sh tools/perf/trace/beauty/fsconfig.sh tools/perf/trace/beauty/fsmount.sh $ $ tools/perf/trace/beauty/fadvise.sh static const char *fadvise_advices[] = { [0] = "NORMAL", [1] = "RANDOM", [2] = "SEQUENTIAL", [3] = "WILLNEED", [4] = "DONTNEED", [5] = "NOREUSE", }; $ The tools/perf/check-headers.sh script, part of the tools/ build process, points out changes in the original files. So its important not to touch the copies in tools/ when doing changes in the original kernel headers, that will be done later, when check-headers.sh inform about the change to the perf tools hackers. --- To pick up the fixes in: 206bb3858949b650 ("coresight: trace id: Remove legacy get trace ID function.") aa19bb4c35834dd5 ("coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID") That just rebuild perf when CORESIGHT=1 is used in the make command line to enable linking with the libopencsd. This addresses this perf build warning: Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h' diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Mike Leach Cc: Namhyung Kim Cc: Suzuki K Poulose Link: http://lore.kernel.org/lkml/ Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/coresight-pmu.h | 34 +++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h index 6c2fd6cc5a983fa4..51ac441a37c3e38f 100644 --- a/tools/include/linux/coresight-pmu.h +++ b/tools/include/linux/coresight-pmu.h @@ -7,8 +7,19 @@ #ifndef _LINUX_CORESIGHT_PMU_H #define _LINUX_CORESIGHT_PMU_H +#include + #define CORESIGHT_ETM_PMU_NAME "cs_etm" -#define CORESIGHT_ETM_PMU_SEED 0x10 + +/* + * The legacy Trace ID system based on fixed calculation from the cpu + * number. This has been replaced by drivers using a dynamic allocation + * system - but need to retain the legacy algorithm for backward comparibility + * in certain situations:- + * a) new perf running on older systems that generate the legacy mapping + * b) older tools that may not update at the same time as the kernel. + */ +#define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu) (0x10 + (cpu * 2)) /* * Below are the definition of bit offsets for perf option, and works as @@ -34,15 +45,16 @@ #define ETM4_CFG_BIT_RETSTK 12 #define ETM4_CFG_BIT_VMID_OPT 15 -static inline int coresight_get_trace_id(int cpu) -{ - /* - * A trace ID of value 0 is invalid, so let's start at some - * random value that fits in 7 bits and go from there. Since - * the common convention is to have data trace IDs be I(N) + 1, - * set instruction trace IDs as a function of the CPU number. - */ - return (CORESIGHT_ETM_PMU_SEED + (cpu * 2)); -} +/* + * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. + * Used to associate a CPU with the CoreSight Trace ID. + * [07:00] - Trace ID - uses 8 bits to make value easy to read in file. + * [59:08] - Unused (SBZ) + * [63:60] - Version + */ +#define CS_AUX_HW_ID_TRACE_ID_MASK GENMASK_ULL(7, 0) +#define CS_AUX_HW_ID_VERSION_MASK GENMASK_ULL(63, 60) + +#define CS_AUX_HW_ID_CURR_VERSION 0 #endif