From nobody Wed Dec 17 10:59:03 2025 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 E5E29EE49AF for ; Mon, 21 Aug 2023 23:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbjHUXbh (ORCPT ); Mon, 21 Aug 2023 19:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbjHUXbd (ORCPT ); Mon, 21 Aug 2023 19:31:33 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2084.outbound.protection.outlook.com [40.107.100.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12400CFC; Mon, 21 Aug 2023 16:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f9tWIxgLEKU5f4phwDN6rzVWrmFPPF5eguJADS4yKqZ0JOXWPo7vRPGmnagSMBGqGH58ybW80SZ2frKjWUVduOr3kLchgvnsegtkyQCjecA0sAtYaniIvqY34V4NzRz/N/opCiQY2jb1LQqVWWF6H6JLfMdIKGbKbqbdbgGF660r0ssiMzHga742nhqo7azN+OcCh3G4AtWnz4RoGcnDE60CYAtIzjsPPefQwyteSQIPy942zJu36FZnUCeDDV2Ag0nlSqUC36jltJ06d2PnsCZx4t9t3yAiHZiyrCY9mwm9HyLr4e0oM40slesZb1/sCL7jFmNaKJURrsc1aC4iHQ== 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=WMUFck+2VMtQIu0eZZmniECKgvvM1ZTyI1KmUy6yZGs=; b=aF+uWFt8hu2HTc+3C9qCJBEGdS6INdmmXgHIzCSFe96JjZPC9XSb0IsS10johT7mNpCuNXCnP2G12ZUUfexnihld/0p8aH//+Tq7IyCAmcZmNUSSqFlJbnNgoHONT7wCpifJOUy1geYuQIJDmaY0wjLj3ckj4Dj5fUcEUSKNnM1U5m/qFa04p+/BJ7L91iCMX+qhVDqu6La0CuaOVnBSYjLF8WJedDUWVIpyt3Zq/+2PwKwcS4pFJGAB4G9DbElopnu6AIio4br3k3oB+yjL3pwqfIbyIhmT0+h2VLzuKBzCxgH/PpwvZs4ksHNKkA7kssA9m5WH0e9Za8A9DtjOwg== 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=WMUFck+2VMtQIu0eZZmniECKgvvM1ZTyI1KmUy6yZGs=; b=udRQNhbUoIUAo2oc58rKV7SHeOnK6f2KK6sAHc3lfnNEft20De7EqX8md/em8zFek0bSPzGwOmgpCZH2/fQlbL2QUj39BWB4/3Ahes2nwcZe0lftD8+K19SOX7XOdhT+HiJBnpLSioX6n3XLINTn+Xi0ZRULlXWu7PZxAD3xGgU= Received: from SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) by CH2PR12MB4134.namprd12.prod.outlook.com (2603:10b6:610:a7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 23:31:09 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::85) by SJ0PR13CA0051.outlook.office365.com (2603:10b6:a03:2c2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:08 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:08 +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; Mon, 21 Aug 2023 18:31:03 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 1/8] x86/resctrl: Add multiple tasks to the resctrl group at once Date: Mon, 21 Aug 2023 18:30:41 -0500 Message-ID: <20230821233048.434531-2-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|CH2PR12MB4134:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a7c6580-a420-4437-0a91-08dba29eb299 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dWHlFevBdQVeZud0HYCV6Cf4k54qASDL2uPtUqwUufKK/iLvgw6y6jbitrQK0XiKl8X2fqYelXwkVtAMG0o0VFdwrrBrkR+R3LJHDv2ZdxTZHCOZw+JZxqYlNPb0esoy4VD3V0sa6wtWtesQEEhztvkJ/AnnL115W6ZnKxfzAVn+WZRhFMuDEYs6vocso8Xsq5CaoT2+YPsaSH9dX28zfmDzo+LrO6maCVIDebf9DNYD7euHKzQ2dwrsnDpSKJ+J2sL+ToTWlB1s9aQERzuqsLK0jaXn0sRCeii4XispaF7N1QyxYZ5nStPHBFO7zhWd8TM2YGpQhcd4cgCD3o7w32CPkIorJBSVp+lo8hfsyEdmxhaIFU1oEQK3Qlyo7ST7KQ3TP8MZR94efK15QvjKeUWbPyXrjiDBT9EN4kY4A0z0JKiQubmhdJevwLU7Bc7pC27ilTQvm6njGsV3TfBVhMf5emWddTf0u7YkKRBMjRSNomaaZyWxC9S7MuQYubGCFRHNlONMnie+HMfA6UbUgPMNOv5HamkXBF6+o9AlyK3xvhbGo3QzMGuT9f9N8toU4iTAOgh+UHmcEHA47jkPXbEY+ENpvFh7JsAOIcHniml/fFZbJnlBZNEvS+8Yrb0oL2i3qNNV3CxXOd9Ig3l13eXKbExX6bAKhAwwuKJQ8uhr/DLCVeL5BEZ0B2vQVgc0E65o+8Fv+yEDkAVuEbtc8LiPEF38t6aso859LrCx7gAKmTagi2+jEP4zIYYGtnEwPFGIyY4J5AokPcq+j48hHQ== 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)(136003)(346002)(39860400002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70586007)(70206006)(316002)(66899024)(110136005)(8676002)(8936002)(2616005)(4326008)(1076003)(36756003)(41300700001)(40460700003)(356005)(82740400003)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(7406005)(7416002)(86362001)(7696005)(47076005)(36860700001)(336012)(44832011)(426003)(5660300002)(16526019)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:08.6557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a7c6580-a420-4437-0a91-08dba29eb299 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4134 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Tan Shaopeng Tested-by: Tan Shaopeng Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- Documentation/arch/x86/resctrl.rst | 8 +++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 25 ++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index cb05d90111b4..af234681756e 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -299,7 +299,13 @@ 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. + 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..8c91c333f9b3 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_puts("Task list parsing error\n"); + 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 Wed Dec 17 10:59:03 2025 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 B95BEEE49AE for ; Mon, 21 Aug 2023 23:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231743AbjHUXb2 (ORCPT ); Mon, 21 Aug 2023 19:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbjHUXb1 (ORCPT ); Mon, 21 Aug 2023 19:31:27 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87BEECD8; Mon, 21 Aug 2023 16:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKOytcUMZpIXs2PFUBUNS2vojxma02lTihr4n3Fq/O9Zr3cAk+lEl0eHVXoNWi0jJ7fBxJVj2k2bjvx+0WC0HgxZ9YpUM9AEcaufsV2HtkOWR+jEFoYjvRLPRdReWz7ZCqPOjBmAimAenlCr4h42q7k+i2jyAiV+07VUr1zFp7m6hlj8VTqYCtxvFTdil7A/Yp7zQCQh4FdhPtVdq+rAPbQfIVhYbMrccyssKtn/SMTmAQsI51m7OY5bqUPbTLTpLqDNvntDBSgomDKc8qAU1vRV8Me3E4jkN/D4gvRvpTbi/L0md43/bhT3szpnNMtus+UitUW5F0zO4RQmZ6BS3Q== 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=3EQ53POh1e7IyFtIwBNyOmrheFBOnyi8T0DZ2hEa5UM=; b=TXcWQs8No0jlq1FuFkVaTWOkO13QAyhiaARZAO8rRUQFbv3+Y/XvN/QJC5uWBHGfrOZSED7jVTC4QtcQ4ii7IJXUxZt6GO6EuUxcyvjJxaS+UXNRGSSGGd+r2FUGshkHvaSzzxYMl8rMjVsbP2+7FQn4SveovcD919vLV2jgGA9CChZBlz4qlXMZJN2ppP5AZ3o1XTfQE3E5J33LzGROh/LBKZOBcryc2Pp9CggvcyB9gMTOGXqF/ZQ4jfdswpdT17QiU/SrKFQXsaj6WO6vJQsfyEgSYb0P8EsFjzPiDkzlFu/njHY4GrKo+1+ZiSDg39WBGRxivmiEkkvqrpVVNQ== 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=3EQ53POh1e7IyFtIwBNyOmrheFBOnyi8T0DZ2hEa5UM=; b=L4rF6PFSe/frHNJszO6u6HDe5X+/PUNauHDYOTVrmFSBrXrVuZoqtQzfk9XXBW1YjXpfM0oZ5IL2aXxNzZmdIeC7u7BeIhPyCFxzWVQp70UFUT4Eu57SjYdE68lOfLMXe34fnn0CQVbAJX72R2sLB3oUaWL4cQfFovGgrQd/00w= Received: from SJ0PR13CA0054.namprd13.prod.outlook.com (2603:10b6:a03:2c2::29) by MW4PR12MB5603.namprd12.prod.outlook.com (2603:10b6:303:16a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Mon, 21 Aug 2023 23:31:09 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::ec) by SJ0PR13CA0054.outlook.office365.com (2603:10b6:a03:2c2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Mon, 21 Aug 2023 23:31:09 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:09 +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; Mon, 21 Aug 2023 18:31:05 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 2/8] x86/resctrl: Simplify rftype flag definitions Date: Mon, 21 Aug 2023 18:30:42 -0500 Message-ID: <20230821233048.434531-3-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|MW4PR12MB5603:EE_ X-MS-Office365-Filtering-Correlation-Id: 47fdc983-b26e-4aa6-4066-08dba29eb310 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 33HyJDn8udo1/h78C8wqu6HWIVpx6ApXYDGD6MWPeHyl7w4w+PyZjG47cQHtvv71DODiWiF6jd13dckmfvuNx9Ciflx3bKOusaiQ+SqNP13VpCJe4kmz4Scc6/WBuuVC4jk968MkTeiKpe/aHIR9EzXcC7H7vs3OAbipl7JtHJHpARhfLi80J0QnIaJLKYaV+Bo4rlv81VOUgKc9gsT+28lSIPWNGfqHrZemwLrWWbMi+gOcKpcVilf3MAEw1Bi/+x3SRPc20cjyTWaYNpzEXuB4VRKD1A1Jq8nIcsBomvH/UeLilObn09G66p4ZCCRqHHBrJ4+s6WAxntpeciLqVoUksFDsBXKbLBtkq9TS0e977Vcp6BuSNW559VHAwKxEs03/n105zgeOPsoklCYsibXUemD9P58IDX6wIQ2GdnEFdj1J1jHc5K3uVP/1m8zdqS27ex+dTx5h42sN9WiV4aSrNl7hDbzEVgwoxw4dEGKKdIC4uqjDMpc09t1A4WgfuyL7RIuW0Q58C6kc5lP+LV4/+6RWnrYQYl6sJk+nQQOfQbNDYEu1NTYYvGd0FuHyZNOcFaaE8AzEL//jhIYjSRE8o/jYVfWXq9wGFerANJlegqrzN2WOxshGMMs5Gp6MltpqU8HTPYu9CX7pWDSVjk+MFndzdH2lQYQMPZjMmKbFGoJ60Bv2AdJ3Lj5W5wPzEEvIHW494qIy+n3wq6ZroXomgOlbl4mKMGGxrl2HfPQhL5zGOmZZKzjBLwAwiWc2EKK8BN0KrfwweTaPCHnEXg== 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)(39860400002)(136003)(396003)(346002)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(356005)(40460700003)(1076003)(2616005)(336012)(426003)(6666004)(16526019)(47076005)(26005)(36860700001)(7696005)(83380400001)(5660300002)(4326008)(44832011)(7416002)(8936002)(8676002)(7406005)(2906002)(478600001)(110136005)(41300700001)(70586007)(316002)(54906003)(70206006)(81166007)(82740400003)(40480700001)(36756003)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:09.4370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47fdc983-b26e-4aa6-4066-08dba29eb310 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5603 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Reviewed-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu --- 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 8c91c333f9b3..2f1b9f69326f 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 Wed Dec 17 10:59:03 2025 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 BD392EE49A6 for ; Mon, 21 Aug 2023 23:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbjHUXbe (ORCPT ); Mon, 21 Aug 2023 19:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbjHUXbd (ORCPT ); Mon, 21 Aug 2023 19:31:33 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A273CCF7; Mon, 21 Aug 2023 16:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QENWy9wbv5J7yv3ZS7g4mShATbh2GgrWQ9XJ7ALbREuFPI2IMaJVxg8yjWQMbAP9bemM7VqEeQg8yuK6ui3f7vE+7jKdt04G5Wyn+jMuFm6V2XmQ/xxrTdrXus6/b9iOqPR2tT4T5bCu4/E9lJsfyemGRcI4zvJBd2f/gREDKKM6DfBjMsxB9mJlSqEdQxaOZ6OpNGMNtH+LvrrfpiEib6euvBa2zghlWb5F18YwCErFodUtvRMpq4O+fkQT2fSwV+w8INW/ppC6xpgusew2ifi+dTep/FpNJh9WGSa59KGfSd9kcIwpzKJm3VRI55apUVV4lOOhizf1HURKI7LRhg== 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=jbct7425WsHDP5S4c7AYuXD5FhetUd8SWVCtwRhW6y0=; b=c1fAKBVaMoe/AcD9r/IGBhHRkwjcY2286dsD4Az9LJnsGotreEpXUZGbnMQuv163CQ1BV+7pbF+s8HafQUmtuRZRNfBxR9NLu7ebnTZWBglH3UG8ZgxBzBpdfDQEiEWHJi2zjPjjy8m/8MSOVvjAkiJGoslTehXqDRz11FtLYgyiee+g3D3buT/iqruRECoCrEvHBe8HX/FMNSYSIlqZ4OoPjXUZThlqpLViIkGG14K2lPviWOetq3BxY0cwth1D4kWRT/7bmaCsPTw8HiIBJzm1rOWSpDqz3jvGJVhxhogtuI8Sssqg91jl9pO06Voc5DXVy5QnoWx2FJGi6Djm5g== 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=jbct7425WsHDP5S4c7AYuXD5FhetUd8SWVCtwRhW6y0=; b=LaKUYAUJJCuH+8SgWaziuDT2SIIhKSZ0mjO9T+3pc+nyYIlUfX7eXxhd4a/vbKE4v3IouPV6jX/NYBywWUfPkPNxv52+wZZRksYdBvKXAZH+Ui20Ki4SUeVqr6WnzRuyBGVoR6nCMVidj9fbTIeES8yo/eNGNE0zzqa6tKDla1U= Received: from SJ0PR13CA0057.namprd13.prod.outlook.com (2603:10b6:a03:2c2::32) by PH7PR12MB6467.namprd12.prod.outlook.com (2603:10b6:510:1f5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Mon, 21 Aug 2023 23:31:10 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::52) by SJ0PR13CA0057.outlook.office365.com (2603:10b6:a03:2c2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:10 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:10 +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; Mon, 21 Aug 2023 18:31:06 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 3/8] x86/resctrl: Rename rftype flags for consistency Date: Mon, 21 Aug 2023 18:30:43 -0500 Message-ID: <20230821233048.434531-4-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|PH7PR12MB6467:EE_ X-MS-Office365-Filtering-Correlation-Id: e472719c-27c4-47a1-ffad-08dba29eb390 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t53NVgmzlDuUcHFv4lPCVWCSmA/I88heZhCACLOwRHTIzhHzwL7dmxaPEQY7EE1nooC2A04dqGCSjE8EgUAFf3XiO653RTVBW8QNEFFEQygtp3P5Iab31vPoUsRbvcR2wpf9TDv6sI22dPKkZDex46jCTImTRf6SnxRrZ8EJdRzS3DV5c/TyAqeajsulIxdIrweuuKwKTgYX6rCDeBqb546DIR3Sfx0A1q0EcHbbLz5reATStNJ/+kFyaG/rKyTVtewBPnysifaT0p1R3DFTSGXypGF8yW0UhlmZyBq1aCDecyDZ0Iawg+lYtRhMGGhiHR0UZkJct8ZA+DhPMSm3yYZTQCTF9n9k8cqvJAmxcOmkvukrsLdyM4zq86/DMOETOMl2IQNuDoX0Jf8BeoUmaKkL+/OQDgPt2MifM6tux5Z4xnn49WSrLN31GFHzrAS8xZm28/0i7J3wAQP2cfeIo1Dk4dZOHcU6ARZAdqPrDaMHXHMYLdTAstL+IT+8TIIoP7C6Fac+kM9wav6eRf8aSR9VunDwyXwOpOg/CHQhd1IPYqEiZOJbdQcILjYTkt5Z6CsxIj+vYdE/DvbVMxW32T15opmNLfogwIpLKEuaEY1o4kIYitcoEWQ6qNHmB1HzOsSx3wTk2yKtqh9kmsBvnwO+07DM0pwIfXaQGGoMSb+bdAYgpK3Cb1pfMtnR5e8ylyY3t/arL0+08fQgRHm8k6nOearXRn7T5X8oAySD86rOmRAkVCgvWhaOajbzouN2ti194k41+fC99qFGMeFzaA== 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)(39860400002)(376002)(346002)(136003)(396003)(451199024)(82310400011)(186009)(1800799009)(36840700001)(40470700004)(46966006)(86362001)(110136005)(5660300002)(44832011)(70586007)(2616005)(41300700001)(70206006)(2906002)(316002)(54906003)(7416002)(7406005)(8676002)(478600001)(8936002)(4326008)(40460700003)(6666004)(7696005)(26005)(356005)(36756003)(82740400003)(81166007)(47076005)(16526019)(336012)(36860700001)(426003)(1076003)(83380400001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:10.2807 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e472719c-27c4-47a1-ffad-08dba29eb390 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6467 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Reviewed-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu --- 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 2f1b9f69326f..3010e3a1394d 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 Wed Dec 17 10:59:03 2025 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 A95EBEE4996 for ; Mon, 21 Aug 2023 23:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231774AbjHUXbj (ORCPT ); Mon, 21 Aug 2023 19:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjHUXbe (ORCPT ); Mon, 21 Aug 2023 19:31:34 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EAFCCFE; Mon, 21 Aug 2023 16:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g0ChFB8NVACV6prCSI9B8NhETl4v+raUiJO5vYTR5fTi1SF8NlR+dMWE8o8JwOlGntHgYQxV6vvJtMDUfjVOFA6E3+yTRub2ENf0jTGhcNHqxXdVQXo0muA6wZ4eCoiRanTmRCoVwC87QBlTXOGiYe6nVXe0zqSo5Ui0Il0okkODT4HQtXqqUSDuOm+cyC5mW5D/sw2dD7IBZc+RvJWK/GoBCktGUgSHk8OBgA3oMcshnr+M4/B6YgVg6mO/2Kuhm0bazyKJw9IW00eNVETOdoKwYvE9YLOmtep1k44hf2M9i/+UHD8whwGOIVjuWOILtTtrr7bXx3ga1yDvaAw6+g== 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=+Q5QuY8M0CrOLhESkFdyThNpHD2gSCTJijwjIGKA9BI=; b=eLQ+o9tMLzqAmaZABmPb84qyK9fhAMUSqZ110AyJC9c0+LUv4yD3CAM9a5UljXARq3q7niWckN1CsRq7qJLA7otAuI8hj3pwuCY0q6ECFx6dbKHpx7WMWWM4dTT+PATEkpY00tUImAsytE4dnqU/iLjhOTW4Gr+D7Q0aMo8mHKyHI1zuPSV5rhjcgqYZ1qjLBw8cHihSY8BX1M4MxZK2PKZaJ9iVbM6uxwyTJ3kkKpseWoCIrPo38MCg2GdRxBASGh89f65g89eLVIFaeCcXluIYM8RwVS2TJyvalF1A2JwtN77Wg9LhiHpNhrRtLcNJBwclJF9Ny0fQBHVbEvRIpg== 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=+Q5QuY8M0CrOLhESkFdyThNpHD2gSCTJijwjIGKA9BI=; b=QVUPO2Sq6w7Xnv41L8jdVm6+t8BtosT/3IP+5iq8HHUYP2iGkjV3iPJGHpMeboPzOJ/Mo3LJ0BhLQJFB6UGCgDgNxfIMFc8zU2m0UUk5zU5Ub+o1W5rkdyP6UYwrCKyUhJLEu3dyvNqhmFzkTdJuy/WhWozKFc5hfYRx5ohAN0A= Received: from SJ0PR13CA0040.namprd13.prod.outlook.com (2603:10b6:a03:2c2::15) by MW3PR12MB4362.namprd12.prod.outlook.com (2603:10b6:303:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 23:31:12 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::2c) by SJ0PR13CA0040.outlook.office365.com (2603:10b6:a03:2c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:12 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:11 +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; Mon, 21 Aug 2023 18:31:08 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 4/8] x86/resctrl: Add comments on RFTYPE flags hierarchy Date: Mon, 21 Aug 2023 18:30:44 -0500 Message-ID: <20230821233048.434531-5-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|MW3PR12MB4362:EE_ X-MS-Office365-Filtering-Correlation-Id: 596a9590-421b-4a5c-7f1d-08dba29eb473 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mw24rV0Er5Imsb1ZttYhBrGLATtZ23YPLmqedKuN6LqJ3YvqPqmFLYByBYOUsw5CR8GlRLZuELOGdILPBCTa7iiaqseDYX0/88NpuaZ+6/EIRqqVawN2ahEtxTfrHIM+TlKdR2CC7bMtLG9mD0oyoOBtntrt6/5/RxEkekr+LQnivDzGfE3mWSm1H5UfQ2M8XoO1g5+zlgSZwIiSAPQKtrHNNVQBft/6OUh1HqBX11wWXsPwgsy78S/0V7AIEPAblx6oeQ6jouq0ypjGHmy1fukG8C+1NP7GGaJe9pI8e7b1qOAmt5erxOXi02ghiP86SMul8HmUWhg+WaQctDXu4rP2aLFyYAhJx4ws6GQ+Qi4xzNUf/OqYiF0K0A1GrrljxFbX0mL6JUrydP2LZZEMc83gLddX+GPYtUeaOSAjSI3CtciQZs936FbWD7acJQmL/KTtgdPTAV8mMKIJW1fTv1f+nVky6y5cGi+IlrQdd9kMrS+nevilL/e0ha8bZ7HwvcsTl+IDcU4Z23qfn80NDGKm176HnpQea5ZR6ets3EWtngxHZQ0XoE37LMRwxN4g0jiHf/d2ojszTnjA3FcYnf73MzO2/Yv9/xeMuUH/xwnUfgWtRJDjphj7bvtEimQvpPzn191w4mPT97Wiy22p3gzJLO3sFJN+frxH1shU//k9zXVsPCG7esaqvpXfAzIwsqSo85NNFH57i/xOflahPOEpQ1ook0lvXg4VLwqPhDS363Wy/SbTEAK5uwSxXasLhDjsW+sFQ7rgT12uZT/crQ== 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)(136003)(346002)(39860400002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70586007)(70206006)(316002)(110136005)(8676002)(8936002)(2616005)(4326008)(1076003)(36756003)(41300700001)(40460700003)(356005)(82740400003)(81166007)(478600001)(6666004)(40480700001)(2906002)(7406005)(7416002)(86362001)(7696005)(47076005)(36860700001)(336012)(44832011)(426003)(5660300002)(16526019)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:11.7651 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 596a9590-421b-4a5c-7f1d-08dba29eb473 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4362 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/internal.h | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2051179a3b91..b09e7abd1299 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -240,6 +240,64 @@ struct rdtgroup { =20 /* * Define the file type flags for base and info directories. + * + * 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. + * + * 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 + * File: num_closids + * + * --> RFTYPE_RES_CACHE (Files for cache control resources) + * Directories: L2, L3 + * 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 only for CTRL group) + * Files: mode, schemata, size + * */ #define RFTYPE_INFO BIT(0) #define RFTYPE_BASE BIT(1) --=20 2.34.1 From nobody Wed Dec 17 10:59:03 2025 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 32D42EE49AE for ; Mon, 21 Aug 2023 23:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231760AbjHUXbg (ORCPT ); Mon, 21 Aug 2023 19:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbjHUXbd (ORCPT ); Mon, 21 Aug 2023 19:31:33 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2052.outbound.protection.outlook.com [40.107.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A5ACF9; Mon, 21 Aug 2023 16:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VlP13MdzFnmCQmyAaeO0atOFoubo0wNXV2ZefrkrPaYUZdis/RdHt7xjaDyKcKJqWQUCDRWP8UbtyGdZgaCcP3A7tvHXmHMXePeBE8rZwfMLouF7UnwsQK5LE/15N12CZNMnXgBSAc+4l6rne7ZYAjSC0MkVR0Bfj3zYMH6kPjRkiWgcTD4/MwPqhrt9R9IdCUrCuPXeZtbqlNCbIQGqBS+6IuM2N7dOQpDdGO9/qtW8/TH2g5Dig0wTciAqQD9QvitjTah4Wvo4JvCahWoiqFonENtRCrJLaXCqDuTauhbvPFdDTglrL8AevuvatXthlbn33oK/dK4oInMoz9y+uQ== 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=GaGbPpaCHGt5x+fG5G4ghhXOmA7ox6AkCPo0SQhwWBU=; b=IKriF4Rk5txRVNLe7mA+S7rgoTbjyOs9UuXixlrX0BNBrfK62m6pIbvy8M0sX96J0qXrgF5upW/S+mNUZF3U0dTnG2gpWmuzyI1BwcJAAe5PoytAQgXY+vbN5ggxdz6JPXzDNt/Q3mD5CH8G49lwSlAOLYdb482OqnBH1l2Q7TBEgsmel8FRQp5Kqlw9BGif3HlZpVh+M1mHb6W8sQhvzbEwA7VUCDZQht/VbKzNyumOnPcIYlM9y0BLtmUFASmMWHCu49WaucfDyuZeHYCtZAIksXJ7f8PzUMK23uBz1tcSWmXSFIgpuewtnzEjdnvakerlENSUzPf+o0vwb3jwKg== 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=GaGbPpaCHGt5x+fG5G4ghhXOmA7ox6AkCPo0SQhwWBU=; b=q1mTQN2L3mRa5uoUcXAutDb3VfevOON0W80XtgSMEbTh0GT16z+D6Cn6tcxnodNMeKl91PAG8P1e68c5+6xV+Di4xzLsi7hV9QduufbPsUg7VqYDcm+XLY/59UgkmtY60Wi1P0QIU7y5VKahYLgpIpSEkNF1Jk6+89l8rLR5CJo= Received: from SJ0PR13CA0060.namprd13.prod.outlook.com (2603:10b6:a03:2c2::35) by PH8PR12MB6986.namprd12.prod.outlook.com (2603:10b6:510:1bd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 23:31:13 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::99) by SJ0PR13CA0060.outlook.office365.com (2603:10b6:a03:2c2::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:12 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:12 +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; Mon, 21 Aug 2023 18:31:09 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 5/8] x86/resctrl: Unwind the errors inside rdt_enable_ctx() Date: Mon, 21 Aug 2023 18:30:45 -0500 Message-ID: <20230821233048.434531-6-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|PH8PR12MB6986:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f840f0a-9d9a-4bb9-02fb-08dba29eb4f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XK0K/9cP1iGRQAcCB0FcQHDt5mjeqY4vjwQnA+dmL4IRfvcHHwSoZvI4Z98nVTQpmDKY0y5gpgn7Zft1G89I3j+avDxNnHCJ8CxAutxjeM9eHffwmm6xNZQyGNtf6Ihe36ZWg3gi2xzMBnwwfYrCG5sZTQWxTbWsBCT5TbterWqZzDNjzVD6h04beGpjaVzUMw01otMtOLtQ/hpTGODMueXqTpA0Hjlw3POZCHa5WCaZw5D0sgZNtlUnZvFsN1VIHxsleC3/QPZHvhEbxLmfKAAcsRdiBEu0eNxHPorJX+E37gMFTqP+4Yi/UE5/cITwInIFKMTeC7ZPYDDVuLSX3A+UCwbPI4/R06X1w9iKBJvELpxZY3YDoTF1fRyESuYG0N/C6LOlHdcLx2vIw5fFcJXjWXvjF7SUgfXKub1/LDQsSkwq8LDJyEdukqknOzzD5ZJD2jXxHL6Yy9oVNbKXpCPaZwrQap4V4ucMhKRnKlA+Q5ANjYsb9/PgsWcaOU3VlxEQ1vquA1j3YZR8lhE0sMArIVRZuTHUUMJkmOdSYRxZmUMixXBh5Z3Hpe5K71xnEZiNkKPmETskSI9lza6+I/msOdIgcEILkLDAoKH59YlTNzi5/We/IgXUzgcIJoPJaPRYm2nOnegnpKuI8UuRmYiBPZfwgcokjjiddppEGXSOBhb8c7Qvu0ar5fea5dZs00iWdbhfp6NShQZYvmZWNjyfyD0xFUv641/AddFkgFXInID9W11xDg87So+tyChhVXzhaUi7kz68UziTvVQxIA== 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)(39860400002)(346002)(396003)(136003)(376002)(82310400011)(451199024)(1800799009)(186009)(36840700001)(40470700004)(46966006)(7406005)(83380400001)(2906002)(7416002)(40480700001)(5660300002)(44832011)(426003)(336012)(26005)(16526019)(36860700001)(86362001)(47076005)(7696005)(8676002)(2616005)(8936002)(4326008)(70206006)(316002)(54906003)(70586007)(110136005)(478600001)(82740400003)(356005)(81166007)(6666004)(36756003)(40460700003)(41300700001)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:12.6402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f840f0a-9d9a-4bb9-02fb-08dba29eb4f9 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6986 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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(). Remove cdp_disable_all() as it is not used anymore after the refactor. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 58 ++++++++++++++++---------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3010e3a1394d..80a4f76bc34b 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,47 @@ 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) +{ + 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); + + if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl)) + 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 +2517,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 +2582,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 +2815,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 Wed Dec 17 10:59:03 2025 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 BFC89EE49AB for ; Mon, 21 Aug 2023 23:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbjHUXbs (ORCPT ); Mon, 21 Aug 2023 19:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231783AbjHUXbp (ORCPT ); Mon, 21 Aug 2023 19:31:45 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E155195; Mon, 21 Aug 2023 16:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MNy71paOyoE8rtxCQ0hPgfUtMtwKgsY2YexFxHPOn9uXLLcMGgbksu3RlWLxane973o9jLZEVEGpkyAAkIQ7tleEtl16xqEN28Ln5lxwF3mDPGVPQt4zGQOqNpqHKMMa2B5uY4RE/6s5a7OR3NtXELAr5qYSHs+Gkl3TwGWR7DpQ89qjFAKe6qeo50krnnYzkKE1XUjzieN+XzZJI/0isAd8aFLJodGC6h/wrFHg+34XKrCZqgJ4L2E1ZPYOyAgycc288FTPtAev5bbpZEpDPW1S3zx8y73SAKiabnvdbNUNkehFDve8fHkiIPHAjqN1s7inK9eOuoMhz3DufoUDNQ== 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=fwJBGBO/RwjlIDTULKcAkbPlh3qJGfZBP9Hqv3dZVLk=; b=KGEOXmBABhcDHh9hHIzmaYQ1uh0Rg6iWVJnl87eaDBDgF5a4vQR1zN/P1av/13kLjkwA61Z94EAKzyYvTs/bNlDLJXAXOlSEp4kyscGM5PRaI3FA31FNoGtQrfFGGQdDmiP4wcJBkJ6yv1g5nH/AkNNLtnz4NZ7nwXuV/2Jjz2Nrm5cHdbqTIG5pBx40k8h/GczIAswuNJRWKwemw0FmDnLs5+P+jJRbtirUMS6toTrqt8/dBqXbEyk6Xoz5/Rch9HUBqHwYZ4RsLpBBxGIha7km38CCCnPvwNhwskCrKEb5kVjQT+XRGSowVJA68Qa3gEZMMI7xX0OEOIT2zc29NQ== 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=fwJBGBO/RwjlIDTULKcAkbPlh3qJGfZBP9Hqv3dZVLk=; b=AmFeWzcsoU457iIeZyF3iQWy5pOJ92T4rv6poL4gSqvxs7jK3xN1s/EDzZkHTzJ7Gz6Jblkv1/JWYqwLYp/mxeKyRg/gD0QKi4fTBuERgJDbcA3bKfkjg0BVzE8dGlNoIPx0AROxLYesGpBACk+Ng6SqvATwD3Gl1g5YFRitztY= Received: from BYAPR21CA0007.namprd21.prod.outlook.com (2603:10b6:a03:114::17) by MW3PR12MB4507.namprd12.prod.outlook.com (2603:10b6:303:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 23:31:14 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:a03:114:cafe::28) by BYAPR21CA0007.outlook.office365.com (2603:10b6:a03:114::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.3 via Frontend Transport; Mon, 21 Aug 2023 23:31:14 +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 MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:14 +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; Mon, 21 Aug 2023 18:31:11 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 6/8] x86/resctrl: Move default group file creation to mount Date: Mon, 21 Aug 2023 18:30:46 -0500 Message-ID: <20230821233048.434531-7-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E5:EE_|MW3PR12MB4507:EE_ X-MS-Office365-Filtering-Correlation-Id: e46223a1-3bd2-4675-2604-08dba29eb5db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j0JJ4YJOHFAwBlE9DMLNfzag7esFZsHpj1CZuHWd5EFnohvrraelrLY0j/0iZ9Ry9xU8JQcEKVb6WWzehj8P4jyAujdFpZPxKBUdCjr55q3WfPdRdO/kr4BTZPy/na7LlUGLG9FYiAhjEwSvaOl2MwlxoC2+wFRJrj8oGDFk/1mbmBbIXd82HXsQRp5pCiatveJauR9UYN+p4eiZWcVT16WquxgrO1Pk+79IFmhdWxI6chcoebQ5r0RXtgUrMtsm+eBLLQEAMOY2QAshnydwo34EKP8wcYsX4BYI/o8kpggZW2prlkbe0T8PilAIELyHSvjtb4kqt12rh3PfN/7Xo6Xh5XTiN/QzEe2zSGSx7fdTR4anRxO/ygdV+lIOizLsIH3QXcGaztSk2x/bHUSwKuh5Nn5Gt/lRcMTQrEGyqeIt96Ie/gWm/Wuhk8xvNYXBBftUlGhBsD5de6d2VAHPy810pm78Au0S9wdt5FQOhgaMjlUxLsZDzCFeJhH/VcPN8GWzv/xKLNwjZSKoYXJNtmU7yEWQ5Etzod0zUwwn5z5eqmdP6A6X3LX738DNqgOD+uOTO8/mWZzixVqhLHG4cAqnFkr32yKMmJZuSUEgCFutXI90VQGEtO2HIfoO99T8aqfdVTIRqv4nMPNbU0+mvJn0FDkHfBlbRCTMIym6isG90HZz4YnoifYAAiVeXohHeYO6M5JixwoFqHPPXi0sgtrj+s5SfH6gmq8pWZXP69gZcLaSk7KMKRqF+mqk0TfkEJbSYTs8slcq51e5Zs3T3A== 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)(136003)(346002)(39860400002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70586007)(70206006)(316002)(110136005)(8676002)(8936002)(2616005)(4326008)(1076003)(36756003)(41300700001)(40460700003)(356005)(82740400003)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(7406005)(7416002)(86362001)(7696005)(47076005)(36860700001)(336012)(44832011)(426003)(5660300002)(16526019)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:14.0909 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e46223a1-3bd2-4675-2604-08dba29eb5db 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: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4507 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 55 +++++++++++++++----------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index b09e7abd1299..44ad98f8c7af 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -611,5 +611,7 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init thread_throttle_mode_init(void); void __init mbm_config_rftype_init(const char *config); void rdt_staged_configs_clear(void); +int rdtgroup_setup_root(struct rdt_fs_context *ctx); +void rdtgroup_destroy_root(void); =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 80a4f76bc34b..98f9f880c30b 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2516,10 +2516,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(); @@ -2528,6 +2532,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; @@ -2584,6 +2594,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); @@ -2654,7 +2666,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; @@ -2824,6 +2835,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); @@ -3705,10 +3717,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) +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, @@ -3716,6 +3726,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; +} + +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; @@ -3725,19 +3749,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) @@ -3859,13 +3871,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) @@ -3898,8 +3908,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; } @@ -3909,5 +3917,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 Wed Dec 17 10:59:03 2025 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 2551EEE49AC for ; Mon, 21 Aug 2023 23:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231800AbjHUXbx (ORCPT ); Mon, 21 Aug 2023 19:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231778AbjHUXbt (ORCPT ); Mon, 21 Aug 2023 19:31:49 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2080.outbound.protection.outlook.com [40.107.95.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3CDCC3; Mon, 21 Aug 2023 16:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtNyQaqf3Yz7cvmVE3SnLa3V0Yulg90kgGAHPkcI7k+FeyxjVaogPyiSYQC/R2hV2P+0IB7wpg/gkLbT2hl6ppCsT8KPJorryfWn4ArZxHHsOwqYxudj8tocQCJC3sjSv8eah+JwmN9DyuJIAyYOikeODS5PFF+NvEtHtVHn0lWfatbgWyPEqG8GWd4FVJ0DranEQ4uAwH3JaODo8CaVwl7oJaNuNDrn/gR93xx1pHEgeY535wZDw7haC24I6/O3fIeNJfURl+TV7cjSN8oPjoCHoOF5epqOj5Zu7VNnoBDQNGhQK2Kw1EqNFqhdLgjObJr9Jp6WMXI03XgXAYgFXA== 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=ix4QNRpJw4L1QShqOhzE5LKToWjyw1ffu2sR4ovlY1Q=; b=cJGR21WsesdsCzXJq30vpnj7rbZcvXxX5MrUnskgO3v+NX+zUrleOMAk2XUENcsIKPYdqmrOt/9DkU8ULTSgrFiux7KWzdzDj8EdTJW3mP6iss9I5UMVJ3shZiNJaYmLMdaCNRfFaZPU8hJJyjSDFQOktjbEVayrnj0xU+5J71vQKphMcfq9ENlVlGEvTHRFcM4RvxmAOIRY7xh07TvQ+HC4Zu7P625stxchsPHvNiDU32SaAvKG7PZse6IF8XtSSnNvuimmqzWyxsaDrWNQU5w3iPohsXJ8jooPpru2aSTveEAgzarkShfzAxZWxQJa4MbLA7a6/8FxswMsMQ01mQ== 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=ix4QNRpJw4L1QShqOhzE5LKToWjyw1ffu2sR4ovlY1Q=; b=MM9ARYF2xhfoKltRWL/9p6W1x67ZYzl/VEHVIkJ5Y2lNCKHCtcEAnL7zk/GV1U+lYkqGD0+X3Qm37QtwVkwrAXk1viW5OBp9heJZ8d7Y6AVVKtVBl4upESAAI1Aw/o4+5K4oTJG+vmM4bsWpbzm9muZu9zUJHG2YwWxvTgzyvx4= Received: from BYAPR21CA0022.namprd21.prod.outlook.com (2603:10b6:a03:114::32) by CO6PR12MB5473.namprd12.prod.outlook.com (2603:10b6:303:13e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 23:31:17 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:a03:114:cafe::69) by BYAPR21CA0022.outlook.office365.com (2603:10b6:a03:114::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.4 via Frontend Transport; Mon, 21 Aug 2023 23:31:17 +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 MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:16 +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; Mon, 21 Aug 2023 18:31:13 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 7/8] x86/resctrl: Introduce "-o debug" mount option Date: Mon, 21 Aug 2023 18:30:47 -0500 Message-ID: <20230821233048.434531-8-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E5:EE_|CO6PR12MB5473:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f04ad7a-399c-4809-27d2-08dba29eb781 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /2HznhTEszLfDDnxNCmpz+8pehJMOCQNE+FOC9g9o9ro+fEt8bglIuNe6N9flMA8chxwcTlr1e1W5jTTy86+LS1HlsCtnxi8AnejQAV5FMCgJZA9Qljx8gqPB2kxFBcv7D+xZVKG8LvVfL7+zllRvMEeL66afiL/ReppzvchkbwmNsIgfbPvzEjPWUNkETICLhXRFaF0XD6w+o2K36gh6h1fA1FqRgfme1uO/2SHhED4VHrpKMHsLTYgLNadBFPM2dRDBkmPtUlX1gcLh3hNHkWFel2B6Nm15q+8VyRH+qi2slmSvyy/tSwpqAxaqFBjDND4p5ob1pB7mmD+yrj9HWTTXoFGmbd9nHCrTkkaq2xekv7hNP/PCzscjjBhHgU8623L3XKAgvxv4phLeYeqzHZpliZ6ELbrbRNWIRD9weADDJhp+dYg6F5vRp1uuR4AmKV2y7Cl7VtRYO9G4c7ITlMDUTG8zLX8fAMzgAj2fc+bVZ6PPIJxJKwJGNOXvKlAyHvk8BTlTza13pjsjOq1wJe8Icj3Me31+r29CwcFS5CRmOHst/zp4vFIEG7bnsKUAFxQLHVSFkGEW+tGvtWXQH/wNBWFjQqYgbq8F6cfGx7pGBvcB+2JNgw9wryvS9U1kOzOvpSXkqe4yLNBFmfjbwLGfNQC9qbAPROeSzFuiik9M13lCw/SO1PlPJ/jIbRL4iT0nDCJGGSWvdF03n5MgVBKkI+/yeL9i842N4oBNMbVyXXQs2pabW538nug4YK0ql9Hhj3LEAWXnEA7my4Vnw== 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)(136003)(346002)(39860400002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70586007)(70206006)(316002)(110136005)(8676002)(8936002)(2616005)(4326008)(1076003)(36756003)(41300700001)(40460700003)(356005)(82740400003)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(7406005)(7416002)(86362001)(7696005)(47076005)(36860700001)(336012)(44832011)(426003)(5660300002)(16526019)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:16.8565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f04ad7a-399c-4809-27d2-08dba29eb781 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: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5473 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add "-o debug" option to mount resctrl filesystem in debug mode. This option is used for adding extra files to help resctrl debugging. Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre --- 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 af234681756e..5a2346d2c561 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 44ad98f8c7af..2fae6d9e24d3 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) @@ -306,6 +307,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 98f9f880c30b..94bd69f9964c 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -56,6 +56,8 @@ static char last_cmd_status_buf[512]; =20 struct dentry *debugfs_resctrl; =20 +static bool resctrl_debug; + void rdt_last_cmd_clear(void) { lockdep_assert_held(&rdtgroup_mutex); @@ -1871,6 +1873,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); @@ -2379,6 +2384,8 @@ static void rdt_disable_ctx(void) =20 if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl)) set_mba_sc(false); + + resctrl_debug =3D false; } =20 static int rdt_enable_ctx(struct rdt_fs_context *ctx) @@ -2403,6 +2410,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: @@ -2607,6 +2617,7 @@ enum rdt_param { Opt_cdp, Opt_cdpl2, Opt_mba_mbps, + Opt_debug, nr__rdt_params }; =20 @@ -2614,6 +2625,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 @@ -2639,6 +2651,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; @@ -3707,6 +3722,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 Wed Dec 17 10:59:03 2025 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 D2B0FEE49AA for ; Mon, 21 Aug 2023 23:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbjHUXbv (ORCPT ); Mon, 21 Aug 2023 19:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231759AbjHUXbp (ORCPT ); Mon, 21 Aug 2023 19:31:45 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2069.outbound.protection.outlook.com [40.107.92.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F02FF19E; Mon, 21 Aug 2023 16:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YHQjjeV/WJT9/1QVif6mEEuW/s2c/70/sCTRDFqale+4YJFW9MRLJGUGSiU56MsH1V+GyugXFHgb4hU/qt6YrjvPv2kojJxhWK7ioXxuWJGKo5CLPEn7bbXFm1TpD59xzm1aXHOiCxQJPs/8H8Xmtz5aIVQKo4ZBRnspb8LBRy6U/1hErwRmwvRLNioXqKriigZgy2JQ/WYQUulR7BX1aUtdsAYQ0evTHIl7oy+Sv07380/5d73wmdaAWRqZavG3CRHoWYhZnOh15fEEN/6TEPbX0oqFr0eMM5DhgvnzAGmugLKaOFyGj59LIdxZ8HRL6DnDN/bEswUPoBBywLkCPg== 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=+5JaRJlGzVTLm2l253/kTdU+ipXbVl1ECpEphihZf7Q=; b=fZOQJFKEM107IJv83fwPIMBg9gIKZ//cIoQLHZAlYU16ux/sPjetk/eJ+lqawO1mQyUmNw3qZlaZ7CFUcS+AR4BrFIpWur6zISs64Ti3yWDCOFz5csnuRiBl5QqjvJphEZU3qYgyueMJaB/DH735WLfvnZUg5Ktm+ok0QHpNqEbFIcaMoK9Ncitmzj5CINKEC4ma5tQ4mo/Q0e1K5Wyn3Drl5wTBQtdxzRTpLow1/fTS2LoqBtZoFAPtFj2BhdnM5HQIBilb53FQyJtda0UixoMFjZv4HHhw8vSb2NdnI+6lc2IBLaBI8bqxdL6iGKxXq4QVlj7QnXugwkJyhY74yA== 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=+5JaRJlGzVTLm2l253/kTdU+ipXbVl1ECpEphihZf7Q=; b=fiN/+YneJ/2bTH+0WbmAhbqXUOWdwuW8Qat7tsIZ0dZ446aRkfCMu+RF+we9RP7blZo5Wb6Yysxnx6XYvbHmIUKxmYfsSjc59oS+52M9JAt+wBTNVHhGAh/Tdu5AC1MK2avrg7+HiYOz9voUYvNuDQ+0IfyLYUSjG2j6OI91MgM= Received: from BYAPR21CA0017.namprd21.prod.outlook.com (2603:10b6:a03:114::27) by LV3PR12MB9354.namprd12.prod.outlook.com (2603:10b6:408:211::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.31; Mon, 21 Aug 2023 23:31:17 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:a03:114:cafe::6a) by BYAPR21CA0017.outlook.office365.com (2603:10b6:a03:114::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.4 via Frontend Transport; Mon, 21 Aug 2023 23:31:17 +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 MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Mon, 21 Aug 2023 23:31:17 +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; Mon, 21 Aug 2023 18:31:14 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 8/8] x86/resctrl: Display hardware ids of resource groups Date: Mon, 21 Aug 2023 18:30:48 -0500 Message-ID: <20230821233048.434531-9-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821233048.434531-1-babu.moger@amd.com> References: <20230821233048.434531-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E5:EE_|LV3PR12MB9354:EE_ X-MS-Office365-Filtering-Correlation-Id: 5425fc69-3ccb-4493-5f14-08dba29eb7d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W2EYCSbynyH3+ZEfijxj9nTKO7iEXt4OXv7ri96oFEu95VgdxuMpdIAX5sm5BvoYJp1j2fW1u5LnMyoaQBUp8iQgHWhCYsgI0WK4Ck6XNxF+h/fPcT/isnyDxpj287Ns2IrMKqqHf21L+gllx3Oic4Z/X6mP6t4VcCViwXUDfDd4ZTqXYuDJuroE2Hxcd52CemkgBDLaKusZUdM8YFvrAYqZ3Z/0M0funEGK0uum0yEYrlj0vqS0ogkdlUm/oDv9em//HjCDZinumZRSXkZD+fWikdNVd6KAnqY/vqbCjo5/GZPC5buScPFn1yxvDfYYJuF7JQ6Tjti7LfnW0eO/8LDckmLvN9gecV1uBzc83CJmChtS9B1CI6xERJYwkoAvNAtd9/FzMsDJl7w99pzHHKJNs9RR5e0lRBqERXV6tmJoJ9c542N+KByOw+QVpkggy4D+qh91XSABQl6RLzi1VUGjCUhFS0GUIjQ86gbAOTHCwsjQho3AxqCkmmcoWIyAJ7a6gw3I7JAspm9NUWnh+5suephfgZS0PUl9Ci/sopszSCC+R7gIJUWa6zYFhO3EB7VqHzKCP+UxdCv7bZn7mgi0mlt7bT/M53WBpERnOW7QAH6NBiSmZBQJObnwf5GjJbg3nnDSXs0ndk5H+eniBMy49R/4TrVK5MLmLOP9VYds+ERgT6yq6yVtmi4JSerjCzrGiNTMUTtg1v87GY68i7hURUxCLCgrftHpgtuZ9ys6rJEG6F3Hiaxmv5y+9IosZjuiO5rxzlIt/CfBG137Tw== 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)(346002)(396003)(376002)(39860400002)(82310400011)(451199024)(1800799009)(186009)(40470700004)(46966006)(36840700001)(86362001)(82740400003)(36756003)(81166007)(356005)(40480700001)(2616005)(16526019)(44832011)(110136005)(70206006)(70586007)(478600001)(316002)(7696005)(6666004)(54906003)(4326008)(5660300002)(1076003)(8936002)(26005)(8676002)(41300700001)(40460700003)(2906002)(36860700001)(336012)(426003)(7416002)(47076005)(7406005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 23:31:17.4347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5425fc69-3ccb-4493-5f14-08dba29eb7d9 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: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9354 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In x86, hardware uses CLOSID and an RMID to identify a control group and a monitoring group respectively. When a user creates a control or monitor group these details are not visible to the user. These details can help debugging. Add CLOSID(ctrl_hw_id) and RMID(mon_hw_id) to the control/monitor groups display in resctrl interface. Users can see these details when resctrl is mounted with "-o debug" option. Other architectures do not use "CLOSID" and "RMID". Use the names ctrl_hw_id and mon_hw_id to refer to "CLOSID" and "RMID" respectively in an effort to keep the naming generic. For example: $cat /sys/fs/resctrl/ctrl_grp1/ctrl_hw_id 1 $cat /sys/fs/resctrl/mon_groups/mon_grp1/mon_hw_id 3 Signed-off-by: Babu Moger Reviewed-by: Fenghua Yu --- Documentation/arch/x86/resctrl.rst | 8 +++++ arch/x86/kernel/cpu/resctrl/internal.h | 6 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 46 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 5a2346d2c561..41ad9b1f0c6a 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -351,6 +351,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": @@ -364,6 +368,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. + Resource allocation rules ------------------------- =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2fae6d9e24d3..3fa32c1c2677 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -296,9 +296,15 @@ struct rdtgroup { * --> RFTYPE_BASE (Files common for both MON and CTRL groups) * Files: cpus, cpus_list, tasks * + * --> RFTYPE_DEBUG (Files to help resctrl debugging) + * File: mon_hw_id + * * --> RFTYPE_CTRL (Files only for CTRL group) * Files: mode, schemata, size * + * --> RFTYPE_DEBUG (Files to help resctrl debugging) + * File: ctrl_hw_id + * */ #define RFTYPE_INFO BIT(0) #define RFTYPE_BASE BIT(1) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 94bd69f9964c..e0c2479acf49 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -776,6 +776,38 @@ 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; +} + +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 /* @@ -1837,6 +1869,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_BASE | RFTYPE_DEBUG, + }, { .name =3D "schemata", .mode =3D 0644, @@ -1860,6 +1899,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