From nobody Fri Jan 2 13:55:40 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 6C840CD98CC for ; Tue, 10 Oct 2023 23:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344170AbjJJXd5 (ORCPT ); Tue, 10 Oct 2023 19:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjJJXdv (ORCPT ); Tue, 10 Oct 2023 19:33:51 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2670A93; Tue, 10 Oct 2023 16:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VsQU5f7LPyTZh/3R9O72z+RJpta1rFvuX9os+BNmDDvamAjLGryAiGfJuM2j5rR3ifnDmu1SBQkGPVWsjvFwX5auFXjrzT5LcsSD3S2TBvJwf3wEtJxoyeBAU9rWgymFtcVj9hWeUaTeZjJvfvjVdlMiLnQiAVl5qF2VP45fLDVwDtdbjL6bvAMNkGCf05N7rM8fm/1xnihGBzZbQUOGkZU2eIO5t/ZuRR467JtSrMmV8aFVVmdAOsyH5Pb/TreKyACX0SnTfSSeI+vR256MJJlp0yi2onDj2EAnqrWVicPftRzXGtaBiG/piLoF9Xtf57cvDfsXUGgOMoEXAy5VLw== 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=IgNwhczAPO//dMRRHaucn0zT8vO7DFd9uRDVyZw4oNg=; b=czpIiiW+tPglH1FSw/r+QMLmcQoaCIAbFHsKMe8B3xmdNlUTEWbaFpZ8Qq8RF2xMOy6spfTYtkUc/M28OiDLZf4G0dhTBsQALbRUl6fiXfChCW9LYrJ/rJkCYOXOfIP6zcZ5Qnn0GgAosR2Q8pgwfeKAnQh9Z2zjU9L9rF3tU05kgyDe6aiPVzUTs9z39+4RI3AhINLnfrk8Hw//cJtHSF/uT9ge8BOELXyATQTnasfLmLW0L3rhApLntP7D0qH2at6hPCttSPgCZJHxMoI2oWsPJDPuw6Hjb0YNy2BpZ9guh+u63pn37f629EJrfbx8nm8KD5dGaOOH7TDtkd+1QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=IgNwhczAPO//dMRRHaucn0zT8vO7DFd9uRDVyZw4oNg=; b=lxXl/nzrAM4BwdKaVnUq1P79+mheca4s0tjcdU/VJ/zew4Nt1vbONXv53L2unyCGbsYRxl6W4nMVLh1dNMsYBaSQYgMKv0jnyAgskXU41kt69Ztb8rAOFkSE+aovWrRZDMPUUysI8IS1cmVcIXy6Bn6kL5k3zthosxU2LEMQU7Q= Received: from MN2PR17CA0017.namprd17.prod.outlook.com (2603:10b6:208:15e::30) by CH3PR12MB8260.namprd12.prod.outlook.com (2603:10b6:610:12a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 23:33:45 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:208:15e:cafe::c1) by MN2PR17CA0017.outlook.office365.com (2603:10b6:208:15e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Tue, 10 Oct 2023 23:33:45 +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 BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:45 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:43 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 01/10] x86/resctrl: Add multiple tasks to the resctrl group at once Date: Tue, 10 Oct 2023 18:33:26 -0500 Message-ID: <20231010233335.998475-2-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4D:EE_|CH3PR12MB8260:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dd48623-20e4-47fe-b8ab-08dbc9e95878 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WT2gFKiry4P7NHmA+hEFmcNotb2NpGULyDA2Uq8bn6oiLacDcvVhI1vcxiaJkmZExrqOO7n+/oYxXfXaRhCltH6gsAnvOJ/R9RY6K+jKkwkPj3e1jkjG9W2WQNQhJgdEPWlK3kyn9zEjaz/IqSr/fICpRZ8Q/3/xwUnHFxp5qWaqZhYqRoR3Qp6tT/hmcoD/Avl8/heLAwt1tsP76Jcb2HdyoK8zY/Rj30HcLpO/j7ZNx0gQ4fsAhVjkVmMYzOvgbDkI5CPSRC2HAn8PAOt01zKoDhKwb5kTH3K7HXCi2gQjiQH7SPNRoZ3iRaJNQ8BAP5OO5fpTQx9f8bX53LwQvIZBAfXD3Tmy35hcUIPsQ+vyncdBwGqtvtlD1rnbx6MjCIg+SVlViJyipOzmsIyaiJgYKObF5uTcN+Hv9GRa5Yz/4+I3iKbLy1jICMG69gXP6aGCn/zMjnsc7CRM6LqWuRt2CNEvF4Qlti7wwh2WOPDAMk9uFEDlzrqAGTB9hIg1LGNdq7antbJEH1SZ531CUov+OGEYCGP+uLLzBNSPrahU72sPVBpPtcbNkj70CejqRY0vyPHUCCrt3PtCuxb/Ar7PTcqtVD9HXv2kX5RRQBVJIreiDRxsSBkpLCZ62HvZxeg1RCuKkC1Wud3o9j7JxJ6n/pgq9/1DlEj2bYzuVPiNan5yONOr4acwUqIQrmnjLw2rb2Stlfmxo42kufFik/JkJ0oKs9SRzWF1gu553MIYT137lyydFJjJA8HN0WR+l4ujxCZ1en7y60Venm8VjA== 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:(13230031)(4636009)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(36756003)(86362001)(66899024)(40480700001)(478600001)(7416002)(1076003)(70586007)(54906003)(44832011)(7696005)(2906002)(2616005)(70206006)(110136005)(7406005)(5660300002)(41300700001)(316002)(6666004)(336012)(66574015)(426003)(47076005)(26005)(16526019)(36860700001)(4326008)(82740400003)(83380400001)(8676002)(40460700003)(8936002)(81166007)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:45.1301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6dd48623-20e4-47fe-b8ab-08dbc9e95878 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: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8260 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resctrl task assignment for monitor or control group needs to be done one at a time. For example: $mount -t resctrl resctrl /sys/fs/resctrl/ $mkdir /sys/fs/resctrl/ctrl_grp1 $echo 123 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 456 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 789 > /sys/fs/resctrl/ctrl_grp1/tasks This is not user-friendly when dealing with hundreds of tasks. Support multiple task assignment in one command with tasks ids separated by commas. For example: $echo 123,456,789 > /sys/fs/resctrl/ctrl_grp1/tasks Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: No changes --- Documentation/arch/x86/resctrl.rst | 9 ++++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 25 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index cb05d90111b4..8154e9975d1e 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -299,7 +299,14 @@ All groups contain the following files: "tasks": Reading this file shows the list of all tasks that belong to this group. Writing a task id to the file will add a task to the - group. If the group is a CTRL_MON group the task is removed from + group. Multiple tasks can be added by separating the task ids + with commas. Tasks will be assigned sequentially. Multiple + failures are not supported. A single failure encountered while + attempting to assign a task will cause the operation to abort and + already added tasks before the failure will remain in the group. + Failures will be logged to /sys/fs/resctrl/info/last_cmd_status. + + If the group is a CTRL_MON group the task is removed from whichever previous CTRL_MON group owned the task and also from any MON group that owned the task. If the group is a MON group, then the task must already belong to the CTRL_MON parent of this diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 725344048f85..f0d163950969 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -696,11 +696,10 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_ope= n_file *of, char *buf, size_t nbytes, loff_t off) { struct rdtgroup *rdtgrp; + char *pid_str; int ret =3D 0; pid_t pid; =20 - if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0) - return -EINVAL; rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); @@ -715,7 +714,27 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open= _file *of, goto unlock; } =20 - ret =3D rdtgroup_move_task(pid, rdtgrp, of); + while (buf && buf[0] !=3D '\0' && buf[0] !=3D '\n') { + pid_str =3D strim(strsep(&buf, ",")); + + if (kstrtoint(pid_str, 0, &pid)) { + rdt_last_cmd_printf("Task list parsing error pid %s\n", pid_str); + ret =3D -EINVAL; + break; + } + + if (pid < 0) { + rdt_last_cmd_printf("Invalid pid %d\n", pid); + ret =3D -EINVAL; + break; + } + + ret =3D rdtgroup_move_task(pid, rdtgrp, of); + if (ret) { + rdt_last_cmd_printf("Error while processing task %d\n", pid); + break; + } + } =20 unlock: rdtgroup_kn_unlock(of->kn); --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 E9D15CD98C0 for ; Tue, 10 Oct 2023 23:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344195AbjJJXeD (ORCPT ); Tue, 10 Oct 2023 19:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344141AbjJJXdx (ORCPT ); Tue, 10 Oct 2023 19:33:53 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B87799D; Tue, 10 Oct 2023 16:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evi3JWRlxCZdbnEolIhCsWgElZAPIQZ3y+rWgn4TXvrgNnlb1aiNjy5wEpMUCMMyD9MKT8A/MtVBCjkckFkFb0cTD6/uKj5UufRsbUVkXw5cycFcrOoHBFG9q9PVAa6Y8gCLCNPXwQySQ5TT2ko7APWU224tFHj+5rBCWSk6i9pVKolkfPJ3T8D3pMmCsHZ5ObjUdB4kndRcLCfctaX1F6sFfxeKY2FMKSHCZzNqxVHy5vfPKAlL+iMRyUOcstzsIwr80t1mSnmWXEBqwagewzg51xW8Er+jzhyEaVZfuif68CfKmctEwnuMSMd+B1sHgmbijnOOQsBGCNjLXMuaGw== 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=T3lo19Z3taUJl5Gy59RynpNh18VIJAYAW9337PE04pQ=; b=QAMU6n8q7cnDrqm1mi+y/kk0fyQIB4tugLx3E8l/4SScitCy0j+mKbwy81SiP3Hhu8BQEJ+WgOQL0XLdHioNl7baqIXMrwub3wUrsMDtBpya98N2ROCv4Q2Gr7KnvGfPu3iZYXOQNfRkwYW1lT0GPyneM2p2kLxIx1Jp6/AaWlzzXwO/mSga+d5JERe+gTkZRy2KUpCPiMdXeAvRCPFil9Gbpj0p/cq4Yg7VKBlnbdW2aW30/ZVCvGzUEBFFYTq8CgLHiFv5TWOp+oilO8h0uy83eecw4SGoTLsJ8eEVmZzcmeJFJXcL3vqKLligEpx6Tqbez0JL74MMjgRdpQS8wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=T3lo19Z3taUJl5Gy59RynpNh18VIJAYAW9337PE04pQ=; b=lbjPAasyuZA2rQm8eG8S0f7bFuFReHJuptsKD3l+2I98GBqoMwGGDiXjF37mzRe+hcNPlcusPxKKuaeBGDbhXt5u6PoiPlVQ/zzCwKDt/WPpWP5csmeumK0gIWO0TeKy1ruWnLBTyMTH5sH91g4gFvp7vL6xkpy3asRVWXDi8ws= Received: from MN2PR01CA0031.prod.exchangelabs.com (2603:10b6:208:10c::44) by DM4PR12MB5748.namprd12.prod.outlook.com (2603:10b6:8:5f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Tue, 10 Oct 2023 23:33:47 +0000 Received: from BL6PEPF0001AB4C.namprd04.prod.outlook.com (2603:10b6:208:10c:cafe::cd) by MN2PR01CA0031.outlook.office365.com (2603:10b6:208:10c::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 23:33: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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4C.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:46 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:44 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 02/10] x86/resctrl: Simplify rftype flag definitions Date: Tue, 10 Oct 2023 18:33:27 -0500 Message-ID: <20231010233335.998475-3-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4C:EE_|DM4PR12MB5748:EE_ X-MS-Office365-Filtering-Correlation-Id: 64623571-b48b-4acb-8833-08dbc9e9596d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRojnqrX2J15LaqQeH8O/al8a+wQutDAl24N6aP4Hdp/gvOVFjwCSXMDVC3f+Z7IIQi8ovr3E8fcjG3UBJg0GvgYcp9/JaKw5k+CjXeSeHcmbYWAhO7n2WqGdxtgJBgt/XOBNLykKAVEOTraS6bmiZ+7eVZRBEQO7SlnK62LGrb3OX7Af3jLX1UIpM1s6s6kyPm3P/6DGEnY1Fb7dGztQJlJcQMGcEUuzAZDAML61ijih8osiPOsX65tX6PNca74mHSWa1GNWvXr0oOtBmZDVNN7Rh0aSWuu+cVYrMToTQHwJlBiNnN+CdNKubXurDpIV3XtCZ06BgdmOfnLblRxmPJgNZUVQF9DRVogbCAkWY641kvN1NOaesEjRSv0M/yNCbujbsVQul5lPi43rNJg7MzAgrm6pqqMwNwQryh41z4XOthXrdd/K5jNbm7gxQ2Wdt9Dpe86iPlf1fPJehLsWeHhzOv5583U0dYNkMB84FWfrOHHPjbRpyfxnr9dD9orYhHXC7S5e+shaof42SzRk2/LFftcfUnzxZRrw9kt76DUCxgbYnKWNKNVtjyoyEiylsLHkgb1M0hXRrDyThKoe8sY5Q2MQx/ybaabY0kYYK/LqQ3gRFC31iRFvqYewkGQoUPiqXdqgbS5+dMj2MM4zfTR1nPprxj40Rmm+BYdOztrrY6vhnhjy2yOZhjyJMG50ExHWBq9K+4ul0es0KFyt+RbeROb0x5gNDoSDkRkngWRpV59hGNlzC53CltwpHHCuclbIS7MzKYm6luYnhCqKQ== 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:(13230031)(4636009)(346002)(39860400002)(396003)(136003)(376002)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799009)(46966006)(40470700004)(36840700001)(40460700003)(16526019)(2616005)(1076003)(26005)(426003)(81166007)(336012)(7696005)(316002)(47076005)(8676002)(6666004)(8936002)(2906002)(7416002)(478600001)(4326008)(36860700001)(7406005)(44832011)(54906003)(70586007)(70206006)(110136005)(41300700001)(86362001)(356005)(82740400003)(36756003)(40480700001)(5660300002)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:46.7345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64623571-b48b-4acb-8833-08dbc9e9596d 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: BL6PEPF0001AB4C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5748 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rftype flags are bitmaps used for adding files under resctrl filesystem. Some of these bitmaps have one extra level of indirection which is not necessary. Make them all direct definition to be consistent and easier to read. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: No changes --- arch/x86/kernel/cpu/resctrl/internal.h | 9 +++------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 +++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 85ceaf9a31ac..62767774810d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -243,12 +243,9 @@ struct rdtgroup { */ #define RFTYPE_INFO BIT(0) #define RFTYPE_BASE BIT(1) -#define RF_CTRLSHIFT 4 -#define RF_MONSHIFT 5 -#define RF_TOPSHIFT 6 -#define RFTYPE_CTRL BIT(RF_CTRLSHIFT) -#define RFTYPE_MON BIT(RF_MONSHIFT) -#define RFTYPE_TOP BIT(RF_TOPSHIFT) +#define RFTYPE_CTRL BIT(4) +#define RFTYPE_MON BIT(5) +#define RFTYPE_TOP BIT(6) #define RFTYPE_RES_CACHE BIT(8) #define RFTYPE_RES_MB BIT(9) #define RF_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f0d163950969..7ddfa4b470e6 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3242,7 +3242,11 @@ static int mkdir_rdt_prepare(struct kernfs_node *par= ent_kn, goto out_destroy; } =20 - files =3D RFTYPE_BASE | BIT(RF_CTRLSHIFT + rtype); + if (rtype =3D=3D RDTCTRL_GROUP) + files =3D RFTYPE_BASE | RFTYPE_CTRL; + else + files =3D RFTYPE_BASE | RFTYPE_MON; + ret =3D rdtgroup_add_files(kn, files); if (ret) { rdt_last_cmd_puts("kernfs fill error\n"); --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 F35AACD98CC for ; Tue, 10 Oct 2023 23:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344183AbjJJXd7 (ORCPT ); Tue, 10 Oct 2023 19:33:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343994AbjJJXdw (ORCPT ); Tue, 10 Oct 2023 19:33:52 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DAC294; Tue, 10 Oct 2023 16:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTSB9LyCSCP0gs8IQNg0FloihfB0TLZNAk2FWKnjoG9OFECtditNZl+sEP1GNrHhx/CVE7Gv3QCGlF3S3ALAc2hi9x6+slefRK3JiPh4S4wBMW7AxS/0zKGEPPPHNaxE0oRW355WH36hDukZOtzZ1bkRp0m9DEyclcjxRo229BJMMNL+/iKqUWQGIVXcZvHlwsBG+DGgJDi7mzFyD0S2Gbenr+1Os7ETYnmZBDz65uPnPW+ZUZvmdup+fIqaQ5nQKrtGDBkGl3+UfXrd37H+k9C7mXUyygqsAy2TopgC5CqntIA7djPbz2bBDiZhjWUCYHfn86uFhESH8psa+OHasg== 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=Wks3xuViPedDO2nYSh7/q+hbubJfaQT34DHMV+GxKOA=; b=YKosFuUyR++W3WLw2gGYozduI93mHXIIA9YAZu1oKNZ5SlJlybppzNOUylRZE7YfuXbfx2HzKVHVYS2RnoODDSuu+/7raRkNHVMXS0623JkTUwaU0eYcqbxJcXgnXDgqMsoMsPFeE/fdz2154NOYRq59UQlGLcceAqjEaC78UegSap+VB3MSKfUFNZfdcMiWk4jIKrWapLlEx2bbwfEcIiAg4Tan9HFWgip2aNGlySdxq6d36lJNZHEJE4oxeK6N5uMSGuV1qhFdcrvZD1n9/NAwQWXX6DAPrORSsqIXiOlSDx3OVrpA9Q2SsyMhryZ7ijk3EHnBMgmRAS/hhlgHMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=Wks3xuViPedDO2nYSh7/q+hbubJfaQT34DHMV+GxKOA=; b=vn8uLrzQ2FytwPiWXD8qD6eIDU6avgAkQAI0YAZFryEMoCzIlXF4vvoGZ5PEDb0uKXnVOZtsLIR2nK2AYZoU4dLIEoeGK70o0dMrwy2UwTnnPfkLbR9cvz/AFwOS0jEl4EIq0OSZj6EYLj8W3Yg2SAeqKfXuLh3htyLwSWnfnk8= Received: from MN2PR01CA0022.prod.exchangelabs.com (2603:10b6:208:10c::35) by MW6PR12MB8661.namprd12.prod.outlook.com (2603:10b6:303:23f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Tue, 10 Oct 2023 23:33:49 +0000 Received: from BL6PEPF0001AB4C.namprd04.prod.outlook.com (2603:10b6:208:10c:cafe::b6) by MN2PR01CA0022.outlook.office365.com (2603:10b6:208:10c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Tue, 10 Oct 2023 23:33:48 +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 BL6PEPF0001AB4C.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:48 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:46 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 03/10] x86/resctrl: Rename rftype flags for consistency Date: Tue, 10 Oct 2023 18:33:28 -0500 Message-ID: <20231010233335.998475-4-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4C:EE_|MW6PR12MB8661:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d5ff5f7-3e4c-4791-4202-08dbc9e95a6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6hgUHljTAa3Ely3ZP1Hm81/ev6y8DrD/V6q2x3ki/S0cn3CJjthN4M4fUuEUKgrPdoXY26a1zEuodYZzxDt+WyaE9uDLRYtPaJamF+CvyEI9nVR8mezhKfnikOMnuQeGV8U/Sz6eE1GbZjUmcFD6a3jrD7AGX+78Du0/t/gPCyckFXlhHfliSES9GmR70yHakpNNxSRCJ/mZoYwX7mcwGK1DfyZlOkpF2+7c2DcWJbxP9uHWkRG2JAGD/pDab+4X133dmuxCEPUpAYyV/cmxLEkbBZklBS0BDpruygMZItmllTNM4SGqoYy9H9P19O5Oco9Pgfy0Bz3pHCCI9yMiXX8aPRJ7IoL8QuqosCRwA8gZPXZuL4TCTOl6hUoRjeNrCJIJ8j8gE4q6d/h/Do/OuFJW+eAb1AklO9BEVBYzLV7w8rwmqBNS9PFzH0w4QMmZAFrNGDgZUK4P+Fhfn+GpfrOzu7NufBmVetDdKOl9MVAkwnrF/gAJCQ7ANniD1I4typmzoIuawmfrLPM1NfAP4XL5Y40bUeHI4thRMrzM8gBuXI6RpSq0vSCdy8uGOzHrysoQMnqqIAn3m1h7DIujkbYvbxbo3IpuYIHquHnczLX5glDwrw6YDqr8oKZTQL+h9mjqFVBalIJH6k9f2YpopvO74yDN3Rir+4dsvMav0TS/RXRaTKGoc24cxOPszJ+cadZk5an1eTF9gTOU+b2lqILg4+bWvlLRQOvKzjsxRsNUIGpUVbbp9ia5cYJGcVCoFzW4D2U8tJnH58Y6fwAHSQ== 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:(13230031)(4636009)(376002)(396003)(346002)(39860400002)(136003)(230922051799003)(82310400011)(64100799003)(186009)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(16526019)(1076003)(26005)(426003)(81166007)(336012)(2616005)(66574015)(7696005)(8676002)(47076005)(8936002)(2906002)(7416002)(478600001)(4326008)(6666004)(7406005)(44832011)(54906003)(70586007)(70206006)(110136005)(5660300002)(316002)(41300700001)(40460700003)(82740400003)(356005)(86362001)(36756003)(40480700001)(36860700001)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:48.3908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d5ff5f7-3e4c-4791-4202-08dbc9e95a6a 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: BL6PEPF0001AB4C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8661 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org resctrl associates rftype flags with its files so that files can be chosen based on the resource, whether it is info or base, and if it is control or monitor type file. These flags use the RF_ as well as RFTYPE_ prefixes. Change the prefix to RFTYPE_ for all these flags to be consistent. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: Moved the RFTYPE_MON_BASE definition to patch 10. (Boris) --- arch/x86/kernel/cpu/resctrl/internal.h | 10 +++--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 42 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 62767774810d..2051179a3b91 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -248,10 +248,10 @@ struct rdtgroup { #define RFTYPE_TOP BIT(6) #define RFTYPE_RES_CACHE BIT(8) #define RFTYPE_RES_MB BIT(9) -#define RF_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) -#define RF_MON_INFO (RFTYPE_INFO | RFTYPE_MON) -#define RF_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) -#define RF_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) +#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) +#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) +#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) +#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) =20 /* List of all resource groups */ extern struct list_head rdt_all_groups; @@ -267,7 +267,7 @@ void __exit rdtgroup_exit(void); * @mode: Access mode * @kf_ops: File operations * @flags: File specific RFTYPE_FLAGS_* flags - * @fflags: File specific RF_* or RFTYPE_* flags + * @fflags: File specific RFTYPE_* flags * @seq_show: Show content of the file * @write: Write to the file */ diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 7ddfa4b470e6..35945b4bf196 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1705,77 +1705,77 @@ static struct rftype res_common_files[] =3D { .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_last_cmd_status_show, - .fflags =3D RF_TOP_INFO, + .fflags =3D RFTYPE_TOP_INFO, }, { .name =3D "num_closids", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_num_closids_show, - .fflags =3D RF_CTRL_INFO, + .fflags =3D RFTYPE_CTRL_INFO, }, { .name =3D "mon_features", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_mon_features_show, - .fflags =3D RF_MON_INFO, + .fflags =3D RFTYPE_MON_INFO, }, { .name =3D "num_rmids", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_num_rmids_show, - .fflags =3D RF_MON_INFO, + .fflags =3D RFTYPE_MON_INFO, }, { .name =3D "cbm_mask", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_default_ctrl_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_CACHE, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, { .name =3D "min_cbm_bits", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_min_cbm_bits_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_CACHE, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, { .name =3D "shareable_bits", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_shareable_bits_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_CACHE, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, { .name =3D "bit_usage", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_bit_usage_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_CACHE, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE, }, { .name =3D "min_bandwidth", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_min_bw_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_MB, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB, }, { .name =3D "bandwidth_gran", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_bw_gran_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_MB, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB, }, { .name =3D "delay_linear", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_delay_linear_show, - .fflags =3D RF_CTRL_INFO | RFTYPE_RES_MB, + .fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB, }, /* * Platform specific which (if any) capabilities are provided by @@ -1794,7 +1794,7 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .write =3D max_threshold_occ_write, .seq_show =3D max_threshold_occ_show, - .fflags =3D RF_MON_INFO | RFTYPE_RES_CACHE, + .fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE, }, { .name =3D "mbm_total_bytes_config", @@ -1841,7 +1841,7 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .write =3D rdtgroup_schemata_write, .seq_show =3D rdtgroup_schemata_show, - .fflags =3D RF_CTRL_BASE, + .fflags =3D RFTYPE_CTRL_BASE, }, { .name =3D "mode", @@ -1849,14 +1849,14 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .write =3D rdtgroup_mode_write, .seq_show =3D rdtgroup_mode_show, - .fflags =3D RF_CTRL_BASE, + .fflags =3D RFTYPE_CTRL_BASE, }, { .name =3D "size", .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_size_show, - .fflags =3D RF_CTRL_BASE, + .fflags =3D RFTYPE_CTRL_BASE, }, =20 }; @@ -1913,7 +1913,7 @@ void __init thread_throttle_mode_init(void) if (!rft) return; =20 - rft->fflags =3D RF_CTRL_INFO | RFTYPE_RES_MB; + rft->fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB; } =20 void __init mbm_config_rftype_init(const char *config) @@ -1922,7 +1922,7 @@ void __init mbm_config_rftype_init(const char *config) =20 rft =3D rdtgroup_get_rftype_by_name(config); if (rft) - rft->fflags =3D RF_MON_INFO | RFTYPE_RES_CACHE; + rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; } =20 /** @@ -2057,21 +2057,21 @@ static int rdtgroup_create_info_dir(struct kernfs_n= ode *parent_kn) if (IS_ERR(kn_info)) return PTR_ERR(kn_info); =20 - ret =3D rdtgroup_add_files(kn_info, RF_TOP_INFO); + ret =3D rdtgroup_add_files(kn_info, RFTYPE_TOP_INFO); if (ret) goto out_destroy; =20 /* loop over enabled controls, these are all alloc_capable */ list_for_each_entry(s, &resctrl_schema_all, list) { r =3D s->res; - fflags =3D r->fflags | RF_CTRL_INFO; + fflags =3D r->fflags | RFTYPE_CTRL_INFO; ret =3D rdtgroup_mkdir_info_resdir(s, s->name, fflags); if (ret) goto out_destroy; } =20 for_each_mon_capable_rdt_resource(r) { - fflags =3D r->fflags | RF_MON_INFO; + fflags =3D r->fflags | RFTYPE_MON_INFO; sprintf(name, "%s_MON", r->name); ret =3D rdtgroup_mkdir_info_resdir(r, name, fflags); if (ret) @@ -3709,7 +3709,7 @@ static int __init rdtgroup_setup_root(void) =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); =20 - ret =3D rdtgroup_add_files(kernfs_root_to_node(rdt_root), RF_CTRL_BASE); + ret =3D rdtgroup_add_files(kernfs_root_to_node(rdt_root), RFTYPE_CTRL_BAS= E); if (ret) { kernfs_destroy_root(rdt_root); goto out; --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 9B4E7CD98C0 for ; Tue, 10 Oct 2023 23:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344196AbjJJXeH (ORCPT ); Tue, 10 Oct 2023 19:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344150AbjJJXdy (ORCPT ); Tue, 10 Oct 2023 19:33:54 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2053.outbound.protection.outlook.com [40.107.100.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C8A9E; Tue, 10 Oct 2023 16:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Is4jBXStRBUdy5Ils8clxwHi0SVoWbqNn4+hsaANrRs1nXGbmbHMKiuQFzJkPFUQyqUqtDXmqAVnhba8ZlP2oBzriDpTmDg0rDmhqC6x+8IQB/kEB2UTF+Yy2hDlsJ4aMKHbnozGdK8c+Bnht9HHcHwEOOVi7xpFUQPmrwTYFbDb1iLPRwM0jbXX5h/msmh9pO4V9SbAquZCGwmoReeqoW6JphGSOlClh7MszxO3yEwEHyuW+Qu0sYG3q+CliovqhsC6BsN2292kBc5yOQdu1a1RxMs5nBcj7DBtz2+9cm53UqjpFy0H0ZUiO6QObnIVw2adBH4lFGlZLzbmDktUyw== 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=VjCrpoDVtV6H0wD3sT5CdSWgeYIuhdHxg4IlNeY2I5s=; b=nmAuaVn6LdKz7wUV5n0QlyEQ8XxMk682Cavuo0K129OdvFopaM2ZZFst3ohu8/5VF+ZfEiSCKNR4AoOGr5QxXlKq1IjYW83rbVoJS8WoKRu0HC2/7O9ndRXGJyGRaG4y04DfcywA4wuJSgxE/R+5OKuEDXM7PWrSdo7pOsH9wKYKqHjbI5lLSUeHIf/CxrxkofvCD+D2nftjPnsbi1pFfkqV/vEtrkK9i1wesmR4ulpWpTMEbFhXoOd9IKjLmYQgrg7jna1+IjI8ANsnhYSLjXtfUlNztNyxiGYARgMMDhqPAju526hmXucFQM24TP0r6Qxzah6e1sqDzp+YH4yoxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=VjCrpoDVtV6H0wD3sT5CdSWgeYIuhdHxg4IlNeY2I5s=; b=iKh/s7RhVN1xkTIRil2KVGxrS7FTt0QSlVbc1CDrrmM647JPzSeVUpLx9Y+UTEghHltwnm02LSSxswxL4ee8jf9qgazWNkzw6mtm5kOBs1lraAIv/J4N+rEwZBKEdTlnsJxlkvYzcvZI95y9W42aMLsureF53y663zE2sMzEiAs= Received: from BL1PR13CA0437.namprd13.prod.outlook.com (2603:10b6:208:2c3::22) by CY5PR12MB6081.namprd12.prod.outlook.com (2603:10b6:930:2b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 23:33:50 +0000 Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:208:2c3:cafe::7) by BL1PR13CA0437.outlook.office365.com (2603:10b6:208:2c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.23 via Frontend Transport; Tue, 10 Oct 2023 23:33:50 +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 BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:50 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:48 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 04/10] x86/resctrl: Add comments on RFTYPE flags hierarchy Date: Tue, 10 Oct 2023 18:33:29 -0500 Message-ID: <20231010233335.998475-5-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB50:EE_|CY5PR12MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 02edfb17-1eeb-4314-0642-08dbc9e95b6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jTuYAQdCN3Lrn/W2B9xpHvFvsrMitLK7Y2QPnCUH1UlvzB+BmhqSD7xiNwse+nGLRt20BVSWp3AZZ8WzU9qIMvdZCJe9KiMrAT7/7wsIItcE+6p3907FyuyM1ytKuPdiFRQvBweJ/at5+nmpi6gvaeOqzovDFIlgh+2iFQhdlAlb1H/DwisA3ML9nds4R5Bg1tceII3U+VtmW5rOIDIIRn9KZpNEUHoEBwftX5DkreYuLwu2Y5UTWiQsh/+dz88p5Pxi1RVhAPRcUmZw2iEJ7thDxhqWiVjE0UX0GBFPmOX8qpiS2p6Q5t4ZH/HMZI+SUCIEm3z7ITuBtYHPqLEnz3+Me8JarNtG0V+m8Y73DwBGFqy0FR3LKLuHcJ8djo/c7v7rs33IiM3D0F3pzM2bevwilBgBdEKLBsLWa0DS5MeXbivkSvKbXHaRIpbIV/JLxlWHrEYn/WGUIBtmuBZkdwyEU9dCYKOE14Kn5MiLXRc5ry9QWAP/aotrkaB+ebtidlZCAaqVyAaAhPfH4sGrOmPypvdCuGU7Eq/xmFin+qUq1Mssdrp2/t4PtepmY3dfWXTKnwqaS1eST+fmpPJXz17TwlRfkc1+pE666ucslxO5u1lwmBqRTFKI8aKxvjta8hudihq8teYM3w4VPv+kKrhsF5Uy5qiI9QRhG32J4QH0M56rZWBoq1S6BEVecVZlyLOTwMq3QwMkFvIKoFQ1lvYkgVs2XwoKG6BxhRWHU/rtqJ9DbxGNuMrlZfIJ9T72g9IFEP0GB0RrSvLWsStSsQ== 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:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(186009)(451199024)(1800799009)(82310400011)(64100799003)(46966006)(36840700001)(40470700004)(86362001)(36756003)(40480700001)(478600001)(7696005)(7416002)(2906002)(2616005)(44832011)(70206006)(70586007)(7406005)(41300700001)(1076003)(110136005)(5660300002)(6666004)(316002)(54906003)(426003)(336012)(47076005)(26005)(16526019)(36860700001)(82740400003)(4326008)(8676002)(40460700003)(356005)(8936002)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:50.0670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02edfb17-1eeb-4314-0642-08dbc9e95b6a 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: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6081 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org resctrl uses RFTYPE flags for creating resctrl directory structure. Definitions and directory structures are not documented. Add comments to improve the readability and help future additions. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: Moved the comments from arch/x86/kernel/cpu/resctrl/internal.h to Documentation/arch/x86/resctrl.rst. (Boris) --- Documentation/arch/x86/resctrl.rst | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 8154e9975d1e..520a7753d829 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -362,6 +362,66 @@ When monitoring is enabled all MON groups will also co= ntain: the sum for all tasks in the CTRL_MON group and all tasks in MON groups. Please see example section for more details on usage. =20 +RESCTRL filesystem implementation notes +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +RESCTRL filesystem has two main components + a. info + b. base + +/sys/fs/resctrl/ + | + --> info (Top level directory named "info". Contains files that + | provide details on control and monitoring resources) + | + --> base (Root directory associated with default resource group + as well as directories created by user for MON and CTRL + groups. Contains files to interact with MON and CTRL + groups) + + Note: resctrl uses flags for files, not for directories. + Directories are created based on the resource type. Added + directories below for better understanding. The RFTYPE flags + are defined in arch/x86/kernel/cpu/resctrl/internal.h. + + info directory structure + --------------------------------------------------------------- + --> RFTYPE_INFO + Directory: info + --> RFTYPE_TOP (Files in top level of info directory) + File: last_cmd_status + + --> RFTYPE_MON (Files for all monitoring resources) + Directory: L3_MON + Files: mon_features, num_rmids + + --> RFTYPE_RES_CACHE (Files for cache monitoring resources) + Directory: L3_MON + Files: max_threshold_occupancy, + mbm_total_bytes_config, + mbm_local_bytes_config + + --> RFTYPE_CTRL (Files for all control resources) + Directories: L2, L3, MB, SMBA, L2CODE, L2DATA, L3CODE, L3DATA + File: num_closids + + --> RFTYPE_RES_CACHE (Files for cache control resources) + Directories: L2, L3, L2CODE, L2DATA, L3CODE, L3DATA + Files: bit_usage, cbm_mask, min_cbm_bits, + shareable_bits + + --> RFTYPE_RES_MB (Files for memory control resources) + Directories: MB, SMBA + Files: bandwidth_gran, delay_linear, + min_bandwidth, thread_throttle_mode + + base directory structure + --------------------------------------------------------------- + --> RFTYPE_BASE (Files common for both MON and CTRL groups) + Files: cpus, cpus_list, tasks + + --> RFTYPE_CTRL (Files for CTRL group) + Files: mode, schemata, size + Resource allocation rules ------------------------- =20 --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 19E4FCD98C0 for ; Tue, 10 Oct 2023 23:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344220AbjJJXeK (ORCPT ); Tue, 10 Oct 2023 19:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344163AbjJJXdz (ORCPT ); Tue, 10 Oct 2023 19:33:55 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D8A93; Tue, 10 Oct 2023 16:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IdNcTOdk+/6UZhryh7S34E8trsqIpCWenN0GN+HIDIc2W9sOBmAmRZ5dAAsa7FMcXxqStVgwmTMKcrwuwVcRvuyreHYaVmVCBL6qAAjDQSQNM2c9mE+nzUBROb9CKfktIS0sXQc8juU6MRwviWc+/AFAxsaPbr58VtE35lA/tp7JJdEdYjJqnYUB+hQskI7qEJgaLNkQchG1aYhoAFX1Idk95Y98b+n8Hyyia4/OlszTbKywDKgei2CuPuxOsEXR+Dq5SCezpfeXZ2mOqPJmp89jPoImmQWCdzBnEZSC/AOEYy1Z2Bgh6BJ4+daGKj8txd8p9qzsN7SUm9wZEORHcA== 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=Bc1oUxiw0dA5e9jsoVcsacmbFKbM3gi7SYCxARNC66U=; b=Y2/UjzJcTrHhVdc8sz3N0GlpaFJvpxLk9Wx/JGPmKvRZ/iOb55Dxlq+X1WIGt6xphmwCMz51r2hKGd+P0Wx++wMhFDtg196YSrL97pMg0YG4dNkxDtRrXsNzoxrkEfD+ATN0cutU7aN2rcA8F2ITNYNOmbjGFFIv+li3/MsWys4LwYPqHXC9KDfYjw/D+ayRwI08AhsGYUpS0vBjsfvLxgzq4mXABFFbxWNVnirWPoCvREIv5tE/KA5+v1jCiptAGnCIYSOOfvE7GawbpA0yODJIe2/z2IdBZLhZFf7+PzZecrBStyC1hXxnA2drKRRhdgMYVpaydsGsmlDgiov59w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=Bc1oUxiw0dA5e9jsoVcsacmbFKbM3gi7SYCxARNC66U=; b=r4Y0SNsq3ffcikIxuL82YlUoEsugX6IHcBsHydYWmnbtcvsm0Li1oiWZ7lKm1W57Oo2a7bqzzrzparX1zHkOEQPYNyHZkwD9Zau7R67kGwBnA/K/lPXdtiqj9Q9PbKqOpunUIPTjTgVbVd7sdkA7lqvBFCIwSqC7km9XjXf7ns0= Received: from MN2PR17CA0033.namprd17.prod.outlook.com (2603:10b6:208:15e::46) by DS7PR12MB6168.namprd12.prod.outlook.com (2603:10b6:8:97::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Tue, 10 Oct 2023 23:33:51 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:208:15e:cafe::80) by MN2PR17CA0033.outlook.office365.com (2603:10b6:208:15e::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 23:33:51 +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 BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:51 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:49 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 05/10] x86/resctrl: Unwind the errors inside rdt_enable_ctx() Date: Tue, 10 Oct 2023 18:33:30 -0500 Message-ID: <20231010233335.998475-6-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4D:EE_|DS7PR12MB6168:EE_ X-MS-Office365-Filtering-Correlation-Id: 901245dd-c94a-48e5-8dea-08dbc9e95c58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j5ox6Xs77fbhhELMUdCCrpk9kNYMbTzzK91CCCPANo+Y+8Kne/8K2dhR801aQLiy7OECvwjlMc83L7WzJbfws55CqSTklHdK97aWa2PCukIDtFup+jlBSgL755V6omvvzMfASMbu8ngg2/g1TIXbUzeSnO+fLdCZvq1aF4cQ/Q9g3kDJ12lxeFUvGG1G+h7YkrziW5SFRM09M0naYzmtaT3q/7rd9W+Nqfai9vIy0Mmk22rRLnM/UkKn2IFkpr/YdWbv+xrqBTJVwdT1IZI1sT45IgybSuycxrn0Z9wjVqrtWWjNNEFnewxIsS0GM6ZUS/s725Dt+D1bKwx+GVEPEDTyk4N7W44E9wY8Dtx09eRqWOSutFih1xQEER4OTPB8ErdDHkHqnJmGoGu7O4aWQ0CBo1Wutf50ERsvJ/TZvIduEGRgv7Tb8PQKc7Nbz2BUnIJlEO8cDKA/Cq+DnGtUgQlFT4Vq1eLDwei2ufIYCTHrm7+OfMi7y62xia15LeRaaL8TrPV8vBbMJENRNjLXQAMgPa/5aXk8kgD8lfGxnFLI2gcYCLAz1ZOu09Itfq10SIK3jDecLZgfofi+RgINaFlJOYktgtAsfSHYqUgHqKYXxG2pVfiECXtpDM5Yq+rUfQ+Au6PaeEhmgcFbnPSA6N+p3ps+soCfVvhRWNt1nV+OFxqgCdQ5G/6qsgLFSDNESd8znT4qrlXAb3dGoGOboZkZFxwsPYUsGyztwfvsuX55a9cqyQJOUm5xGygv649Hh4FNL+0qbJ+C5fGqKKZ4eg== 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:(13230031)(4636009)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(451199024)(82310400011)(1800799009)(64100799003)(186009)(40470700004)(36840700001)(46966006)(82740400003)(7696005)(2616005)(1076003)(478600001)(426003)(316002)(41300700001)(336012)(40480700001)(66574015)(7406005)(7416002)(44832011)(47076005)(2906002)(8676002)(110136005)(5660300002)(70586007)(54906003)(70206006)(4326008)(16526019)(8936002)(26005)(83380400001)(36756003)(40460700003)(36860700001)(356005)(86362001)(81166007)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:51.6458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 901245dd-c94a-48e5-8dea-08dbc9e95c58 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: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6168 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rdt_enable_ctx() enables the features provided during resctrl mount. Additions to rdt_enable_ctx() are required to also modify error paths of rdt_enable_ctx() callers to ensure correct unwinding if errors are encountered after calling rdt_enable_ctx(). This is error prone. Introduce rdt_disable_ctx() to refactor the error unwinding of rdt_enable_ctx() to simplify future additions. This also simplifies cleanup in rdt_kill_sb(). Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: Removed the redundant comment about cdp_disable_all().(Boris) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 53 ++++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 35945b4bf196..3ea874c80c22 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2290,14 +2290,6 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_le= vel l, bool enable) return 0; } =20 -static void cdp_disable_all(void) -{ - if (resctrl_arch_get_cdp_enabled(RDT_RESOURCE_L3)) - resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); - if (resctrl_arch_get_cdp_enabled(RDT_RESOURCE_L2)) - resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); -} - /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup @@ -2377,19 +2369,42 @@ static int mkdir_mondata_all(struct kernfs_node *pa= rent_kn, struct rdtgroup *prgrp, struct kernfs_node **mon_data_kn); =20 +static void rdt_disable_ctx(void) +{ + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); + set_mba_sc(false); +} + static int rdt_enable_ctx(struct rdt_fs_context *ctx) { int ret =3D 0; =20 - if (ctx->enable_cdpl2) + if (ctx->enable_cdpl2) { ret =3D resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, true); + if (ret) + goto out_done; + } =20 - if (!ret && ctx->enable_cdpl3) + if (ctx->enable_cdpl3) { ret =3D resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, true); + if (ret) + goto out_cdpl2; + } =20 - if (!ret && ctx->enable_mba_mbps) + if (ctx->enable_mba_mbps) { ret =3D set_mba_sc(true); + if (ret) + goto out_cdpl3; + } + + return 0; =20 +out_cdpl3: + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); +out_cdpl2: + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); +out_done: return ret; } =20 @@ -2497,13 +2512,13 @@ static int rdt_get_tree(struct fs_context *fc) } =20 ret =3D rdt_enable_ctx(ctx); - if (ret < 0) - goto out_cdp; + if (ret) + goto out; =20 ret =3D schemata_list_create(); if (ret) { schemata_list_destroy(); - goto out_mba; + goto out_ctx; } =20 closid_init(); @@ -2562,11 +2577,8 @@ static int rdt_get_tree(struct fs_context *fc) kernfs_remove(kn_info); out_schemata_free: schemata_list_destroy(); -out_mba: - if (ctx->enable_mba_mbps) - set_mba_sc(false); -out_cdp: - cdp_disable_all(); +out_ctx: + rdt_disable_ctx(); out: rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); @@ -2798,12 +2810,11 @@ static void rdt_kill_sb(struct super_block *sb) cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 - set_mba_sc(false); + rdt_disable_ctx(); =20 /*Put everything back to default values. */ for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); - cdp_disable_all(); rmdir_all_sub(); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 BD29CCD98C0 for ; Tue, 10 Oct 2023 23:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbjJJXeQ (ORCPT ); Tue, 10 Oct 2023 19:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344181AbjJJXd7 (ORCPT ); Tue, 10 Oct 2023 19:33:59 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB31BAF; Tue, 10 Oct 2023 16:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YIS4MfX1CnlXO5LT2lFSzf8ReC9KYD+JSnPZ1Eyu0Wu3HUIGTsN/A4eiApwg1M5fROFrxjpsE0LgvldWhjCUQVHUoazuAOubCtLz0inaXUZM3+AKpg5am5x/MJSA4ArCZWXd6/7jDrgcQbWWFFjpHgbbjdLbidAk3Tls4RDt5+QxImlIuVT0ZJZ6itMBlI/KJKGusI8ZlVDXou9TWWJAx3fcZcby8EK6D3svd0cH2IyI9k3iM6KojbWBde4xIW/EHS8j9O0y5aoLn6tyrR68UAwTt+A0rlRKHuu3eoFJJOaMh2NHi9LDHYlNKVJuA90woJQaO8jfuhBj0ijzFupCpg== 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=17+APesLAgJrzKT0p23QwGARelWvZo7zmLb7Gnj/sjE=; b=Yohr93ej1JnBuHFxtKVTmYKMeZD8ppNVJjfl05SG6/6LxQu5efFqBQZVxYv21bLMe/A42a1Z6SQYNnkKmlwkVf+KRMMGctXbR8GbfBRT6nRcyEjUZF4RaLXD1pM662TTen/fNoZfD9pYV7oWJ9cQa7dNY7jXeBTN2Ccy2p9mQCOiXKg6oWjl8QxgIrVqR8sg/NmbvNOjdA6NNX3FrZOHEpWxBnSovBmgTItYdS3sGl9xq4VkkvfJ8Jo89RUR3LWnWoEyXBrq54KSOs+k3KkXvhXf3IHDE0YO31PASCpMnkpPgDxwXyr0tWFrKXewkSDvt7qYZaTSWjzrgZZx8H0wvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=17+APesLAgJrzKT0p23QwGARelWvZo7zmLb7Gnj/sjE=; b=wGiDeWkS4GvAantDHFYnTtioaylF8W1zxRqKbI3q11uUJbpZcVMoS6gc7yB/XYGLqPmqTxnYRZgEf/RzALWCVctIU3AXhSoDKCVXeLF+eyvEpKyIl+0egQcshGA/mVrtQ+EAEOflYyBXT/rvZHWZid1d+2OpP6dFtSwG8BcBHmk= Received: from BL1P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::12) by LV2PR12MB5965.namprd12.prod.outlook.com (2603:10b6:408:172::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 23:33:53 +0000 Received: from BL6PEPF0001AB51.namprd04.prod.outlook.com (2603:10b6:208:2c7:cafe::24) by BL1P222CA0007.outlook.office365.com (2603:10b6:208:2c7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 23:33:53 +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 BL6PEPF0001AB51.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:53 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:51 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 06/10] x86/resctrl: Move default group file creation to mount Date: Tue, 10 Oct 2023 18:33:31 -0500 Message-ID: <20231010233335.998475-7-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB51:EE_|LV2PR12MB5965:EE_ X-MS-Office365-Filtering-Correlation-Id: 90a03560-7414-497c-4f45-08dbc9e95d43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kw7XCzTcDJAaw1oSDkY9pNXXp7KGDDegIvusmdZiyUKaMimqQ6hLsJe6MQsDpremopk6MCJvRynNNVB6Zrvj28FemkcJmcmhU9/QAtAvlnD2m3PCuLUd8ZdUKL4RdTN2OYOrhC2/g926/VXq5ja77TbhQHjHHgCHgpr1LUPTZrsa9r2npr6bX9dHIos6euOw8+d94aEQf02hHk68+fNKmUNCYLa+nJ70xmxygrhUAyJbGpEaD94aAl7JWK0gLQzznApwPF1TJ2U7tWEIOBTkoVq4Set2XxdHy55G4RsZQLo6Jo8TQlUKw3Wz5R6vCgsOkw/nLXBZCO4EVS+nY/KJTe0Y7gmMy0JCX5I8O97m4OxiPN5XBL3z+XRqwWyc8Zpam8PBUWbTPfIu7sVj7ae6DNHDeHCP4LKwmFxy371lmCdKYo6ylJt36dMa/MgrhzIilLp1z2q5ld7JA+6ez0lDQIhZNwVnqQ7qPJPyyak7xIq38SD6FqtGRyqLE2C/Gb48ffuMuMRCyvwA2Chqzlo6l1qNZcqdeGZegKGcjOppcDem66Ey+EBX4ru2g4m/jaYhA4shHuobrCSBEN3MeoJfBZU2wWlyDc4ZymknBq+/uId9SZOEnYEBvaoWQEg+0jRNOFGbiuPhv+MWcISDHIXN+4HyVFQ+ZYN6ulAzIQ0rTSeIzZ8cqqwbbPe9ZehbSINTyoEOb+xD/xZ6cXphavzjs6ES2AqV0ySb8lUVZoSu6pydK2qnERwIXGWRNOzooG1YBSTsR3y66rlqN59V7qzXaw== 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:(13230031)(4636009)(396003)(376002)(39860400002)(136003)(346002)(230922051799003)(64100799003)(82310400011)(451199024)(1800799009)(186009)(46966006)(36840700001)(40470700004)(40480700001)(7696005)(40460700003)(2616005)(41300700001)(1076003)(356005)(81166007)(82740400003)(16526019)(26005)(36756003)(70586007)(70206006)(110136005)(54906003)(86362001)(316002)(47076005)(83380400001)(5660300002)(44832011)(7416002)(7406005)(426003)(336012)(66574015)(36860700001)(2906002)(8936002)(4326008)(8676002)(478600001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:53.1687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90a03560-7414-497c-4f45-08dbc9e95d43 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: BL6PEPF0001AB51.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5965 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The default resource group and its files are created during kernel init time. Upcoming changes will make some resctrl files optional based on a mount parameter. If optional files are to be added to the default group based on the mount option, then each new file needs to be created separately and call kernfs_activate() again. Create all files of the default resource group during resctrl mount, destroyed during unmount, to avoid scattering resctrl file addition across two separate code flows. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: No changes --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 58 +++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3ea874c80c22..a34657f0bd0c 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -54,6 +54,9 @@ static struct kernfs_node *kn_mondata; static struct seq_buf last_cmd_status; static char last_cmd_status_buf[512]; =20 +static int rdtgroup_setup_root(struct rdt_fs_context *ctx); +static void rdtgroup_destroy_root(void); + struct dentry *debugfs_resctrl; =20 void rdt_last_cmd_clear(void) @@ -2511,10 +2514,14 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } =20 - ret =3D rdt_enable_ctx(ctx); + ret =3D rdtgroup_setup_root(ctx); if (ret) goto out; =20 + ret =3D rdt_enable_ctx(ctx); + if (ret) + goto out_root; + ret =3D schemata_list_create(); if (ret) { schemata_list_destroy(); @@ -2523,6 +2530,12 @@ static int rdt_get_tree(struct fs_context *fc) =20 closid_init(); =20 + ret =3D rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE); + if (ret) + goto out_schemata_free; + + kernfs_activate(rdtgroup_default.kn); + ret =3D rdtgroup_create_info_dir(rdtgroup_default.kn); if (ret < 0) goto out_schemata_free; @@ -2579,6 +2592,8 @@ static int rdt_get_tree(struct fs_context *fc) schemata_list_destroy(); out_ctx: rdt_disable_ctx(); +out_root: + rdtgroup_destroy_root(); out: rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); @@ -2649,7 +2664,6 @@ static int rdt_init_fs_context(struct fs_context *fc) if (!ctx) return -ENOMEM; =20 - ctx->kfc.root =3D rdt_root; ctx->kfc.magic =3D RDTGROUP_SUPER_MAGIC; fc->fs_private =3D &ctx->kfc; fc->ops =3D &rdt_fs_context_ops; @@ -2819,6 +2833,7 @@ static void rdt_kill_sb(struct super_block *sb) rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; schemata_list_destroy(); + rdtgroup_destroy_root(); static_branch_disable_cpuslocked(&rdt_alloc_enable_key); static_branch_disable_cpuslocked(&rdt_mon_enable_key); static_branch_disable_cpuslocked(&rdt_enable_key); @@ -3700,10 +3715,8 @@ static struct kernfs_syscall_ops rdtgroup_kf_syscall= _ops =3D { .show_options =3D rdtgroup_show_options, }; =20 -static int __init rdtgroup_setup_root(void) +static int rdtgroup_setup_root(struct rdt_fs_context *ctx) { - int ret; - rdt_root =3D kernfs_create_root(&rdtgroup_kf_syscall_ops, KERNFS_ROOT_CREATE_DEACTIVATED | KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK, @@ -3711,6 +3724,20 @@ static int __init rdtgroup_setup_root(void) if (IS_ERR(rdt_root)) return PTR_ERR(rdt_root); =20 + ctx->kfc.root =3D rdt_root; + rdtgroup_default.kn =3D kernfs_root_to_node(rdt_root); + + return 0; +} + +static void rdtgroup_destroy_root(void) +{ + kernfs_destroy_root(rdt_root); + rdtgroup_default.kn =3D NULL; +} + +static void __init rdtgroup_setup_default(void) +{ mutex_lock(&rdtgroup_mutex); =20 rdtgroup_default.closid =3D 0; @@ -3720,19 +3747,7 @@ static int __init rdtgroup_setup_root(void) =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); =20 - ret =3D rdtgroup_add_files(kernfs_root_to_node(rdt_root), RFTYPE_CTRL_BAS= E); - if (ret) { - kernfs_destroy_root(rdt_root); - goto out; - } - - rdtgroup_default.kn =3D kernfs_root_to_node(rdt_root); - kernfs_activate(rdtgroup_default.kn); - -out: mutex_unlock(&rdtgroup_mutex); - - return ret; } =20 static void domain_destroy_mon_state(struct rdt_domain *d) @@ -3854,13 +3869,11 @@ int __init rdtgroup_init(void) seq_buf_init(&last_cmd_status, last_cmd_status_buf, sizeof(last_cmd_status_buf)); =20 - ret =3D rdtgroup_setup_root(); - if (ret) - return ret; + rdtgroup_setup_default(); =20 ret =3D sysfs_create_mount_point(fs_kobj, "resctrl"); if (ret) - goto cleanup_root; + return ret; =20 ret =3D register_filesystem(&rdt_fs_type); if (ret) @@ -3893,8 +3906,6 @@ int __init rdtgroup_init(void) =20 cleanup_mountpoint: sysfs_remove_mount_point(fs_kobj, "resctrl"); -cleanup_root: - kernfs_destroy_root(rdt_root); =20 return ret; } @@ -3904,5 +3915,4 @@ void __exit rdtgroup_exit(void) debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl"); - kernfs_destroy_root(rdt_root); } --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 7D137CD98C0 for ; Tue, 10 Oct 2023 23:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343994AbjJJXeV (ORCPT ); Tue, 10 Oct 2023 19:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344209AbjJJXeE (ORCPT ); Tue, 10 Oct 2023 19:34:04 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32ADB8; Tue, 10 Oct 2023 16:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5AxDnu0weRenwVyq3Ud+PHD7l3ldar/OvYcY82bbDrRb9qs2r8CS7Yy4MZ4PHbXTw1ZMICUs+ZW9/NpeRrLgw1R/c1iih6cGEWtro+LhHn5mXaQjSugmsRBvTb6F9GXwn5Y74jn8l02cfa/pstysl1ZLEORansN57e7aZJyfsGpKS5urlfmYKtKIYBMOWisHaMHF2t7kemS2p+d2usQmvgmAr9GTnpvsJvGVy9fkXMZVJIYOwXQTQGFTTnzZ0wOjvMEqGEoTeJen7cU5LPn8a16bw5+EiD71/rZ+3zgnf7+m6bVthGr/Ndmzfrm+8U1WTomNp8bvgsr+En9+TxsWg== 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=H+WfvfgXRMRbjdYp1Vi5GEwXugoe5e8TZLnv0VoakJk=; b=K10bAKJcdIU6yLZbQA4GC8gYEhobbS8PRiWV//JMitkaCBmNbzK22NDhhYlUiOVJK3kBKd52qConVGAHsjDGTzm50rV7MiyzQUangZzHJoXiu7DaZNrUiepyXEbGksW6QmU35d6f+/zTw9CtbYer93Mv9HKb8e2QkxXTsDq+a205LLo3I2BnFhmkbZgx6ExuRgch7Cj8H1Yvsklp8G4/RfluoF4JSrTYcq6owrYw3OayNsy+9zy2j68rnMrQ+nwTEXMIryaARj5UvAFi2AkfkCUJNJE/u3pRjAfAY7l1tlgSv2ij1AsFa3KSh2J7H27wN9tAj1DmVTh8ypxHJNiqGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=H+WfvfgXRMRbjdYp1Vi5GEwXugoe5e8TZLnv0VoakJk=; b=lOwIOFVdPKTKgFN5G7QoqZsp4pHG9fSUTf5G/tMBcccHBNWSC/LM2pxTwbarCsmpO3iM1rRN5h5rsL17NSeTIHUIremKm5lRjoolpQOLOCLHMIwP1ky88H7PQAfVAycmhP89bAWTDL84xfhHeS51Pt2Eb/oJu6FfsaqgacpLd20= Received: from MN2PR17CA0015.namprd17.prod.outlook.com (2603:10b6:208:15e::28) by CH2PR12MB4152.namprd12.prod.outlook.com (2603:10b6:610:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 23:33:54 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:208:15e:cafe::ad) by MN2PR17CA0015.outlook.office365.com (2603:10b6:208:15e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Tue, 10 Oct 2023 23:33:54 +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 BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:54 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:53 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 07/10] x86/resctrl: Introduce "-o debug" mount option Date: Tue, 10 Oct 2023 18:33:32 -0500 Message-ID: <20231010233335.998475-8-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4D:EE_|CH2PR12MB4152:EE_ X-MS-Office365-Filtering-Correlation-Id: 310d600b-cbdc-4f34-8ca6-08dbc9e95e3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nc4QAnEZYrWB8VcVqkXG04wtYezeD1yZ6B+jpE2LzyCCNJIR9X6EDG6GGHb1mo8l7dxQZnrFEtiOojQcYKk9HirB0HjVQSXQIMXOKw65PwrL8zflYD9se/TEHTJDv0L7fJtsqec7NsF0APNjMU6bEqpf47Lh+2JGvR8Zb2COqvM/OgCyNBPSazXn3a9CN2beOGJTiomoKZpw0mbRYCks8WjWsOdLub5A1WtGJgncBLNbqxgkBjgB+lAooKQnIXF13wheZr2buEJRlyiYEJ1rQ7gu+chi6vTHvIt/9Bm++w62h3zEHAfqrlx791Px/+xFlwvseqY/BjWGJUmzfzyG8Ewl0fWB4enH47yES9NTBULKKDB0u9O1lcBXJNZKkDAVuNekCzyDqVpMAXRJBp+6onQlvLiYfn3VvPzOPL/uN5oHwSP2O//7bEoHD9cRlH+Lzd3l+LqpIbieDTGfSI3rVumNeDYHEgcs7MqAmA46WTwFV1Q83Tm+sR75qXSj9mRk37GfQ7WzYq4ZCgpk0y82WGxXExBnwSSHqmKDvNs4CZp4HblVOfzIUlW5MegMaOKoyQ8Ub/hRJRfUFKSy+2Y2luof0KkA/AeA6wET1FFHgZsePEgMclIRH8xwtB1Nsv3gO6lKPaAez6zjAdVhqWXWgtlvKkTtZrzNdzamuJKb1wqe29+Csa7Fl6T0/pI0BgzvTfIV6MnCCqm/oxwWMFawUXutTD0shGkD0hQg4pi6mFQz8LO48xXjrHQDPNTSII/cdoqOSUIzlIO8/imFysGRuw== 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:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(186009)(451199024)(1800799009)(82310400011)(64100799003)(36840700001)(40470700004)(46966006)(2616005)(1076003)(2906002)(7696005)(40460700003)(16526019)(81166007)(356005)(82740400003)(86362001)(47076005)(36860700001)(426003)(36756003)(26005)(66574015)(40480700001)(336012)(83380400001)(8676002)(5660300002)(8936002)(44832011)(4326008)(478600001)(41300700001)(316002)(7416002)(54906003)(110136005)(6666004)(70206006)(70586007)(7406005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:54.8021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 310d600b-cbdc-4f34-8ca6-08dbc9e95e3c 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: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4152 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add "-o debug" option to mount resctrl filesystem in debug mode. When in debug mode resctrl displays files that have the new RFTYPE_DEBUG flag to help resctrl debugging. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: No changes --- Documentation/arch/x86/resctrl.rst | 5 ++++- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 520a7753d829..1774f7b8450f 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -35,7 +35,7 @@ about the feature from resctrl's info directory. =20 To use the feature mount the file system:: =20 - # mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps]] /sys/fs/resctrl + # mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps][,debug]] /sys/fs/re= sctrl =20 mount options are: =20 @@ -46,6 +46,9 @@ mount options are: "mba_MBps": Enable the MBA Software Controller(mba_sc) to specify MBA bandwidth in MBps +"debug": + Make debug files accessible. Available debug files are annotated with + "Available only with debug option". =20 L2 and L3 CDP are controlled separately. =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2051179a3b91..f0d135e004e2 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -59,6 +59,7 @@ struct rdt_fs_context { bool enable_cdpl2; bool enable_cdpl3; bool enable_mba_mbps; + bool enable_debug; }; =20 static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc) @@ -248,6 +249,7 @@ struct rdtgroup { #define RFTYPE_TOP BIT(6) #define RFTYPE_RES_CACHE BIT(8) #define RFTYPE_RES_MB BIT(9) +#define RFTYPE_DEBUG BIT(10) #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index a34657f0bd0c..150105c21fee 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -59,6 +59,8 @@ static void rdtgroup_destroy_root(void); =20 struct dentry *debugfs_resctrl; =20 +static bool resctrl_debug; + void rdt_last_cmd_clear(void) { lockdep_assert_held(&rdtgroup_mutex); @@ -1874,6 +1876,9 @@ static int rdtgroup_add_files(struct kernfs_node *kn,= unsigned long fflags) =20 lockdep_assert_held(&rdtgroup_mutex); =20 + if (resctrl_debug) + fflags |=3D RFTYPE_DEBUG; + for (rft =3D rfts; rft < rfts + len; rft++) { if (rft->fflags && ((fflags & rft->fflags) =3D=3D rft->fflags)) { ret =3D rdtgroup_add_file(kn, rft); @@ -2377,6 +2382,8 @@ static void rdt_disable_ctx(void) resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); set_mba_sc(false); + + resctrl_debug =3D false; } =20 static int rdt_enable_ctx(struct rdt_fs_context *ctx) @@ -2401,6 +2408,9 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx) goto out_cdpl3; } =20 + if (ctx->enable_debug) + resctrl_debug =3D true; + return 0; =20 out_cdpl3: @@ -2605,6 +2615,7 @@ enum rdt_param { Opt_cdp, Opt_cdpl2, Opt_mba_mbps, + Opt_debug, nr__rdt_params }; =20 @@ -2612,6 +2623,7 @@ static const struct fs_parameter_spec rdt_fs_paramete= rs[] =3D { fsparam_flag("cdp", Opt_cdp), fsparam_flag("cdpl2", Opt_cdpl2), fsparam_flag("mba_MBps", Opt_mba_mbps), + fsparam_flag("debug", Opt_debug), {} }; =20 @@ -2637,6 +2649,9 @@ static int rdt_parse_param(struct fs_context *fc, str= uct fs_parameter *param) return -EINVAL; ctx->enable_mba_mbps =3D true; return 0; + case Opt_debug: + ctx->enable_debug =3D true; + return 0; } =20 return -EINVAL; @@ -3705,6 +3720,9 @@ static int rdtgroup_show_options(struct seq_file *seq= , struct kernfs_root *kf) if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl)) seq_puts(seq, ",mba_MBps"); =20 + if (resctrl_debug) + seq_puts(seq, ",debug"); + return 0; } =20 --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 81BAACD98C0 for ; Tue, 10 Oct 2023 23:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229639AbjJJXeO (ORCPT ); Tue, 10 Oct 2023 19:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344199AbjJJXeD (ORCPT ); Tue, 10 Oct 2023 19:34:03 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676F99E; Tue, 10 Oct 2023 16:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTjmgpO6qWK1q26X5GmrcBGn3ybnlFvNDaFj8edyn/YDysue2wCRXWkmMwXMYWNq/4HYnngGqs7nlVmS+kwsmcw8iQmR2aRinoHvB+q4qzQo0iaGTA7rLlSPZPeRrjSsMJMJXvldLb+Z1UKCO3mRAB/M+Kat5THY8Kpd7if1C4kxZj98o3H8g1zgHGoNIkDQGn7H5+hfbvHNLBhupnsaRNwif8QfF5MGac5MHoUjTI6HJ9cTTA8gkvvqjGh3GM+qDqF3bAin17NNfQLpyerRGGitMRgowiikfJ+dSElUn9gS47qAKhtpFUKk4p6hqUY61QRPurO0HDxf4bn+GpojsQ== 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=akFdCl0umwGazU7ouu48BHdA5i+GpQXriOV1oTjjoDQ=; b=nxcgiDGXcVI/6HL1YR7c34zw/iw60sKNotZ9/6PdxSvP1fbwy41C9IaBJhyRR2DIgTiE/p45wbiYboYeKrS0iD2QQypPMo4CadlxoYncff2uMUHl3nFDEK2ushEjdjY9lB8YCnwOr/iO3hN+UFM/UY5tNqbAqBl7KMaqTtCDolyjFnJEw5cUPBQB1IK110HitkDl3dnNZdgBpaAFzf4ph4GzpSVnIJdOCyI2AFXe4nR4jEWA65lxGXAjLebFxvJjAiI0SnJlb5DJMY1EwsbHdZFiF93Nh8W5NOa/pVJGyqmYAgfOge06vxFfv0M+2oEWrL0G9ACHkbnAs0JOgHgyJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=akFdCl0umwGazU7ouu48BHdA5i+GpQXriOV1oTjjoDQ=; b=Gx2MSrAnYQ7DXYQ8vz1n7ZoalDrUDnOI4xx9qjyFQnT0CTeEnKsEW7iSFchf13Kr4cZK9iUxjenYqKQtiX49hXTRwA3NYIdb1KUB+Tj7utyeGmmxRBef/juJf/WOX8mKbNXzljrIha8ld93AyV7JtaS76OCsXDdag4cvH9JHA/Y= Received: from MN2PR17CA0019.namprd17.prod.outlook.com (2603:10b6:208:15e::32) by CH0PR12MB8507.namprd12.prod.outlook.com (2603:10b6:610:189::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.43; Tue, 10 Oct 2023 23:33:56 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:208:15e:cafe::9b) by MN2PR17CA0019.outlook.office365.com (2603:10b6:208:15e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 23:33: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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:56 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:54 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 08/10] x86/resctrl: Display CLOSID for resource group Date: Tue, 10 Oct 2023 18:33:33 -0500 Message-ID: <20231010233335.998475-9-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB4D:EE_|CH0PR12MB8507:EE_ X-MS-Office365-Filtering-Correlation-Id: 7580660a-f97d-4ad9-e44a-08dbc9e95f36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QhtuF+6GzUdv6Rlb0SScBAGFJVjqtsSkQlLX9f6t0v8hWhMOe4WhiOfhDPoC6LYtcT4wwqEh6kyP/4P7BZDXQ7DgCREp//B0BeNtQ4vIvYE1iXaj3FdxC04HL2DqlM/p1dyyOKotIR81kcc+aePKDU1e54jYppQsbmK4YrQRjcapDSrkiwFVrgRoFFd8I2TUoUGPPagtIjuIuiHJt/JpX9umTYTJRFUPXn8iZd4HNiTZ+fpwF6TBFAhnWD3LvstirnJQi5ZG2DJA1IIUAPqE4ZqMO4ZRWC5kmOBn8YYUk7d1KcKQDVxnzOsBtdN0AKTPrAjcKjqOePh0ZxRAYeMbj8T2n9eJqNGuX/zQFfKe+K30CqWjjTuPuqiyVw30x/4LojrQ/blalETDK09h1sTsjv2cOKL4FjH1FVbxW4KVabgAtJKPz305UOkjbNPok3fyfqUIoSp8OEvzjlyKam7xrrqbS4fPn432e7/RDKpUVVYsSinqsLBahcxYmkwFZPHuYa84V3aZ3nSRj2SZbDnfil5wT6So2tfzZBHbi8muSGnNAmPM3SnhU4Pxiaj1D+2aXVqVF4l+WPPxIVso6v15sPf7m3B+b0vdVk+K4joeyRoG7sVrzOp+pE1EdMjwrotnsDg4NJ1cg7a6q4bwJu0hGiusk929eF+2TmA/7A8VQUhYk3KsFm/abPs5N9pzVyvHEFHHK7tM6eei4R3h3aR5PGaN17035nya5WhbR4gg1ts3CY+3a195KtXZ8hgcg9jioOTWakcYOxg7ETvKJjeECw== 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:(13230031)(4636009)(346002)(396003)(376002)(136003)(39860400002)(230922051799003)(82310400011)(64100799003)(1800799009)(186009)(451199024)(46966006)(36840700001)(40470700004)(70586007)(41300700001)(316002)(110136005)(66574015)(70206006)(54906003)(6666004)(26005)(2616005)(1076003)(7416002)(426003)(7696005)(16526019)(2906002)(47076005)(83380400001)(8936002)(7406005)(336012)(8676002)(5660300002)(4326008)(44832011)(356005)(478600001)(36860700001)(81166007)(36756003)(86362001)(40460700003)(82740400003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:56.4428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7580660a-f97d-4ad9-e44a-08dbc9e95f36 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: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8507 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In x86, hardware uses CLOSID to identify a control group. When a user creates a control group this information is not visible to the user. It can help resctrl debugging. Add CLOSID(ctrl_hw_id) to the control groups display in resctrl interface. Users can see this detail when resctrl is mounted with "-o debug" option. Other architectures do not use "CLOSID". Use the names ctrl_hw_id to refer to "CLOSID" in an effort to keep the naming generic. For example: $cat /sys/fs/resctrl/ctrl_grp1/ctrl_hw_id 1 Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: Moved the comments about RFTYPE_DEBUG to resctrl.rst. (Boris) --- Documentation/arch/x86/resctrl.rst | 7 +++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 1774f7b8450f..5dcd7d250ca8 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -352,6 +352,10 @@ When control is enabled all CTRL_MON groups will also = contain: file. On successful pseudo-locked region creation the mode will automatically change to "pseudo-locked". =20 +"ctrl_hw_id": + Available only with debug option. The identifier used by hardware + for the control group. On x86 this is the CLOSID. + When monitoring is enabled all MON groups will also contain: =20 "mon_data": @@ -425,6 +429,9 @@ RESCTRL filesystem has two main components --> RFTYPE_CTRL (Files for CTRL group) Files: mode, schemata, size =20 + --> RFTYPE_DEBUG (Files to help resctrl debugging) + File: ctrl_hw_id + Resource allocation rules ------------------------- =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 150105c21fee..953b082cec8a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -779,6 +779,22 @@ static int rdtgroup_tasks_show(struct kernfs_open_file= *of, return ret; } =20 +static int rdtgroup_closid_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdtgroup *rdtgrp; + int ret =3D 0; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (rdtgrp) + seq_printf(s, "%u\n", rdtgrp->closid); + else + ret =3D -ENOENT; + rdtgroup_kn_unlock(of->kn); + + return ret; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1863,6 +1879,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_size_show, .fflags =3D RFTYPE_CTRL_BASE, }, + { + .name =3D "ctrl_hw_id", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_closid_show, + .fflags =3D RFTYPE_CTRL_BASE | RFTYPE_DEBUG, + }, =20 }; =20 --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 C8223CD98C0 for ; Tue, 10 Oct 2023 23:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344242AbjJJXeY (ORCPT ); Tue, 10 Oct 2023 19:34:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344141AbjJJXeF (ORCPT ); Tue, 10 Oct 2023 19:34:05 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2086.outbound.protection.outlook.com [40.107.237.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8611BE0; Tue, 10 Oct 2023 16:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A09/HRyQnSlBWJCexeRgVIFOXTfGQ/KTHrYWNv++ceq+zOAnEuGwDUEMk2WLlru71GJpa1CTVg3LWhk45sUpHFeCgkP7y59a49GSIHS5ab3ASp268le+2lgHs/3DhE6UMm1NNohu1PHagSd3UFdpVJytG3hYvgdSkjBYwbW75yZ3kE9AlG9PVdEuyWQcJvMCaZx7tEoYUHhDKMthlx1ATjh6oEiFKXAewrqNs806OmoeeEcygFfERaoWRDmTAYhhvGJrGmgyHFmNpJ7lyTwB0NRl8VK+zc9tKSXXzwjEXj1T8CmP4ojgA8rWO406+RFiOF1g2d3lYm5MhTyrcCWUHA== 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=6dc+oJiQA2vAp3G2TZl+W32BuVWJbjfvwNJiGkrhQPQ=; b=fWqbSBQAkMdzxLMxWZOUseJCjtd8bLgNeTBsjMIbkm8P1BO8wV4IlNREgpbdy3cvNbfNOuV83JWguzdGKiU6cRI0Ci7Fk3aLsraQ5OUu9l9xGEoeewQkXzkUuUfiZwwDdPyrWI96RTxNd5IETSO+bkgVFKcgdB60mpgXie0iHl6MkhaK8RoJUSbJUdnm3qR1noIA+soZNz3PW154UlQ7qDbQpjTE0V478HjH2Im0083QqMrCjEX0xIQYOguQPHY4KJnfTc2fyTUUnHSTmzrj5JLQ7zeAu6f+1FPqQdru3ATIKTr9bZrHfHOVkgGub7C4kqezRC3sJf9lF90GeycWGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=6dc+oJiQA2vAp3G2TZl+W32BuVWJbjfvwNJiGkrhQPQ=; b=d676wSvbq+pazsBsnGz4Javt/eWUMpqC3C9Bu5cNT6W5NV4MKf/FaPSVb6dkqDEQuR4+GnlSx8FmgcocO91FUaH07yXZ6gWzUloO9xiAJ3b2vEKkOFOz5dqh05FKgblpcgAiz49nSWItf70fQzdyOfKIMeU1kjVhlgb0Ev+NToQ= Received: from BL1PR13CA0449.namprd13.prod.outlook.com (2603:10b6:208:2c3::34) by CY8PR12MB7291.namprd12.prod.outlook.com (2603:10b6:930:54::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Tue, 10 Oct 2023 23:33:58 +0000 Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:208:2c3:cafe::21) by BL1PR13CA0449.outlook.office365.com (2603:10b6:208:2c3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.23 via Frontend Transport; Tue, 10 Oct 2023 23:33:58 +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 BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:58 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:56 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 09/10] x86/resctrl: Add support for the files for MON groups only Date: Tue, 10 Oct 2023 18:33:34 -0500 Message-ID: <20231010233335.998475-10-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB50:EE_|CY8PR12MB7291:EE_ X-MS-Office365-Filtering-Correlation-Id: e26d3233-126e-4de7-42a9-08dbc9e96038 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nJ3Lfg2BUiYtiOL5R24wsXiCEamJBlLCMue7S1a0NXcy9/Oar0KZb22bCPC0aA+dnuIOdbe7TGFFOB48Avu2rw3udMza4lKgDpRVGzGsJdGQIGFrYyXQzrLPVu+p8+uYv9560IRSiP3jefQhFCZ/byL3WTFpWZqpNkYOaLat4gdZNSGgk6H362uSLHlmrgqf3CHTkx5J8k9wMlXzk+EVOwv1l5ABrrPHBIHzXBFWn6Uj6J/YDPSpw8p8OBW83VA6Azv4E+5KT0eUGEkiBCkYP35ETq1gVCir239xu5mm6NuIkf3khc7zJ+LcEMAKFN+nS2Q2yTfbQ0q8ON/vO/NryhMAuIi9lZvzTM8vt52soBfOZhsKT3krhgn2Ae73e1nLfHdfblUhd0HyBwdbh2N9LKKfkjmYd8D3rC/S/2Vc+Njy61nEzSXVbuSh2GR9XK859/B/SFTu8pHGMHb+IuOvdFUxYYVm8zyAnXGX9GmwkMoGqkxl4lmL3K/R9Aur5vrMmT3UOT5LRpG74p5TEq6zVUb7Njkd34cG0UsgiZSM/wa3HcAx2fsNwBoauIW89vA3j1dKHvOpzKTDIZ7NeDW2cCAFBnxgvwgDxEfNGkisYGwRvvJIYLYGVOn/NJY03ZTYtLLFo4c37R5IcgL9aauoM7U//i0CWtLFot5tAzqUfVBYbesYs0zmlq4tkoOt+7dB1cyhG6t2dye7wqjy4JRfikKoIUM7854Vp+8LVX7o2+08IU9pRihbondoLRx7rD2gOqRsaE2cNZ6NzjTf7xS12w== 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:(13230031)(4636009)(396003)(376002)(346002)(39860400002)(136003)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799009)(40470700004)(46966006)(36840700001)(426003)(1076003)(36860700001)(16526019)(66574015)(82740400003)(478600001)(70586007)(36756003)(81166007)(7696005)(54906003)(336012)(2616005)(83380400001)(6666004)(356005)(26005)(47076005)(70206006)(41300700001)(8936002)(40460700003)(7416002)(110136005)(44832011)(8676002)(4326008)(316002)(40480700001)(5660300002)(2906002)(86362001)(7406005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:58.1294 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e26d3233-126e-4de7-42a9-08dbc9e96038 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: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7291 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Files unique to monitoring groups have the RFTYPE_MON flag. When a new monitoring group is created the resctrl files with flags RFTYPE_BASE (files common to all resource groups) and RFTYPE_MON (files unique to monitoring groups) are created to support interacting with the new monitoring group. A resource group can support both monitoring and control, also termed a CTRL_MON resource group. CTRL_MON groups should get both monitoring and control resctrl files but that is not the case. Only the RFTYPE_BASE and RFTYPE_CTRL files are created for CTRL_MON groups. Ensure that files with the RFTYPE_MON flag are created for CTRL_MON groups. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Reinette Chatre -- v12: Removed the comments about the later patch. The text is moved to patch 10. (Boris) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 953b082cec8a..55d1b90f460e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2533,6 +2533,7 @@ static void schemata_list_destroy(void) static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); + unsigned long flags =3D RFTYPE_CTRL_BASE; struct rdt_domain *dom; struct rdt_resource *r; int ret; @@ -2563,7 +2564,10 @@ static int rdt_get_tree(struct fs_context *fc) =20 closid_init(); =20 - ret =3D rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE); + if (rdt_mon_capable) + flags |=3D RFTYPE_MON; + + ret =3D rdtgroup_add_files(rdtgroup_default.kn, flags); if (ret) goto out_schemata_free; =20 @@ -3253,8 +3257,8 @@ static int mkdir_rdt_prepare(struct kernfs_node *pare= nt_kn, enum rdt_group_type rtype, struct rdtgroup **r) { struct rdtgroup *prdtgrp, *rdtgrp; + unsigned long files =3D 0; struct kernfs_node *kn; - uint files =3D 0; int ret; =20 prdtgrp =3D rdtgroup_kn_lock_live(parent_kn); @@ -3306,10 +3310,13 @@ static int mkdir_rdt_prepare(struct kernfs_node *pa= rent_kn, goto out_destroy; } =20 - if (rtype =3D=3D RDTCTRL_GROUP) + if (rtype =3D=3D RDTCTRL_GROUP) { files =3D RFTYPE_BASE | RFTYPE_CTRL; - else + if (rdt_mon_capable) + files |=3D RFTYPE_MON; + } else { files =3D RFTYPE_BASE | RFTYPE_MON; + } =20 ret =3D rdtgroup_add_files(kn, files); if (ret) { --=20 2.34.1 From nobody Fri Jan 2 13:55:40 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 B4A03CD98CC for ; Tue, 10 Oct 2023 23:34:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344163AbjJJXe2 (ORCPT ); Tue, 10 Oct 2023 19:34:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344147AbjJJXeJ (ORCPT ); Tue, 10 Oct 2023 19:34:09 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88AF810E; Tue, 10 Oct 2023 16:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bm+xJk6NwfS/Y7W1kVpDI7MFnWuEe6dZ1fEAn+FLMCoQmEpzPijZk3f0e2zLqXxJYv3Xmq51W4MeUTxVVUq/Uurv6psZjNxNODweuM1xA/V7456PyUiFmMHf7w8HwhtLPhNKpj+bxOjUnsvRzzmwJc/I22mwSH7iJDbco13wJgrVQGwX3FVziKlRq5uALyBLHusKml2PqZH7HNFjsuBX9OHmoVUO8wE/2IpBBMTJ/feMCmGeB9YO/sJyHNSUsA9fTt0Xix2zj93VJpo0p7pbsB1z+sS+5X7U2vbIyzKbtabWEgI2Y0W3aIB3Sg4lmi0h5Fc5rw3murr1nmq/omXZog== 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=wmaph0uUsn266K3VN15HgWwURdzFPwcIi3WSSi8E0hg=; b=MP9jZVeDF7MIWgl6kZPpTDb85dVJuyj0/Dh25D2QcTw5X6csxngcLiW1eKHbYsn2p4saFjFiNg6v+ik7y/EX8cHDt6O1WisA3m6yjQzHJnwmUQgyeZxevhVljgIVzx6AZVuoX8lL+G7Xpls7J7cjZS5MlYlHxZ+FvZfpJ8E+r30pwFEKCaS9de1Bne7ZYsvxpyUAph/TbEo0sjdsAMpR2u18EM1KRR7WE4HVeuAyDOkvRaTDuBS8L7aUNlmmUb1HwAJjPJWnisK+Mea9lsKoTd2B9adHetm5lLvMUztrEZTQiiott/AXiSFJsL7O0BrlrWQj0G3uc7Cy30cvUoMrGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=wmaph0uUsn266K3VN15HgWwURdzFPwcIi3WSSi8E0hg=; b=zEkP4sO2tRXZuawc8lywSGWSFQp/EuJpqKLqwz0Nr7i2NGDbsjVs9YzmjRrS2dAyKn7RAWHaRt03YMEaqgyVactGjPGtx4/Btby4ZwN7nnJG9mcXYSThrkZXfhfwBKgkV8NaC1SbaxClOxA2oCiHbVPvf3j+u7GhbxwfAKcHofQ= Received: from BL1P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::22) by DS0PR12MB7946.namprd12.prod.outlook.com (2603:10b6:8:151::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 23:33:59 +0000 Received: from BL6PEPF0001AB51.namprd04.prod.outlook.com (2603:10b6:208:2c7:cafe::d6) by BL1P222CA0017.outlook.office365.com (2603:10b6:208:2c7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 23:33:59 +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 BL6PEPF0001AB51.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 23:33:59 +0000 Received: from bmoger-ubuntu.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.2507.27; Tue, 10 Oct 2023 18:33:57 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 10/10] x86/resctrl: Display RMID of resource group Date: Tue, 10 Oct 2023 18:33:35 -0500 Message-ID: <20231010233335.998475-11-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010233335.998475-1-babu.moger@amd.com> References: <20231010233335.998475-1-babu.moger@amd.com> 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: BL6PEPF0001AB51:EE_|DS0PR12MB7946:EE_ X-MS-Office365-Filtering-Correlation-Id: b587c890-9256-4c89-ab08-08dbc9e9612c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sm9w+nekjc9rNYc7jdqzRp5EAXGzw0t68uAIUOhO6ksx0mUGtRjGhSYYGoEmGIZPF1M/+opBVyZcvpNbZQR8T8ry+XbdJ+L++zxaNy83pSoRmy4Dp8LTBNh/BEbx1sFmXyjALmNT6f7ZSi3cDa4VdUsmVK9wEnykYRpItcjJGxBECKcAd3dhfSOxBFIuMSnX7TjBEZ4JG/VbN9C2dEQQi/+z9k60xQMXpPqELyRpziI7CxmDML04MP27DjwbvGzZbune8IAGB9wsM1BucoZk7gGVxjDwQvY8Xkvfu9IhT2Qs3l2xUBNLlur57sf2B4dfZqy2+9PtI0EFJDvAf8Yh4K+5epgxTNvd9hZrzwngEH5gXC/x/Uqt1oI1dIkEzO6Xv7i3qsIbIDGfGYOe+sfklIXBBlV5/tg6hg55OKYnlrtfuK2JTi7PxXDMscq5HE1zr0gu6+ZHklj3fuUzbfLT4e9Cr0bp6DhOuXtytWXAhHtybt/hhHeAPr1qHtfgfVxY6IiI/ls2yGaAIiPl0cjjSKCk9QrNWRT/GjwLI7gxNG749BdD5+7lsE79mynGUac6XtRnXAZs1QKIRJHYxaMeCgP+FeciQCBu+/nyP61WiJU6bsnfKeWw/T2He4ouCBQT87rxzLZD89THh6KCPRwnWU7hNT5QkIsRmDf/TzIkD/Rx9JFSD4kmq1EmZixnjjMfi1EBUPqRtm63PjK++SrMqxnUlSJ6ZzLOIbALrZIdctt7cJmfaWS7lGs8fVaLXBnzbt9IFO8g+SjU9NdWJHh6+g== 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:(13230031)(4636009)(376002)(396003)(346002)(136003)(39860400002)(230922051799003)(186009)(1800799009)(82310400011)(64100799003)(451199024)(46966006)(36840700001)(40470700004)(40460700003)(1076003)(478600001)(7696005)(2616005)(6666004)(47076005)(66574015)(426003)(16526019)(336012)(83380400001)(7406005)(7416002)(2906002)(44832011)(5660300002)(70586007)(54906003)(110136005)(70206006)(26005)(4326008)(8676002)(8936002)(41300700001)(316002)(82740400003)(36860700001)(81166007)(86362001)(36756003)(356005)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 23:33:59.7312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b587c890-9256-4c89-ab08-08dbc9e9612c 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: BL6PEPF0001AB51.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7946 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In x86, hardware uses RMID to identify a monitoring group. When a user creates a monitor group these details are not visible. These details can help resctrl debugging. Add RMID(mon_hw_id) to the monitor groups display in resctrl interface. Users can see these details when resctrl is mounted with "-o debug" option. Add RFTYPE_MON_BASE complements existing RFTYPE_CTRL_BASE and represents files belonging to monitoring groups. Other architectures do not use "RMID". Use the name mon_hw_id to refer to "RMID" in an effort to keep the naming generic. For example: $cat /sys/fs/resctrl/mon_groups/mon_grp1/mon_hw_id 3 Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen --- v12: Moved the comments from arch/x86/kernel/cpu/resctrl/internal.h to Documentation/arch/x86/resctrl.rst. (Boris) Moved RFTYPE_MON_BASE definition here where it is being used. (Boris) --- Documentation/arch/x86/resctrl.rst | 9 +++++++++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 5dcd7d250ca8..e89b889980ae 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -369,6 +369,10 @@ When monitoring is enabled all MON groups will also co= ntain: the sum for all tasks in the CTRL_MON group and all tasks in MON groups. Please see example section for more details on usage. =20 +"mon_hw_id": + Available only with debug option. The identifier used by hardware + for the monitor group. On x86 this is the RMID. + RESCTRL filesystem implementation notes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RESCTRL filesystem has two main components @@ -426,6 +430,11 @@ RESCTRL filesystem has two main components --> RFTYPE_BASE (Files common for both MON and CTRL groups) Files: cpus, cpus_list, tasks =20 + --> RFTYPE_MON (Files for MON group) + + --> RFTYPE_DEBUG (Files to help resctrl debugging) + File: mon_hw_id + --> RFTYPE_CTRL (Files for CTRL group) Files: mode, schemata, size =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index f0d135e004e2..714606275b98 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -254,6 +254,7 @@ struct rdtgroup { #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON) =20 /* List of all resource groups */ extern struct list_head rdt_all_groups; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 55d1b90f460e..ef4b18091e5d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -795,6 +795,22 @@ static int rdtgroup_closid_show(struct kernfs_open_fil= e *of, return ret; } =20 +static int rdtgroup_rmid_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdtgroup *rdtgrp; + int ret =3D 0; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (rdtgrp) + seq_printf(s, "%u\n", rdtgrp->mon.rmid); + else + ret =3D -ENOENT; + rdtgroup_kn_unlock(of->kn); + + return ret; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1856,6 +1872,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_tasks_show, .fflags =3D RFTYPE_BASE, }, + { + .name =3D "mon_hw_id", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_rmid_show, + .fflags =3D RFTYPE_MON_BASE | RFTYPE_DEBUG, + }, { .name =3D "schemata", .mode =3D 0644, --=20 2.34.1