Skip to content

Commit

Permalink
x86/resctrl: Only show tasks' pid in current pid namespace
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/2034469

[ Upstream commit 2997d94 ]

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]/
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>
  • Loading branch information
Shawn Wang authored and roxanan1996 committed Oct 2, 2023
1 parent e668c04 commit 3a1c383
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/x86/kernel/cpu/resctrl/rdtgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
{
struct task_struct *p, *t;
pid_t pid;

rcu_read_lock();
for_each_process_thread(p, t) {
if (is_closid_match(t, r) || is_rmid_match(t, r))
seq_printf(s, "%d\n", t->pid);
if (is_closid_match(t, r) || is_rmid_match(t, r)) {
pid = task_pid_vnr(t);
if (pid)
seq_printf(s, "%d\n", pid);
}
}
rcu_read_unlock();
}
Expand Down

0 comments on commit 3a1c383

Please sign in to comment.