Skip to contentSkip to conversation

MIPS: Use rcu to lookup a task in mipsmt_sys_sched_setaffinity()

PATCH Applied Davidlohr Bueso 2 participants 2 messages Aug 31, 2020 – Sep 3, 2020 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Use rcu to lookup a task in mipsmt_sys_sched_setaffinity()

The call simply looks up the corresponding task (without iterating the tasklist), which is safe under rcu instead of the tasklist_lock. In addition, the setaffinity counter part already does this.

---
 arch/mips/kernel/mips-mt-fpaff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/mips-mt-fpaff.c +2 -2
index 1a08428eedcf..6c590ef27648 100644
@@ -167,7 +167,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len,
 		return -EINVAL;
 
 	get_online_cpus();
-	read_lock(&tasklist_lock);
+	rcu_read_lock();
 
 	retval = -ESRCH;
 	p = find_process_by_pid(pid);
@@ -181,7 +181,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len,
 	cpumask_and(&mask, &allowed, cpu_active_mask);
 
 out_unlock:
-	read_unlock(&tasklist_lock);
+	rcu_read_unlock();
 	put_online_cpus();
 	if (retval)
 		return retval;
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 8 lines · Davidlohr Bueso

The call simply looks up the corresponding task (without iterating the tasklist), which is safe under rcu instead of the tasklist_lock. In addition, the setaffinity counter part already does this.

---
 arch/mips/kernel/mips-mt-fpaff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]