From patchwork Fri Aug 11 20:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 134674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1337444vqi; Fri, 11 Aug 2023 13:26:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGuWpoHz+kIwUZlW2rq2z7BNY+SqhAYyzrighIvfrUsLmGrTPM3aPDSelcLG3UdfcORB/E X-Received: by 2002:a05:6512:78c:b0:4fe:db6:cb3a with SMTP id x12-20020a056512078c00b004fe0db6cb3amr2119532lfr.22.1691785610503; Fri, 11 Aug 2023 13:26:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691785610; cv=pass; d=google.com; s=arc-20160816; b=mHlE7bUbXjZ+YTiFvpv41dbSac7A0zRDyG2cCiwShax6r4fq1PJZMZDp/lY4tD8NZV WF7dpJTLG5+oeRnw2uWJW0Iz9viZTT13n2ghl9tvs4EMZYLR5Otq5eGMtdN3hsieImUO yFiLA5vdqPrERqxM4cH3GgiiCy0RQU8dqbKzp7fXxeikOZGud6R0KUGI+ROS9qvWiHBG 0PuGbVtzMlFQVWduvE56jWurlUFsJpY8EH93qEZmBMvqraHLa/ROiuHLMQhwTVKAcQwF y5SynHlLxBgU7AaV23RvleYOhfNZZC1fRzX1yDzbjs8fND5Sx5x19mbF216+C4CBTU76 giFg== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=U5U4v7REjseNyp8szDNRtG7x0pMTTwGKkVR2CiMPjyg=; fh=h28vckfI3GX5WFto8VbLoaUMI0xqlhwXGWb2ZADi/Dw=; b=Wii/7T/5QFsQ5Amk78qSoIysy6x6VkElAI9O2yPkDbeCFba6tV46tRtbJIRuQh/s65 jinmRqdzZWyqd0Lmd6+zxGDWBwubDp+lg3a7dot5R+91DXeqhFL0FSwSbCzGg2RI5T0u WZD/JTyZoKa9pizz5zLAR8z1nwPaCF1cSHb6mUb5HNTTEpqpHUTdsiqMg0RxwiqC6h2L wQiigFSP7HbBGUtDklu/CE2s3z5Cca5gGoGkIKQ/oTU2jUEfxk78v2zurpvP7pIbSYFp YFH0/5WPo3P8rhyvctBVu7gPNgqnH/+gR2nV58TnM1beDJzQ4KU5gmDe820fZSZoTY7q fcTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=naBOIk9l; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a50fc0e000000b005230e273470si4095811edr.253.2023.08.11.13.26.26; Fri, 11 Aug 2023 13:26:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=naBOIk9l; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235507AbjHKUIk (ORCPT + 99 others); Fri, 11 Aug 2023 16:08:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbjHKUIj (ORCPT ); Fri, 11 Aug 2023 16:08:39 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C81730F8; Fri, 11 Aug 2023 13:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5AYe56Fgx38hrjxYKGriijby5VoDJvb50VH8BzEh5HCIYih/eU6jBT+YJrSqUEqi/l+EaxpBtxLadHGYJ3mw9njH2Co0gSqdbrXTMsvF441IAdaYGGLmawPZ+oKUtAMQUch6gDKT48dE8fs5rjZAzL2sr7muDD8o4yFl6Mg7CGVnAB/YaJGb83vovgDLQTh/yTt3dhweovdtlKU/LvJwRRdrz43ZRfMrNzzoRfh5vu4Cc5KVgj5SwGOJiOvyn9IItUNBFIxk03KUfgX3fir7316BvvT4n9Jpx6Fg8QJxuxTQx7mByU2dHn8SzY8c5GE7yA060zxQz8ISVhFkoDfKw== 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=U5U4v7REjseNyp8szDNRtG7x0pMTTwGKkVR2CiMPjyg=; b=Zn54HZKGzJajuExXZJp9elnIf30YSGXvFWAnJOMaWFVW5bycJdXzhWBZtYy8Mnzo7jLHSCEwStc9qrXN9iKr4IOZlcf6DBX5B1ERfZAc2JjQL5brgDEX2YAJFd+MehGAdPx5+clsHxE/Ult6yk6Mv7dFxjPoQ2Hl+LO/xXmZxEkcDluJQiMclfK9K1Xl6LAPe7lANX2L0ca6aKaVKwcOdM0ftfRsl5Hm/tyr6dWOf42MRcf2qtX6LSAdg9Elu6DTxl9/I/zKyg/X7qw44el5wQ091ijKbgaqIL6bZx/sXDqoVKULsDPGbvgHAUOzTODjtbCHVnqKI2R4Oseica/9WQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=csgroup.eu 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=U5U4v7REjseNyp8szDNRtG7x0pMTTwGKkVR2CiMPjyg=; b=naBOIk9l2oHQkboehBCRR4HQzzVrq7sUII2vN8qbMgVf9kZKbmxEr4+k2Q/uejlQ2kMD0HIA7RVcbn+MIMX5gEzs6XCkyU6E/a5cwp7nhBQ1R79acZx4BR3OOJEmifiJON7UPbAlGocy1Rkgh0lWGkV4vjStI5qU627SIRiDnio= Received: from MW4PR04CA0267.namprd04.prod.outlook.com (2603:10b6:303:88::32) by DM4PR12MB5261.namprd12.prod.outlook.com (2603:10b6:5:398::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 20:08:35 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::f) by MW4PR04CA0267.outlook.office365.com (2603:10b6:303:88::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.31 via Frontend Transport; Fri, 11 Aug 2023 20:08:35 +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 MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Fri, 11 Aug 2023 20:08:34 +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.2507.27; Fri, 11 Aug 2023 15:08:24 -0500 Subject: [PATCH v7 1/8] x86/resctrl: Add multiple tasks to the resctrl group at once From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Fri, 11 Aug 2023 15:08:18 -0500 Message-ID: <169178449820.1147205.3688106607892992826.stgit@bmoger-ubuntu> In-Reply-To: <169178429591.1147205.4030367096506551808.stgit@bmoger-ubuntu> References: <169178429591.1147205.4030367096506551808.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 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: MWH0EPF000971E7:EE_|DM4PR12MB5261:EE_ X-MS-Office365-Filtering-Correlation-Id: 0123427f-177e-45b5-b42b-08db9aa6be0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1U3QJXG3KnFR61H1YnxmceKnWHKg8hKLcRV9hRuFIpmgJ8OBh34Wm2ecvoOSPtfc/JMYA/Zxk63BkyJEOCCrNVJd2uj5znd+CiDtn7NnDqPePSpMvxoFwyZ9k6w2wOsWiKwHSjV9nfigKds892E75Mv5uOrpXmhP4bsQ2ZCBlBEDb1n3DCxGTNpna6eYjNuQnMFqiPugDrpWDmUH0qdLTY21PND7Tcz49iG4IVXbyPttyZdpVAHwg0CY7cM0EE6GEvJzFFePr9GoDwpsNpnjtZHLX6423GkFg+4CMc4eFBiJOpJyXj8Si9oIY4mBxmeMQA/V6Rqh2tNrpyM4H7JOgME6H5CvvGmMGzYi4kgc+ibHhjxW83yu7yTN4WSHjyMpFoLPOSms+jmwLEqKP93fBRmtzacgMKa0lxPeEM74vIbKkPQQmCyu0wo2+NhC/qTGZejJnHr+h5G/3XZS8viuYNg2TTJHbe1cjxr17VNO0S8s9tYE3hEk6CyDRkRzv+mf0xAS/68/NIEYwKsU7H9C73YZMMlbZm7zkA/G/IaUVjZG4Spj3Bp9noRVN1aNCLPxSS5+Yvi2G1NleDAgg/DgTxzwYQ25DPkzsOt4dXhMe3FeeVBBr+6C38fuNRqT8kFm4eVjqOvKOpwvgjCmV1JinaM1W10sdDIKACZLcBS2fxvdWa0F1nh4T77WjkH3Nq4Dtzd0U9VWBfJaa/4s0cp+iB6JtjXrqWInrJSE5/hiDEHVPuFK5urbUO4ST5ZATtwRXDtfmoqvUVAHM85jZhZbH361AR8DRHfS4TttwKwedK0= 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)(39860400002)(376002)(136003)(396003)(346002)(451199021)(186006)(1800799006)(82310400008)(46966006)(36840700001)(40470700004)(40460700003)(66899021)(40480700001)(54906003)(110136005)(16526019)(26005)(70206006)(336012)(6666004)(478600001)(70586007)(103116003)(86362001)(426003)(47076005)(83380400001)(36860700001)(16576012)(33716001)(44832011)(316002)(41300700001)(7406005)(7416002)(4326008)(9686003)(356005)(2906002)(81166007)(8676002)(82740400003)(5660300002)(8936002)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 20:08:34.4959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0123427f-177e-45b5-b42b-08db9aa6be0a 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: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5261 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773965788553148981 X-GMAIL-MSGID: 1773965788553148981 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/resctrl.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/resctrl/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_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_puts("Task list parsing error\n"); + 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);