The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace
@ 2023-05-15  6:04 Shawn Wang
  2023-05-16 19:04 ` Fenghua Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn Wang @ 2023-05-15  6:04 UTC (permalink / raw)
  To: fenghua.yu, reinette.chatre
  Cc: tglx, mingo, bp, dave.hansen, x86, hpa, linux-kernel

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.

Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/
Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files")
Signed-off-by: Shawn Wang <shawnwang@linux.alibaba.com>
Tested-by: Reinette Chatre <reinette.chatre@intel.com>
Acked-by: Reinette Chatre <reinette.chatre@intel.com>
---
Changes since v1:
- Update commit message and commit tags.

 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 6ad33f355861..61cdd9b1bb6d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -726,11 +726,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();
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace
  2023-05-15  6:04 [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace Shawn Wang
@ 2023-05-16 19:04 ` Fenghua Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Fenghua Yu @ 2023-05-16 19:04 UTC (permalink / raw)
  To: Shawn Wang, reinette.chatre
  Cc: tglx, mingo, bp, dave.hansen, x86, hpa, linux-kernel


On 5/14/23 23:04, Shawn Wang wrote:
> 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.
> 
> Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/
> Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files")
> Signed-off-by: Shawn Wang <shawnwang@linux.alibaba.com>
> Tested-by: Reinette Chatre <reinette.chatre@intel.com>
> Acked-by: Reinette Chatre <reinette.chatre@intel.com>

Acked-by: Fenghua Yu <fenghua.yu@intel.com>

Thanks.

-Fenghua

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-16 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15  6:04 [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace Shawn Wang
2023-05-16 19:04 ` Fenghua Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox