Skip to content

Commit e6b2fac

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Use is_closid_match() in more places
rdtgroup_tasks_assigned() and show_rdt_tasks() loop over threads testing for a CTRL/MON group match by closid/rmid with the provided rdtgrp. Further down the file are helpers to do this, move these further up and make use of them here. These helpers additionally check for alloc/mon capable. This is harmless as rdtgroup_mkdir() tests these capable flags before allowing the config directories to be created. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lkml.kernel.org/r/20200708163929.2783-7-james.morse@arm.com
1 parent a21a439 commit e6b2fac

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,18 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
592592
return ret;
593593
}
594594

595+
static bool is_closid_match(struct task_struct *t, struct rdtgroup *r)
596+
{
597+
return (rdt_alloc_capable &&
598+
(r->type == RDTCTRL_GROUP) && (t->closid == r->closid));
599+
}
600+
601+
static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r)
602+
{
603+
return (rdt_mon_capable &&
604+
(r->type == RDTMON_GROUP) && (t->rmid == r->mon.rmid));
605+
}
606+
595607
/**
596608
* rdtgroup_tasks_assigned - Test if tasks have been assigned to resource group
597609
* @r: Resource group
@@ -607,8 +619,7 @@ int rdtgroup_tasks_assigned(struct rdtgroup *r)
607619

608620
rcu_read_lock();
609621
for_each_process_thread(p, t) {
610-
if ((r->type == RDTCTRL_GROUP && t->closid == r->closid) ||
611-
(r->type == RDTMON_GROUP && t->rmid == r->mon.rmid)) {
622+
if (is_closid_match(t, r) || is_rmid_match(t, r)) {
612623
ret = 1;
613624
break;
614625
}
@@ -706,8 +717,7 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
706717

707718
rcu_read_lock();
708719
for_each_process_thread(p, t) {
709-
if ((r->type == RDTCTRL_GROUP && t->closid == r->closid) ||
710-
(r->type == RDTMON_GROUP && t->rmid == r->mon.rmid))
720+
if (is_closid_match(t, r) || is_rmid_match(t, r))
711721
seq_printf(s, "%d\n", t->pid);
712722
}
713723
rcu_read_unlock();
@@ -2245,18 +2255,6 @@ static int reset_all_ctrls(struct rdt_resource *r)
22452255
return 0;
22462256
}
22472257

2248-
static bool is_closid_match(struct task_struct *t, struct rdtgroup *r)
2249-
{
2250-
return (rdt_alloc_capable &&
2251-
(r->type == RDTCTRL_GROUP) && (t->closid == r->closid));
2252-
}
2253-
2254-
static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r)
2255-
{
2256-
return (rdt_mon_capable &&
2257-
(r->type == RDTMON_GROUP) && (t->rmid == r->mon.rmid));
2258-
}
2259-
22602258
/*
22612259
* Move tasks from one to the other group. If @from is NULL, then all tasks
22622260
* in the systems are moved unconditionally (used for teardown).

0 commit comments

Comments
 (0)