aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2024-01-03 10:03:59 -0800
committerTony Luck <tony.luck@intel.com>2024-01-03 10:03:59 -0800
commit7ed38879e3e3848b1514d25593b50c8be1e385bd (patch)
treec3fb33fbcf66939cdafa1ed61153dbcb89459162
parent40ae200383e2214bd199d09d519df04c201599bc (diff)
downloadlinux-resctrl2_patches_v6.7-rc8.tar.gz
resctrl2: Add multiple tasks to the resctrl group at onceresctrl2_patches_v6.7-rc8
Copied from Babu Moger's legacy resctrl change: fe2a20ea0b09 ("x86/resctrl: Add multiple tasks to the resctrl group at once") Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--fs/resctrl2/tasks.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/fs/resctrl2/tasks.c b/fs/resctrl2/tasks.c
index 6c107025aa346f..45ac4798829489 100644
--- a/fs/resctrl2/tasks.c
+++ b/fs/resctrl2/tasks.c
@@ -156,16 +156,35 @@ static int resctrl_move_task(pid_t pid, struct resctrl_group *rg, struct kernfs_
static ssize_t tasks_write(char *buf, size_t nbytes, struct resctrl_group *rg,
struct kernfs_open_file *of)
{
+ char *pid_str;
+ int ret = 0;
pid_t pid;
resctrl_last_cmd_clear();
- if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0) {
- resctrl_last_cmd_printf("task input '%s' is not a number\n", strim(buf));
- return -EINVAL;
+ while (buf && buf[0] != '\0' && buf[0] != '\n') {
+ pid_str = strim(strsep(&buf, ","));
+
+ if (kstrtoint(pid_str, 0, &pid)) {
+ resctrl_last_cmd_printf("Task list parsing error pid %s\n", pid_str);
+ ret = -EINVAL;
+ break;
+ }
+
+ if (pid < 0) {
+ resctrl_last_cmd_printf("Invalid pid %d\n", pid);
+ ret = -EINVAL;
+ break;
+ }
+
+ ret = resctrl_move_task(pid, rg, of);
+ if (ret) {
+ resctrl_last_cmd_printf("Error while processing task %d\n", pid);
+ break;
+ }
}
- return resctrl_move_task(pid, rg, of);
+ return ret ?: nbytes;
}
bool resctrl_add_task_file(struct kernfs_node *parent_kn)