[PATCH] do_sched_setscheduler: don't take tasklist_lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We don't need to take tasklist_lock or disable irqs for
find_task_by_pid() + get_task_struct(). Use RCU locks
instead.

Signed-off-by: Oleg Nesterov <[email protected]>

--- 2.6.18-rc3/kernel/sched.c~1_dss	2006-07-16 01:53:08.000000000 +0400
+++ 2.6.18-rc3/kernel/sched.c	2006-08-13 20:19:02.000000000 +0400
@@ -4156,14 +4156,15 @@ do_sched_setscheduler(pid_t pid, int pol
 		return -EINVAL;
 	if (copy_from_user(&lparam, param, sizeof(struct sched_param)))
 		return -EFAULT;
-	read_lock_irq(&tasklist_lock);
+
+	rcu_read_lock();
 	p = find_process_by_pid(pid);
-	if (!p) {
-		read_unlock_irq(&tasklist_lock);
+	if (p)
+		get_task_struct(p);
+	rcu_read_unlock();
+	if (!p)
 		return -ESRCH;
-	}
-	get_task_struct(p);
-	read_unlock_irq(&tasklist_lock);
+
 	retval = sched_setscheduler(p, policy, &lparam);
 	put_task_struct(p);
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux