From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0444C433FE for ; Mon, 9 May 2022 04:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbiEIE5c (ORCPT ); Mon, 9 May 2022 00:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234321AbiEIEyC (ORCPT ); Mon, 9 May 2022 00:54:02 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2072.outbound.protection.outlook.com [40.107.237.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F28F7A1446; Sun, 8 May 2022 21:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VTRPXpuyOPWzSBph+rZqK2pIJPL7E8F8ygQhWiNwmSZzTVZbYKIfE61EHAnqZkR2fmzuUULlD4uD6PzNQ39uIaX/CRmWW/7TsAjFQb/uGIyhQuSZzFG3RDQJsMYF8saQAXMBpc2cQlITxfgumOWvzK4m3F7bJhy8svHhuQ9+F2hkbEMIQx/a/MRIncrh/nBh6ht1LbAg/nTW1pwVBDpFIqx7ifvSo1uAlzABdn8ECdlckMGKRBGpNN9oXLOsQMJ0NYsRiVFM1pxWYRC1bL2qPBktzbMnHnjIUus8qUSSLFBiC4EQeFdgJITN2wRRMrv5PcAEypXshF/h/O5Uk3LKSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WcElq48EYRSapD7GKojon7GCvxvDUTeof7FynrUPmNw=; b=gOXH9eAAdhNz0MqLBklpPTXwF22UdLlM69cNlog0dc6rJREqdCj7F/UmqB5yNFbflBCFoCd4A8eP9FdvISfT/tsGRs3wV7Qg/Pit7ZRrc4bSGQULiVtcxrAexD4H9kWZnOtENVZ1N0DkGgNxhspTGf/UAhBEDU58XTkHfUJE4AOtnAYVSXvVXO/hVCrKdab67CCaAUfl+RRL4EmKkdk0Na2p9fsEsqdkPawfGMGwTQdfDzPjqos2e7V8zyRMm3qNfZcRpvgkCjvykFSaRlMIjd4/zxgPkCjvKAJcNmQEzjLUxKVcbxBXPMlwPa7iJqbBplgHLE/bbJcF8bGMgBVxHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WcElq48EYRSapD7GKojon7GCvxvDUTeof7FynrUPmNw=; b=wbF7sD30y6qtr3f3LLvBk2oxLykRybEBTNJ32w7vFJGhnCbEaVhXq5od8zh9hBuinT/dVnoMHpq4d+HpoBbmQ/GWd/i/AmPS4H8YYkYrAP3Yl4J+1i2IEZCK3ZNr2hAN+kR++GqqwZehAHMkMYDpj4Z0c4N7oRDuvKKC0PO781Y= Received: from MW4PR04CA0303.namprd04.prod.outlook.com (2603:10b6:303:82::8) by DM6PR12MB3833.namprd12.prod.outlook.com (2603:10b6:5:1cf::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Mon, 9 May 2022 04:50:05 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::6d) by MW4PR04CA0303.outlook.office365.com (2603:10b6:303:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22 via Frontend Transport; Mon, 9 May 2022 04:50:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:05 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:49:55 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 1/8] perf/amd/ibs: Cascade pmu init functions' return value Date: Mon, 9 May 2022 10:19:07 +0530 Message-ID: <20220509044914.1473-2-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 791300b8-9c26-4f78-26b8-08da317762b9 X-MS-TrafficTypeDiagnostic: DM6PR12MB3833:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gp3V41TT0MeIxCwf4IjTSK3e6kFkbeYKf7ZLHp+g1Tx56LEN2kJoK2zBlpNuuUYOt4P5vRAvm1ozLlGLvnYXQaVXPdWx3DqmM/vQlWijrrJFnMM/adq/A+9uBsX5maiGw9LkNoyK4YPClDC1FBc0SqOq2o95igYsqx0C6TKbC5nn8fKYFauA1oNCxoHOd/jLFskoJh8UFeXy4rvN0xyFQ7FXG0Hd4W176w/v8Zd+44L5Q5eCntXWMLuiG/YLF45eXmNTrymW577eoalifMBnVf3SHcoDQ8O/DANhv+l2KSzAeRGZV61mK+lrSqR1y9OsG+FgOLWzbQXmCTStcKMWorXTlFFZFDLSZ9SnfnGmwMYN5LdaTN1SlpQF/q1dUEKEp/4lzJsxbGi3BuomrH5UQPzWLbGP/3rRWtb4EENwZgW3DGgj9b/QGh8q3IV4Il5aTwCDd3H25VFmYGWedfBNgh2DoX38mNRvgqoP2T9eHq3Il0sxY1eFj7DSPdEAfdzYfERSKovAqAiQG1DR/MF1zl7yU3YXszknQxTol0HRCqu0whLlYpQL//Y/DriBr+qwHEVvfQDOJsh2TfDOvsoMHcMDETMnoK0XHqp148TZ+WH2R37JoGstIcuo797nfpO0H61nM1r3GM5Aq9y+HNczHD+awAuHLi1aN/TfTdsWAO9s+Z9zwZbXSAjFUPxBUIShN7ptWUKWALlyQvFF7gHFtg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(426003)(336012)(1076003)(2616005)(86362001)(40460700003)(47076005)(82310400005)(186003)(26005)(16526019)(316002)(44832011)(5660300002)(7416002)(4326008)(8936002)(36756003)(81166007)(36860700001)(2906002)(70206006)(70586007)(54906003)(6666004)(356005)(83380400001)(7696005)(110136005)(8676002)(508600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:05.1642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 791300b8-9c26-4f78-26b8-08da317762b9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3833 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" IBS pmu initialization code ignores return value provided by callee functions. Fix it. Signed-off-by: Ravi Bangoria --- arch/x86/events/amd/ibs.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 9739019d4b67..367ca899e6e8 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -759,9 +759,10 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *p= erf_ibs, char *name) return ret; } =20 -static __init void perf_event_ibs_init(void) +static __init int perf_event_ibs_init(void) { struct attribute **attr =3D ibs_op_format_attrs; + int ret; =20 /* * Some chips fail to reset the fetch count when it is written; instead @@ -773,7 +774,9 @@ static __init void perf_event_ibs_init(void) if (boot_cpu_data.x86 =3D=3D 0x19 && boot_cpu_data.x86_model < 0x10) perf_ibs_fetch.fetch_ignore_if_zero_rip =3D 1; =20 - perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); + ret =3D perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); + if (ret) + return ret; =20 if (ibs_caps & IBS_CAPS_OPCNT) { perf_ibs_op.config_mask |=3D IBS_OP_CNT_CTL; @@ -786,15 +789,35 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=3D IBS_OP_MAX_CNT_EXT_MASK; } =20 - perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); + ret =3D perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); + if (ret) + goto err_op; + + ret =3D register_nmi_handler(NMI_LOCAL, perf_ibs_nmi_handler, 0, "perf_ib= s"); + if (ret) + goto err_nmi; =20 - register_nmi_handler(NMI_LOCAL, perf_ibs_nmi_handler, 0, "perf_ibs"); pr_info("perf: AMD IBS detected (0x%08x)\n", ibs_caps); + return 0; + +err_nmi: + perf_pmu_unregister(&perf_ibs_op.pmu); + free_percpu(perf_ibs_op.pcpu); + perf_ibs_op.pcpu =3D NULL; +err_op: + perf_pmu_unregister(&perf_ibs_fetch.pmu); + free_percpu(perf_ibs_fetch.pcpu); + perf_ibs_fetch.pcpu =3D NULL; + + return ret; } =20 #else /* defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD) */ =20 -static __init void perf_event_ibs_init(void) { } +static __init int perf_event_ibs_init(void) +{ + return 0; +} =20 #endif =20 @@ -1064,9 +1087,7 @@ static __init int amd_ibs_init(void) x86_pmu_amd_ibs_starting_cpu, x86_pmu_amd_ibs_dying_cpu); =20 - perf_event_ibs_init(); - - return 0; + return perf_event_ibs_init(); } =20 /* Since we need the pci subsystem to init ibs we can't do this earlier: */ --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99F26C43217 for ; Mon, 9 May 2022 04:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiEIE5p (ORCPT ); Mon, 9 May 2022 00:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234323AbiEIEyK (ORCPT ); Mon, 9 May 2022 00:54:10 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2044.outbound.protection.outlook.com [40.107.236.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D42A1446; Sun, 8 May 2022 21:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vwu1JFSJFESV2ZY0u1V2bGirvYqhXYqq8TiztFFlMoukMJCfjqPXGFKLUcH3UI2pw1xnezneY6fu/S3o5igX/HsYqu7UAeY3yrr6pB2LOdkpQLHFzmXGvU6eJQ+zgKPOQcXtIG8HefJaIDJY9M5jENWNfgk+aJqjEC2jGJL1lAM/CRZx1D8ayD3WM+SamkOq4g9gJCNCf+U4LTdagjJ3Riik63KrBQi+W95wDyYjVf3yTMWCqnkE2RCYNgjBToMZ2BN5ofmKjT3WG6DIUYfjqNJIdFpgTRdeCuzlNOYgt+LokwPEuQg6ZAYkwzCPjB5N6acZTN1TpYflBoaBcHSvCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xs+k5HhUJJ/Pgb+Ox3NwfAm79h933k7PrpYC0G0a4FM=; b=kgSS1gxyVYbm/Ehsize31zNDB0JBdwvsp8bjn1+89dI1yrjQeBrHbl8fCZMvPkrf7cExiP1Rxk+woXjJJEp2M5aQ/IqWPF4rGoi9v8QzGAM3S1iJGNuCCliqlqOyqhvLDUJC3MduR3KJwtHMRW28IwC01IWZ1ch8pCrkFSRt9U/60ru5L9mwbehBNYPBDwVIb/SptlmBeBcKV4qiDblQcBZ1b5cZoMjOUO6vQIbqJlZVqSOLqC94HBQD1e47MJEZplWL9pQ3nYwbsfA0j0FagtNNzJHNS2qUaMEeq93jrTuUOKaAPKFmf2TcSfDoZ0XVqVWVjl9p6pE3YKXUNbqM0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xs+k5HhUJJ/Pgb+Ox3NwfAm79h933k7PrpYC0G0a4FM=; b=w6vPOjnTCpWQaE81V+FOX4wGoghyYy49Xh6/9URnv4Amya9uQSm6y3gOSKlFFveNuplmr4fFP5nU/Et6L41rlK+gN7/aRLD4/I66aeA/LNe2j2p5GUHGJmlOv0Xi/fzu4YWbzw3Pus0Nxh5l+o/a4gLcWkDtD/E/vYBmTar8CkQ= Received: from MW4PR04CA0108.namprd04.prod.outlook.com (2603:10b6:303:83::23) by DM5PR12MB1177.namprd12.prod.outlook.com (2603:10b6:3:6d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Mon, 9 May 2022 04:50:13 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::3e) by MW4PR04CA0108.outlook.office365.com (2603:10b6:303:83::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 04:50:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:13 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:04 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 2/8] perf/amd/ibs: Use ->is_visible callback for dynamic attributes Date: Mon, 9 May 2022 10:19:08 +0530 Message-ID: <20220509044914.1473-3-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1906eaf2-2396-49eb-38a7-08da3177676a X-MS-TrafficTypeDiagnostic: DM5PR12MB1177:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: csd4dfIH4toiS1QpD+h2eYHaTAIw+m6aLXsgLKh8TYtyneoTMhXJ10AFtkTi0/5UbL5iSbGA8BPJCYx5lhnFv0x+FlHMhyWtwQ2+UwoYGgjCIwMhjgw0OiC2+/AQl64Z5oHgvrpUj9lyln21/LC5X4eoaGl7bqwtGwCAAwBCemqxjm+jyquhk/76lVvnXL39tM23cHVRZHjAQSi2L0kWmHV2oSzHUha5gTapo6W6dUni9HqZp17ATxut1y24/o1wrjfktAOSAZHmbjyw2pXS+uBLByTyID/VyxhXLAClrIskyegKsWoBunkDgAoSogcB+acUaP0tIFEP0ekaBCl05wIVDHL3PiM7glpa+EZsLTmfu/nS9hN2U7k5BEInyPavNmzWLN8KU+vqjHkpo5bMtMqmDodLsuuSDPts3lT4nKz+Us4IT7vOYqy1hUZVC19FxSr+MPIQ9hahsrTr93myKjLw9lPpTRNGb/gAEojUfCz0/qvBLcutTjQi1SIPSV6rNGy3cEPq0n0SRGDNDnQd1X/ubls3FAdyItB3fqCzPudTSdIb68Y+NzMq+NhgzDRzhv0G3m7NcKwBqPNCyccHqZZHrvnI8jmnCKnIoTwBTe0xoGs0qELGHgVfHFgvj/5EAjdEva4rVssoM5xC77K0fybHnP7D+IOsdg1TTEMHqRcmIFr8vzDSWrKbT9m+l4I39bz3GCIGycL+v3+Rv8Rq5g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(2906002)(82310400005)(4326008)(110136005)(70206006)(70586007)(8676002)(54906003)(356005)(86362001)(81166007)(508600001)(316002)(8936002)(83380400001)(2616005)(5660300002)(1076003)(44832011)(426003)(47076005)(36756003)(7416002)(40460700003)(336012)(26005)(16526019)(186003)(36860700001)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:13.0355 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1906eaf2-2396-49eb-38a7-08da3177676a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1177 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently, some attributes are added at build time whereas others at boot time depending on IBS pmu capabilities. Instead, we can just add all attribute groups at build time but hide individual group at boot time using more appropriate ->is_visible() callback. Also, struct perf_ibs has bunch of fields for pmu attributes which just pass on the pointer, does not do anything else. Remove them. Signed-off-by: Ravi Bangoria --- arch/x86/events/amd/ibs.c | 78 +++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 367ca899e6e8..785212b5dfd6 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -94,10 +94,6 @@ struct perf_ibs { unsigned int fetch_ignore_if_zero_rip : 1; struct cpu_perf_ibs __percpu *pcpu; =20 - struct attribute **format_attrs; - struct attribute_group format_group; - const struct attribute_group *attr_groups[2]; - u64 (*get_count)(u64 config); }; =20 @@ -518,16 +514,61 @@ static void perf_ibs_del(struct perf_event *event, in= t flags) =20 static void perf_ibs_read(struct perf_event *event) { } =20 +/* + * We need to initialize with empty group if all attributes in the + * group are dynamic. + */ +static struct attribute *attrs_empty[] =3D { + NULL, +}; + +static struct attribute_group empty_format_group =3D { + .name =3D "format", + .attrs =3D attrs_empty, +}; + +static const struct attribute_group *empty_attr_groups[] =3D { + &empty_format_group, + NULL, +}; + PMU_FORMAT_ATTR(rand_en, "config:57"); PMU_FORMAT_ATTR(cnt_ctl, "config:19"); =20 -static struct attribute *ibs_fetch_format_attrs[] =3D { +static struct attribute *rand_en_attrs[] =3D { &format_attr_rand_en.attr, NULL, }; =20 -static struct attribute *ibs_op_format_attrs[] =3D { - NULL, /* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ +static struct attribute_group group_rand_en =3D { + .name =3D "format", + .attrs =3D rand_en_attrs, +}; + +static const struct attribute_group *fetch_attr_groups[] =3D { + &group_rand_en, + NULL, +}; + +static umode_t +cnt_ctl_is_visible(struct kobject *kobj, struct attribute *attr, int i) +{ + return ibs_caps & IBS_CAPS_OPCNT ? attr->mode : 0; +} + +static struct attribute *cnt_ctl_attrs[] =3D { + &format_attr_cnt_ctl.attr, + NULL, +}; + +static struct attribute_group group_cnt_ctl =3D { + .name =3D "format", + .attrs =3D cnt_ctl_attrs, + .is_visible =3D cnt_ctl_is_visible, +}; + +static const struct attribute_group *op_attr_update[] =3D { + &group_cnt_ctl, NULL, }; =20 @@ -551,7 +592,6 @@ static struct perf_ibs perf_ibs_fetch =3D { .max_period =3D IBS_FETCH_MAX_CNT << 4, .offset_mask =3D { MSR_AMD64_IBSFETCH_REG_MASK }, .offset_max =3D MSR_AMD64_IBSFETCH_REG_COUNT, - .format_attrs =3D ibs_fetch_format_attrs, =20 .get_count =3D get_ibs_fetch_count, }; @@ -577,7 +617,6 @@ static struct perf_ibs perf_ibs_op =3D { .max_period =3D IBS_OP_MAX_CNT << 4, .offset_mask =3D { MSR_AMD64_IBSOP_REG_MASK }, .offset_max =3D MSR_AMD64_IBSOP_REG_COUNT, - .format_attrs =3D ibs_op_format_attrs, =20 .get_count =3D get_ibs_op_count, }; @@ -739,17 +778,6 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *p= erf_ibs, char *name) =20 perf_ibs->pcpu =3D pcpu; =20 - /* register attributes */ - if (perf_ibs->format_attrs[0]) { - memset(&perf_ibs->format_group, 0, sizeof(perf_ibs->format_group)); - perf_ibs->format_group.name =3D "format"; - perf_ibs->format_group.attrs =3D perf_ibs->format_attrs; - - memset(&perf_ibs->attr_groups, 0, sizeof(perf_ibs->attr_groups)); - perf_ibs->attr_groups[0] =3D &perf_ibs->format_group; - perf_ibs->pmu.attr_groups =3D perf_ibs->attr_groups; - } - ret =3D perf_pmu_register(&perf_ibs->pmu, name, -1); if (ret) { perf_ibs->pcpu =3D NULL; @@ -761,7 +789,6 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *pe= rf_ibs, char *name) =20 static __init int perf_event_ibs_init(void) { - struct attribute **attr =3D ibs_op_format_attrs; int ret; =20 /* @@ -774,14 +801,14 @@ static __init int perf_event_ibs_init(void) if (boot_cpu_data.x86 =3D=3D 0x19 && boot_cpu_data.x86_model < 0x10) perf_ibs_fetch.fetch_ignore_if_zero_rip =3D 1; =20 + perf_ibs_fetch.pmu.attr_groups =3D fetch_attr_groups; + ret =3D perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); if (ret) return ret; =20 - if (ibs_caps & IBS_CAPS_OPCNT) { + if (ibs_caps & IBS_CAPS_OPCNT) perf_ibs_op.config_mask |=3D IBS_OP_CNT_CTL; - *attr++ =3D &format_attr_cnt_ctl.attr; - } =20 if (ibs_caps & IBS_CAPS_OPCNTEXT) { perf_ibs_op.max_period |=3D IBS_OP_MAX_CNT_EXT_MASK; @@ -789,6 +816,9 @@ static __init int perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=3D IBS_OP_MAX_CNT_EXT_MASK; } =20 + perf_ibs_op.pmu.attr_groups =3D empty_attr_groups; + perf_ibs_op.pmu.attr_update =3D op_attr_update; + ret =3D perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); if (ret) goto err_op; --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EB41C433F5 for ; Mon, 9 May 2022 04:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233787AbiEIE4G (ORCPT ); Mon, 9 May 2022 00:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234326AbiEIEyP (ORCPT ); Mon, 9 May 2022 00:54:15 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2068.outbound.protection.outlook.com [40.107.236.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37374A1446; Sun, 8 May 2022 21:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUZ/4JxRHwGSv7JKRHsE9dUC2RCBwhDAF5kdcI0zXNqrGwg/mJgzugdpU6A8trb/u9lq9kq1kV+/xp3+OExCM12FIWMz45Upu4OQKTS/5wb+UtsVA7mTXlpQanRs1WQ76+LlrAzsIcDgvCv2RIiqsiN6fbYy6HQrFGXTrkCNfHgJYrwWgUeYe+dRHpAtQiAts2sielQKTxgplEy4Wn/QomiDghqvmf4s12Vc7eKNpgOLM/iFBUtCRlFZd6Va0Zx9BmL59Bn01+YMLZQwxYvlJ1MVrQ/lR8JwjHYt5JgnMUPeWUUBTcd0kI5ILvi2ywBqMsqAblYCnpONA/oGQ7p/0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7jfWMFg1bsD8010TgxLteIn1mWdzlbOQ8FtGemtHDn0=; b=a/iA1rd+RWDSp3DG42qQj0qGxlJ+fJVabzDAALO9XukYMOOqYuQPcQ6Tb8QpmV3UY6kAyPf+i478WugPqFo1n4ZoIr1Hym8/ToePBDu0xyrgCP7YDbR8jAXwX5AMrKdD6R09MM60GO3Nx88gZgFNW5BXsSMrcHJ+1acshONbBZOgkkmWwQvWIsH2dB85+/HWCeZMAYu/ynuRfCTl0GGN49pZtPFodG4IM2XA+WUbVbyehCpiIq+gxwvdUnr35a2Q3JPtLvlS0YjfT91B3BxR7ONNPNquCrteV4y05TCCDwSX0Yw7M0Ut2N0nSQuZVr117CwUkI6v1FX5NO0YrnPs0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7jfWMFg1bsD8010TgxLteIn1mWdzlbOQ8FtGemtHDn0=; b=ct/zlR2KgQCyuzs7LyadMxUJ27Jwk437WTgfNdCZ08KjqXqI1z9ONfMlvijw0W1p60OL/HbE2i6f5XUrb/DXCOP1IBTtdrc8Zscp0OJCY79KSOUEQG2KRGRfgpJ6td1cJkkmimRkhG2yeiXodXKXE8Y6dEJ7O3BMVax7FbkokiQ= Received: from BN9PR03CA0532.namprd03.prod.outlook.com (2603:10b6:408:131::27) by BN6PR12MB1394.namprd12.prod.outlook.com (2603:10b6:404:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Mon, 9 May 2022 04:50:20 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::cb) by BN9PR03CA0532.outlook.office365.com (2603:10b6:408:131::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 04:50:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:20 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:12 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 3/8] perf/amd/ibs: Add support for L3 miss filtering Date: Mon, 9 May 2022 10:19:09 +0530 Message-ID: <20220509044914.1473-4-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be680c47-5f63-43eb-fce6-08da31776bd5 X-MS-TrafficTypeDiagnostic: BN6PR12MB1394:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KR32KRux1Ho1hNo9uTiVJxftUhBdzaq/qY45JtZG0x6Qjdw9etRtkhKqnLtIjcRRGmgtNQGEoJ+IqxCISCeHmj+gvdY/OC2v1sAohFU0gxeqi38B+4xSlvYhmDRTY/RzrnZwHj0nmKIwuWrrXb/mXrbXaL3xka85cjffG83dSEk6GLGehXpkCwQ9RRnOAaWjExDh/SAkvKCynIeVVBWBX+JnDR6mKYFR0rUlth5rSJJ3abbtv0PqQTT1buewOWtyGfjWmAVKIgpv681oczB2CAT4EuJTOCIN9IM2StrXfFmxO9+vYObbfP83rGqoG/14YQJBNrMfiWI7ISsFAXX4uNpQS+RH5dhkJ6UPDLGv3haiqUfSTUD40zi797UcUR9W3/W3FEE3OydxfEhzZUawBEYuJ8Qa1IhgeSqnh9cOkTu8I4D7ol0W1sZHghZYckyP2HaKpwtl+VcdLC+utHGFCj35ofp4pAqxtqvNHBKI8qICBrnfq1oTDYtkVBh9qEvV8BOi3Xy31gVa/4iNYUtH6egYYesESguEBtKkPXZR6JkLoyDvHO+IUYCALk/dtVa1wE+LG2twxhPa07gzTmmN1mnIWdYA69/hEL/iOJ+BMBb/t1JnnlnG+OCR5LpQsqgYsgpPV9He5qrqtCV4nDBNbQxzymf4PHNA2O3vdukXjsCKMZM1tLO+ru6XSg5NtRkZ/SJxc+P2cv3yVDj6c+5ziA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(1076003)(8676002)(2616005)(70586007)(4326008)(83380400001)(70206006)(47076005)(426003)(336012)(186003)(508600001)(86362001)(6666004)(16526019)(26005)(316002)(82310400005)(54906003)(110136005)(7696005)(7416002)(81166007)(8936002)(36860700001)(40460700003)(356005)(36756003)(44832011)(2906002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:20.5776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be680c47-5f63-43eb-fce6-08da31776bd5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1394 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems. Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage: # perf record -a -e ibs_op/l3missonly=3D1/ --raw-samples sleep 5 Signed-off-by: Ravi Bangoria --- arch/x86/events/amd/ibs.c | 67 +++++++++++++++++++++++++++---- arch/x86/include/asm/perf_event.h | 3 ++ 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 785212b5dfd6..52d2eb9ff19a 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -534,22 +534,46 @@ static const struct attribute_group *empty_attr_group= s[] =3D { =20 PMU_FORMAT_ATTR(rand_en, "config:57"); PMU_FORMAT_ATTR(cnt_ctl, "config:19"); +PMU_EVENT_ATTR_STRING(l3missonly, fetch_l3missonly, "config:59"); +PMU_EVENT_ATTR_STRING(l3missonly, op_l3missonly, "config:16"); + +static umode_t +zen4_ibs_extensions_is_visible(struct kobject *kobj, struct attribute *att= r, int i) +{ + return ibs_caps & IBS_CAPS_ZEN4IBSEXTENSIONS ? attr->mode : 0; +} =20 static struct attribute *rand_en_attrs[] =3D { &format_attr_rand_en.attr, NULL, }; =20 +static struct attribute *fetch_l3missonly_attrs[] =3D { + &fetch_l3missonly.attr.attr, + NULL, +}; + static struct attribute_group group_rand_en =3D { .name =3D "format", .attrs =3D rand_en_attrs, }; =20 +static struct attribute_group group_fetch_l3missonly =3D { + .name =3D "format", + .attrs =3D fetch_l3missonly_attrs, + .is_visible =3D zen4_ibs_extensions_is_visible, +}; + static const struct attribute_group *fetch_attr_groups[] =3D { &group_rand_en, NULL, }; =20 +static const struct attribute_group *fetch_attr_update[] =3D { + &group_fetch_l3missonly, + NULL, +}; + static umode_t cnt_ctl_is_visible(struct kobject *kobj, struct attribute *attr, int i) { @@ -561,14 +585,26 @@ static struct attribute *cnt_ctl_attrs[] =3D { NULL, }; =20 +static struct attribute *op_l3missonly_attrs[] =3D { + &op_l3missonly.attr.attr, + NULL, +}; + static struct attribute_group group_cnt_ctl =3D { .name =3D "format", .attrs =3D cnt_ctl_attrs, .is_visible =3D cnt_ctl_is_visible, }; =20 +static struct attribute_group group_op_l3missonly =3D { + .name =3D "format", + .attrs =3D op_l3missonly_attrs, + .is_visible =3D zen4_ibs_extensions_is_visible, +}; + static const struct attribute_group *op_attr_update[] =3D { &group_cnt_ctl, + &group_op_l3missonly, NULL, }; =20 @@ -787,10 +823,8 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *p= erf_ibs, char *name) return ret; } =20 -static __init int perf_event_ibs_init(void) +static __init int perf_ibs_fetch_init(void) { - int ret; - /* * Some chips fail to reset the fetch count when it is written; instead * they need a 0-1 transition of IbsFetchEn. @@ -801,12 +835,17 @@ static __init int perf_event_ibs_init(void) if (boot_cpu_data.x86 =3D=3D 0x19 && boot_cpu_data.x86_model < 0x10) perf_ibs_fetch.fetch_ignore_if_zero_rip =3D 1; =20 + if (ibs_caps & IBS_CAPS_ZEN4IBSEXTENSIONS) + perf_ibs_fetch.config_mask |=3D IBS_FETCH_L3MISSONLY; + perf_ibs_fetch.pmu.attr_groups =3D fetch_attr_groups; + perf_ibs_fetch.pmu.attr_update =3D fetch_attr_update; =20 - ret =3D perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); - if (ret) - return ret; + return perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); +} =20 +static __init int perf_ibs_op_init(void) +{ if (ibs_caps & IBS_CAPS_OPCNT) perf_ibs_op.config_mask |=3D IBS_OP_CNT_CTL; =20 @@ -816,10 +855,24 @@ static __init int perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=3D IBS_OP_MAX_CNT_EXT_MASK; } =20 + if (ibs_caps & IBS_CAPS_ZEN4IBSEXTENSIONS) + perf_ibs_op.config_mask |=3D IBS_OP_L3MISSONLY; + perf_ibs_op.pmu.attr_groups =3D empty_attr_groups; perf_ibs_op.pmu.attr_update =3D op_attr_update; =20 - ret =3D perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); + return perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); +} + +static __init int perf_event_ibs_init(void) +{ + int ret; + + ret =3D perf_ibs_fetch_init(); + if (ret) + return ret; + + ret =3D perf_ibs_op_init(); if (ret) goto err_op; =20 diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_= event.h index b06e4c573add..a24b637a6e1d 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -391,6 +391,7 @@ struct pebs_xmm { #define IBS_CAPS_OPBRNFUSE (1U<<8) #define IBS_CAPS_FETCHCTLEXTD (1U<<9) #define IBS_CAPS_OPDATA4 (1U<<10) +#define IBS_CAPS_ZEN4IBSEXTENSIONS (1U<<11) =20 #define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \ | IBS_CAPS_FETCHSAM \ @@ -404,6 +405,7 @@ struct pebs_xmm { #define IBSCTL_LVT_OFFSET_MASK 0x0F =20 /* IBS fetch bits/masks */ +#define IBS_FETCH_L3MISSONLY (1ULL<<59) #define IBS_FETCH_RAND_EN (1ULL<<57) #define IBS_FETCH_VAL (1ULL<<49) #define IBS_FETCH_ENABLE (1ULL<<48) @@ -420,6 +422,7 @@ struct pebs_xmm { #define IBS_OP_CNT_CTL (1ULL<<19) #define IBS_OP_VAL (1ULL<<18) #define IBS_OP_ENABLE (1ULL<<17) +#define IBS_OP_L3MISSONLY (1ULL<<16) #define IBS_OP_MAX_CNT 0x0000FFFFULL #define IBS_OP_MAX_CNT_EXT 0x007FFFFFULL /* not a register bit mask */ #define IBS_OP_MAX_CNT_EXT_MASK (0x7FULL<<20) /* separate upper 7 bits */ --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41ACAC4167D for ; Mon, 9 May 2022 04:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234193AbiEIE6B (ORCPT ); Mon, 9 May 2022 00:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234329AbiEIEy1 (ORCPT ); Mon, 9 May 2022 00:54:27 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2032329C; Sun, 8 May 2022 21:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fTD0KPGAUQ0IWvhDWS+e4IFEhT+PBoPJx8TGpZfcVK99AKPzNucI9oiD2zWTSL6sfKoX6iUzkbwNO32UTKkTpn+5A+x2+0o+IVTlLfkNMV+AZ4fZ+JbvH7pci5z1q9m+rnb3asGzzpPF8NCr1hTBFez60p66BwDDorro0ID7+7Ixz6bVV6C2g8lk74GqYiY6NyCZKchYicb+YBU4NkDmGdX1IjHBUq7L3rzFzl+rAQV6cP8DZGgihCzs3dD4f3AagHOpq6Aj0cr2TE248mov7k/L35YII3LQ+xEbNadcdMZrvHTlck1qwcM0ojyBJZUiUH8t0n1FV+jstEinyXb1xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O6CrwUMjg7j5oPD52iUObPLZlNGVwDXbbjjHWSg/GTQ=; b=MNM0PxgswpcwJxux1gWG1CDtYNePiBpIXx6An0uKEjkoaHYYGxDDuCe4ChzUDumVYLPf2YOF83Qe/oA+bGNos6MnsuyBzwwaxVPWPLmx0er2M3ZZSUiYIR04qQJ87V9/rQvIg3Nbf2qtFGzw7EKSBYKRqwF7tagb7Pg/cFySHXPeinzBnE1tdW083ufvXXnOdDwpyPPuSDZPOJdhGnPA5jUQwunvUO5BYL9rECc/Dm8GftmeHk3d3XqpC9h5bqD6bpNtbbfj75tScn/OqnpuFB4JsqicYN37PryD6kzehdcShIm7XL+9g8x94qGmoi1jFNQqAzgO0aBmUBntLkLLVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O6CrwUMjg7j5oPD52iUObPLZlNGVwDXbbjjHWSg/GTQ=; b=SZTkNbkcX1GrKaPjRyHI/6Gd9dSx2W/4+UH4cS0Jl35cx0elcajFW1GC7FUDW5QRhrCJ1gHqrlqEJY/FsFLRx1pjDryEOMOoY+1+q54ZnXQ/HY0yEm8y9no2Ga+oaka1I05cFc1fBUgw65rqzMaz0cKwzek6ZPhzAqixNEwudlw= Received: from BN9PR03CA0348.namprd03.prod.outlook.com (2603:10b6:408:f6::23) by DM6PR12MB4387.namprd12.prod.outlook.com (2603:10b6:5:2ac::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Mon, 9 May 2022 04:50:30 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::1d) by BN9PR03CA0348.outlook.office365.com (2603:10b6:408:f6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 04:50:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:30 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:20 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 4/8] perf/amd/ibs: Advertise zen4_ibs_extensions as pmu capability attribute Date: Mon, 9 May 2022 10:19:10 +0530 Message-ID: <20220509044914.1473-5-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afd0efa6-9fd9-478c-f662-08da3177718f X-MS-TrafficTypeDiagnostic: DM6PR12MB4387:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PAYayKB9qYdAAGjGZAU/htGnOFdOBLYoY34XhMFZfDHE6HwdKnIdbrm37Z9WvK2vnPOq0lVN5BXtcU6XiCuXEzns0C8QIXYLuqXQQzX+6st956wrntjRFdao6ozy2p7Aj/VU+v5HOSsY4iNIEofORimbcn1JEHYUIf0/lR+PRpXMAktzFrJRCAse3e71b6+ARLPx7l7+cQRARZ8vpW2B1qB7vL5tguPwQoJYQTgt2lIW/0+tHrN9rTtbVWPEQYnCm/WiQIZZaQud6ZwFQsZ9uk+sWpDG9ijdOt3DZqsiUwWVer3o4UZElZaskyPw3ZFjb+ia53t2QOvFigomc2KLH5azkgXydQfm9K3CpvIOnMGw1p02gQuE5Lc3Mon7VTxvfU0mAfBIyxaH+U2sYsTUpLWJz3BlPUvefPGnD1/hF8R5PJ6YRIX3Tg4E9UuEmPvE4NXvcaV4/4z3PEEFDbKULn/f4g5MBKs8JLKJFwri1FMw91t0C184pxvJZFgxpNw56Of84ZjjkUoXuZNZPYj/xbfndrHxeAZ+miVna70Tju19fDxKvcjMMB7tzlWFFHTxNf1bTgw8JygdQe0A8herVsDrshmQZooTTQ1I2fUvK1xnJ3mGHtuMBun3AMAcAr0S0ioLRJKMSRJdgNmfDMF4ydRhC0yqvkoU0zP233E3pKbK23NR05g6erlCRA88jJA1e+A5dhf+Fw3IJ6QkLusp6Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(316002)(16526019)(508600001)(8936002)(54906003)(36860700001)(110136005)(81166007)(356005)(8676002)(70206006)(86362001)(4326008)(70586007)(83380400001)(26005)(44832011)(6666004)(7416002)(40460700003)(7696005)(1076003)(2616005)(186003)(82310400005)(336012)(2906002)(47076005)(426003)(36756003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:30.1694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afd0efa6-9fd9-478c-f662-08da3177718f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4387 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" PMU driver can advertise certain feature via capability attribute('caps' sysfs directory) which can be consumed by userspace tools like perf. Add zen4_ibs_extensions capability attribute for IBS pmus. This attribute will be enabled when CPUID_Fn8000001B_EAX[11] is set. With patch on Zen4: $ ls /sys/bus/event_source/devices/ibs_op/caps zen4_ibs_extensions Signed-off-by: Ravi Bangoria --- arch/x86/events/amd/ibs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 52d2eb9ff19a..12b0fd4a0328 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -527,8 +527,14 @@ static struct attribute_group empty_format_group =3D { .attrs =3D attrs_empty, }; =20 +static struct attribute_group empty_caps_group =3D { + .name =3D "caps", + .attrs =3D attrs_empty, +}; + static const struct attribute_group *empty_attr_groups[] =3D { &empty_format_group, + &empty_caps_group, NULL, }; =20 @@ -536,6 +542,7 @@ PMU_FORMAT_ATTR(rand_en, "config:57"); PMU_FORMAT_ATTR(cnt_ctl, "config:19"); PMU_EVENT_ATTR_STRING(l3missonly, fetch_l3missonly, "config:59"); PMU_EVENT_ATTR_STRING(l3missonly, op_l3missonly, "config:16"); +PMU_EVENT_ATTR_STRING(zen4_ibs_extensions, zen4_ibs_extensions, "1"); =20 static umode_t zen4_ibs_extensions_is_visible(struct kobject *kobj, struct attribute *att= r, int i) @@ -553,6 +560,11 @@ static struct attribute *fetch_l3missonly_attrs[] =3D { NULL, }; =20 +static struct attribute *zen4_ibs_extensions_attrs[] =3D { + &zen4_ibs_extensions.attr.attr, + NULL, +}; + static struct attribute_group group_rand_en =3D { .name =3D "format", .attrs =3D rand_en_attrs, @@ -564,13 +576,21 @@ static struct attribute_group group_fetch_l3missonly = =3D { .is_visible =3D zen4_ibs_extensions_is_visible, }; =20 +static struct attribute_group group_zen4_ibs_extensions =3D { + .name =3D "caps", + .attrs =3D zen4_ibs_extensions_attrs, + .is_visible =3D zen4_ibs_extensions_is_visible, +}; + static const struct attribute_group *fetch_attr_groups[] =3D { &group_rand_en, + &empty_caps_group, NULL, }; =20 static const struct attribute_group *fetch_attr_update[] =3D { &group_fetch_l3missonly, + &group_zen4_ibs_extensions, NULL, }; =20 @@ -605,6 +625,7 @@ static struct attribute_group group_op_l3missonly =3D { static const struct attribute_group *op_attr_update[] =3D { &group_cnt_ctl, &group_op_l3missonly, + &group_zen4_ibs_extensions, NULL, }; =20 --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C410AC433FE for ; Mon, 9 May 2022 04:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234125AbiEIE5k (ORCPT ); Mon, 9 May 2022 00:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234334AbiEIEyh (ORCPT ); Mon, 9 May 2022 00:54:37 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2042.outbound.protection.outlook.com [40.107.220.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D1A27CFA; Sun, 8 May 2022 21:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTNi9VGt3laKTlgZWcCIpgyTe77O16vaLMhNHcoFdbjw+zBgt1K4S4cVLNCt6ceCXFCg4VkqsTbraHeksB54VbO2xyKe7UElXBAaEwwxPJtf2ueOQAzKSCC7XCuiIpPo6o50MwgV4r4T3CbQ6AJkmdbnhjBEQH81nRx3zSUYqIbEee95bGXCMs8LcyLfPlZR5J53o84LVGYqedxTk1WG3+QNiD4xL8UsCLT+U/2PFLgl+wHEX7lnvUH72xk54DGKx+PUHDq5+rWqEm3D4lb978AQfD2nRuKaqVZzbvd/El2VFuEZUcNLD89wIITx/d8MLRax7KlrBCAzhgqMm2YhZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8OOXXu6v5KPvB+r6zyrx9a4ZJj65cznCHut5dWhNESk=; b=cdnF+82Kpa4T/4w7UnYDfktMtNMAPB8e7BYo9uSmUkr4GSpm+PzjovOPHW2uSzqU4vtzCjkzsfjgrspqReHjloADMOlr/ShEGzrNtrJBkyw7m3OwQ2oX3VKxRUCNOAF61xzuhMl1cZRcLqeN/UrCcZeAYnV10DaQKY//XcaB1HITMdajhynzbKSdRq6WWfSa8/BJ/e4OVxy/7ysGinXOl8ndly8TnMKw2HuyaINprUa40Thxjmp1+WPx1RXqHVeYvXAIQk2Q6xQRSVxYG0vhyPdnvtGBwN/EKfAJmGz6EftiXUPZSY9OnVpCftYwpE70fab/nsk5wViTEvfESBjWIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8OOXXu6v5KPvB+r6zyrx9a4ZJj65cznCHut5dWhNESk=; b=kgzlFbliQh3dYWdYqsAhpENJNrJbbpaGlS41tm+YsIVQa1NTnlqiJtj1cqXU1H6qY9Wp0/YgEQC6zGgWAX4O5i4c/2cdnpdPVAV2bnbjTloTT3FkI64aFgMtYe3u2+BP3tf7lJBZAk6n6w+GP3ApZzb3DFboMJPz+OqO/+0bHSg= Received: from BN8PR04CA0050.namprd04.prod.outlook.com (2603:10b6:408:d4::24) by DM6PR12MB4124.namprd12.prod.outlook.com (2603:10b6:5:221::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Mon, 9 May 2022 04:50:38 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::6b) by BN8PR04CA0050.outlook.office365.com (2603:10b6:408:d4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22 via Frontend Transport; Mon, 9 May 2022 04:50:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:38 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:29 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 5/8] perf record ibs: Warn about sampling period skew Date: Mon, 9 May 2022 10:19:11 +0530 Message-ID: <20220509044914.1473-6-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10322187-d6f5-4313-d871-08da3177768f X-MS-TrafficTypeDiagnostic: DM6PR12MB4124:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b7Q6mTGvKkZwFfXwXqgF8YwjQt1wMOZED57BIinjBLfqXFKF/zIgck2U22gN6wulTQyXen0AJyc/WIDLxNrZrZZoNT+UVCyoPtaBHyaFrP76KKVf57vfVhWsC+fYGjF8s+1IpvaCTHXRYrR/5knQQe8yTLYa/EBXuq4e5/lIQK8NMF+IuwUxG1ix4BORV2d1N8IkrnNxIGG1W7e3kT/p1gmaDRP5Bvj8G255Qf7It2jBmRh4GE9TzXNkfXqkJF0AumqrhwzxvPoBADKJLvwP7vceg0vFeOpPcfc4aMJRG3vp16FM9VmZ4jhIX0aKAhiRxpDm2uckRoOxviBfT9uQA/un64oyE4NkYrRDZfyDzTyz1A5s5YfuRgFRz50uhAelRy5G7pbwak97yqQmmKLWAMOfGsjLoQttAvhrwMICoD3sunok+Sd2MEelc4DSCtaIfOYdi5PS3xq8PwoQ+agcGyiF9D5R3Nmt/Q7ddzIHVWr4GgHLf9hLzw46C9EYAqV6RsHoyREVVxPvjR3+mw+g8mXg7sS8VM+wMR94UdDjKtqoAnxyAdMg9SuPO8neDR4iEjLCzCglQtVoNzFPvkqK/p7jAa7GgBpnKCq2Z4VtJY+UyCHr1KJ25X7BU14tcZw/V+BiV5rDcwXrDfYsID7RTXRBSuxoOmNJfHWlF9gN8S8GWERr9bOFveNN0QHqG0C+RAIe7Cn27L0Anpviyy4QOA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(83380400001)(16526019)(186003)(6666004)(36860700001)(7696005)(44832011)(26005)(1076003)(2616005)(2906002)(36756003)(47076005)(336012)(82310400005)(426003)(40460700003)(110136005)(356005)(5660300002)(86362001)(7416002)(508600001)(8936002)(54906003)(70206006)(70586007)(8676002)(4326008)(81166007)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:38.5729 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10322187-d6f5-4313-d871-08da3177768f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4124 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu) when IBS L3 miss filtering is enabled. This causes a sampling period skew but there is no way to reconstruct aggregated sampling period. So print a warning at perf record if user sets l3missonly=3D1. Ex: # perf record -c 10000 -C 0 -e ibs_op/l3missonly=3D1/ WARNING: Hw internally resets sampling period when L3 Miss Filtering is e= nabled and tagged operation does not cause L3 Miss. This causes sampling period = skew. Signed-off-by: Ravi Bangoria --- tools/perf/arch/x86/util/evsel.c | 34 ++++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 7 +++++++ tools/perf/util/evsel.h | 1 + 3 files changed, 42 insertions(+) diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/ev= sel.c index ac2899a25b7a..6399faa70a88 100644 --- a/tools/perf/arch/x86/util/evsel.c +++ b/tools/perf/arch/x86/util/evsel.c @@ -4,6 +4,8 @@ #include "util/evsel.h" #include "util/env.h" #include "linux/string.h" +#include "util/pmu.h" +#include "util/debug.h" =20 void arch_evsel__set_sample_weight(struct evsel *evsel) { @@ -29,3 +31,35 @@ void arch_evsel__fixup_new_cycles(struct perf_event_attr= *attr) =20 free(env.cpuid); } + +static void ibs_l3miss_warn(void) +{ + pr_warning( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is e= nabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period = skew.\n"); +} + +void arch_evsel__warn_ambiguity(struct evsel *evsel, struct perf_event_att= r *attr) +{ + struct perf_env *env =3D evsel__env(evsel); + struct perf_pmu *evsel_pmu =3D evsel__find_pmu(evsel); + struct perf_pmu *ibs_fetch_pmu =3D perf_pmu__find("ibs_fetch"); + struct perf_pmu *ibs_op_pmu =3D perf_pmu__find("ibs_op"); + static int warned_once; + + if (warned_once || !perf_env__cpuid(env) || !env->cpuid || + !strstarts(env->cpuid, "AuthenticAMD") || !evsel_pmu) + return; + + if (ibs_fetch_pmu && ibs_fetch_pmu->type =3D=3D evsel_pmu->type) { + if (attr->config & (1ULL << 59)) { + ibs_l3miss_warn(); + warned_once =3D 1; + } + } else if (ibs_op_pmu && ibs_op_pmu->type =3D=3D evsel_pmu->type) { + if (attr->config & (1ULL << 16)) { + ibs_l3miss_warn(); + warned_once =3D 1; + } + } +} diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2a1729e7aee4..4f8b72d4a521 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1064,6 +1064,11 @@ void __weak arch_evsel__fixup_new_cycles(struct perf= _event_attr *attr __maybe_un { } =20 +void __weak arch_evsel__warn_ambiguity(struct evsel *evsel __maybe_unused, + struct perf_event_attr *attr __maybe_unused) +{ +} + static void evsel__set_default_freq_period(struct record_opts *opts, struct perf_event_attr *attr) { @@ -1339,6 +1344,8 @@ void evsel__config(struct evsel *evsel, struct record= _opts *opts, */ if (evsel__is_dummy_event(evsel)) evsel__reset_sample_bit(evsel, BRANCH_STACK); + + arch_evsel__warn_ambiguity(evsel, attr); } =20 int evsel__set_filter(struct evsel *evsel, const char *filter) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 041b42d33bf5..195ae30ec45b 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -281,6 +281,7 @@ void evsel__set_sample_id(struct evsel *evsel, bool use= _sample_identifier); =20 void arch_evsel__set_sample_weight(struct evsel *evsel); void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr); +void arch_evsel__warn_ambiguity(struct evsel *evsel, struct perf_event_att= r *attr); =20 int evsel__set_filter(struct evsel *evsel, const char *filter); int evsel__append_tp_filter(struct evsel *evsel, const char *filter); --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0212C433EF for ; Mon, 9 May 2022 04:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234096AbiEIE5h (ORCPT ); Mon, 9 May 2022 00:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbiEIEyr (ORCPT ); Mon, 9 May 2022 00:54:47 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622B63A71E; Sun, 8 May 2022 21:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SqJPIVJRwjfQSO9ZSBrX1lNZHwoG357tGke5iW4gy3Oqib60yfL8Lu8aZ/0gu+w6QphQc4Nza5GLYdc5lyU2QHUXjymZi63NMiNVRHun5ZmvPokkVSHhJQku9FKaEYPpcU4UchsIFYnfSKPnqXbY9uqCgwjjGY1v4OOiMq0gXr8Y06CH8l3+550AkJjfZ2HlFI9Dyt9+O+zYMfa8Zb1iNqMUHAH1RPJe0/TFu+EiJ/zdTsAYYLRCZWCdH7C7IwQnBa6QLeXghuoQrLswEDWfyFdHG6fYDAH44VOd/uJpXIWQUPfAVP2VFb8wV4gKDQXqaiSaqyXzKC8rklmeRGdqgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RUbaC/U5Wza5GZCANa6emuId5ZyGI3+t3afhKyW5Bhs=; b=AWnSg3t9hEkjOP6IETKpX5pQGLE672jaQz1+FaXfjcOaA/uCM1VhIj5CYrrQwyG/NSrkwUAxilGb4d2iaCiYrJFQq5Nhq/Vxy7iRFEFj+7Ttfu9nZ+UIksGvyDFZPTi1GfLrQtCCV3ADqzj7gpTGfHhol6/o8U9TixBqzb4Nv67myWlnv2vRV7BNDLhdstx2IFSUP8pyWrTBsM541hOXhn7hYPftgBv14nTbCDbnygY8gvIzFfa6WJfLfJbWX12N6zjEOA8lnl9BfZaU8mg162pj+PJUlJqavxLbOLtpMfyUSpzzmlyWAyaMiBiLZ//yKIVjNTcIc7Lr0S9Q7jvDFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RUbaC/U5Wza5GZCANa6emuId5ZyGI3+t3afhKyW5Bhs=; b=P7EmLyyYNq4pDGsBy3HSGj6OwWNefTksx6S39q5dODgLVNcTRD58tgOrZ8HybaY0hInaJaSfVsAErJvHlRKn8eYQQ68CNFXxPzN4kI7QwafdHghYOLG7h2HyYKXEFNMhnyVGq0dBKMR5jbFeyId8278By6qUYtbw19FKIVT6zR4= Received: from BN8PR16CA0025.namprd16.prod.outlook.com (2603:10b6:408:4c::38) by PH0PR12MB5449.namprd12.prod.outlook.com (2603:10b6:510:e7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Mon, 9 May 2022 04:50:47 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::98) by BN8PR16CA0025.outlook.office365.com (2603:10b6:408:4c::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 04:50:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:47 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:38 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 6/8] perf header: Parse non-cpu pmu capabilities Date: Mon, 9 May 2022 10:19:12 +0530 Message-ID: <20220509044914.1473-7-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37d0aa08-5e80-4208-8769-08da31777bdf X-MS-TrafficTypeDiagnostic: PH0PR12MB5449:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qkdg2SF4tgLC02igj6ry5quW5NmtjSxvucgQU23MJzTK/k/ocZfwlFtsP9jQUS/EBsIAWF4m0rTW+p6goIWsKRZTZ6BIRqbvI5f5WAKUhrh57artfYA6FdOl0H6YICatXmB27lUVguFkTmUvTrQ2+d/ioPIRcK7wBV1mK8wyBEKPZyGd2f8nvMq3FTyFq2gVQ8u9+3uhgBW8qUj/vUveqSMyK+PtpbWEKUthz8GFx5WbwEYNSMmnI6gvhTiIJhWs49nH4ZnnZ3hxkrN++bxfUHf82TNwGgb/Ej85XpMF/kxH6mJliY2O29pRztZpoS+0ybyuLwWPj1piBK3WZqheIuDEhJRlNiS8+CzIPX9f8/kMQWpDTRZH33Q1ZHJmSgQmUmJs11ffxilp75ynLtyqSUCLxz2qgabBX+SLAxwjDU19Sellypvs1pIVWwjXo3112Xey+//oPWiUAUOV8z4O699J+BqnHdtUXbQbMZGmxrW5JWK+S1TmplZiUEQ5utuPZ4a+swfLeagh+cEDhUzjNOHvbzCwDP8aYIAx2appGSPrUy0WQODnJqrOhKD6/DNltbD/DtHlPjL9P2ql9jeBQpsKiu0NCXUND0NifvyJ5y7xjWOD2HDHUiyGGPeGmR25POtO31NnFBZdO4laCJvxli0SBtY8teVqtXXLvzlb1B7XmvFeHLx11TCGZdmf18rz6iZ27II8mKabB4W/kUkjyg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(26005)(70586007)(81166007)(8676002)(70206006)(8936002)(86362001)(4326008)(7416002)(44832011)(5660300002)(7696005)(508600001)(30864003)(2906002)(54906003)(110136005)(6666004)(2616005)(1076003)(316002)(36756003)(36860700001)(40460700003)(82310400005)(336012)(426003)(16526019)(186003)(83380400001)(356005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:47.4837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37d0aa08-5e80-4208-8769-08da31777bdf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5449 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Pmus advertise their capabilities via sysfs attribute files but perf tool currently parses only core(cpu) pmu capabilities. Add support for parsing non-cpu pmu capabilities. Signed-off-by: Ravi Bangoria --- .../Documentation/perf.data-file-format.txt | 18 ++ tools/perf/util/env.c | 48 +++- tools/perf/util/env.h | 11 + tools/perf/util/header.c | 211 ++++++++++++++++++ tools/perf/util/header.h | 1 + tools/perf/util/pmu.c | 15 +- tools/perf/util/pmu.h | 2 + 7 files changed, 301 insertions(+), 5 deletions(-) diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/per= f/Documentation/perf.data-file-format.txt index f56d0e0fbff6..dea3acb36558 100644 --- a/tools/perf/Documentation/perf.data-file-format.txt +++ b/tools/perf/Documentation/perf.data-file-format.txt @@ -435,6 +435,24 @@ struct { } [nr_pmu]; }; =20 + HEADER_PMU_CAPS =3D 32, + + List of pmu capabilities (except cpu pmu which is already + covered by HEADER_CPU_PMU_CAPS) + +struct { + u32 nr_pmus; + struct { + u8 core_type; /* For hybrid topology */ + char pmu_name[]; + u16 nr_caps; + struct { + char name[]; + char value[]; + } [nr_caps]; + } [nr_pmus]; +}; + other bits are reserved and should ignored for now HEADER_FEAT_BITS =3D 256, =20 diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 579e44c59914..928633f07086 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -179,7 +179,7 @@ static void perf_env__purge_bpf(struct perf_env *env __= maybe_unused) =20 void perf_env__exit(struct perf_env *env) { - int i; + int i, j; =20 perf_env__purge_bpf(env); perf_env__purge_cgroups(env); @@ -222,6 +222,14 @@ void perf_env__exit(struct perf_env *env) zfree(&env->hybrid_cpc_nodes[i].pmu_name); } zfree(&env->hybrid_cpc_nodes); + + for (i =3D 0; i < env->nr_pmus_with_caps; i++) { + zfree(&env->env_pmu_caps[i].pmu_name); + for (j =3D 0; j < env->env_pmu_caps[i].nr_caps; j++) + zfree(&env->env_pmu_caps[i].pmu_caps[j]); + zfree(&env->env_pmu_caps[i].pmu_caps); + } + zfree(&env->env_pmu_caps); } =20 void perf_env__init(struct perf_env *env) @@ -527,3 +535,41 @@ int perf_env__numa_node(struct perf_env *env, struct p= erf_cpu cpu) =20 return cpu.cpu >=3D 0 && cpu.cpu < env->nr_numa_map ? env->numa_map[cpu.c= pu] : -1; } + +char *perf_env__find_pmu_cap(struct perf_env *env, u8 core_type, + const char *pmu_name, const char *cap) +{ + struct env_pmu_caps *env_pmu_caps =3D env->env_pmu_caps; + char *cap_eq; + int cap_size; + char **ptr; + int i, j; + + if (!pmu_name || !cap) + return NULL; + + cap_size =3D strlen(cap); + cap_eq =3D zalloc(cap_size + 2); + if (!cap_eq) + return NULL; + + memcpy(cap_eq, cap, cap_size); + cap_eq[cap_size] =3D '=3D'; + + for (i =3D 0; i < env->nr_pmus_with_caps; i++) { + if (env_pmu_caps[i].core_type !=3D core_type || + strcmp(env_pmu_caps[i].pmu_name, pmu_name)) + continue; + + ptr =3D env_pmu_caps[i].pmu_caps; + + for (j =3D 0; j < env_pmu_caps[i].nr_caps; j++) { + if (!strncmp(ptr[j], cap_eq, cap_size + 1)) { + free(cap_eq); + return &ptr[j][cap_size + 1]; + } + } + } + free(cap_eq); + return NULL; +} diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index a3541f98e1fc..2b767f4ae6e0 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -50,6 +50,13 @@ struct hybrid_cpc_node { char *pmu_name; }; =20 +struct env_pmu_caps { + u8 core_type; + char *pmu_name; + u16 nr_caps; + char **pmu_caps; +}; + struct perf_env { char *hostname; char *os_release; @@ -75,6 +82,7 @@ struct perf_env { int nr_cpu_pmu_caps; int nr_hybrid_nodes; int nr_hybrid_cpc_nodes; + int nr_pmus_with_caps; char *cmdline; const char **cmdline_argv; char *sibling_cores; @@ -95,6 +103,7 @@ struct perf_env { unsigned long long memory_bsize; struct hybrid_node *hybrid_nodes; struct hybrid_cpc_node *hybrid_cpc_nodes; + struct env_pmu_caps *env_pmu_caps; #ifdef HAVE_LIBBPF_SUPPORT /* * bpf_info_lock protects bpf rbtrees. This is needed because the @@ -172,4 +181,6 @@ bool perf_env__insert_btf(struct perf_env *env, struct = btf_node *btf_node); struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id); =20 int perf_env__numa_node(struct perf_env *env, struct perf_cpu cpu); +char *perf_env__find_pmu_cap(struct perf_env *env, u8 core_type, + const char *pmu_name, const char *cap); #endif /* __PERF_ENV_H */ diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index a27132e5a5ef..23d89dbfcd96 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -217,6 +217,19 @@ static int __do_read(struct feat_fd *ff, void *addr, s= size_t size) return __do_read_buf(ff, addr, size); } =20 +static int do_read_u16(struct feat_fd *ff, u16 *addr) +{ + int ret; + + ret =3D __do_read(ff, addr, sizeof(*addr)); + if (ret) + return ret; + + if (ff->ph->needs_swap) + *addr =3D bswap_16(*addr); + return 0; +} + static int do_read_u32(struct feat_fd *ff, u32 *addr) { int ret; @@ -1580,6 +1593,77 @@ static int write_hybrid_cpu_pmu_caps(struct feat_fd = *ff, return 0; } =20 +/* + * File format: + * + * struct { + * u32 nr_pmus; + * struct { + * u8 core_type; + * char pmu_name[]; + * u16 nr_caps; + * struct { + * char name[]; + * char value[]; + * } [nr_caps]; + * } [nr_pmus]; + * }; + */ +static int write_pmu_caps(struct feat_fd *ff, struct evlist *evlist __mayb= e_unused) +{ + struct perf_pmu_caps *caps =3D NULL; + struct perf_pmu *pmu =3D NULL; + u8 core_type =3D 0; + u32 nr_pmus =3D 0; + int ret; + + while ((pmu =3D perf_pmu__scan(pmu))) { + if (!pmu->name || !strncmp(pmu->name, "cpu", 3) || + perf_pmu__caps_parse(pmu) <=3D 0) + continue; + nr_pmus++; + } + + ret =3D do_write(ff, &nr_pmus, sizeof(nr_pmus)); + if (ret < 0) + return ret; + + if (!nr_pmus) + return 0; + + while ((pmu =3D perf_pmu__scan(pmu))) { + if (!pmu->name || !strncmp(pmu->name, "cpu", 3) || !pmu->nr_caps) + continue; + + /* + * Currently core_type is always set to 0. But it can be + * used in future for hybrid topology pmus. + */ + ret =3D do_write(ff, &core_type, sizeof(core_type)); + if (ret < 0) + return ret; + + ret =3D do_write_string(ff, pmu->name); + if (ret < 0) + return ret; + + ret =3D do_write(ff, &pmu->nr_caps, sizeof(pmu->nr_caps)); + if (ret < 0) + return ret; + + list_for_each_entry(caps, &pmu->caps, list) { + ret =3D do_write_string(ff, caps->name); + if (ret < 0) + return ret; + + ret =3D do_write_string(ff, caps->value); + if (ret < 0) + return ret; + } + } + return 0; +} + static void print_hostname(struct feat_fd *ff, FILE *fp) { fprintf(fp, "# hostname : %s\n", ff->ph->env.hostname); @@ -2209,6 +2293,31 @@ static void print_mem_topology(struct feat_fd *ff, F= ILE *fp) } } =20 +static void print_pmu_caps(struct feat_fd *ff, FILE *fp) +{ + struct env_pmu_caps *env_pmu_caps =3D ff->ph->env.env_pmu_caps; + int nr_pmus_with_caps =3D ff->ph->env.nr_pmus_with_caps; + const char *delimiter =3D ""; + char **ptr; + int i, j; + + if (!nr_pmus_with_caps) + return; + + for (i =3D 0; i < nr_pmus_with_caps; i++) { + fprintf(fp, "# %s pmu capabilities: ", env_pmu_caps[i].pmu_name); + + ptr =3D env_pmu_caps[i].pmu_caps; + + delimiter =3D ""; + for (j =3D 0; j < env_pmu_caps[i].nr_caps; j++) { + fprintf(fp, "%s%s", delimiter, ptr[j]); + delimiter =3D ", "; + } + fprintf(fp, "\n"); + } +} + static int __event_process_build_id(struct perf_record_header_build_id *be= v, char *filename, struct perf_session *session) @@ -3319,6 +3428,107 @@ static int process_hybrid_cpu_pmu_caps(struct feat_= fd *ff, return ret; } =20 +static int __process_pmu_caps(struct feat_fd *ff, struct env_pmu_caps *env= _pmu_caps) +{ + u16 nr_caps =3D env_pmu_caps->nr_caps; + int name_size, value_size; + char *name, *value, *ptr; + u16 i; + + env_pmu_caps->pmu_caps =3D zalloc(sizeof(char *) * nr_caps); + if (!env_pmu_caps->pmu_caps) + return -1; + + for (i =3D 0; i < nr_caps; i++) { + name =3D do_read_string(ff); + if (!name) + goto error; + + value =3D do_read_string(ff); + if (!value) + goto free_name; + + name_size =3D strlen(name); + value_size =3D strlen(value); + ptr =3D zalloc(sizeof(char) * (name_size + value_size + 2)); + if (!ptr) + goto free_value; + + memcpy(ptr, name, name_size); + ptr[name_size] =3D '=3D'; + memcpy(ptr + name_size + 1, value, value_size); + env_pmu_caps->pmu_caps[i] =3D ptr; + + free(value); + free(name); + } + return 0; + +free_value: + free(value); +free_name: + free(name); +error: + for (; i > 0; i--) + free(env_pmu_caps->pmu_caps[i - 1]); + free(env_pmu_caps->pmu_caps); + return -1; +} + +static int process_pmu_caps(struct feat_fd *ff, void *data __maybe_unused) +{ + struct env_pmu_caps *env_pmu_caps; + u32 nr_pmus; + u32 i; + u16 j; + + ff->ph->env.nr_pmus_with_caps =3D 0; + ff->ph->env.env_pmu_caps =3D NULL; + + if (do_read_u32(ff, &nr_pmus)) + return -1; + + if (!nr_pmus) + return 0; + + env_pmu_caps =3D zalloc(sizeof(struct env_pmu_caps) * nr_pmus); + if (!env_pmu_caps) + return -ENOMEM; + + for (i =3D 0; i < nr_pmus; i++) { + if (__do_read(ff, &env_pmu_caps[i].core_type, sizeof(env_pmu_caps[i].cor= e_type))) + goto error; + + env_pmu_caps[i].pmu_name =3D do_read_string(ff); + if (!env_pmu_caps[i].pmu_name) + goto error; + + if (do_read_u16(ff, &env_pmu_caps[i].nr_caps)) + goto free_pmu_name; + + if (!__process_pmu_caps(ff, &env_pmu_caps[i])) + continue; + +free_pmu_name: + free(env_pmu_caps[i].pmu_name); + goto error; + } + + ff->ph->env.nr_pmus_with_caps =3D nr_pmus; + ff->ph->env.env_pmu_caps =3D env_pmu_caps; + return 0; + +error: + for (; i > 0; i--) { + free(env_pmu_caps[i - 1].pmu_name); + for (j =3D 0; j < env_pmu_caps[i - 1].nr_caps; j++) + free(env_pmu_caps[i - 1].pmu_caps[j]); + free(env_pmu_caps[i - 1].pmu_caps); + } + free(env_pmu_caps); + return -1; +} + #define FEAT_OPR(n, func, __full_only) \ [HEADER_##n] =3D { \ .name =3D __stringify(n), \ @@ -3382,6 +3592,7 @@ const struct perf_header_feature_ops feat_ops[HEADER_= LAST_FEATURE] =3D { FEAT_OPR(CLOCK_DATA, clock_data, false), FEAT_OPN(HYBRID_TOPOLOGY, hybrid_topology, true), FEAT_OPR(HYBRID_CPU_PMU_CAPS, hybrid_cpu_pmu_caps, false), + FEAT_OPR(PMU_CAPS, pmu_caps, false), }; =20 struct header_print_data { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 0eb4bc29a5a4..e9a067bb8b9e 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -47,6 +47,7 @@ enum { HEADER_CLOCK_DATA, HEADER_HYBRID_TOPOLOGY, HEADER_HYBRID_CPU_PMU_CAPS, + HEADER_PMU_CAPS, HEADER_LAST_FEATURE, HEADER_FEAT_BITS =3D 256, }; diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 9a1c7e63e663..8d599acb7569 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1890,16 +1890,22 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu) const char *sysfs =3D sysfs__mountpoint(); DIR *caps_dir; struct dirent *evt_ent; - int nr_caps =3D 0; + + if (pmu->caps_initialized) + return pmu->nr_caps; =20 if (!sysfs) return -1; =20 + pmu->nr_caps =3D 0; + snprintf(caps_path, PATH_MAX, "%s" EVENT_SOURCE_DEVICE_PATH "%s/caps", sysfs, pmu->name); =20 - if (stat(caps_path, &st) < 0) + if (stat(caps_path, &st) < 0) { + pmu->caps_initialized =3D true; return 0; /* no error if caps does not exist */ + } =20 caps_dir =3D opendir(caps_path); if (!caps_dir) @@ -1926,13 +1932,14 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu) continue; } =20 - nr_caps++; + pmu->nr_caps++; fclose(file); } =20 closedir(caps_dir); =20 - return nr_caps; + pmu->caps_initialized =3D true; + return pmu->nr_caps; } =20 void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 541889fa9f9c..593005e68bea 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -46,6 +46,8 @@ struct perf_pmu { struct perf_cpu_map *cpus; struct list_head format; /* HEAD struct perf_pmu_format -> list */ struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ + bool caps_initialized; + u16 nr_caps; struct list_head caps; /* HEAD struct perf_pmu_caps -> list */ struct list_head list; /* ELEM */ struct list_head hybrid_list; --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C5FC4167E for ; Mon, 9 May 2022 04:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbiEIE6R (ORCPT ); Mon, 9 May 2022 00:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbiEIEzR (ORCPT ); Mon, 9 May 2022 00:55:17 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2043.outbound.protection.outlook.com [40.107.236.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D61011E480; Sun, 8 May 2022 21:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PngRIO2td1UqR4PQwZNKx99Po3kxB4U98Ff/34hJvSEm9zHncwA8x7zUKJtXzsevZAQFaH1bz8uyWRBTa7jek2WdA3CqQhe8JboY1OqkkEMWqwmLDuAGzC+v5o6QpgZwYovlMPS32bVRxHYnawIqIfysy3ujj2DRkcPRKvFjytoiU5JP029kWdBHTlJYfgWOdFndECvO6hnBRlc+39FqxsbaO3N5g83Cb7BaeWWmLOD64EMWs00hAwqOJZs85p7LCHdx/olh1S6pNDw1VZDb71hhPMzm8ImzEJqWg0o/Ngb0K8AvZc4ysX0n77c5i3WMx6kdYX7QOzwH9guUtelWyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QNnsVau31cr+ANHm4Iw3OYjauKD0sCxswonAd4w6OR0=; b=mifC6CImiRNryRg/hh1utP9Ru3aLiJm/2U5JDrRm86Z+rNHLN4GdXXNGKKn/bdG5Y9UYiI9E0xwkFoOZEp1WlGUzyc/tHvvrOzxnetjR+VYa/pt5eI6y/9d4rguBFTivmFUhPdaIRb77dv+gp17k1Y2vEhoYdUnzTM95GxzXumEm3yBDtgTuHXVRpRlI5f8bhJzYCiaAnTZvD5evHk7OAKTtCIi2Ny6MCYmT0YgDzbs7qWZ5gdKFYhxYlmJVbUoYGGD6S9KO6nfOJMTuZD3bAIhIMO/tqNWmKtRqWyoq6cvuYI9rPeVYuCySVN1XMAOKzjURwOqg/Sg72i1G+6zp2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QNnsVau31cr+ANHm4Iw3OYjauKD0sCxswonAd4w6OR0=; b=lwUPD8f6siQndlpowGFnCl/+l6gQ/8OQ+HAwm7pR3WovGAQnCzzXvyVag+o119BBPMJN+MovkJy2LCRtWtPAFjsYiBVlXYRVF1qo48AArNBFwMRPFMcm+/H/GE3EXStXTv7tTv0LhhNDwvOGowxGrwRmqj5BFIeeu+xT7vb/oAg= Received: from BN8PR04CA0063.namprd04.prod.outlook.com (2603:10b6:408:d4::37) by DM5PR12MB1561.namprd12.prod.outlook.com (2603:10b6:4:b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Mon, 9 May 2022 04:50:56 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::e0) by BN8PR04CA0063.outlook.office365.com (2603:10b6:408:d4::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21 via Frontend Transport; Mon, 9 May 2022 04:50:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:50:55 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:47 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 7/8] perf script ibs: Support new IBS bits in raw trace dump Date: Mon, 9 May 2022 10:19:13 +0530 Message-ID: <20220509044914.1473-8-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d872614-50f8-466f-6f08-08da317780f0 X-MS-TrafficTypeDiagnostic: DM5PR12MB1561:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vYdcHB76V0Nkjw6Rtd37cupJ8UZPIduIaGf51nQbWW245KIjxARE/guT20zrexIqCWBtwyJl9xGdX11TXzMHn7ut1rDlfCFoDSsNk66RMYOfegESRzObQkZAV4G2aoGXWFmpWQ1xIBW8lcAzSm8WtHAg23PgcquxNdDjiAgwRRFHafYwOPJ5H2MNxIhtZ9GbL96X1ZW0ct/VYrHi3k8Z63jTUWvE6tl1zPjC/ckaZLZ7nVWklcQm5ZUyzjtJqgSRAFrlIlMA6c5iC6cTK0BcSKuEFXQ9tTavV/Z5KsOqu5zmkk4vs9vYyF1jr9lQ644KOCnBVSUuR3w+qgoG7nwz4ITSuPF6VfMD2PyUqeH67W1lfxboaAgPFEaLemsF+yHAKqqInx1HM1eDi0HgLaX6vE3rFKaegH/szBSOMhh7Nd6YB4XeibSliL7kwbeAkzJi0UJ2MZoN+hrfbucxcN7ATqTXif95i9oyz2Vbp6CKF7gRFuWgMocL0V0QAR4oqQMSFVd1ze1TW4lXOQkgb+cWXStlt59EzLWOm9KJRXAlGZv3rDVHEFkqsqSNKyKLIlop/4AstC77RVRM9obt2US7chtydRq/e7WSTjYuD+vYLR1vvAPZuEpZF0c6H4VQvtoRRr/60H7u5jT3oS6XCZCk02N6loppnxYy7j8pRAfIZ5Qc2bXwI0/l0Gz5tZ+TonIKdepu0Thk1EiWxarRGN/gbQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(6666004)(82310400005)(2906002)(7696005)(4326008)(36756003)(8676002)(86362001)(5660300002)(7416002)(40460700003)(44832011)(26005)(81166007)(70206006)(70586007)(2616005)(8936002)(508600001)(1076003)(110136005)(356005)(54906003)(336012)(426003)(186003)(316002)(16526019)(36860700001)(83380400001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:50:55.9831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d872614-50f8-466f-6f08-08da317780f0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1561 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" IBS support has been enhanced with two new features in upcoming uarch: 1. DataSrc extension and 2. L3 miss filtering. Additional set of bits has been introduced in IBS registers to exploit these features. Interpret those bits while doing perf report/script raw dump. IBS op pmu ex: $ sudo ./perf record -c 130 -a -e ibs_op/l3missonly=3D1/ --raw-samples $ sudo ./perf report -D ... ibs_op_ctl: 0000004500070008 MaxCnt 128 L3MissOnly 1 En 1 Val 1 CntCtl 0=3Dcycles CurCnt 69 ibs_op_data: 0000000000710002 CompToRetCtr 2 TagToRetCtr 113 BrnRet 0 RipInvalid 0 BrnFuse 0 Microcode 0 ibs_op_data2: 0000000000000002 CacheHitSt 0=3DM-state RmtNode 0 DataSrc 2=3DA peer cache in a near CCX ibs_op_data3: 000000681d1700a1 LdOp 1 StOp 0 DcL1TlbMiss 0 DcL2TlbMiss 0 DcL1TlbHit2M 0 DcL1TlbHit1G 1 DcL2TlbHit2M 0 DcMiss 1 DcMisAcc 0 DcWcMemAcc 0 DcUcMemAcc 0 DcLockedOp 0 DcMissNoMabAlloc 1 DcLinAddrValid 1 DcPhyAddrValid 1 DcL2TlbHit1G 0 L2Miss 1 SwPf 0 OpMemWidth 8 bytes OpDcMissOpenMemReqs 7 DcMissLat 104 TlbRefillLat 0 IBS Fetch pmu ex: $ sudo ./perf record -c 130 -a -e ibs_fetch/l3missonly=3D1/ --raw-samples $ sudo ./perf report -D ... ibs_fetch_ctl: 3c1f00c700080008 MaxCnt 128 Cnt 128 Lat 199 En 1 Val 1 Comp 1 IcMiss 1 PhyAddrValid 1 L1TlbPgSz 4KB L1TlbMiss 0 L2TlbMiss 0 RandEn 0 L2Miss 1 L3MissOnly 1 FetchOcMiss 1 FetchL3Miss 1 With the DataSrc extensions, the source of data can be decoded among: - Local L3 or other L1/L2 in CCX. - A peer cache in a near CCX. - Data returned from DRAM. - A peer cache in a far CCX. - DRAM address map with "long latency" bit set. - Data returned from MMIO/Config/PCI/APIC. - Extension Memory (S-Link, GenZ, etc - identified by the CS target and/or address map at DF's choice). - Peer Agent Memory. Signed-off-by: Ravi Bangoria --- arch/x86/include/asm/amd-ibs.h | 16 ++++--- tools/arch/x86/include/asm/amd-ibs.h | 16 ++++--- tools/perf/util/amd-sample-raw.c | 68 ++++++++++++++++++++++++---- 3 files changed, 80 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/amd-ibs.h b/arch/x86/include/asm/amd-ibs.h index 46e1df45efc0..b40b2d4ea2ac 100644 --- a/arch/x86/include/asm/amd-ibs.h +++ b/arch/x86/include/asm/amd-ibs.h @@ -29,7 +29,10 @@ union ibs_fetch_ctl { rand_en:1, /* 57: random tagging enable */ fetch_l2_miss:1,/* 58: L2 miss for sampled fetch * (needs IbsFetchComp) */ - reserved:5; /* 59-63: reserved */ + l3_miss_only:1, /* 59: Collect L3 miss samples only */ + fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */ + fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */ + reserved:2; /* 62-63: reserved */ }; }; =20 @@ -38,14 +41,14 @@ union ibs_op_ctl { __u64 val; struct { __u64 opmaxcnt:16, /* 0-15: periodic op max. count */ - reserved0:1, /* 16: reserved */ + l3_miss_only:1, /* 16: Collect L3 miss samples only */ op_en:1, /* 17: op sampling enable */ op_val:1, /* 18: op sample valid */ cnt_ctl:1, /* 19: periodic op counter control */ opmaxcnt_ext:7, /* 20-26: upper 7 bits of periodic op maximum count */ - reserved1:5, /* 27-31: reserved */ + reserved0:5, /* 27-31: reserved */ opcurcnt:27, /* 32-58: periodic op counter current count */ - reserved2:5; /* 59-63: reserved */ + reserved1:5; /* 59-63: reserved */ }; }; =20 @@ -71,11 +74,12 @@ union ibs_op_data { union ibs_op_data2 { __u64 val; struct { - __u64 data_src:3, /* 0-2: data source */ + __u64 data_src_lo:3, /* 0-2: data source low */ reserved0:1, /* 3: reserved */ rmt_node:1, /* 4: destination node */ cache_hit_st:1, /* 5: cache hit state */ - reserved1:57; /* 5-63: reserved */ + data_src_hi:2, /* 6-7: data source high */ + reserved1:56; /* 8-63: reserved */ }; }; =20 diff --git a/tools/arch/x86/include/asm/amd-ibs.h b/tools/arch/x86/include/= asm/amd-ibs.h index 174e7d83fcbd..21e01cf6162e 100644 --- a/tools/arch/x86/include/asm/amd-ibs.h +++ b/tools/arch/x86/include/asm/amd-ibs.h @@ -29,7 +29,10 @@ union ibs_fetch_ctl { rand_en:1, /* 57: random tagging enable */ fetch_l2_miss:1,/* 58: L2 miss for sampled fetch * (needs IbsFetchComp) */ - reserved:5; /* 59-63: reserved */ + l3_miss_only:1, /* 59: Collect L3 miss samples only */ + fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */ + fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */ + reserved:2; /* 62-63: reserved */ }; }; =20 @@ -38,14 +41,14 @@ union ibs_op_ctl { __u64 val; struct { __u64 opmaxcnt:16, /* 0-15: periodic op max. count */ - reserved0:1, /* 16: reserved */ + l3_miss_only:1, /* 16: Collect L3 miss samples only */ op_en:1, /* 17: op sampling enable */ op_val:1, /* 18: op sample valid */ cnt_ctl:1, /* 19: periodic op counter control */ opmaxcnt_ext:7, /* 20-26: upper 7 bits of periodic op maximum count */ - reserved1:5, /* 27-31: reserved */ + reserved0:5, /* 27-31: reserved */ opcurcnt:27, /* 32-58: periodic op counter current count */ - reserved2:5; /* 59-63: reserved */ + reserved1:5; /* 59-63: reserved */ }; }; =20 @@ -71,11 +74,12 @@ union ibs_op_data { union ibs_op_data2 { __u64 val; struct { - __u64 data_src:3, /* 0-2: data source */ + __u64 data_src_lo:3, /* 0-2: data source low */ reserved0:1, /* 3: reserved */ rmt_node:1, /* 4: destination node */ cache_hit_st:1, /* 5: cache hit state */ - reserved1:57; /* 5-63: reserved */ + data_src_hi:2, /* 6-7: data source high */ + reserved1:56; /* 8-63: reserved */ }; }; =20 diff --git a/tools/perf/util/amd-sample-raw.c b/tools/perf/util/amd-sample-= raw.c index d19d765195c5..63303f583bc0 100644 --- a/tools/perf/util/amd-sample-raw.c +++ b/tools/perf/util/amd-sample-raw.c @@ -18,6 +18,7 @@ #include "pmu-events/pmu-events.h" =20 static u32 cpu_family, cpu_model, ibs_fetch_type, ibs_op_type; +static bool zen4_ibs_extensions; =20 static void pr_ibs_fetch_ctl(union ibs_fetch_ctl reg) { @@ -39,6 +40,7 @@ static void pr_ibs_fetch_ctl(union ibs_fetch_ctl reg) }; const char *ic_miss_str =3D NULL; const char *l1tlb_pgsz_str =3D NULL; + char l3_miss_str[sizeof(" L3MissOnly _ FetchOcMiss _ FetchL3Miss _")] =3D= ""; =20 if (cpu_family =3D=3D 0x19 && cpu_model < 0x10) { /* @@ -53,12 +55,19 @@ static void pr_ibs_fetch_ctl(union ibs_fetch_ctl reg) ic_miss_str =3D ic_miss_strs[reg.ic_miss]; } =20 + if (zen4_ibs_extensions) { + snprintf(l3_miss_str, sizeof(l3_miss_str), + " L3MissOnly %d FetchOcMiss %d FetchL3Miss %d", + reg.l3_miss_only, reg.fetch_oc_miss, reg.fetch_l3_miss); + } + printf("ibs_fetch_ctl:\t%016llx MaxCnt %7d Cnt %7d Lat %5d En %d Val %d C= omp %d%s " - "PhyAddrValid %d%s L1TlbMiss %d L2TlbMiss %d RandEn %d%s\n", + "PhyAddrValid %d%s L1TlbMiss %d L2TlbMiss %d RandEn %d%s%s\n", reg.val, reg.fetch_maxcnt << 4, reg.fetch_cnt << 4, reg.fetch_lat, reg.fetch_en, reg.fetch_val, reg.fetch_comp, ic_miss_str ? : "", reg.phy_addr_valid, l1tlb_pgsz_str ? : "", reg.l1tlb_miss, reg.l2tlb_mis= s, - reg.rand_en, reg.fetch_comp ? (reg.fetch_l2_miss ? " L2Miss 1" : " L2Mis= s 0") : ""); + reg.rand_en, reg.fetch_comp ? (reg.fetch_l2_miss ? " L2Miss 1" : " L2Mis= s 0") : "", + l3_miss_str); } =20 static void pr_ic_ibs_extd_ctl(union ic_ibs_extd_ctl reg) @@ -68,9 +77,15 @@ static void pr_ic_ibs_extd_ctl(union ic_ibs_extd_ctl reg) =20 static void pr_ibs_op_ctl(union ibs_op_ctl reg) { - printf("ibs_op_ctl:\t%016llx MaxCnt %9d En %d Val %d CntCtl %d=3D%s CurCn= t %9d\n", - reg.val, ((reg.opmaxcnt_ext << 16) | reg.opmaxcnt) << 4, reg.op_en= , reg.op_val, - reg.cnt_ctl, reg.cnt_ctl ? "uOps" : "cycles", reg.opcurcnt); + char l3_miss_only[sizeof(" L3MissOnly _")] =3D ""; + + if (zen4_ibs_extensions) + snprintf(l3_miss_only, sizeof(l3_miss_only), " L3MissOnly %d", reg.l3_mi= ss_only); + + printf("ibs_op_ctl:\t%016llx MaxCnt %9d%s En %d Val %d CntCtl %d=3D%s Cur= Cnt %9d\n", + reg.val, ((reg.opmaxcnt_ext << 16) | reg.opmaxcnt) << 4, l3_miss_only, + reg.op_en, reg.op_val, reg.cnt_ctl, + reg.cnt_ctl ? "uOps" : "cycles", reg.opcurcnt); } =20 static void pr_ibs_op_data(union ibs_op_data reg) @@ -84,7 +99,34 @@ static void pr_ibs_op_data(union ibs_op_data reg) reg.op_brn_ret, reg.op_rip_invalid, reg.op_brn_fuse, reg.op_microcode); } =20 -static void pr_ibs_op_data2(union ibs_op_data2 reg) +static void pr_ibs_op_data2_extended(union ibs_op_data2 reg) +{ + static const char * const data_src_str[] =3D { + "", + " DataSrc 1=3DLocal L3 or other L1/L2 in CCX", + " DataSrc 2=3DA peer cache in a near CCX", + " DataSrc 3=3DData returned from DRAM", + " DataSrc 4=3D(reserved)", + " DataSrc 5=3DA peer cache in a far CCX", + " DataSrc 6=3DDRAM address map with \"long latency\" bit set", + " DataSrc 7=3DData returned from MMIO/Config/PCI/APIC", + " DataSrc 8=3DExtension Memory (S-Link, GenZ, etc)", + " DataSrc 9=3D(reserved)", + " DataSrc 10=3D(reserved)", + " DataSrc 11=3D(reserved)", + " DataSrc 12=3DPeer Agent Memory", + /* 13 to 31 are reserved. Avoid printing them. */ + }; + int data_src =3D (reg.data_src_hi << 3) | reg.data_src_lo; + + printf("ibs_op_data2:\t%016llx %sRmtNode %d%s\n", reg.val, + (data_src =3D=3D 1 || data_src =3D=3D 2 || data_src =3D=3D 5) ? + (reg.cache_hit_st ? "CacheHitSt 1=3DO-State " : "CacheHitSt 0=3DM-state= ") : "", + reg.rmt_node, + data_src < (int)ARRAY_SIZE(data_src_str) ? data_src_str[data_src] : ""); +} + +static void pr_ibs_op_data2_default(union ibs_op_data2 reg) { static const char * const data_src_str[] =3D { "", @@ -98,9 +140,16 @@ static void pr_ibs_op_data2(union ibs_op_data2 reg) }; =20 printf("ibs_op_data2:\t%016llx %sRmtNode %d%s\n", reg.val, - reg.data_src =3D=3D 2 ? (reg.cache_hit_st ? "CacheHitSt 1=3DO-Stat= e " + reg.data_src_lo =3D=3D 2 ? (reg.cache_hit_st ? "CacheHitSt 1=3DO-S= tate " : "CacheHitSt 0=3DM-state ") : "", - reg.rmt_node, data_src_str[reg.data_src]); + reg.rmt_node, data_src_str[reg.data_src_lo]); +} + +static void pr_ibs_op_data2(union ibs_op_data2 reg) +{ + if (zen4_ibs_extensions) + return pr_ibs_op_data2_extended(reg); + pr_ibs_op_data2_default(reg); } =20 static void pr_ibs_op_data3(union ibs_op_data3 reg) @@ -279,6 +328,9 @@ bool evlist__has_amd_ibs(struct evlist *evlist) pmu_mapping +=3D strlen(pmu_mapping) + 1 /* '\0' */; } =20 + if (perf_env__find_pmu_cap(env, 0, "ibs_op", "zen4_ibs_extensions")) + zen4_ibs_extensions =3D 1; + if (ibs_fetch_type || ibs_op_type) { if (!cpu_family) parse_cpuid(env); --=20 2.27.0 From nobody Sun May 10 09:54:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63902C41535 for ; Mon, 9 May 2022 04:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234351AbiEIE6K (ORCPT ); Mon, 9 May 2022 00:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233706AbiEIEzX (ORCPT ); Mon, 9 May 2022 00:55:23 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 370981238BC; Sun, 8 May 2022 21:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WZSGM1DAhUOcC7JGgmrJsQ01karVcW2aCDRtoQs9Bkf720KX5RyV4OZmLHJAtIB1m/7AxDQEcRJrYhBhQBTg8ZOODiybvP7+uTzH4JZKMPpEbjdQ3BGe4yowSqrX7grclqSIhgTKhlQz5lYvWKKNMSvAVFC13cGH7zWNCzoI+aUhhMk9sl9O77UIslVFeAEV7jbFhl0RVsSYZEyGMSMojmRPg/hrIyOqntHKvy14bg2FC7aPvqNH64j1RrjJ7maK8h3LNmRCpntQy7CzQZm9GtDzUBDtt5TAifUvxd96coYV4N2zf5zsGaqbdo55xZTnKrBd2BWoWsyRYrS+nnUAMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RvGO2hnqcqHJP2EtSdwF+bhOn1fiHAiP1GSeVlAY9M4=; b=mV2vqeyVsiynWT9lLbn76FEWB8yUO+9KWyKtT5MCbFJBY5wXolKkmzs6WxjisRx0GPrQCJ9qa6so8UvV36W7+UabdqT4YJu9o6aBaEOvu/c1NUNNyT4/NEoc8ww60y7buG6427uUczlhm2of3ePVG7zQMeAMcnDTnAcbwC5j6K+njvZcEn5NKkO9lP94NPMjfR7+qtFcKXO5exIgqtZ9EdNM2xJrCZIMijN4N6XN2kYL8Z3emiqpKEl0AhNo69sP5m5oHqY7ZuQaoie6dbigOVg3DY8EAidZDbcmW3XAu7FEKVQqok4WC7HZD75ppb2Xzp1Uy6v53CQet570Qgl3+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RvGO2hnqcqHJP2EtSdwF+bhOn1fiHAiP1GSeVlAY9M4=; b=aIfMDqbdn07BbWSs2woV6CRXecue21TTXyAsY+7du234u5NfvlDZgVQYV4tFwSvnnoQfZ2cGOdSShuqEiyU+HVRdhaxXR60YpBo7anNaHq2Ho7lzdn3YlJmdGrWMN2G+edfdpDPGfFQKha+1qBGCkWDmajSCUxTkgZ+bisyxYUk= Received: from BN8PR04CA0052.namprd04.prod.outlook.com (2603:10b6:408:d4::26) by DM6PR12MB4862.namprd12.prod.outlook.com (2603:10b6:5:1b7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Mon, 9 May 2022 04:51:05 +0000 Received: from BN8NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::93) by BN8PR04CA0052.outlook.office365.com (2603:10b6:408:d4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20 via Frontend Transport; Mon, 9 May 2022 04:51:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT042.mail.protection.outlook.com (10.13.177.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 04:51:05 +0000 Received: from BLR-5CG113396H.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sun, 8 May 2022 23:50:55 -0500 From: Ravi Bangoria To: , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 8/8] perf ibs: Fix comment Date: Mon, 9 May 2022 10:19:14 +0530 Message-ID: <20220509044914.1473-9-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509044914.1473-1-ravi.bangoria@amd.com> References: <20220509044914.1473-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03f892ed-2b81-406c-b296-08da31778689 X-MS-TrafficTypeDiagnostic: DM6PR12MB4862:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3D5q6lC7SYLhpXSEOdfMvU4QsAwf0MQlx/GOf5yhu19DHXq8ezzInFSBfCr3bTIwBmlux/SkFrJvEGEQuy781F3rMKuihY/zOQBXsLMwgtKRgb0JcOvTzVBLj/sKNes9ivTZIblGUXUWIeXgWxd8iE9Gfgfx2RBO4Z/0qUg/E94EeHIDPevQiF6L3U8GKNORQHgPoiamPNQ0YVI/vL9ypGEvqyTgO1cO0XluxS5bUl7bqzoBS9byLXbmbmEUrfhLb/5d9wH/5t2E1yt+pnrw9zoxlVaTOyoWOR+2PDrdQ4tQeyAABIoatc+AwuTUZeiywbPFIkjmiqbEXVxb4XMi3VGj2qvkmqcqP2FJKJK5DaOmpaptLktU8gb09EUT6AW0YxnqGvk9gkPxru7ypvzWusxWpfEcTV43CVfrpIaHbuRAu7ApzeXMVIIdq0vI0LeZ5X1nyVFQqTyRHaZE47TT8wit/ZXxaM0nPBPzyuEODpAAOjFxd0Fqg5oKSfLHRw4Y09rXounYf0Ez/O4drCD8YHJj49xD0PxdqdrUeT1PsQBNFecH9ykkXAEWfbEnpBha27IXqI+G9mt4fn9+qbQJw08FKpff10rY6a2gxMNUF5+XupUGxc3o19yJcH+ErLsBqKxq6tI9N5rvkGLXi34vCVxySVQB6iSEzfZq1zEs/pZZjZzrIzqVhiMEy2Zfzt3iCyM8OuURdPnQQJvy9MyIIg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2616005)(36860700001)(81166007)(8676002)(4326008)(26005)(4744005)(86362001)(44832011)(7696005)(6666004)(2906002)(356005)(83380400001)(7416002)(5660300002)(508600001)(8936002)(40460700003)(316002)(1076003)(16526019)(36756003)(186003)(70206006)(70586007)(82310400005)(110136005)(47076005)(54906003)(426003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 04:51:05.3605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03f892ed-2b81-406c-b296-08da31778689 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4862 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" s/IBS Op Data 2/IBS Op Data 1/ for MSR 0xc0011035. Signed-off-by: Ravi Bangoria --- arch/x86/include/asm/amd-ibs.h | 2 +- tools/arch/x86/include/asm/amd-ibs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/amd-ibs.h b/arch/x86/include/asm/amd-ibs.h index b40b2d4ea2ac..f3eb098d63d4 100644 --- a/arch/x86/include/asm/amd-ibs.h +++ b/arch/x86/include/asm/amd-ibs.h @@ -52,7 +52,7 @@ union ibs_op_ctl { }; }; =20 -/* MSR 0xc0011035: IBS Op Data 2 */ +/* MSR 0xc0011035: IBS Op Data 1 */ union ibs_op_data { __u64 val; struct { diff --git a/tools/arch/x86/include/asm/amd-ibs.h b/tools/arch/x86/include/= asm/amd-ibs.h index 21e01cf6162e..9a3312e12e2e 100644 --- a/tools/arch/x86/include/asm/amd-ibs.h +++ b/tools/arch/x86/include/asm/amd-ibs.h @@ -52,7 +52,7 @@ union ibs_op_ctl { }; }; =20 -/* MSR 0xc0011035: IBS Op Data 2 */ +/* MSR 0xc0011035: IBS Op Data 1 */ union ibs_op_data { __u64 val; struct { --=20 2.27.0