Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1201600rdg; Fri, 13 Oct 2023 13:27:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAd51eV0cSpkrzP7XSZet5CJk3G12ONyrbvZi8V5bHWWeRwA9cANdSfeZMpfW6BTGv1gi1 X-Received: by 2002:a17:90b:4c8f:b0:27d:5a7:3960 with SMTP id my15-20020a17090b4c8f00b0027d05a73960mr1696573pjb.21.1697228820834; Fri, 13 Oct 2023 13:27:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697228820; cv=pass; d=google.com; s=arc-20160816; b=KN7scXD3/FymTIpwzZbVlQa6AsLGjk3pKBWuwENlxYO71kiS7M+ogNfDfTOztXUSiW XpNl9xnW4rtV6NvkwZMJsBVoAZ27rLbPKBeLpKPwkPIVEvr7Nf294Sgp2s/n6tSCKfGm ZQ7OvpvH0GgjBzUHVt3w5/5NDFDoHkEzooeNsvwAeeBl1xBQhquNK6KcS/qoaUj4VVOD eVgzreAoroipa8c6JuQcwz1gVVvsN9rYZMjatuzFk7bX79eZ8H6yQ1sFe3/lJ0ssSt1a cHNEzNKviPB3qxB+Jm85b83R2hMAQ8c9MPBmxyQZ7exdP5GVQCb1EbUpYnVjhj0Dn2FF dd/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mCatZGSWZUcdPVlebxVWApBrEvhOCVHeak/FRA/3ww0=; fh=a8QQDpsyeps30vd5Li+WI6v6dtcd7xKVvftia9bksQM=; b=mx5hsG/ULe24BE82XHTHQYbwS/ymBkmyKMJfobE27Q6ttdGgnmHki3sZ6sFK6zdnHU 8fpHZAMsYFBJPo3ACXYmfOAf3dmMm/MSbzOW+7ISjX6iiHLmbWlCC0rdILBj1uRUn6Kp buQr8bT27klufd1gE7dqIMvz1/phOT9ikkS5/MygLsosrJoHITR8N2hj+hc9MAwedYMC NbJeuprWWJhBjgE+MZwbM9ui3J8m9QKIu2kT8bFZOWt3KfUViJvZpn1tCpxaPOzQmenU cyer9OcJAaCaZ2qyWGkK3xZz7TDK4jaoRwkVSpvJvezdabWddRUax3bsbOZPBaIqy4lP UdHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=COdohcC0; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cb4-20020a056a00430400b00690d8405fe6si4031130pfb.317.2023.10.13.13.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=COdohcC0; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7A81D8303B16; Fri, 13 Oct 2023 13:26:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232099AbjJMU0W (ORCPT + 99 others); Fri, 13 Oct 2023 16:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232041AbjJMU0T (ORCPT ); Fri, 13 Oct 2023 16:26:19 -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 3EC0AB7; Fri, 13 Oct 2023 13:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3lxQiX58+3luBYVR7jDHfBi7W2SuEABlw5Qx9bqKfrtkbFvgnDj88t8ptUE5nEH42IQYT7Adt1Tqx3RQQePEIDb61o0fIi9/IFz/ZCK4o3kbmnNSVFmX/qZRjChBNWWgC18+/KiO/NqNKZyvmZtFsVKVUZ9viE/G1W5VaJooR2Xtj1pXjqqupVBEuaORWW0S3jvetUYvc+pU1W1MTXVKCRJBNhvLMEQIiHCzvi86ngfkB/HyhwGfNFCK9QCN/VP6gYD8p04xMMZygywWP/F0G9d9T09xg4hugjEAtAuk3n9G3GJf5ZzvmjEkkpF+dKtRK17ER87wG5tlKG+szwrGA== 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=mCatZGSWZUcdPVlebxVWApBrEvhOCVHeak/FRA/3ww0=; b=kdV/jgxPbXKcZyUjKB3sjZ7W18jpTWNB7U3cMXHnW23hIAmdaQrqm+hW4LVk+zn5sxTKeDkixg2ArzdVXrH6DjpVTl1WrhGcIMusISW9N8BnOu3DtAxwB+5m9meEmezItqElaP6txJ7i/9bmpSFHaBYBcyTIEvN202S9GGlWqi+c8YbbipalAAVsrCdCTYgzTbaPb/lfl482dJENnJa9RdZIWYdaQY5p43Fe2V1Dc/0+ioEgsxFpKNssaKGmR7grPQ5KKUtGINyfV5YVc6y00jHYqdPIhqK6XAwdSsrEhMCTIdJB6nsWFXj0Cae61Pnd+c2B4pEvCACCX60PFl2M6w== 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=mCatZGSWZUcdPVlebxVWApBrEvhOCVHeak/FRA/3ww0=; b=COdohcC0ds4zA4oheQxwNOElulRth9qc0LQDLwXZ2yzPnZlc8P3Uqj0jZcK27Mt6XDHYP0+29pcgL+0Hoa36duSqbI+2jA+Bwjkx8qGN+IPOBEeX5yMcTCtG4ajTEqClnzMXUHq+wfSToWTUvsGCwDi10ww/GZAvZZz29Dkw3c0= Received: from DS7PR07CA0023.namprd07.prod.outlook.com (2603:10b6:5:3af::28) by DM4PR12MB5389.namprd12.prod.outlook.com (2603:10b6:5:39e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 20:26:14 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:5:3af:cafe::c5) by DS7PR07CA0023.outlook.office365.com (2603:10b6:5:3af::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 20:26: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 DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 20:26: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; Fri, 13 Oct 2023 15:26:10 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 01/10] x86/resctrl: Add multiple tasks to the resctrl group at once Date: Fri, 13 Oct 2023 15:25:53 -0500 Message-ID: <20231013202602.2492645-2-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013202602.2492645-1-babu.moger@amd.com> References: <20231013202602.2492645-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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: DS1PEPF0001709D:EE_|DM4PR12MB5389:EE_ X-MS-Office365-Filtering-Correlation-Id: 8837f41e-2c08-4603-84b4-08dbcc2aa592 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5anyITFDpSPxA4atFvXN6038GQKo50wJVu42ya/wcFpLYsePok02QetYOp3hszNnDD1VYM4l50pMAuRQ27myDi7OL0bp9MwHudvW3JXO8FM19bL3kA9S4egMLv20VnL4Rfih+zWqk/zldDwqhhS4kiCgzrlUynDz9I1xsbyRPjFubTEX8ddmJK+WcKcyJGNNM+hp831E7y5AMuicZN+uh5NVkHr4BQDXpg8GYgxKlS+si3XdNcecLzl83kKYKOTmFTJBXaKxHxgFSqMXS85dbkexYirtiNwg2M/HtURfbaUxDZ6rVz5XsClEpeJIyUyfX5OPJLl4wXHSGFZ7crSm6xclxZQyE45VI+eADG1rYghx0fH5s3Hwv8H6pCVp4I+EjRC3OClVUPe1KIPxss/L4j7Fp5LaRkyxcmprNctauk5Z7eyPg8D8zowrYCdiUkeY+VkVprnnT+zB7mkTXPhK27SfEd9bnURomf8EaGRzGhHqnPybjvERMJwh/c/sq3tCAf8Zpdg+iDDGtWP2PbyrG20M2y1oTbC5FJ/h7Ir+D2mPiJVPSGsOP3r6w2kTKZOlcCFs9jj7MtNMXaE/uXGTJq9ML9peCO3ORhnUajD53epo6K98NGLaxW5zXIHsRbl35KA45eylFYtXCUr1hu7EBgas7VK2NizvCa4EssSK+VgOpF8GTevbJ1k0Cyo6MKjTXyWC8r4PxYsMF6wFApC7IcSBElc2xc4HjZ0czp2/hDvBQwx403uqHQSSFqil71Fa48GejF1k5nX9GiOZJNA+9A== 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)(376002)(136003)(396003)(230922051799003)(451199024)(1800799009)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(7416002)(7406005)(6666004)(2906002)(40460700003)(478600001)(41300700001)(4326008)(5660300002)(8936002)(66899024)(8676002)(40480700001)(44832011)(316002)(54906003)(110136005)(70586007)(70206006)(7696005)(36756003)(83380400001)(47076005)(26005)(16526019)(82740400003)(336012)(66574015)(426003)(36860700001)(81166007)(356005)(86362001)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 20:26:14.0811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8837f41e-2c08-4603-84b4-08dbcc2aa592 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: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5389 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:26:51 -0700 (PDT) The resctrl task assignment for monitor or control group needs to be done one at a time. For example: $mount -t resctrl resctrl /sys/fs/resctrl/ $mkdir /sys/fs/resctrl/ctrl_grp1 $echo 123 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 456 > /sys/fs/resctrl/ctrl_grp1/tasks $echo 789 > /sys/fs/resctrl/ctrl_grp1/tasks This is not user-friendly when dealing with hundreds of tasks. Support multiple task assignment in one command with tasks ids separated by commas. For example: $echo 123,456,789 > /sys/fs/resctrl/ctrl_grp1/tasks Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo Järvinen --- v13: No changes v12: No changes --- Documentation/arch/x86/resctrl.rst | 9 ++++++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 25 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst index 4c6421e2aa31..178ab1d8f747 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -306,7 +306,14 @@ All groups contain the following files: "tasks": Reading this file shows the list of all tasks that belong to this group. Writing a task id to the file will add a task to the - group. If the group is a CTRL_MON group the task is removed from + group. Multiple tasks can be added by separating the task ids + with commas. Tasks will be assigned sequentially. Multiple + failures are not supported. A single failure encountered while + attempting to assign a task will cause the operation to abort and + already added tasks before the failure will remain in the group. + Failures will be logged to /sys/fs/resctrl/info/last_cmd_status. + + If the group is a CTRL_MON group the task is removed from whichever previous CTRL_MON group owned the task and also from any MON group that owned the task. If the group is a MON group, then the task must already belong to the CTRL_MON parent of this diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 09848ff11f7b..fe239691628a 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_open_file *of, char *buf, size_t nbytes, loff_t off) { struct rdtgroup *rdtgrp; + char *pid_str; int ret = 0; pid_t pid; - if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0) - return -EINVAL; rdtgrp = 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; } - ret = rdtgroup_move_task(pid, rdtgrp, of); + while (buf && buf[0] != '\0' && buf[0] != '\n') { + pid_str = strim(strsep(&buf, ",")); + + if (kstrtoint(pid_str, 0, &pid)) { + rdt_last_cmd_printf("Task list parsing error pid %s\n", pid_str); + ret = -EINVAL; + break; + } + + if (pid < 0) { + rdt_last_cmd_printf("Invalid pid %d\n", pid); + ret = -EINVAL; + break; + } + + ret = rdtgroup_move_task(pid, rdtgrp, of); + if (ret) { + rdt_last_cmd_printf("Error while processing task %d\n", pid); + break; + } + } unlock: rdtgroup_kn_unlock(of->kn); -- 2.34.1