From nobody Tue Apr 14 09:22:33 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 B86CBC4708E for ; Tue, 3 Jan 2023 22:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjACWHm (ORCPT ); Tue, 3 Jan 2023 17:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238343AbjACWHF (ORCPT ); Tue, 3 Jan 2023 17:07:05 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB22F008; Tue, 3 Jan 2023 14:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aMMmVzKWFg5GMBI2k9cfPAJcUTWFOYSjuFIgWhCY3tI7iBx+aWzEz4sG/jVwA3+Zr994tOp/3eg0wEzAzsK4M46I0nXr2Kq+wbv6VY3F9vBpEp4axD4h7ity36GfMvhCSz7zDf2Wcgq4f4lIqR5KM80sA3zRHei2B557p9qrSUwI7eFAKIrjKHwPakBJMDWYnFMG0coBoU3IpAZizyacWjXqeRK7AmBg9O1cNoW4txFNzjj9ssT07WqKj5ppGAS0B+I66ZHBkrD8or+Txv0+DIhI50zl0nCzT9ypYGLqCFedsNNiLgzk4gv9MD1LHEAlCI/CY6/FqPVyxMGSXQXUxg== 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=XGoGdo5+YBuE6uAlKVq9zY0tvuT7OvAW/M2XeRWX/o4=; b=lXeja4ARC1lKpvjELpKgSRHm+OvkOWTQaP/VhpR9Rsq8gKG+PfXOW5AEyquB0T0QeAvrUP+fipgrDxeuAXGnxCV884MYf1TDvlLvfHv+YdJBSOCsIl7A93tzlObKhf6mPZTm2KpeyCLh0hT+66XB4F/+6OT7NxQw0/0gvR+fqincH3CuOloXt/Ea28vvU7zqD7V0hiC8xbEpmRoKe1HJbnbDMdn5KTZUzLuufDYDBHdVsIE+C2JJZAjiBvmwxNL3KyZasKeLx/6ySPTgR6GSuKp0nTO6KsAX8zgvXYayyA+xP3backtOlszgtiwhWxCOnZ7CsgS1EskV+c3ga0seDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XGoGdo5+YBuE6uAlKVq9zY0tvuT7OvAW/M2XeRWX/o4=; b=C/Ql8vcBnZRD8McJbNqOBK7B06Ruf7mfOUSgv6Kcx3T/voqP4+vtJbHxL0borjGhnDnjrx86qwyUWwfBgv2RbgGSF1sTvplnYxlY6e3cQrDxpqMJ+JpfAwwLVo/3hyuhcoaA4Clqb7DgmtkBJjD17+QgSis0QXzTMPqdb9t/6Lw= Received: from DM5PR07CA0110.namprd07.prod.outlook.com (2603:10b6:4:ae::39) by CY8PR12MB8066.namprd12.prod.outlook.com (2603:10b6:930:70::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:06:37 +0000 Received: from DS1PEPF0000E645.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::33) by DM5PR07CA0110.outlook.office365.com (2603:10b6:4:ae::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.19 via Frontend Transport; Tue, 3 Jan 2023 22:06:37 +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 DS1PEPF0000E645.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.8 via Frontend Transport; Tue, 3 Jan 2023 22:06:37 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 16:06:35 -0600 Subject: [RFC PATCH 1/3] x86/resctrl: Add multiple tasks to the resctrl group at once From: Babu Moger To: , CC: , , , , , , , , , , Date: Tue, 3 Jan 2023 16:06:35 -0600 Message-ID: <167278359522.34228.17439739885350817510.stgit@bmoger-ubuntu> In-Reply-To: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> References: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E645:EE_|CY8PR12MB8066:EE_ X-MS-Office365-Filtering-Correlation-Id: 41f26d17-a2b6-4a1a-74d1-08daedd6c8c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uZEsVfrM5HH8l6khSVSPNVOEpBNxdThYo4HMJ0ox01fJy0G5sfvpc0PhW0izXucLFZeWKt0/OL4cGMpx3zsH18rWJpSaWyIMATRGqoulafIQQOfc7vzfRTVKuyhWNHMHGu4rer03VFRHAtFmN+tTJk/I3J8jlbvoTuGpMTey1qRNs0YApOpQ3Di/uZt2/gJjdWU9PktsuVRYFzVQOM7YYK8ansQjbn+H6nvHNvpC4Eg0LTDWONONuorjkkJp6LlAXhumikjQisnZIdeml66bGXCVMGd7c+LZkDwTh+apv8/S9XVA8uGhzYu0JVsLGU1bWD9rMAoUQqvc5mRPNcVn7o+eNPK1SkY7ggZjV3K79wcXlVkiHWieMcdFnXTfDfMLjGTiCbJsrWEvWutC0bo31lniO3O0jM9iiUDWw/fOfMJKETvsdHMsI1pOALuQ6uD+v9ahhRQ9krXzGXYfx3ErxRBHzfn5/EHHjutuu7n2gyW48hJlI8Ksa6nGJBY2FKSpsWtNIgRb4OENnAkqCqA9BmnOMc9fV7sY6fWgex7Cokfr8XfF1/YVgoZqDrmJDWoHQNUqc+0QQmqcSd0puszxb/N0OzH4JUWPy0dUWWJyPpP4H4iE4Otn+XbcYadUCJH36n88D0wKU7Wl8CwRDCDgAgjH/UvnDyHH6T/bp8rR4KH0wSAa72PCCGPzPyyaS+4PcjsVqh8MszY1nICftthypubZz6Gr0Z2vDtjWWxatUjpA92NVxJIB0hNeQ96achT6qwjbv3H0OZSMhLDgY513WWtyZKT6WEjdULF4TKj4Y/8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(7916004)(396003)(376002)(136003)(346002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(5660300002)(2906002)(7416002)(44832011)(8936002)(8676002)(41300700001)(4326008)(66899015)(16576012)(316002)(70206006)(70586007)(54906003)(110136005)(478600001)(9686003)(33716001)(82310400005)(336012)(26005)(16526019)(40480700001)(186003)(426003)(83380400001)(47076005)(103116003)(82740400003)(356005)(81166007)(86362001)(40460700003)(36860700001)(22166009)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:06:37.2798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41f26d17-a2b6-4a1a-74d1-08daedd6c8c6 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: DS1PEPF0000E645.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8066 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right now, the resctrl task assignment for the MONITOR or CONTROL group needs to be one at a time. For example: $mount -t resctrl resctrl /sys/fs/resctrl/ $mkdir /sys/fs/resctrl/clos1 $echo 123 > /sys/fs/resctrl/clos1/tasks $echo 456 > /sys/fs/resctrl/clos1/tasks $echo 789 > /sys/fs/resctrl/clos1/tasks This is not user-friendly when dealing with hundreds of tasks. Improve the user experience by supporting the multiple task assignment in one command with tasks separated by commas. For example: $echo 123,456,789 > /sys/fs/resctrl/clos1/tasks Signed-off-by: Babu Moger --- Documentation/x86/resctrl.rst | 13 ++++++------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 35 ++++++++++++++++++++++++++--= ---- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Documentation/x86/resctrl.rst b/Documentation/x86/resctrl.rst index 71a531061e4e..f26e16412bcb 100644 --- a/Documentation/x86/resctrl.rst +++ b/Documentation/x86/resctrl.rst @@ -208,12 +208,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 - 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 - group. The task is removed from any previous MON group. - + group. Multiple tasks can be assigned at once with each task + separated by commas. 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 group. The task is removed from any previous MON + group. =20 "cpus": Reading this file shows a bitmask of the logical CPUs owned by diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index e5a48f05e787..344607853f4c 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -686,28 +686,49 @@ 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) + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { - rdtgroup_kn_unlock(of->kn); - return -ENOENT; + ret =3D -ENOENT; + goto exit; + } + +next: + if (!buf || buf[0] =3D=3D '\0') + goto exit; + + pid_str =3D strim(strsep(&buf, ",")); + + if (kstrtoint(pid_str, 0, &pid) || pid < 0) { + ret =3D -EINVAL; + goto exit; } + rdt_last_cmd_clear(); =20 if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED || - rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { - ret =3D -EINVAL; + rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { rdt_last_cmd_puts("Pseudo-locking in progress\n"); - goto unlock; + ret =3D -EINVAL; + goto exit; } =20 ret =3D rdtgroup_move_task(pid, rdtgrp, of); =20 -unlock: + goto next; + +exit: + cpus_read_unlock(); rdtgroup_kn_unlock(of->kn); =20 return ret ?: nbytes; From nobody Tue Apr 14 09:22:33 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 1F8D0C3DA7D for ; Tue, 3 Jan 2023 22:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238565AbjACWHt (ORCPT ); Tue, 3 Jan 2023 17:07:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238426AbjACWHG (ORCPT ); Tue, 3 Jan 2023 17:07:06 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1B2E026; Tue, 3 Jan 2023 14:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jXDhfEPUP+BTDEHaj997Dv7PHhX2Jk1EwY+uwHVESX0f63Wb2rcDewiLRhYQCk1B+JqBr9dyfCB7l5PLhe6CKWaeYTn1cQNMPdZzTpe2ZnV1UCEfbm/egmDiZDp/oOXx2madVL24RDRm0qEdS3IcyV8hbI1QK5ITrydwGPFOK6JxSfT4mXYIkrAlMUJe9Y1M20Z1u1gU/PhLajWhkgKj5BinO2AA6YJaci8Y3rpw7upZudEe4xuz/kV+ANw4hcrYZtKcb/VTxg8UducCNmPwHNaxWrLAPv0U7GcW06jqtzdCrebikX0ji3DxXdftGi7mIunSVVKgxfdYnWdYgcb9lA== 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=pf+NVcrXEfYCXvA+xTtaovDfj4mw15ywKxmSHmquV6I=; b=eeiaDtouvPxoTRXC8wpgzh8mxz3EEvggA7qPJpennZzScwcP5NJ4bMtRvHLhyDvCQuGFF5pRMPI4+rumSF1/UWl4tebp1mr4GwGQBlzs1o45PPyuNPqnovNQJeaysGzNNgoE1cL0LlMAvijp+M5FgnfYgF7a5ArbePywmsdXWpt6CSr2zyI+sgq2XfJ9AIrlly9mMchBgrRrIsi4oMDprVDsaqGwH38Ntbe6VkCU/StULetWELfReGkQU97LFnLlCsyG6UaR81kFXJxscPdLeOl8mMBUOHWpt5Pgc2d41ZfYDnToY9pw2+bUQ6/pdIl75uMcSGgt7jiS+QQmDAORwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pf+NVcrXEfYCXvA+xTtaovDfj4mw15ywKxmSHmquV6I=; b=2xjTjSoe7K2BKPoo4dbGfJkotpD8mtS0ePy6xlqxXYDrR+zC6zlRSSHt1Oa4ayqeSwdKjen1+iDDuoBLDKKsP91UmqtMcFQLGlbV47DIitGXDoT9xKgOz0GU9BY3UIeqGjSAKwbpIWEuyffA76lgNr2Omu5BHRnNGcX633yxVws= Received: from DM6PR12CA0036.namprd12.prod.outlook.com (2603:10b6:5:1c0::49) by DS0PR12MB7948.namprd12.prod.outlook.com (2603:10b6:8:152::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:06:48 +0000 Received: from DS1PEPF0000E63E.namprd02.prod.outlook.com (2603:10b6:5:1c0:cafe::a1) by DM6PR12CA0036.outlook.office365.com (2603:10b6:5:1c0::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.19 via Frontend Transport; Tue, 3 Jan 2023 22:06: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 DS1PEPF0000E63E.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.8 via Frontend Transport; Tue, 3 Jan 2023 22:06:48 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 16:06:47 -0600 Subject: [RFC PATCH 2/3] x86/resctrl: Move the task's threads to the group automatically From: Babu Moger To: , CC: , , , , , , , , , , Date: Tue, 3 Jan 2023 16:06:41 -0600 Message-ID: <167278360189.34228.2442698916556329960.stgit@bmoger-ubuntu> In-Reply-To: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> References: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E63E:EE_|DS0PR12MB7948:EE_ X-MS-Office365-Filtering-Correlation-Id: 1389525f-b800-487b-26ad-08daedd6cf90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aRx0cpDZTUwfL9QtUuVAoDVfah3WwFZTL22E4WX/leA+h17Dt+fPlRXzIxpmZD+qojfl2XlfUnqaYqNQVRsY8WwOfhlmRkXNOa/D+R4SzFzvDHNbm1lSJ2AK9OUxqCWz6CqCiZz0XvOKHYbmXJumSACiTNl/b6rObTTlgJkTnRTjjiKn4ewmvA2kqcAZk9FbN6egJnuLdYEi6HFOaccgI8E53ybKIl/3xBH6IL/SgW8+ukkADjhf7tKeehAKy+KCl4DPeANY3kEbD+YJlolMe1KxLFGS0KqD3L4suPhU3as91kTVUJkOvLOgibJNSn//Y0W5LLLYdI5qbK2ErMiecXHbAQDEgt60iG/rjHYkMaxTCQl/wdeJfmsC8ygKkfhTvdpeXnpEcP46v13/RkE8EPl0oqAnjK5YetNl9EUlfetJ11bdOnnoITDZJbdXLv3TI8SzXT2jfru3ikUR8FLYFn/arCXBE39/Y1anFKRJAbOUqm/WrXiKhwAKFawPy7XMp6CG0LMOBkv3cFlIgbw5oP0wiAhS/SNtW7A8cEMzdTMVBjkfg3Ztt/K/mDtyqI78tXp9VFz+6uGX5HocI6y3v8biAWnUuSGAWEw707gA/SQmpeMsQvQFn7mrPlX6FuEmp2A14jZQuYUm4yP8sJwB6V+SbwzhVoF7TVLq9PD41RCNZdsQY5ckMV217Q4XSEuYSYx9wCJrLZqZ+avURUjcwzVayj/c5J8UND97U7THhTGES0F5VGgA+Teh5y+HDDsgR5UGcPArclbO+x5hMX4wmENE/MTs6AI1CFQSTFRz7zU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(7916004)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199015)(36840700001)(46966006)(40470700004)(81166007)(82740400003)(356005)(103116003)(86362001)(70206006)(70586007)(8676002)(54906003)(4326008)(110136005)(41300700001)(82310400005)(426003)(40460700003)(7416002)(16526019)(40480700001)(2906002)(5660300002)(316002)(8936002)(16576012)(9686003)(336012)(47076005)(44832011)(83380400001)(33716001)(478600001)(26005)(186003)(36860700001)(6666004)(66899015)(22166009)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:06:48.6680 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1389525f-b800-487b-26ad-08daedd6cf90 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: DS1PEPF0000E63E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7948 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some micro benchmarks run multiple threads when started. Monitoring (or controlling) the benchmark using the task id is bit tricky. Users need to track all the threads and assign them individually to monitor or control. For example: $stream_lowOverhead -codeAlg 13 -nRep 100000 -cores 0 1 2 3 -memMB 32 -alignKB 8192 -aPadB 0 -bPadB 0 -cPadB 0 -testMask 1 $pidof stream_lowOverhead 6793 This benchmark actually runs multiple threads underneath on the cores listed above. It can be seen with the command: $ps -T -p 6793 PID SPID TTY TIME CMD 6793 6793 pts/2 00:00:00 stream_lowOverh 6793 6802 pts/2 00:01:25 stream_lowOverh 6793 6803 pts/2 00:01:25 stream_lowOverh 6793 6804 pts/2 00:01:25 stream_lowOverh 6793 6805 pts/2 00:01:25 stream_lowOverh Users need to assign these threads individually to the resctrl group for monitoring or controlling. $echo 6793 > /sys/fs/restrl/clos1/tasks $echo 6802 > /sys/fs/restrl/clos1/tasks $echo 6803 > /sys/fs/restrl/clos1/tasks $echo 6804 > /sys/fs/restrl/clos1/tasks $echo 6805 > /sys/fs/restrl/clos1/tasks That is not easy when dealing with numerous threads. Detect the task's threads automatically and assign them to the resctrl group when parent task is assigned. For example: $echo 6793 > /sys/fs/restrl/clos1/tasks All the threads will be assigned to the group automatically. $cat /sys/fs/restrl/clos1/tasks 6793 6793 6802 6803 6804 6805 Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 344607853f4c..0d71ed22cfa9 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -685,6 +685,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgrou= p *rdtgrp, static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { + struct task_struct *task, *thread; struct rdtgroup *rdtgrp; char *pid_str; int ret =3D 0; @@ -723,7 +724,13 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open= _file *of, goto exit; } =20 - ret =3D rdtgroup_move_task(pid, rdtgrp, of); + task =3D find_task_by_vpid(pid); + thread =3D task; + do { + ret =3D rdtgroup_move_task(thread->pid, rdtgrp, of); + if (ret) + goto exit; + } while_each_thread(task, thread); =20 goto next; =20 From nobody Tue Apr 14 09:22:33 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 32F55C4708E for ; Tue, 3 Jan 2023 22:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238583AbjACWHu (ORCPT ); Tue, 3 Jan 2023 17:07:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238527AbjACWHK (ORCPT ); Tue, 3 Jan 2023 17:07:10 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A487D15FED; Tue, 3 Jan 2023 14:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPzJYiRuuHQpXNxujpGY89+LiQRfLvnczRqPxhKOPIka3zEku98MatPU/ampy9wOw8rVjTfGf5jHO2WTfZXS7ARM+qOrJGut7OC7BbTYkfDkF8KOxFxZ6QhSrPHCOfuKQkQyFlFKlxJGU9jExkGuToCqvYu99e2IRh5kc/iqSFP/7BcIkb/ttPPJT7FG8GaY5RexjOv+auQ6BO/FveAx5ojhsSIvvfIvNEzqFf1NUflixtqXDdFJMq1t229KKMo0MM0aHgtRT5JxIs3/6cVO14Qmwevvy+JQMzMzk6Vjl1TlSMma276GE0QFfCuqaqrBKiXn7EI9t5u3A0Vrq4ymXw== 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=/7qtJrEoGp8AP6Vo7LCbs2EEQvG7I8yvIULPC360r3w=; b=XcXYR1JXQ+QGrMFpgJ0gvTNKAg0h4EkNV3hECDxk7KHIvLZDe2xQrJUVUSfxJ3h8YfIEAKX7axOGQbS33mOUgtlVQZdWf/JSyxvAN+0CRFCBh9AoPpfmZvTebN5xVbmv0kIJaKBaC4FhcX9xaneP9ut6w9Ha12wCCplp+LrKRjCEvoZe2N80kbZ/RgqQJ5OHcC/mg6g0UXw2bWpw2/ySuOgQUtjrbLgkzAx3O9ex/0pwFTdFSaPGSYBjiVRcxBB9Pu//g0bzy3EaHlNIGivba397o8YqILK2e8AwtMRBW8xDXanQVpFztAJR5xK8DNxRKJw/tSyBaz11ckq+WwvreA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/7qtJrEoGp8AP6Vo7LCbs2EEQvG7I8yvIULPC360r3w=; b=hHASKWSDMiEvCkRCDj3wLHEdXJ6km+uY7a+PsiEWpKa3MMm8uOrWqDWVphpdMotmEoL5dgebo1ek6+FddhGgS4LyTRU03wymAtXKm2YBIoP/l+qY3KxG1lA9uSvA3DftYIBDRk3Tb1w0CN4ih9vMiQQq0dhhYsIt2Yx//2nS3D4= Received: from DM5PR07CA0106.namprd07.prod.outlook.com (2603:10b6:4:ae::35) by CH3PR12MB7523.namprd12.prod.outlook.com (2603:10b6:610:148::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:07:00 +0000 Received: from DS1PEPF0000E645.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::d3) by DM5PR07CA0106.outlook.office365.com (2603:10b6:4:ae::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.19 via Frontend Transport; Tue, 3 Jan 2023 22:06:55 +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 DS1PEPF0000E645.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.8 via Frontend Transport; Tue, 3 Jan 2023 22:06:55 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 16:06:53 -0600 Subject: [RFC PATCH 3/3] x86/resctrl: Display the RMID and COSID for resctrl groups From: Babu Moger To: , CC: , , , , , , , , , , Date: Tue, 3 Jan 2023 16:06:53 -0600 Message-ID: <167278361325.34228.16916982678071203069.stgit@bmoger-ubuntu> In-Reply-To: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> References: <167278351577.34228.12803395505584557101.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E645:EE_|CH3PR12MB7523:EE_ X-MS-Office365-Filtering-Correlation-Id: 0311d435-4be1-497f-e124-08daedd6d35a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7qkIw5T0LQwSF8QI9+Qw4aDPkRsFHAEauFugseDkLZNvVc/tR/xBQ8ov6Jk1puzGkWiOD5/ZvGJzQAznsLPgwrHdRQsZ70ikPnSvwUFqRQBeZI+nyWA9v7D7rX0wra5bkOrwSulDq1rGN6w36mF/aQDK2TwU7KkBy6ATLoaJPbZwZzzt68Kp2JePQ9vdioPlfacH1CnCkX4b04tHzFNuhYsqZJqGTguM5Us071qT8vskkZaPKANZShDx//eVxLTfr4nqV7faHmRPmOjclavUnPU0sNOosEi4+tPadX7pVQWYbfdOI/Mk9HKQOEOawyzR3M2bEIqxS/Md7qVE4URaIbPQskZ+LuZT1AUa2zr8uRgyyRTzPU//S+C+vKwhkTWjgmF4j+T9mZuGM9w6KoWl0tTeCL7J1jbd5uuRdiwuTzgiua1GHno02JNlkRkZu94Rrgkg3XUntyc62SvxUf5DA+3bHYfrHorr94MFEbcYm1Q7y84GvTZJVQtCbsbt8h6cUmIxTswojLLms3h7F379w6UPEj8Dklg5Mv4ZA8pcbegQLr6CO26yyDZekjmb9aVOG+0ZOZUrSa9uXxvKz0wFWSBUiIE1l1R8wUIc1gAE4hBEF7iEwBElkRZOJK2RjhPuYfZgheuQh5tiR3qFlNhK8dkSR0Qkt3vpkkFD04yFbvmyhjfGzesELRVUpkDeMu5lDL6Wlzu4pC2n8QfoemsZNOCzMBAiy/ng8UpKk/E2FSlm6G4QE8r6dElRkYGC3RVeK8VUgjJ7ECZ9mHm93S0u03TGpVuYD8C29Fhy63SiHgU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(7916004)(376002)(346002)(136003)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(83380400001)(47076005)(426003)(16526019)(336012)(26005)(9686003)(82310400005)(33716001)(103116003)(40480700001)(40460700003)(86362001)(36860700001)(81166007)(82740400003)(356005)(186003)(478600001)(41300700001)(8676002)(4326008)(2906002)(7416002)(5660300002)(8936002)(44832011)(16576012)(316002)(70586007)(70206006)(54906003)(110136005)(22166009)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:06:55.0297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0311d435-4be1-497f-e124-08daedd6d35a 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: DS1PEPF0000E645.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7523 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a user creates a control or monitor group, the CLOSID or RMID are not visible to the user. These are architecturally defined entities. There is no harm in displaying these in resctrl groups. Sometimes it can help to debug the issues. Add CLOSID and RMID to the control/monitor groups display in resctrl interface. $cat /sys/fs/resctrl/clos1/closid 1 $cat /sys/fs/resctrl/mon_groups/mon1/rmid 3 Signed-off-by: Babu Moger --- Documentation/x86/resctrl.rst | 15 ++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 46 ++++++++++++++++++++++++++++= ++++ 2 files changed, 61 insertions(+) diff --git a/Documentation/x86/resctrl.rst b/Documentation/x86/resctrl.rst index f26e16412bcb..8520514bc8b5 100644 --- a/Documentation/x86/resctrl.rst +++ b/Documentation/x86/resctrl.rst @@ -231,6 +231,14 @@ All groups contain the following files: Just like "cpus", only using ranges of CPUs instead of bitmasks. =20 =20 +"rmid": + Reading this file shows the resource monitoring id (RMID) for + monitoring the resource utilization. Monitoring is performed by + tagging each core(or thread) or process via a Resource Monitoring + ID (RMID). Kernel assigns a new RMID when a group is created + depending on the available RMIDs. Multiple cores(or threads) or + processes can share a same RMID in a resctrl domain. + When control is enabled all CTRL_MON groups will also contain: =20 "schemata": @@ -252,6 +260,13 @@ 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 +"closid": + Reading this file shows the Class of Service (CLOS) id which acts + as a resource control tag on which the resources can be throttled. + Kernel assigns a new CLOSID a control group is created depending + on the available CLOSIDs. Multiple cores(or threads) or processes + can share a same CLOSID in a resctrl domain. + When monitoring is enabled all MON groups will also contain: =20 "mon_data": diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 0d71ed22cfa9..98b4798e5cae 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -769,6 +769,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 /* @@ -1593,6 +1625,20 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_size_show, .fflags =3D RF_CTRL_BASE, }, + { + .name =3D "closid", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_closid_show, + .fflags =3D RF_CTRL_BASE, + }, + { + .name =3D "rmid", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_rmid_show, + .fflags =3D RFTYPE_BASE, + }, =20 }; =20