Commit a7ef7878 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

[PATCH] Make suspend possible with a traced process at a breakpoint

It should be possible to suspend, either to RAM or to disk, if there's a
traced process that has just reached a breakpoint.  However, this is a
special case, because its parent process might have been frozen already and
then we are unable to deliver the "freeze" signal to the traced process.
If this happens, it's better to cancel the freezing of the traced process.

Ref. http://bugzilla.kernel.org/show_bug.cgi?id=6787Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f5d635f6
...@@ -1557,6 +1557,14 @@ static inline void freeze(struct task_struct *p) ...@@ -1557,6 +1557,14 @@ static inline void freeze(struct task_struct *p)
p->flags |= PF_FREEZE; p->flags |= PF_FREEZE;
} }
/*
* Sometimes we may need to cancel the previous 'freeze' request
*/
static inline void do_not_freeze(struct task_struct *p)
{
p->flags &= ~PF_FREEZE;
}
/* /*
* Wake up a frozen process * Wake up a frozen process
*/ */
......
...@@ -66,13 +66,25 @@ static inline void freeze_process(struct task_struct *p) ...@@ -66,13 +66,25 @@ static inline void freeze_process(struct task_struct *p)
} }
} }
static void cancel_freezing(struct task_struct *p)
{
unsigned long flags;
if (freezing(p)) {
pr_debug(" clean up: %s\n", p->comm);
do_not_freeze(p);
spin_lock_irqsave(&p->sighand->siglock, flags);
recalc_sigpending_tsk(p);
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}
}
/* 0 = success, else # of processes that we failed to stop */ /* 0 = success, else # of processes that we failed to stop */
int freeze_processes(void) int freeze_processes(void)
{ {
int todo, nr_user, user_frozen; int todo, nr_user, user_frozen;
unsigned long start_time; unsigned long start_time;
struct task_struct *g, *p; struct task_struct *g, *p;
unsigned long flags;
printk( "Stopping tasks: " ); printk( "Stopping tasks: " );
start_time = jiffies; start_time = jiffies;
...@@ -85,6 +97,10 @@ int freeze_processes(void) ...@@ -85,6 +97,10 @@ int freeze_processes(void)
continue; continue;
if (frozen(p)) if (frozen(p))
continue; continue;
if (p->state == TASK_TRACED && frozen(p->parent)) {
cancel_freezing(p);
continue;
}
if (p->mm && !(p->flags & PF_BORROWED_MM)) { if (p->mm && !(p->flags & PF_BORROWED_MM)) {
/* The task is a user-space one. /* The task is a user-space one.
* Freeze it unless there's a vfork completion * Freeze it unless there's a vfork completion
...@@ -126,13 +142,7 @@ int freeze_processes(void) ...@@ -126,13 +142,7 @@ int freeze_processes(void)
do_each_thread(g, p) { do_each_thread(g, p) {
if (freezeable(p) && !frozen(p)) if (freezeable(p) && !frozen(p))
printk(KERN_ERR " %s\n", p->comm); printk(KERN_ERR " %s\n", p->comm);
if (freezing(p)) { cancel_freezing(p);
pr_debug(" clean up: %s\n", p->comm);
p->flags &= ~PF_FREEZE;
spin_lock_irqsave(&p->sighand->siglock, flags);
recalc_sigpending_tsk(p);
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}
} while_each_thread(g, p); } while_each_thread(g, p);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
return todo; return todo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment