From nobody Mon Feb 9 16:18:10 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 D9188C7EE2D for ; Thu, 1 Jun 2023 19:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjFATBL (ORCPT ); Thu, 1 Jun 2023 15:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbjFATBH (ORCPT ); Thu, 1 Jun 2023 15:01:07 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2070.outbound.protection.outlook.com [40.107.94.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3485184; Thu, 1 Jun 2023 12:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ODfIwWKBvGqiWo2WWAdLUFd0YPpYV1SkAyNj+JCUNnl88Uy7sF/bt9v9zvUQdJOcs4HAmYhgBLncIfNvisljBh175vv3R7EUMym3IqCp7s6d0992EYTuKZgPvYPicO49/7qxeE/sZiZhhC6keVvKFjFiiw5VOtogeAtstPf/H3p1FcsNypQHZbBbCV+ZaA/b9zwG2QOHIPJHP6Pz1/uObIymB8FkuUxZYriTGVkoEgNCq/Mc+5Ug07YpZeUf7WIGoLKtU+lthqYGP3HFhNPQkVwc2NfQjTdOGvOquMW+99NHJRUlz57xczAzef+HXfj1WK24VDKca7V9ftKmHpo1GQ== 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=G+Ri0OnIn94g0sfsasntb/wfY9Ip1jUmxeT1yDBE54A=; b=lME24c35jIEIRRoN9MhjSihb6U8JYPQYdC4hJVNSHuY9as+6GBnXhm2pTRURXqHZRPMeCHpwGLGol0RW54/MpPlzjvTdr2G3j22xMlzU75msR1ky8q902cEPttQ8AeoicmcFaN4GOoN3/uqbbZ3DUasorkeZ28gkCeScd84Jm5pAsuVbXFioJ/ssP1BHrakBEX8jlWgWCXl19lgvMKg8lDs6EO3rLrYRjWQ2uUMuGI0TgBYm0e0QBx7NiPD9abGQHzGlRyyuwy7HQ5NgZU6CSYL3y129a+xpmp5dX8RFCjQoDnCFLONLllbkxC4UL4cBfWXzPjW+coX4VRiwNAR4ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G+Ri0OnIn94g0sfsasntb/wfY9Ip1jUmxeT1yDBE54A=; b=XbYQ4fliniaeKUQY8V98TFNVsOvqAIeBrGY9I1/tvN6AHpMoP3XYXZkvu+TNIscNIThVjU2Vb11pN+Xo3+6x5tDQHjajjBQwo1tDlGai4oKgaxFNF/2NIPml62wmDbELJYSb+w9ornShHOZJ/0+4p/KLAVu0r2vj+vhf5Dd0Q0Y= Received: from BN0PR03CA0050.namprd03.prod.outlook.com (2603:10b6:408:e7::25) by MN6PR12MB8471.namprd12.prod.outlook.com (2603:10b6:208:473::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Thu, 1 Jun 2023 19:00:59 +0000 Received: from BN8NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e7:cafe::54) by BN0PR03CA0050.outlook.office365.com (2603:10b6:408:e7::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 19:00:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT027.mail.protection.outlook.com (10.13.177.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 19:00:59 +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; Thu, 1 Jun 2023 14:00:56 -0500 Subject: [PATCH v5 1/8] x86/resctrl: Add multiple tasks to the resctrl group at once From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Thu, 1 Jun 2023 14:00:54 -0500 Message-ID: <168564605452.527584.8450496267087240475.stgit@bmoger-ubuntu> In-Reply-To: <168564586603.527584.10518315376465080920.stgit@bmoger-ubuntu> References: <168564586603.527584.10518315376465080920.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: 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: BN8NAM11FT027:EE_|MN6PR12MB8471:EE_ X-MS-Office365-Filtering-Correlation-Id: 57b0aee3-8b1c-4b07-660c-08db62d28992 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aBJ63Ky2+pJhpJHP4+xCnHBhp8jah6s4G/xxTJSJOW2KSOanjfAHBekmHFQxEga8TEavzFQiQ1PGjOwP2C5KFwoA7ovGaOYESfIickPgSrVcL/AZsElSFx/ITsaR4xzbfqRc5jDH9Jd5vMWnm8ryqzn6X6AdkGkFOXN8ZO32CeShH/o+d7dRgoSV2MXYB9czBMtNcuHT5Wk2/Nn5UOnZMyrl8pCnxLnZNEXxI/KfGgox+E/6+PovswxO846sLB/zevbQLdeZjL1SIW1T/c5LL7KtJKqsW4VmCa2eMgMRGirg461FuI0hdngHl7ByZ5hJMckv59ZWVao2tP21nmzpOxQsVdOp1zDN6BWtzEsVye54B41VQt1JnEstE1nNhHApY7oo8XB7TattrSbHyAwX7b97o+Tj3OwI7forMwQ8OB5cqJ00obI1vLS8ObLdr3Jd6KbBOdkhU3Ly3VdDXQblWzbSsnH2KYe+iJw5HD3Sxx+/bn9tnHfzhHU4v2HRQ3/alrxyT11bomXr5OpW2VNqNS4n9xVQKfh9MahM1VRZPQzoJBiNYFwtYwaO99XliTpe6ixp56KfXWTbCg02OnGUt2uLFkTDiZHs2WWvqKef+eLZeHMrhyo0aqPtsv9eSIcQ3NxOgq1C5IUXcjJgxyJZ7AP46yiVtDgqR60mpv/rlIoxcs0dtRHgFOpsth5xOTWS/QPk9nrlAttRnjoQ8wkWGs7NH4G6bCK1vGh2Z1X4R6Z376u32IhHm2Dh6r3bCgUaWWmtscHXemaP9HCjhwhekw3UKNsWtW9xVLU7myIgBDk= 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:(13230028)(7916004)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(356005)(82310400005)(82740400003)(81166007)(36860700001)(47076005)(83380400001)(33716001)(70206006)(70586007)(426003)(16576012)(66899021)(4326008)(110136005)(336012)(86362001)(54906003)(103116003)(2906002)(316002)(16526019)(186003)(26005)(9686003)(44832011)(7416002)(7406005)(5660300002)(41300700001)(8676002)(8936002)(478600001)(40460700003)(40480700001)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 19:00:59.3159 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57b0aee3-8b1c-4b07-660c-08db62d28992 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: BN8NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8471 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resctrl task assignment for monitor or control group needs to be done one at a time. For example: $mount -t resctrl resctrl /sys/fs/resctrl/ $mkdir /sys/fs/resctrl/ctrl_grp1 $echo 123 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 456 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 789 > /sys/fs/resctrl/ctrl_grp1/tasks This is not user-friendly when dealing with hundreds of tasks. Support multiple task assignment in one command with tasks ids separated by commas. For example: $echo 123,456,789 > /sys/fs/resctrl/ctrl_grp1/tasks Signed-off-by: Babu Moger --- Documentation/arch/x86/resctrl.rst | 8 +++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 30 ++++++++++++++++++++--------= -- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 387ccbcb558f..290f01aa3002 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -292,7 +292,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 6ad33f355861..504137a5d31f 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); @@ -708,16 +707,27 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_ope= n_file *of, } 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; - rdt_last_cmd_puts("Pseudo-locking in progress\n"); - goto unlock; - } + while (buf && buf[0] !=3D '\0') { + pid_str =3D strim(strsep(&buf, ",")); =20 - ret =3D rdtgroup_move_task(pid, rdtgrp, of); + if (kstrtoint(pid_str, 0, &pid)) { + rdt_last_cmd_puts("Task list parsing error\n"); + ret =3D -EINVAL; + break; + } =20 -unlock: + if (pid < 0) { + rdt_last_cmd_printf("Invalid pid %d value\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; + } + } rdtgroup_kn_unlock(of->kn); =20 return ret ?: nbytes;