Skip to content

Commit

Permalink
Use write_trylock_irqsave in ptrace_attach
Browse files Browse the repository at this point in the history
This patch makes ptrace_attach use write_trylock_irqsave().

[[email protected]: remove unneeded initialisation]
Signed-off-by: Sripathi Kodi <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sripathi authored and Linus Torvalds committed Jul 16, 2007
1 parent e1f4a88 commit 6175ecf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6175ecf

Please sign in to comment.