mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
posix-timers: check ->it_signal instead of ->it_pid to validate the timer
Impact: clean up, speed up ->it_pid (was ->it_process) has also a special meaning: if it is NULL, the timer is under deletion or it wasn't initialized yet. We can check ->it_signal != NULL instead, this way we can - simplify sys_timer_create() a bit - remove yet another check from lock_timer() - move put_pid(->it_pid) into release_posix_timer() which runs outside of ->it_lock Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
27af4245b6
commit
899921025b
1 changed files with 7 additions and 10 deletions
|
@ -464,6 +464,7 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
|
||||||
idr_remove(&posix_timers_id, tmr->it_id);
|
idr_remove(&posix_timers_id, tmr->it_id);
|
||||||
spin_unlock_irqrestore(&idr_lock, flags);
|
spin_unlock_irqrestore(&idr_lock, flags);
|
||||||
}
|
}
|
||||||
|
put_pid(tmr->it_pid);
|
||||||
sigqueue_free(tmr->sigq);
|
sigqueue_free(tmr->sigq);
|
||||||
kmem_cache_free(posix_timers_cache, tmr);
|
kmem_cache_free(posix_timers_cache, tmr);
|
||||||
}
|
}
|
||||||
|
@ -477,7 +478,6 @@ sys_timer_create(const clockid_t which_clock,
|
||||||
{
|
{
|
||||||
struct k_itimer *new_timer;
|
struct k_itimer *new_timer;
|
||||||
int error, new_timer_id;
|
int error, new_timer_id;
|
||||||
struct pid *it_pid;
|
|
||||||
sigevent_t event;
|
sigevent_t event;
|
||||||
int it_id_set = IT_ID_NOT_SET;
|
int it_id_set = IT_ID_NOT_SET;
|
||||||
|
|
||||||
|
@ -531,9 +531,9 @@ sys_timer_create(const clockid_t which_clock,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
it_pid = get_pid(good_sigevent(&event));
|
new_timer->it_pid = get_pid(good_sigevent(&event));
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
if (!it_pid) {
|
if (!new_timer->it_pid) {
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ sys_timer_create(const clockid_t which_clock,
|
||||||
event.sigev_notify = SIGEV_SIGNAL;
|
event.sigev_notify = SIGEV_SIGNAL;
|
||||||
event.sigev_signo = SIGALRM;
|
event.sigev_signo = SIGALRM;
|
||||||
event.sigev_value.sival_int = new_timer->it_id;
|
event.sigev_value.sival_int = new_timer->it_id;
|
||||||
it_pid = get_pid(task_tgid(current));
|
new_timer->it_pid = get_pid(task_tgid(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
new_timer->it_sigev_notify = event.sigev_notify;
|
new_timer->it_sigev_notify = event.sigev_notify;
|
||||||
|
@ -551,7 +551,6 @@ sys_timer_create(const clockid_t which_clock,
|
||||||
new_timer->sigq->info.si_code = SI_TIMER;
|
new_timer->sigq->info.si_code = SI_TIMER;
|
||||||
|
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
spin_lock_irq(¤t->sighand->siglock);
|
||||||
new_timer->it_pid = it_pid;
|
|
||||||
new_timer->it_signal = current->signal;
|
new_timer->it_signal = current->signal;
|
||||||
list_add(&new_timer->list, ¤t->signal->posix_timers);
|
list_add(&new_timer->list, ¤t->signal->posix_timers);
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
spin_unlock_irq(¤t->sighand->siglock);
|
||||||
|
@ -587,7 +586,7 @@ static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags)
|
||||||
timr = idr_find(&posix_timers_id, (int)timer_id);
|
timr = idr_find(&posix_timers_id, (int)timer_id);
|
||||||
if (timr) {
|
if (timr) {
|
||||||
spin_lock(&timr->it_lock);
|
spin_lock(&timr->it_lock);
|
||||||
if (timr->it_pid && timr->it_signal == current->signal) {
|
if (timr->it_signal == current->signal) {
|
||||||
spin_unlock(&idr_lock);
|
spin_unlock(&idr_lock);
|
||||||
return timr;
|
return timr;
|
||||||
}
|
}
|
||||||
|
@ -834,8 +833,7 @@ retry_delete:
|
||||||
* This keeps any tasks waiting on the spin lock from thinking
|
* This keeps any tasks waiting on the spin lock from thinking
|
||||||
* they got something (see the lock code above).
|
* they got something (see the lock code above).
|
||||||
*/
|
*/
|
||||||
put_pid(timer->it_pid);
|
timer->it_signal = NULL;
|
||||||
timer->it_pid = NULL;
|
|
||||||
|
|
||||||
unlock_timer(timer, flags);
|
unlock_timer(timer, flags);
|
||||||
release_posix_timer(timer, IT_ID_SET);
|
release_posix_timer(timer, IT_ID_SET);
|
||||||
|
@ -861,8 +859,7 @@ retry_delete:
|
||||||
* This keeps any tasks waiting on the spin lock from thinking
|
* This keeps any tasks waiting on the spin lock from thinking
|
||||||
* they got something (see the lock code above).
|
* they got something (see the lock code above).
|
||||||
*/
|
*/
|
||||||
put_pid(timer->it_pid);
|
timer->it_signal = NULL;
|
||||||
timer->it_pid = NULL;
|
|
||||||
|
|
||||||
unlock_timer(timer, flags);
|
unlock_timer(timer, flags);
|
||||||
release_posix_timer(timer, IT_ID_SET);
|
release_posix_timer(timer, IT_ID_SET);
|
||||||
|
|
Loading…
Reference in a new issue