mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 06:01:23 +00:00
[PATCH] Simpler signal-exit concurrency handling
Some simplification in checking signal delivery against concurrent exit. Instead of using get_task_struct_rcu(), which increments the task_struct reference count, check the reference count after acquiring sighand lock. Signed-off-by: "Paul E. McKenney" <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
e56d090310
commit
2d89c92907
1 changed files with 6 additions and 5 deletions
|
@ -1102,18 +1102,19 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
ret = check_kill_permission(sig, info, p);
|
ret = check_kill_permission(sig, info, p);
|
||||||
if (!ret && sig && (sp = p->sighand)) {
|
if (!ret && sig && (sp = rcu_dereference(p->sighand))) {
|
||||||
if (!get_task_struct_rcu(p))
|
|
||||||
return -ESRCH;
|
|
||||||
spin_lock_irqsave(&sp->siglock, flags);
|
spin_lock_irqsave(&sp->siglock, flags);
|
||||||
if (p->sighand != sp) {
|
if (p->sighand != sp) {
|
||||||
spin_unlock_irqrestore(&sp->siglock, flags);
|
spin_unlock_irqrestore(&sp->siglock, flags);
|
||||||
put_task_struct(p);
|
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
if ((atomic_read(&sp->count) == 0) ||
|
||||||
|
(atomic_read(&p->usage) == 0)) {
|
||||||
|
spin_unlock_irqrestore(&sp->siglock, flags);
|
||||||
|
return -ESRCH;
|
||||||
|
}
|
||||||
ret = __group_send_sig_info(sig, info, p);
|
ret = __group_send_sig_info(sig, info, p);
|
||||||
spin_unlock_irqrestore(&sp->siglock, flags);
|
spin_unlock_irqrestore(&sp->siglock, flags);
|
||||||
put_task_struct(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue