Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3115624rdg; Tue, 17 Oct 2023 05:18:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGd2h1Jw+wRjjIKuRuhlSpP6pEHTg1p46xyfdR1AX0RPc4DZfOVN4jPmI9nsgooT1Eblf4F X-Received: by 2002:a17:90b:4acf:b0:27d:2601:bc92 with SMTP id mh15-20020a17090b4acf00b0027d2601bc92mr2519931pjb.11.1697545123300; Tue, 17 Oct 2023 05:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545123; cv=none; d=google.com; s=arc-20160816; b=jpP1xZhdKZbvtUxA6xMLS38c0K0OIZEIt+nEpGK7PEuaASUp4CCGUpV5yP05jnHPGb U/2Dzd4WEZU2bRHlj+Zln3q3/W39/XEKW1auFgonWMb+NDm6B3BaTCZQlu4tRp8KuhGk AChov62HKls3CncNx9U5kjX2oLMw2DIDpftif6fWoalNi6EN6Zfg6zIEw20nnvqKSDlE lruHsn5GgwYtJ6WxLM2ToVLMocEeVJVd0KDdDY9NV5Ka4moBjXLhikkdCnqwtzBAvW0D UYfW5714fJBuFExgmWzWz4G+dNNok7KQr1AOCEs3JOb5a5iZnxBA1TPommYUhoW1f6Qy M51A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=QbYP9dGfEQSVZtPNiC/4mXl13vm8ozRDwm7/4xMAAVM=; fh=xlieDj8o+jXNpmF12Ogr15ctNOIP4IDTbgVIdoNwRD8=; b=KVclt3rC+/2XZBNsB6nqQE0aJ6f8RlVgmz6PMoh+qwxGvW07L7lV5dEsqT0K7KExYM TVnlwW4RnURgE9nA/bCji7QSjfaIJzzjrD70ZKj2ndTFck3MkXFL/RfOqDpQBzCrZfBG Bz535405fHd4CFNClTlDyQ09FTPhX8LlJF5r4BhjJHC7BYJvGd13uwORdP8idBEMyV03 jp3hsV9t0Ck7SruTLk8sq5r/tcZJWzLmuwXPahWTH80r18nQr+eZGczOyBJdLC8sZnL+ P4P98Zr4tcNN/3drbY9lir3wiXnZ5IC1eJbZh7PXGjlnwBBi3DZ7Kg1NYb+s/PmHNWhf Mo5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4PbyoR0a; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id lp13-20020a17090b4a8d00b00277496b6ec1si1774330pjb.34.2023.10.17.05.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4PbyoR0a; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F11E0801C1AA; Tue, 17 Oct 2023 05:18:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233857AbjJQMSg (ORCPT + 99 others); Tue, 17 Oct 2023 08:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234794AbjJQMSG (ORCPT ); Tue, 17 Oct 2023 08:18:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF14B95; Tue, 17 Oct 2023 05:18:04 -0700 (PDT) Date: Tue, 17 Oct 2023 12:18:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697545083; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QbYP9dGfEQSVZtPNiC/4mXl13vm8ozRDwm7/4xMAAVM=; b=4PbyoR0a6tmvfBHMGrGf0Q3tO0nQUjRxHfYlXPblr6dMdF4fCyvph4YoIjbRAWQ3dqFtuv CWI35peKYMR7qeyosrB8udg0NiOqP2O2XwET2ysrUal3Fj+EQyKhdZu4euAEqTIFHesFDG wp0o+mWbh93QMsFdFSCM68fmljzxpZPFsaD5m6tQ5MOOLE5xk1WVSYMDad9OhSWDYn1DUv BUslMZqX9lVe1DDMBt9GPJ/ir/3nOZ/2uZC91+UCJy+IfZ03pzk8IY8m1UAtO5IrzNUr7y CTOA7l6lWGmAAQL9Plz75SOurXdQAD4AGnf+vMIEDNqXuDFeNP3fs8AlHPzmTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697545083; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QbYP9dGfEQSVZtPNiC/4mXl13vm8ozRDwm7/4xMAAVM=; b=3ESPB+KFr4j+1Ce9nJz8K1BO9fRHYtPmUyDHw0Yh/ki0dJctdjWsg/n5xdaW9aDJtelVPa yX3Xm+gE6D3rmQAA== From: "tip-bot2 for Babu Moger" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Add multiple tasks to the resctrl group at once Cc: Babu Moger , "Borislav Petkov (AMD)" , Peter Newman , Tan Shaopeng , Fenghua Yu , Reinette Chatre , ilpo.jarvinen@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231017002308.134480-2-babu.moger@amd.com> References: <20231017002308.134480-2-babu.moger@amd.com> MIME-Version: 1.0 Message-ID: <169754508299.3135.1526802957654004468.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 05:18:42 -0700 (PDT) The following commit has been merged into the x86/cache branch of tip: Commit-ID: fe2a20ea0b0953189e57740debc7dcc789d1ea55 Gitweb: https://git.kernel.org/tip/fe2a20ea0b0953189e57740debc7dcc789d= 1ea55 Author: Babu Moger AuthorDate: Mon, 16 Oct 2023 19:23:00 -05:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 17 Oct 2023 11:27:50 +02:00 x86/resctrl: Add multiple tasks to the resctrl group at once 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 Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Peter Newman Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo J=C3=A4rvinen Tested-by: Peter Newman Tested-by: Tan Shaopeng Link: https://lore.kernel.org/r/20231017002308.134480-2-babu.moger@amd.com --- 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/resc= trl.rst index 4c6421e..178ab1d 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/res= ctrl/rdtgroup.c index 09848ff..fe23969 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 =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); @@ -715,7 +714,27 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_f= ile *of, goto unlock; } =20 - ret =3D rdtgroup_move_task(pid, rdtgrp, of); + while (buf && buf[0] !=3D '\0' && buf[0] !=3D '\n') { + pid_str =3D strim(strsep(&buf, ",")); + + if (kstrtoint(pid_str, 0, &pid)) { + rdt_last_cmd_printf("Task list parsing error pid %s\n", pid_str); + ret =3D -EINVAL; + break; + } + + if (pid < 0) { + rdt_last_cmd_printf("Invalid pid %d\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; + } + } =20 unlock: rdtgroup_kn_unlock(of->kn);