* [PATCH] do_sched_setscheduler: don't take tasklist_lock
@ 2006-08-13 17:03 Oleg Nesterov
2006-08-13 17:21 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-08-13 17:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, Thomas Gleixner, Steven Rostedt, linux-kernel
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 <oleg@tv-sign.ru>
--- 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] do_sched_setscheduler: don't take tasklist_lock
2006-08-13 17:03 [PATCH] do_sched_setscheduler: don't take tasklist_lock Oleg Nesterov
@ 2006-08-13 17:21 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2006-08-13 17:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, Thomas Gleixner, Steven Rostedt, linux-kernel
On 08/13, Oleg Nesterov wrote:
>
> We don't need to take tasklist_lock or disable irqs for
> find_task_by_pid() + get_task_struct(). Use RCU locks
> instead.
On the other hand, I think sched_setscheduler() does need tasklist_lock!
It is unsafe do dereference ->signal unless tasklist_lock or ->siglock
is held (or p == current). Yes, we pin the task structure, but this can't
prevent from release_task()->__exit_signal() which sets ->signal = NULL.
So, I think this patch
[PATCH] Drop tasklist lock in do_sched_setscheduler
commit e74c69f46d93d29eea0ad8647863d1c6488f0f55
is not correct.
Am I missed something?
Oleg.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-08-13 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-13 17:03 [PATCH] do_sched_setscheduler: don't take tasklist_lock Oleg Nesterov
2006-08-13 17:21 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox