Skip to content

Commit 2997d94

Browse files
Shawn Wangbp3tk0v
authored andcommitted
x86/resctrl: Only show tasks' pid in current pid namespace
When writing a task id to the "tasks" file in an rdtgroup, rdtgroup_tasks_write() treats the pid as a number in the current pid namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows the list of global pids from the init namespace, which is confusing and incorrect. To be more robust, let the "tasks" file only show pids in the current pid namespace. Fixes: e02737d ("x86/intel_rdt: Add tasks files") Signed-off-by: Shawn Wang <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Reinette Chatre <[email protected]> Acked-by: Fenghua Yu <[email protected]> Tested-by: Reinette Chatre <[email protected]> Link: https://lore.kernel.org/all/[email protected]/
1 parent 7877cb9 commit 2997d94

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
726726
static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
727727
{
728728
struct task_struct *p, *t;
729+
pid_t pid;
729730

730731
rcu_read_lock();
731732
for_each_process_thread(p, t) {
732-
if (is_closid_match(t, r) || is_rmid_match(t, r))
733-
seq_printf(s, "%d\n", t->pid);
733+
if (is_closid_match(t, r) || is_rmid_match(t, r)) {
734+
pid = task_pid_vnr(t);
735+
if (pid)
736+
seq_printf(s, "%d\n", pid);
737+
}
734738
}
735739
rcu_read_unlock();
736740
}

0 commit comments

Comments
 (0)