Use write_trylock_irqsave in ptrace_attach

This patch makes ptrace_attach use write_trylock_irqsave().

[akpm@linux-foundation.org: remove unneeded initialisation]
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Sripathi Kodi 2007-07-15 23:39:26 -07:00 committed by Linus Torvalds
parent e1f4a88c5a
commit 6175ecfed3

View file

@ -161,6 +161,7 @@ int ptrace_may_attach(struct task_struct *task)
int ptrace_attach(struct task_struct *task)
{
int retval;
unsigned long flags;
audit_ptrace(task);
@ -181,9 +182,7 @@ int ptrace_attach(struct task_struct *task)
* cpu's that may have task_lock).
*/
task_lock(task);
local_irq_disable();
if (!write_trylock(&tasklist_lock)) {
local_irq_enable();
if (!write_trylock_irqsave(&tasklist_lock, flags)) {
task_unlock(task);
do {
cpu_relax();
@ -211,7 +210,7 @@ int ptrace_attach(struct task_struct *task)
force_sig_specific(SIGSTOP, task);
bad:
write_unlock_irq(&tasklist_lock);
write_unlock_irqrestore(&tasklist_lock, flags);
task_unlock(task);
out:
return retval;