diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-08-05 15:13:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-08-06 11:57:45 -0400 |
commit | a7ef7878ea7c8bca9b624db3f61223cdadda2a0a (patch) | |
tree | 3727435826f2fe3d054f0f3fbc3e60f2b37d8bad | |
parent | f5d635f649607b09b0b4620d25d028fd2b1b7ea5 (diff) |
[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=6787
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/sched.h | 8 | ||||
-rw-r--r-- | kernel/power/process.c | 26 |
2 files changed, 26 insertions, 8 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6afa72e080cb..6674fc1e51bf 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1558,6 +1558,14 @@ static inline void freeze(struct task_struct *p) | |||
1558 | } | 1558 | } |
1559 | 1559 | ||
1560 | /* | 1560 | /* |
1561 | * Sometimes we may need to cancel the previous 'freeze' request | ||
1562 | */ | ||
1563 | static inline void do_not_freeze(struct task_struct *p) | ||
1564 | { | ||
1565 | p->flags &= ~PF_FREEZE; | ||
1566 | } | ||
1567 | |||
1568 | /* | ||
1561 | * Wake up a frozen process | 1569 | * Wake up a frozen process |
1562 | */ | 1570 | */ |
1563 | static inline int thaw_process(struct task_struct *p) | 1571 | static inline int thaw_process(struct task_struct *p) |
diff --git a/kernel/power/process.c b/kernel/power/process.c index b2a5f671d6cd..72e72d2c61e6 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
@@ -66,13 +66,25 @@ static inline void freeze_process(struct task_struct *p) | |||
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | static void cancel_freezing(struct task_struct *p) | ||
70 | { | ||
71 | unsigned long flags; | ||
72 | |||
73 | if (freezing(p)) { | ||
74 | pr_debug(" clean up: %s\n", p->comm); | ||
75 | do_not_freeze(p); | ||
76 | spin_lock_irqsave(&p->sighand->siglock, flags); | ||
77 | recalc_sigpending_tsk(p); | ||
78 | spin_unlock_irqrestore(&p->sighand->siglock, flags); | ||
79 | } | ||
80 | } | ||
81 | |||
69 | /* 0 = success, else # of processes that we failed to stop */ | 82 | /* 0 = success, else # of processes that we failed to stop */ |
70 | int freeze_processes(void) | 83 | int freeze_processes(void) |
71 | { | 84 | { |
72 | int todo, nr_user, user_frozen; | 85 | int todo, nr_user, user_frozen; |
73 | unsigned long start_time; | 86 | unsigned long start_time; |
74 | struct task_struct *g, *p; | 87 | struct task_struct *g, *p; |
75 | unsigned long flags; | ||
76 | 88 | ||
77 | printk( "Stopping tasks: " ); | 89 | printk( "Stopping tasks: " ); |
78 | start_time = jiffies; | 90 | start_time = jiffies; |
@@ -85,6 +97,10 @@ int freeze_processes(void) | |||
85 | continue; | 97 | continue; |
86 | if (frozen(p)) | 98 | if (frozen(p)) |
87 | continue; | 99 | continue; |
100 | if (p->state == TASK_TRACED && frozen(p->parent)) { | ||
101 | cancel_freezing(p); | ||
102 | continue; | ||
103 | } | ||
88 | if (p->mm && !(p->flags & PF_BORROWED_MM)) { | 104 | if (p->mm && !(p->flags & PF_BORROWED_MM)) { |
89 | /* The task is a user-space one. | 105 | /* The task is a user-space one. |
90 | * Freeze it unless there's a vfork completion | 106 | * Freeze it unless there's a vfork completion |
@@ -126,13 +142,7 @@ int freeze_processes(void) | |||
126 | do_each_thread(g, p) { | 142 | do_each_thread(g, p) { |
127 | if (freezeable(p) && !frozen(p)) | 143 | if (freezeable(p) && !frozen(p)) |
128 | printk(KERN_ERR " %s\n", p->comm); | 144 | printk(KERN_ERR " %s\n", p->comm); |
129 | if (freezing(p)) { | 145 | cancel_freezing(p); |
130 | pr_debug(" clean up: %s\n", p->comm); | ||
131 | p->flags &= ~PF_FREEZE; | ||
132 | spin_lock_irqsave(&p->sighand->siglock, flags); | ||
133 | recalc_sigpending_tsk(p); | ||
134 | spin_unlock_irqrestore(&p->sighand->siglock, flags); | ||
135 | } | ||
136 | } while_each_thread(g, p); | 146 | } while_each_thread(g, p); |
137 | read_unlock(&tasklist_lock); | 147 | read_unlock(&tasklist_lock); |
138 | return todo; | 148 | return todo; |