From patchwork Thu Jun 1 19:00:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 102142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp552099vqr; Thu, 1 Jun 2023 12:06:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n3ob3fJFTwCCsO9yX+5RXStFhGhuMlXC69DSot8Y6/2DabOF88jsZaVgECOk2KKr9KXp0 X-Received: by 2002:a05:6a00:1789:b0:646:74ce:a36c with SMTP id s9-20020a056a00178900b0064674cea36cmr13094682pfg.8.1685646372928; Thu, 01 Jun 2023 12:06:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685646372; cv=pass; d=google.com; s=arc-20160816; b=QV8EtfhYBN9CcPX1Z7hD4lxtyxRiNUsICNBBU8M4eplDfxJIHplaGwz2mvqzez8SSD Xa5vHx9p8DFTMUhYdNSzSDA86cCNfdGCPvgT037+ekBLT08dI+txWFSGIKCo+op97oZb gYYobRW9/2rNEM5w4+Zx0F9sSA8veLckmTkcyF7oZHB3cKOG3AYMNHAmygbBDzxDkQEW t/I79/msmPkS3TiQ1ZMt/tP0B8tGveeJKUVoKfFKN803cmYFucFydPHan+QAkjTnEcBb W2kDA5zwWiMblYVaRy42Ajw9oltwV97d7FXxW7wtZ2LoJax9bmVC4QWHOc8Oasm3D+C9 bgvA== 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=G+Ri0OnIn94g0sfsasntb/wfY9Ip1jUmxeT1yDBE54A=; b=c9KbsmIQDqXS3GF3EiQDfjI4kPbC2JBYWhsdTi0P9RV4/uJzaMIDieMyEIo+SO0OaO kEH51FievkeDWwbg2CVDVvrAkzRcb8oNezaa48lQuiJuwmTKYQ/rpp8XiZbaWJ8kZQ2T 33Jpsk3ktxi0YFzVDWhicFwFsXcQTFL+DErf8qGtVMHSYJMtI9TPSHfnXzQiBDbdbiGM worXWKlGoE0TH5wwmPSVzAXzBRCnrPtQMx2D4wSRDm8Bx/dhTg76XXBKEroYqq1dEQp8 sAzi3yKiU1MEHfC37vuJOSwdaDpb1Xoilov7HB2DhDi3OugKDjbMr3ORRgtlepzbBMh0 N2cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=XbYQ4fli; 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 b127-20020a62cf85000000b0064d2ddc63ebsi5823506pfg.306.2023.06.01.12.05.59; Thu, 01 Jun 2023 12:06:12 -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=XbYQ4fli; 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 S232248AbjFATBK (ORCPT + 99 others); Thu, 1 Jun 2023 15:01:10 -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 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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767528331562672873?= X-GMAIL-MSGID: =?utf-8?q?1767528331562672873?= 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/resctrl.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/resctrl/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_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); @@ -708,16 +707,27 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, } rdt_last_cmd_clear(); - if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED || - rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { - ret = -EINVAL; - rdt_last_cmd_puts("Pseudo-locking in progress\n"); - goto unlock; - } + while (buf && buf[0] != '\0') { + pid_str = strim(strsep(&buf, ",")); - ret = rdtgroup_move_task(pid, rdtgrp, of); + if (kstrtoint(pid_str, 0, &pid)) { + rdt_last_cmd_puts("Task list parsing error\n"); + ret = -EINVAL; + break; + } -unlock: + if (pid < 0) { + rdt_last_cmd_printf("Invalid pid %d value\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; + } + } rdtgroup_kn_unlock(of->kn); return ret ?: nbytes;