From nobody Tue Apr 7 05:10:14 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 B77E5C433F5 for ; Mon, 10 Oct 2022 20:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbiJJUbD (ORCPT ); Mon, 10 Oct 2022 16:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbiJJUaE (ORCPT ); Mon, 10 Oct 2022 16:30:04 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2078.outbound.protection.outlook.com [40.107.102.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04C8C22BFE; Mon, 10 Oct 2022 13:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdLDBMgFzHD5ZaN4iA+g5FBvwKUeYiyiqqkfPxscHkZy3eA2yRsaWzQ1JBge/y1IFqNecbaWdJNYILujCxOjpP6iwrMMpJt25yKsJdW+m89EE2Fj0D7wg/O/h2cazub8tNomXr/yXPa65EoOuI+8G/RrOm6sfx32azq74GqjthjjQUkC+bnlHPyBrtsIA9SOc0XEVXqTJqtoA0zE58P9AOXC3mmunFaUtMTIt7/YWec414P/l3bikdOPKNFtBODRUMfzPP3j2ZMM0xh2NoQ1CFrFhMHk/+jFQMhSPbHQbx81P6Gd0Ok3Mzzyoo8mz7n6eO9t5qZgUFzq8YmWPcbWCA== 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=PHmsdfuyUZgBV9NaapYbUaxFPpD5iENV7ySgSROjkVU=; b=OfLN0ifdJoHrEvdIRmoSrVepas5pNTl46cQyHDj5Oc+BxgZapujfz0Zp75eAgq6QVw4YC6YfVv3M8Buekk72udmmritTyNXbm/EH+Rq/BzcJZ2zHS3cRNDWDUpNUGuTbGqkg6qP0UlEGMMgKisc6VQP1egFtJvjwj9G9WDu+OrMD6VzEgVwm3bCzT/2Q3oJPba7JJ8Lcx9U5wf9iq0/jHiSgyRH8LVft0s0LXLc4RdirnpCucpGFGCchSmhoaGF8r3hSMjEMHFdPuwsQPs8gNDSwWcYGSYqmTN9Qo/bjpEnrGFLlba7mvWszrFgutT1gHuxpG2mK5hiDY+4D4v4oQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=opensource.wdc.com 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=PHmsdfuyUZgBV9NaapYbUaxFPpD5iENV7ySgSROjkVU=; b=L7kcsx23juSaWO+X2Q4v2D2Z6DnV9OFl3HK1X+TIOYyO8CRux2NzYDWGqSyBPIaK0dMFwH+5JB52w8TDIU64Lpq9ISBQr8T6vpKTOd0Fjc+AoRk15TgAhkTLPzIuTz0najAFIhx65220Ry81rYdrM89dQUISzz6wRB9ldr5Zf9Q= Received: from DS7PR03CA0209.namprd03.prod.outlook.com (2603:10b6:5:3b6::34) by DS0PR12MB6629.namprd12.prod.outlook.com (2603:10b6:8:d3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.15; Mon, 10 Oct 2022 20:29:29 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::3a) by DS7PR03CA0209.outlook.office365.com (2603:10b6:5:3b6::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.15 via Frontend Transport; Mon, 10 Oct 2022 20:29:29 +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 DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5709.10 via Frontend Transport; Mon, 10 Oct 2022 20:29:28 +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.28; Mon, 10 Oct 2022 15:29:26 -0500 Subject: [PATCH v6 06/12] x86/resctrl: Introduce data structure to support monitor configuration From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 10 Oct 2022 15:29:26 -0500 Message-ID: <166543376626.23830.5138502593585732085.stgit@bmoger-ubuntu> In-Reply-To: <166543345606.23830.3120625408601531368.stgit@bmoger-ubuntu> References: <166543345606.23830.3120625408601531368.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: DM6NAM11FT046:EE_|DS0PR12MB6629:EE_ X-MS-Office365-Filtering-Correlation-Id: 52442821-4cd1-4b45-83d4-08daaafe21b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y89+J21fVdSNCV7UrBvCmMaa7gA/5kqtpF38WwSnNTm6YWVRgRTPEJWfI3OD8aRol9J0E+99iTW5faHThB9odvBPhxu6ph5UyyJqiWTk3G+34d+U14VadEZOsiuu7z599OlnH8a9m0KqTV3jdJ6iuuicmZlIYpP5RMgOSOQFqie/lTEXyZWkKOQOYSpSmUbDY+7k1n5uNeIk1NE9doBXa+VDCfN8IY7tFaUys3kLANKOjiluu9IO/HvY4XJUbcG5zQBwsgcj2Q2nx7H4Sr8FKTo6TGgVm7wljSwCQggfkOLOnkA6VM0ashrH1B4mrlonyrV8bWjTDR6WoPbBmeGOWSq8iGAXis/f89rx0NIq2wv3P5XouaJHknjHQRfNNwj+2b7XZalnt48ZR2FRYURHBO1IODI8yDzIvo9Ld9B1GFQ7gGwam0+HkuvKlwBJw1AoeBB4We4I3vhDNmf8+AWCswB3yCDEEzwCHEuOeuWi6u4oZyf/vQee7NQchL3CHaGeUJcvrrtEyrSBL+zBk4wiaRQtejIerySBNroeWLtDPuOrurK9p7OwvkxmB392AzztP07T+VzodFcvB3V9V/c7zus9BVqDxakR3J7uuCFk6ipZMKBGgWjnl6AAiI91p12yWAnIcIFLtu59FMv8qfgbZgjxvpoWxlNTo6cgNDe+yH4FnQslTyCp0vq2qsiL/XsaJOPh+x1KnT/xOBBaSdMs6UUjcPqWcbTPDTL9XHlUL3ZBLLK0qKNoQ6SDJk4lb+DgRXhJxG+YJmLECW1m+Nv1TzzxxJ+G3bmY6Fd2qn2oJ/EYN297sGgy966o6fnwrxG/5OXv8LVIZiOQb409ZZSvYA== 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)(7916004)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(316002)(110136005)(54906003)(81166007)(36860700001)(86362001)(8676002)(9686003)(16576012)(70206006)(356005)(26005)(4326008)(33716001)(70586007)(478600001)(2906002)(41300700001)(8936002)(40480700001)(186003)(16526019)(5660300002)(7416002)(82310400005)(44832011)(426003)(103116003)(47076005)(82740400003)(336012)(83380400001)(40460700003)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2022 20:29:28.9524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52442821-4cd1-4b45-83d4-08daaafe21b5 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6629 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new field in mon_evt to support Bandwidth Monitoring Event Configuration(BMEC) and also update the "mon_features" display. The sysfs file "mon_features" will display the monitor configuration if supported. Before the change. $cat /sys/fs/resctrl/info/L3_MON/mon_features llc_occupancy mbm_total_bytes mbm_local_bytes After the change if BMEC is supported. $cat /sys/fs/resctrl/info/L3_MON/mon_features llc_occupancy mbm_total_bytes mbm_total_config mbm_local_bytes mbm_local_config Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 3 ++- arch/x86/kernel/cpu/resctrl/internal.h | 4 +++- arch/x86/kernel/cpu/resctrl/monitor.c | 7 ++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index d79f494a4e91..46813b1c50c2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -814,6 +814,7 @@ static __init bool get_rdt_alloc_resources(void) static __init bool get_rdt_mon_resources(void) { struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + bool mon_configurable =3D rdt_cpu_has(X86_FEATURE_BMEC); =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) rdt_mon_features |=3D (1 << QOS_L3_OCCUP_EVENT_ID); @@ -825,7 +826,7 @@ static __init bool get_rdt_mon_resources(void) if (!rdt_mon_features) return false; =20 - return !rdt_get_mon_l3_config(r); + return !rdt_get_mon_l3_config(r, mon_configurable); } =20 static __init void __check_quirks_intel(void) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 16e3c6e03c79..b458f768f30c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -63,11 +63,13 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); * struct mon_evt - Entry in the event list of a resource * @evtid: event id * @name: name of the event + * @configurable: true if the event is configurable * @list: entry in &rdt_resource->evt_list */ struct mon_evt { enum resctrl_event_id evtid; char *name; + bool configurable; struct list_head list; }; =20 @@ -522,7 +524,7 @@ int closids_supported(void); void closid_free(int closid); int alloc_rmid(void); void free_rmid(u32 rmid); -int rdt_get_mon_l3_config(struct rdt_resource *r); +int rdt_get_mon_l3_config(struct rdt_resource *r, bool configurable); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index efe0c30d3a12..4b8adb7f1c5c 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -746,7 +746,7 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_local_event.list, &r->evt_list); } =20 -int rdt_get_mon_l3_config(struct rdt_resource *r) +int rdt_get_mon_l3_config(struct rdt_resource *r, bool configurable) { unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -783,6 +783,11 @@ int rdt_get_mon_l3_config(struct rdt_resource *r) if (ret) return ret; =20 + if (configurable) { + mbm_total_event.configurable =3D true; + mbm_local_event.configurable =3D true; + } + l3_mon_evt_init(r); =20 r->mon_capable =3D true; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 1271fd1ae2f3..5f0ef1bf4c78 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1001,8 +1001,11 @@ static int rdt_mon_features_show(struct kernfs_open_= file *of, struct rdt_resource *r =3D of->kn->parent->priv; struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) + list_for_each_entry(mevt, &r->evt_list, list) { seq_printf(seq, "%s\n", mevt->name); + if (mevt->configurable) + seq_printf(seq, "%s_config\n", mevt->name); + } =20 return 0; }