From patchwork Wed Jul 19 23:21:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 122924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2776910vqt; Wed, 19 Jul 2023 16:41:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFY/Rbv64adLXkTmLLf8voTFhR8zEv3hwODa4HljcTvnTr/O+71cx+M4oujAI74ZHH9owMl X-Received: by 2002:a17:906:530c:b0:997:ba19:61a1 with SMTP id h12-20020a170906530c00b00997ba1961a1mr3309028ejo.32.1689810116149; Wed, 19 Jul 2023 16:41:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689810116; cv=pass; d=google.com; s=arc-20160816; b=jY8efJlPa3lOkyYGi5mr6LgtfIArwYOqADq7wxlYCmqtbHakNpRofZxngmRgKQ5DqG TTNaIsqSJf9slYU2ipOAwJhdMUADog+WZYPpsBVLHwOXROJ4Tl2/VxLWXJpmUFzPPhkx 3ZMXEqJ3KMNPI7+oMtNip1SELGaoDm5xRA2AN4/q25yYyRPBt2uPuXZ2DlksctUpxlOF L7aLXjJXn4S08W+j3wIS/kkgMGCTzO5gb7s2QRA8hS8xSqsZn0AtqeW7k90QSQpARhXs EiLp3QZD9UffZjmApxDSH/6u5jPfBOCF38WbJwva3RgeKm9Y8rmJ1lQVH0+lnrKLjrld qXlA== 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=61Al6Z6LQLHeKfkTRNM6veo5Vu35Uwnfb24p/WvWesA=; fh=h28vckfI3GX5WFto8VbLoaUMI0xqlhwXGWb2ZADi/Dw=; b=iqM9ZaktAERvAvNsvOdAnwWFMRwLp/SJ8LHnBUu6N7z5kifBJUABea7IAyJvqm8W6d suwcDhFWvNZvHwPF6oLeOP+iZB+PhwwdaQvbDbB8XVSC1nbfVJDo6JgyeADKN2QqI1d2 xYgqs7pHqFrDFiTJ8LeYmt7y1pg+f4bL51Y+afmNBupYse7ZPxn66iVcYX3Mp8rY0YJq n1MTm7AML24rNJ4XYNp1DTUDEjYk/41HaZb7ThZlNQk5+GQIHRl7u+dt5CuTjeYteY5v Sk7fLGkXth/wJxzdQ/CsUJwRiIRI4aiwd0Ng/8as4SzbEXSfJZ7dob6lPkEdTlnzHImr GSEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=4OQW55Qj; 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 z22-20020a170906815600b009659573b4e3si3635977ejw.51.2023.07.19.16.41.32; Wed, 19 Jul 2023 16:41:56 -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=4OQW55Qj; 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 S229945AbjGSXVf (ORCPT + 99 others); Wed, 19 Jul 2023 19:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbjGSXVc (ORCPT ); Wed, 19 Jul 2023 19:21:32 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8FCA19BC; Wed, 19 Jul 2023 16:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ne5kQlhSYZTjxCRITS/m5i7kyggViAIc2rJGDC6qXlgPHSHFwD3XCdmvMxcZiw5f1pj6x1qSHh9HW/V9+er1s7yMi91H+WcWfZievAmX4ZumiiUcHlXcP34YWMa2o/sq71zi0tSD2KiuLQ5MXJgeARcequXncfTMZXmFyvS2hSuF7xwVxiQqhnAhgmUHqppSyzOm+7NJ+TPUulLQo1BG7kwZSYXEphb9zVm5xjk6SSy0sdoO1ppNbs/sC5KBf2fI2IHB/GGPYQkycBIHm0ua11z39G5HZyPglAZCTo+uSH0jq+SQ/gRxKsdX2ZsImofs5w3FlHbIacvTQoVOx9FlmA== 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=61Al6Z6LQLHeKfkTRNM6veo5Vu35Uwnfb24p/WvWesA=; b=kMsUByR7CRgFKB5W2K6/dEtjnfNVTaislE62PxtnHsQmHXWmnDX1k75+cyJatnmaVcj3x7OWQchh9r/fbLy9GnTKD0I7RezVnXT6jyzeb8OjkOhM3Zh+0dd9R5Hp/aiCdR8dWymRnbZ2HX30o0ZcsXjEc6Cwqv37sj58oUOgsc6LMwMlttOR97HZEcHCnvP6RKCO13PMm6jroEWcWM/K/yQ4Aj1ziL2Lwqc4HaBmd6KdNPmWgFozuiuN0kXkoMWrbv2zmnUSNlyhwE4LK2p3hYbBBm0dDVtBlE4tLaA0hqjHoidA/tllW5Ippc10SQNXQ5co2cNMQGsrazr2erlJXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=61Al6Z6LQLHeKfkTRNM6veo5Vu35Uwnfb24p/WvWesA=; b=4OQW55QjIXZ2NfcMeRydYFRLyJBHMrlLcS2B0+jpl4v1hKZcn8YgFSHYaQVY4vfGRsVQTj8vTSx2zkK55LBAvmZnmpiFXwkuKNsyYvq2hb1UL9dhHXN6Ncat455GR4kz45P4nKPowLLnMF3vPJj++m4tRqHAkhV1p+FjRJMl9SM= Received: from DS7PR03CA0337.namprd03.prod.outlook.com (2603:10b6:8:55::25) by SJ1PR12MB6220.namprd12.prod.outlook.com (2603:10b6:a03:455::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Wed, 19 Jul 2023 23:21:29 +0000 Received: from DM6NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:8:55:cafe::e9) by DS7PR03CA0337.outlook.office365.com (2603:10b6:8:55::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 23:21:28 +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 DM6NAM11FT104.mail.protection.outlook.com (10.13.173.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 23:21:28 +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.23; Wed, 19 Jul 2023 18:21:26 -0500 Subject: [PATCH v6 1/8] x86/resctrl: Add multiple tasks to the resctrl group at once From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Wed, 19 Jul 2023 18:21:20 -0500 Message-ID: <168980888032.1619861.1165593867700435801.stgit@bmoger-ubuntu> In-Reply-To: <168980872063.1619861.420806535295905172.stgit@bmoger-ubuntu> References: <168980872063.1619861.420806535295905172.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 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: DM6NAM11FT104:EE_|SJ1PR12MB6220:EE_ X-MS-Office365-Filtering-Correlation-Id: 96af125d-1238-4855-d82d-08db88aee148 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B1f9Q4CMFvA2wcK+oaNgQURFQ+NA9c6KvM1fUMni5Tra6r80sG5TTDjkZ2N7J33J8JE8kWLHjqqbzL+uOgRue9W4/N3mLKFCrMLgTgR6wo2tHcxYcAa4hvQgV91xayxBnbQaQh8WCgwAg27lizTPfv4RN3AKWG11gk2nFOBnkzpFJzR7b5PYsYyJwwmy0MCCY+5LTqMjK5LkJQdxZN5OU3sbTqBXrizBAH7bSkd1ka1brFGU58QqdXcAf1SCoihVYewXh2FMqKg3CjS41IahB7paMlYmK2fxcCmxLJDaZEIN/RHpHOAR7SC/z38/6/Ev8NYT6Lx16Pi/uKyqXPTYcXj8XfeFkgOc9iHYDwIUuMvvu52iB87cG/U8rtqtMzc3qfzUaH18/87ezAtDLPjyJydtBFjRJJ9JT214s6Aoc0y+eH+mPassDE6eVr06vItFiCy2ahdYqegYPULCEYq/aIzEuhtffGOL+jZ8p9/IOgqTCQ34mMveN4EZbpp0dkaom0Z4KHNbaTU06Xqc9/S9snpi3H3iim82wtVKuaNqsp0IPmRcsd1H7jF53sJ5G0t0V0+wFUe87SVAFtpxWOPqsK5f+Qi191t/rkJWxSqTUu1KiyZQOSRyWAQdDzD5MQeglI22ES568oURkOqYC8PRKeAHrl0LULGSH57yPeLC9Kl5SZj9ZGeqPHsbidKm9jhVe4J3UXLx5gFADxvgSP9owVvh4F9vrsBnfV7/VJjUeo2IbqJGKt32x3Z1RAhoabG1w4t5w04XiT9v5LrwtdPWez4sQinCJxs4/JhUymg7oFY= 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)(4636009)(7916004)(346002)(376002)(396003)(39860400002)(136003)(451199021)(82310400008)(46966006)(36840700001)(40470700004)(66899021)(4326008)(54906003)(6666004)(478600001)(110136005)(83380400001)(82740400003)(36860700001)(426003)(47076005)(40460700003)(86362001)(103116003)(40480700001)(336012)(356005)(2906002)(33716001)(70586007)(44832011)(186003)(16526019)(26005)(316002)(9686003)(70206006)(81166007)(7406005)(16576012)(8676002)(41300700001)(5660300002)(8936002)(7416002)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 23:21:28.7610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96af125d-1238-4855-d82d-08db88aee148 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: DM6NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6220 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,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: 1771894332710790910 X-GMAIL-MSGID: 1771894332710790910 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 | 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);