[RFC PATCH 18/19] x86/resctrl: Refactor show_rdt_tasks() to support PLZA task matching

Babu Moger posted 19 patches 2 weeks, 3 days ago
[RFC PATCH 18/19] x86/resctrl: Refactor show_rdt_tasks() to support PLZA task matching
Posted by Babu Moger 2 weeks, 3 days ago
Refactor show_rdt_tasks() to use a new rdt_task_match() helper that checks
t->plza when PLZA is enabled for a group, falling back to CLOSID/RMID
matching otherwise. This ensures correct task display for PLZA-enabled
groups.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 fs/resctrl/rdtgroup.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index bea017f9bd40..a116daa53f17 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -845,6 +845,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
 	return ret ?: nbytes;
 }
 
+static inline bool rdt_task_match(struct task_struct *t,
+				  struct rdtgroup *r, bool plza)
+{
+	if (plza)
+		return t->plza;
+
+	return is_closid_match(t, r) || is_rmid_match(t, r);
+}
+
 static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
 {
 	struct task_struct *p, *t;
@@ -852,11 +861,12 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
 
 	rcu_read_lock();
 	for_each_process_thread(p, t) {
-		if (is_closid_match(t, r) || is_rmid_match(t, r)) {
-			pid = task_pid_vnr(t);
-			if (pid)
-				seq_printf(s, "%d\n", pid);
-		}
+		if (!rdt_task_match(t, r, r->plza))
+			continue;
+
+		pid = task_pid_vnr(t);
+		if (pid)
+			seq_printf(s, "%d\n", pid);
 	}
 	rcu_read_unlock();
 }
-- 
2.34.1