aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/freezer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/freezer.c')
-rw-r--r--kernel/freezer.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/kernel/freezer.c b/kernel/freezer.c
index b1e7a7b3d2cd..c3496c6a91b2 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -52,39 +52,29 @@ bool __refrigerator(bool check_kthr_stop)
52 /* Hmm, should we be allowed to suspend when there are realtime 52 /* Hmm, should we be allowed to suspend when there are realtime
53 processes around? */ 53 processes around? */
54 bool was_frozen = false; 54 bool was_frozen = false;
55 long save; 55 long save = current->state;
56 56
57 /*
58 * No point in checking freezing() again - the caller already did.
59 * Proceed to enter FROZEN.
60 */
61 spin_lock_irq(&freezer_lock);
62repeat:
63 current->flags |= PF_FROZEN;
64 spin_unlock_irq(&freezer_lock);
65
66 save = current->state;
67 pr_debug("%s entered refrigerator\n", current->comm); 57 pr_debug("%s entered refrigerator\n", current->comm);
68 58
69 spin_lock_irq(&current->sighand->siglock);
70 recalc_sigpending(); /* We sent fake signal, clean it up */
71 spin_unlock_irq(&current->sighand->siglock);
72
73 for (;;) { 59 for (;;) {
74 set_current_state(TASK_UNINTERRUPTIBLE); 60 set_current_state(TASK_UNINTERRUPTIBLE);
61
62 spin_lock_irq(&freezer_lock);
63 current->flags |= PF_FROZEN;
75 if (!freezing(current) || 64 if (!freezing(current) ||
76 (check_kthr_stop && kthread_should_stop())) 65 (check_kthr_stop && kthread_should_stop()))
66 current->flags &= ~PF_FROZEN;
67 spin_unlock_irq(&freezer_lock);
68
69 if (!(current->flags & PF_FROZEN))
77 break; 70 break;
78 was_frozen = true; 71 was_frozen = true;
79 schedule(); 72 schedule();
80 } 73 }
81 74
82 /* leave FROZEN */ 75 spin_lock_irq(&current->sighand->siglock);
83 spin_lock_irq(&freezer_lock); 76 recalc_sigpending(); /* We sent fake signal, clean it up */
84 if (freezing(current)) 77 spin_unlock_irq(&current->sighand->siglock);
85 goto repeat;
86 current->flags &= ~PF_FROZEN;
87 spin_unlock_irq(&freezer_lock);
88 78
89 pr_debug("%s left refrigerator\n", current->comm); 79 pr_debug("%s left refrigerator\n", current->comm);
90 80