summaryrefslogtreecommitdiff
path: root/kernel/posix-timers.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-09-22 14:42:48 -0700
committerThomas Gleixner <tglx@linutronix.de>2008-09-24 15:45:48 +0200
commit36b2f046000b358b62b9d116cb10a2b1c5be5cbf (patch)
tree577f367d2408d6ed2618d49f412afa91bcb915e8 /kernel/posix-timers.c
parent2cd499e38ec241691e4bce50bddc8f57e4cc9bd0 (diff)
posix-timers: sys_timer_create: simplify and s/tasklist/rcu/
- Change the code to do rcu_read_lock() instead of taking tasklist_lock, it is safe to get_task_struct(p) if p was found under RCU. However, now we must not use process's sighand/signal, they may be NULL. We can use current->sighand/signal instead, this "process" must belong to the current's thread-group. - Factor out the common code for 2 "if (timer_event_spec)" branches, the !timer_event_spec case can use current too. - use spin_lock_irq() instead of _irqsave(), kill "flags". Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: mingo@elte.hu Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r--kernel/posix-timers.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 60b262051d1d..5b761903b49a 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -463,7 +463,6 @@ sys_timer_create(const clockid_t which_clock,
struct k_itimer *new_timer;
int new_timer_id;
struct task_struct *process;
- unsigned long flags;
sigevent_t event;
int it_id_set = IT_ID_NOT_SET;
@@ -521,16 +520,11 @@ sys_timer_create(const clockid_t which_clock,
new_timer->it_sigev_signo = event.sigev_signo;
new_timer->it_sigev_value = event.sigev_value;
- read_lock(&tasklist_lock);
- if ((process = good_sigevent(&event))) {
+ rcu_read_lock();
+ process = good_sigevent(&event);
+ if (process)
get_task_struct(process);
- spin_lock_irqsave(&process->sighand->siglock, flags);
- new_timer->it_process = process;
- list_add(&new_timer->list,
- &process->signal->posix_timers);
- spin_unlock_irqrestore(&process->sighand->siglock, flags);
- }
- read_unlock(&tasklist_lock);
+ rcu_read_unlock();
if (!process) {
error = -EINVAL;
goto out;
@@ -541,19 +535,18 @@ sys_timer_create(const clockid_t which_clock,
new_timer->it_sigev_value.sival_int = new_timer->it_id;
process = current->group_leader;
get_task_struct(process);
- spin_lock_irqsave(&process->sighand->siglock, flags);
- new_timer->it_process = process;
- list_add(&new_timer->list, &process->signal->posix_timers);
- spin_unlock_irqrestore(&process->sighand->siglock, flags);
}
+ spin_lock_irq(&current->sighand->siglock);
+ new_timer->it_process = process;
+ list_add(&new_timer->list, &current->signal->posix_timers);
+ spin_unlock_irq(&current->sighand->siglock);
/*
* In the case of the timer belonging to another task, after
* the task is unlocked, the timer is owned by the other task
* and may cease to exist at any time. Don't use or modify
* new_timer after the unlock call.
*/
-
out:
if (error)
release_posix_timer(new_timer, it_id_set);