Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 86709
b: refs/heads/master
c: a6c0e1f
h: refs/heads/master
i:
  86707: 3ec53ec
v: v3
  • Loading branch information
Linus Torvalds committed Mar 4, 2008
1 parent b96f460 commit 9eceaf4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 966ea8c4b74aa6fde2d58c50a904619fd849ae93
refs/heads/master: a6c0e1f71d37b89c883d636eca48a017c055c8c4
29 changes: 12 additions & 17 deletions trunk/kernel/power/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,15 @@ void refrigerator(void)
__set_current_state(save);
}

static void fake_signal_wake_up(struct task_struct *p, int resume)
static void fake_signal_wake_up(struct task_struct *p)
{
unsigned long flags;

spin_lock_irqsave(&p->sighand->siglock, flags);
signal_wake_up(p, resume);
signal_wake_up(p, 0);
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}

static void send_fake_signal(struct task_struct *p)
{
if (task_is_stopped(p))
force_sig_specific(SIGSTOP, p);
fake_signal_wake_up(p, task_is_stopped(p));
}

static int has_mm(struct task_struct *p)
{
return (p->mm && !(p->flags & PF_BORROWED_MM));
Expand Down Expand Up @@ -121,7 +114,7 @@ static int freeze_task(struct task_struct *p, int with_mm_only)
if (freezing(p)) {
if (has_mm(p)) {
if (!signal_pending(p))
fake_signal_wake_up(p, 0);
fake_signal_wake_up(p);
} else {
if (with_mm_only)
ret = 0;
Expand All @@ -135,7 +128,7 @@ static int freeze_task(struct task_struct *p, int with_mm_only)
} else {
if (has_mm(p)) {
set_freeze_flag(p);
send_fake_signal(p);
fake_signal_wake_up(p);
} else {
if (with_mm_only) {
ret = 0;
Expand Down Expand Up @@ -182,15 +175,17 @@ static int try_to_freeze_tasks(int freeze_user_space)
if (frozen(p) || !freezeable(p))
continue;

if (task_is_traced(p) && frozen(p->parent)) {
cancel_freezing(p);
continue;
}

if (!freeze_task(p, freeze_user_space))
continue;

if (!freezer_should_skip(p))
/*
* Now that we've done set_freeze_flag, don't
* perturb a task in TASK_STOPPED or TASK_TRACED.
* It is "frozen enough". If the task does wake
* up, it will immediately call try_to_freeze.
*/
if (!task_is_stopped_or_traced(p) &&
!freezer_should_skip(p))
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
Expand Down
16 changes: 14 additions & 2 deletions trunk/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,6 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info)
/* Let the debugger run. */
__set_current_state(TASK_TRACED);
spin_unlock_irq(&current->sighand->siglock);
try_to_freeze();
read_lock(&tasklist_lock);
if (!unlikely(killed) && may_ptrace_stop()) {
do_notify_parent_cldstop(current, CLD_TRAPPED);
Expand All @@ -1640,6 +1639,13 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info)
read_unlock(&tasklist_lock);
}

/*
* While in TASK_TRACED, we were considered "frozen enough".
* Now that we woke up, it's crucial if we're supposed to be
* frozen that we freeze now before running anything substantial.
*/
try_to_freeze();

/*
* We are back. Now reacquire the siglock before touching
* last_siginfo, so that we are sure to have synchronized with
Expand Down Expand Up @@ -1757,9 +1763,15 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
sigset_t *mask = &current->blocked;
int signr = 0;

relock:
/*
* We'll jump back here after any time we were stopped in TASK_STOPPED.
* While in TASK_STOPPED, we were considered "frozen enough".
* Now that we woke up, it's crucial if we're supposed to be
* frozen that we freeze now before running anything substantial.
*/
try_to_freeze();

relock:
spin_lock_irq(&current->sighand->siglock);
for (;;) {
struct k_sigaction *ka;
Expand Down

0 comments on commit 9eceaf4

Please sign in to comment.