From patchwork Mon Oct 17 22:26:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 3775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1669552wrs; Mon, 17 Oct 2022 15:29:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sidkNiyvD2ln4wuArorWuPFpbyUlDP5qBd6Ng4hzG0c1baqG4zS2C4tPPdw99Nuz5OpMd X-Received: by 2002:a17:902:f643:b0:185:3e6d:6171 with SMTP id m3-20020a170902f64300b001853e6d6171mr13852802plg.123.1666045760674; Mon, 17 Oct 2022 15:29:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666045760; cv=pass; d=google.com; s=arc-20160816; b=AiAyx8tgIEsU0jDj42EDq+V64KfmY7HkEszov4JCWdp0dnTiViTno+iz/5jtcKfFos 5pPnP5mqW9FBLO2OjvYGLGhX/ikiGa92GIz8oZ6Z+oMtd9o4uwZxdGx1DY0XLyTfCRU0 1E3sBA/VNcsl2fYSh3JIBu9hI/aKUbLh4UXHbFJNPnU3ZoKQeXrE2rEU3xjph9tP9xiZ zUS5s7Tb2eTqPrpbocYCrXeBrGIYrS14j7NonhjRdZ6n45SAxQR6IgLCVcPo0Tt9AKCG 22YtxI9kXXZzctuvnNWVQSZgqqC7gvkKyDYr4E8TozEsJ8pMCAmQOwgUSFsL7umTSh1c zjhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=jSm02XV3XZEFn04nLHzL7xnXTw3Dm4EvTrmeFsesXnk=; b=cCgYsRuwOJgpc8z+D9yilLiFkgNWDvTKZ0s5+VPszIjFCAG05G3LbrO/rDN5eIVAhm wruWfJFq7nRxkXDhiwBiZPS7YSRIKPY3ulSpjDUKBZVdBpklmUDm9gDH3qHL8kQjIXXY BtR5pSKz3BKhoAOlqNSj9+aLsN1Cz1aEvkD2/fQ5VOymQbln2/ky1DtTUFwXVcAd15Rn 3qY3GfGLmnr0ptlE3Jf/wSCri3ewlumYt1kk/Fitw03N0tPQ1MtdKwWqtARVNme7GOuG kO/r3OnHfb+QTYHK43+LYftZQ8TR9mKBGO3xWb8MR2n94gfIHAbp3XL6W2kVr2NyTNoc zpmw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BvIMmDZt; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a056a00140300b00565cb1ebdb8si14923672pfu.275.2022.10.17.15.29.06; Mon, 17 Oct 2022 15:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BvIMmDZt; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbiJQW0w (ORCPT + 99 others); Mon, 17 Oct 2022 18:26:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbiJQW0u (ORCPT ); Mon, 17 Oct 2022 18:26:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDDA2814E0; Mon, 17 Oct 2022 15:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeZGy1D5AlZleH3VjSO3A7MeCe8fU3IHz4k6artwiW/8x440lGKTCNKJvGp9dnVMPEc79mxkCMwjWeGOothEyY1F0I8/4Z2KIr23ZTcGQDt1jC31ZSt7djO5BwWmFzF7IS2NMNv9DHhoKw0G25j971hHBEtnZRP37ol1/1Ot765efwe8iOPgNIxuX9Y2YX5R+AEyiwJn0jsQWrtAD1XeSeeC92qrT9b/kp0sXVAFuP5cGQmeNC8mE+A8xli6HgbeKtSNcUsIJ00esDfYtN5NbMln712owpqTi9IXCgfXNpuMT4s7kx8e+zyDFVn+1RaRV2INZfJatID+D2S31sdmaA== 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=jSm02XV3XZEFn04nLHzL7xnXTw3Dm4EvTrmeFsesXnk=; b=Wt5M+8gn4paN3u+9RCzxGgZMSBc7+rU6fAkOfC72kMRJf4TbSrYvORsZI6ysx44eTDpXDhOJChWvSmsvPa8o+lIuRUaZNeQsVpJB9ok5suTxxVaRrs33J0zxWOPuQG7NTgJKsmjG3YuD/bQwWtcMQrQ4XEY+dOui+DQABvRhQwK9Ydw2LvXViCOw5EIJN2LoBOShVbIW8J/6eRmm+tgJiUbAWTfQf0Z/EFX/bcOdXa0zGHn7B7N3xscuY/JsqgaAd09itKmzRUOl7R3vmRJ6SY6xd3KSX39tXjtcLUnVJOPUtEMs0XKYsQk0hgTzFJSYVESUg7hcz5a/pXjSppjrGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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=jSm02XV3XZEFn04nLHzL7xnXTw3Dm4EvTrmeFsesXnk=; b=BvIMmDZtNR0jSX3e+OfFr0+iinsMJGXxNzq5Un+zH1JXTs3Esw/M6UVN8q4yz7PZGp8h5n4Iq2X0tg79BRsbgu/J43h25nJ4bx78vfIsKvGL93e7spAS3mjFZNBdvMnimEY9RBsBBXJGem05jULk5wHorwQtCJ1KnqsNXaZyF68= Received: from BN9PR03CA0719.namprd03.prod.outlook.com (2603:10b6:408:ef::34) by BL1PR12MB5208.namprd12.prod.outlook.com (2603:10b6:208:311::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Mon, 17 Oct 2022 22:26:28 +0000 Received: from BN8NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ef:cafe::19) by BN9PR03CA0719.outlook.office365.com (2603:10b6:408:ef::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Mon, 17 Oct 2022 22:26:28 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT063.mail.protection.outlook.com (10.13.177.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Mon, 17 Oct 2022 22:26:27 +0000 Received: from [127.0.1.1] (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.31; Mon, 17 Oct 2022 17:26:25 -0500 Subject: [PATCH v7 03/12] x86/cpufeatures: Add Bandwidth Monitoring Event Configuration feature flag From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 17 Oct 2022 17:26:25 -0500 Message-ID: <166604558527.5345.9308279363992246757.stgit@bmoger-ubuntu> In-Reply-To: <166604543832.5345.9696970469830919982.stgit@bmoger-ubuntu> References: <166604543832.5345.9696970469830919982.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT063:EE_|BL1PR12MB5208:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dd98b17-abcb-43ba-9051-08dab08ea20d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J+WceEQZoKApUnvvU4WNGjrxW+r8g242aO/hmKGIES6yBeeW6F/sxwkFuzYqD+k0J1kWm5zyQL0DA6FubUrwUx/1KQGqhxnFt1IUK1ZDxwKLgTsRNLg6MonTwLlvghxdDOwW9YQekV1FU+uCZ62HVZcdOvkYH/9rxMuXek88AgCnda9xGQhv0kj2RI1agv2vLgl09/TNyGfxJZbLt3gFTwM0zoqQjybrUfVs43EaDQ93HScw7mxUbeD8XSbxuGecJoHmXtT5grf850Hg56moP7vyd5eaVl3gNBpXPeJTVfaBMtBRZ9c9s/oUT3x1cWSTFDCgOihecxgIpqkcna7uGSeDI7pdZo1B+9RSZZn6gnvbiAUd5yjt/d2yMU9pU2YDCUDl0o44b0QHHtkSwcdvYokuG2lNTPNnHDe6h0j4q3Y7BVekHNpF9I/GYbdsUpBoHnzQiB7fIMSvtYuTZoVMSxx2yMWD5psWOxmLl37lou8oQV//AF9ekxxaxmt45s+PYOIH/xJnVFyLKvXl5QxEHIr/tAk7M8nqdGkQjYviONZXESPU0+So4foFuMbwV6As92LNNrGwuL4ceNupu0sFXsSVg5/x0a5myqi/XSPjtm+J8zRJdEHJEPEQ+08IWsiI3DqPRDfzgEOdqaA1cBcLsYGMCNWNkIVVDSEyzDlU5uLbM1dlLxNbQHZKnHi1qlw5fVbBz8HzcjmdYUptGLaDW6THG8AnsL9lw8+/XcgaeYZ42BPHsBHM346s7yyCzKWEb7RoKzD/K2K+xbClkLA/7Ox4g2h+lwt+uCIGKln88Z1trisYtOymeeOyus/KFW9xlyleOz/Zx+IpMimj1gITYdCaag5KUKqJ/bfmtaOmVtWkOJ8ZyVu7jrkLKoNJpscP3LiJfaXJSoa7FzHUC0vEjQ== 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:(13230022)(4636009)(7916004)(346002)(376002)(39860400002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(33716001)(26005)(9686003)(103116003)(186003)(426003)(336012)(70206006)(82310400005)(316002)(16576012)(70586007)(47076005)(478600001)(16526019)(966005)(83380400001)(54906003)(40480700001)(356005)(40460700003)(110136005)(2906002)(36860700001)(81166007)(86362001)(8676002)(8936002)(82740400003)(41300700001)(7416002)(5660300002)(4326008)(44832011)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2022 22:26:27.6520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4dd98b17-abcb-43ba-9051-08dab08ea20d 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: BN8NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5208 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746975599811139963?= X-GMAIL-MSGID: =?utf-8?q?1746975599811139963?= Newer AMD processors support the new feature Bandwidth Monitoring Event Configuration (BMEC). The feature support is identified via CPUID Fn8000_0020_EBX_x0 (ECX=0). Bits Field Name Description 3 EVT_CFG Bandwidth Monitoring Event Configuration (BMEC) Currently, the bandwidth monitoring events mbm_total_bytes and mbm_local_bytes are set to count all the total and local reads/writes respectively. With the introduction of slow memory, the two counters are not enough to count all the different types of memory events. With the feature BMEC, the users have the option to configure mbm_total_bytes and mbm_local_bytes to count the specific type of events. Each BMEC event has a configuration MSR, QOS_EVT_CFG (0xc000_0400h + EventID) which contains one field for each bandwidth type that can be used to configure the bandwidth event to track any combination of supported bandwidth types. The event will count requests from every bandwidth type bit that is set in the corresponding configuration register. Following are the types of events supported: ==== ======================================================== Bits Description ==== ======================================================== 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain ==== ======================================================== By default, the mbm_total_bytes configuration is set to 0x7F to count all the event types and the mbm_local_bytes configuration is set to 0x15 to count all the local memory events. Feature description is available in the specification, "AMD64 Technology Platform Quality of Service Extensions, Revision: 1.03 Publication Link: https://www.amd.com/en/support/tech-docs/amd64-technology-platform-quality-service-extensions Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Signed-off-by: Babu Moger --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 583b88bcc7e1..bf0fd022e80a 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -305,6 +305,7 @@ #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime firmware calls */ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */ #define X86_FEATURE_SMBA (11*32+18) /* Slow Memory Bandwidth Allocation */ +#define X86_FEATURE_BMEC (11*32+19) /* AMD Bandwidth Monitoring Event Configuration (BMEC) */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index c881bcafba7d..4555f9596ccf 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -68,6 +68,7 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_TOTAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, + { X86_FEATURE_BMEC, X86_FEATURE_CQM_LLC }, { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 5a5f17ed69a2..67c4d24e06ef 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -45,6 +45,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, + { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { 0, 0, 0, 0, 0 }