···12 do {13 hub_events();14 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));15- if (current->flags & PF_FREEZE)16- refrigerator(PF_FREEZE);17 } while (!signal_pending(current));1819from drivers/usb/core/hub.c::hub_thread()
···12 do {13 hub_events();14 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));15+ try_to_freeze();016 } while (!signal_pending(current));1718from drivers/usb/core/hub.c::hub_thread()
+1-1
Documentation/power/swsusp.txt
···164should be held at that point and it must be safe to sleep there), and165add:166167- try_to_freeze(PF_FREEZE);168169If the thread is needed for writing the image to storage, you should170instead set the PF_NOFREEZE process flag when creating the thread (and
···164should be held at that point and it must be safe to sleep there), and165add:166167+ try_to_freeze();168169If the thread is needed for writing the image to storage, you should170instead set the PF_NOFREEZE process flag when creating the thread (and
+1-3
arch/frv/kernel/signal.c
···536 if (!user_mode(regs))537 return 1;538539- if (current->flags & PF_FREEZE) {540- refrigerator(0);541 goto no_signal;542- }543544 if (!oldset)545 oldset = ¤t->blocked;
···536 if (!user_mode(regs))537 return 1;538539+ if (try_to_freeze())0540 goto no_signal;0541542 if (!oldset)543 oldset = ¤t->blocked;
···517 if ((regs->ccr & 0x10))518 return 1;519520+ if (try_to_freeze())0521 goto no_signal;0522523 current->thread.esp0 = (unsigned long) regs;524
+1-1
arch/i386/kernel/io_apic.c
···573 for ( ; ; ) {574 set_current_state(TASK_INTERRUPTIBLE);575 time_remaining = schedule_timeout(time_remaining);576- try_to_freeze(PF_FREEZE);577 if (time_after(jiffies,578 prev_balance_time+balanced_irq_interval)) {579 preempt_disable();
···573 for ( ; ; ) {574 set_current_state(TASK_INTERRUPTIBLE);575 time_remaining = schedule_timeout(time_remaining);576+ try_to_freeze();577 if (time_after(jiffies,578 prev_balance_time+balanced_irq_interval)) {579 preempt_disable();
+1-3
arch/i386/kernel/signal.c
···608 if (!user_mode(regs))609 return 1;610611- if (current->flags & PF_FREEZE) {612- refrigerator(0);613 goto no_signal;614- }615616 if (!oldset)617 oldset = ¤t->blocked;
···608 if (!user_mode(regs))609 return 1;610611+ if (try_to_freeze)0612 goto no_signal;0613614 if (!oldset)615 oldset = ¤t->blocked;
+1-3
arch/m32r/kernel/signal.c
···371 if (!user_mode(regs))372 return 1;373374- if (current->flags & PF_FREEZE) {375- refrigerator(0);376 goto no_signal;377- }378379 if (!oldset)380 oldset = ¤t->blocked;
···371 if (!user_mode(regs))372 return 1;373374+ if (try_to_freeze()) 0375 goto no_signal;0376377 if (!oldset)378 oldset = ¤t->blocked;
+1-2
arch/ppc/kernel/signal.c
···705 unsigned long frame, newsp;706 int signr, ret;707708- if (current->flags & PF_FREEZE) {709- refrigerator(PF_FREEZE);710 signr = 0;711 if (!signal_pending(current))712 goto no_signal;
···705 unsigned long frame, newsp;706 int signr, ret;707708+ if (try_to_freeze()) {0709 signr = 0;710 if (!signal_pending(current))711 goto no_signal;
+1-1
arch/x86_64/kernel/signal.c
···425 if (!user_mode(regs))426 return 1;427428- if (try_to_freeze(0))429 goto no_signal;430431 if (!oldset)
···425 if (!user_mode(regs))426 return 1;427428+ if (try_to_freeze())429 goto no_signal;430431 if (!oldset)
+1-2
drivers/block/pktcdvd.c
···1251 VPRINTK("kcdrwd: wake up\n");12521253 /* make swsusp happy with our thread */1254- if (current->flags & PF_FREEZE)1255- refrigerator(PF_FREEZE);12561257 list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {1258 if (!pkt->sleep_time)
···1251 VPRINTK("kcdrwd: wake up\n");12521253 /* make swsusp happy with our thread */1254+ try_to_freeze();012551256 list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {1257 if (!pkt->sleep_time)
+1-3
drivers/ieee1394/ieee1394_core.c
···10411042 while (1) {1043 if (down_interruptible(&khpsbpkt_sig)) {1044- if (current->flags & PF_FREEZE) {1045- refrigerator(0);1046 continue;1047- }1048 printk("khpsbpkt: received unexpected signal?!\n" );1049 break;1050 }
···10411042 while (1) {1043 if (down_interruptible(&khpsbpkt_sig)) {1044+ if (try_to_freeze())01045 continue;01046 printk("khpsbpkt: received unexpected signal?!\n" );1047 break;1048 }
+1-1
drivers/ieee1394/nodemgr.c
···15101511 if (down_interruptible(&hi->reset_sem) ||1512 down_interruptible(&nodemgr_serialize)) {1513- if (try_to_freeze(PF_FREEZE))1514 continue;1515 printk("NodeMgr: received unexpected signal?!\n" );1516 break;
···15101511 if (down_interruptible(&hi->reset_sem) ||1512 down_interruptible(&nodemgr_serialize)) {1513+ if (try_to_freeze())1514 continue;1515 printk("NodeMgr: received unexpected signal?!\n" );1516 break;
+1-1
drivers/input/gameport/gameport.c
···439 do {440 gameport_handle_events();441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));442- try_to_freeze(PF_FREEZE);443 } while (!signal_pending(current));444445 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
···439 do {440 gameport_handle_events();441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));442+ try_to_freeze();443 } while (!signal_pending(current));444445 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
+1-1
drivers/input/serio/serio.c
···344 do {345 serio_handle_events();346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));347- try_to_freeze(PF_FREEZE);348 } while (!signal_pending(current));349350 printk(KERN_DEBUG "serio: kseriod exiting\n");
···344 do {345 serio_handle_events();346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));347+ try_to_freeze();348 } while (!signal_pending(current));349350 printk(KERN_DEBUG "serio: kseriod exiting\n");
···62 break;63 if (kthread_should_stop())64 break;65- if (current->flags & PF_FREEZE)66- refrigerator(PF_FREEZE);6768 /* feed buffer data to demux */69 if (buf->state == STATE_DONE)
···62 break;63 if (kthread_should_stop())64 break;65+ try_to_freeze();06667 /* feed buffer data to demux */68 if (buf->state == STATE_DONE)
+1-1
drivers/net/8139too.c
···1606 do {1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);1608 /* make swsusp happy with our thread */1609- try_to_freeze(PF_FREEZE);1610 } while (!signal_pending (current) && (timeout > 0));16111612 if (signal_pending (current)) {
···1606 do {1607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);1608 /* make swsusp happy with our thread */1609+ try_to_freeze();1610 } while (!signal_pending (current) && (timeout > 0));16111612 if (signal_pending (current)) {
+1-2
drivers/net/irda/sir_kthread.c
···135 remove_wait_queue(&irda_rq_queue.kick, &wait);136137 /* make swsusp happy with our thread */138- if (current->flags & PF_FREEZE)139- refrigerator(PF_FREEZE);140141 run_irda_queue();142 }
···135 remove_wait_queue(&irda_rq_queue.kick, &wait);136137 /* make swsusp happy with our thread */138+ try_to_freeze();0139140 run_irda_queue();141 }
+2-2
drivers/net/irda/stir4200.c
···763 {764#ifdef CONFIG_PM765 /* if suspending, then power off and wait */766- if (unlikely(current->flags & PF_FREEZE)) {767 if (stir->receiving)768 receive_stop(stir);769 else···771772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);773774- refrigerator(PF_FREEZE);775776 if (change_speed(stir, stir->speed))777 break;
···763 {764#ifdef CONFIG_PM765 /* if suspending, then power off and wait */766+ if (unlikely(freezing(current))) {767 if (stir->receiving)768 receive_stop(stir);769 else···771772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);773774+ refrigerator();775776 if (change_speed(stir, stir->speed))777 break;
+1-1
drivers/net/wireless/airo.c
···2918 flush_signals(current);29192920 /* make swsusp happy with our thread */2921- try_to_freeze(PF_FREEZE);29222923 if (test_bit(JOB_DIE, &ai->flags))2924 break;
···2918 flush_signals(current);29192920 /* make swsusp happy with our thread */2921+ try_to_freeze();29222923 if (test_bit(JOB_DIE, &ai->flags))2924 break;
+1-1
drivers/pcmcia/cs.c
···718 }719720 schedule();721- try_to_freeze(PF_FREEZE);722723 if (!skt->thread)724 break;
···847 wait_event_interruptible_timeout(us->delay_wait,848 test_bit(US_FLIDX_DISCONNECTING, &us->flags),849 delay_use * HZ);850- if (current->flags & PF_FREEZE) {851- refrigerator(PF_FREEZE);852 goto retry;853- }854 }855856 /* If the device is still connected, perform the scanning */
···847 wait_event_interruptible_timeout(us->delay_wait,848 test_bit(US_FLIDX_DISCONNECTING, &us->flags),849 delay_use * HZ);850+ if (try_to_freeze())0851 goto retry;0852 }853854 /* If the device is still connected, perform the scanning */
+2-2
drivers/w1/w1.c
···646 while (!control_needs_exit || have_to_wait) {647 have_to_wait = 0;648649- try_to_freeze(PF_FREEZE);650 msleep_interruptible(w1_timeout * 1000);651652 if (signal_pending(current))···725 allow_signal(SIGTERM);726727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {728- try_to_freeze(PF_FREEZE);729 msleep_interruptible(w1_timeout * 1000);730731 if (signal_pending(current))
···646 while (!control_needs_exit || have_to_wait) {647 have_to_wait = 0;648649+ try_to_freeze();650 msleep_interruptible(w1_timeout * 1000);651652 if (signal_pending(current))···725 allow_signal(SIGTERM);726727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {728+ try_to_freeze();729 msleep_interruptible(w1_timeout * 1000);730731 if (signal_pending(current))
···167 }168169 wake_up(&journal->j_wait_done_commit);170- if (current->flags & PF_FREEZE) {171 /*172 * The simpler the better. Flushing journal isn't a173 * good idea, because that depends on threads that may···175 */176 jbd_debug(1, "Now suspending kjournald\n");177 spin_unlock(&journal->j_state_lock);178- refrigerator(PF_FREEZE);179 spin_lock(&journal->j_state_lock);180 } else {181 /*
···167 }168169 wake_up(&journal->j_wait_done_commit);170+ if (freezing(current)) {171 /*172 * The simpler the better. Flushing journal isn't a173 * good idea, because that depends on threads that may···175 */176 jbd_debug(1, "Now suspending kjournald\n");177 spin_unlock(&journal->j_state_lock);178+ refrigerator();179 spin_lock(&journal->j_state_lock);180 } else {181 /*
···2788 /* In case a wakeup came while all threads were active */2789 jfs_commit_thread_waking = 0;27902791- if (current->flags & PF_FREEZE) {2792 LAZY_UNLOCK(flags);2793- refrigerator(PF_FREEZE);2794 } else {2795 DECLARE_WAITQUEUE(wq, current);2796···2987 /* Add anon_list2 back to anon_list */2988 list_splice_init(&TxAnchor.anon_list2, &TxAnchor.anon_list);29892990- if (current->flags & PF_FREEZE) {2991 TXN_UNLOCK();2992- refrigerator(PF_FREEZE);2993 } else {2994 DECLARE_WAITQUEUE(wq, current);2995
···2788 /* In case a wakeup came while all threads were active */2789 jfs_commit_thread_waking = 0;27902791+ if (freezing(current)) {2792 LAZY_UNLOCK(flags);2793+ refrigerator();2794 } else {2795 DECLARE_WAITQUEUE(wq, current);2796···2987 /* Add anon_list2 back to anon_list */2988 list_splice_init(&TxAnchor.anon_list2, &TxAnchor.anon_list);29892990+ if (freezing(current)) {2991 TXN_UNLOCK();2992+ refrigerator();2993 } else {2994 DECLARE_WAITQUEUE(wq, current);2995
+1-1
fs/lockd/clntproc.c
···313 prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);314 if (!signalled ()) {315 schedule_timeout(NLMCLNT_GRACE_WAIT);316- try_to_freeze(PF_FREEZE);317 if (!signalled ())318 status = 0;319 }
···313 prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);314 if (!signalled ()) {315 schedule_timeout(NLMCLNT_GRACE_WAIT);316+ try_to_freeze();317 if (!signalled ())318 status = 0;319 }
+2-2
fs/xfs/linux-2.6/xfs_buf.c
···17711772 INIT_LIST_HEAD(&tmp);1773 do {1774- if (unlikely(current->flags & PF_FREEZE)) {1775 xfsbufd_force_sleep = 1;1776- refrigerator(PF_FREEZE);1777 } else {1778 xfsbufd_force_sleep = 0;1779 }
···17711772 INIT_LIST_HEAD(&tmp);1773 do {1774+ if (unlikely(freezing(current))) {1775 xfsbufd_force_sleep = 1;1776+ refrigerator();1777 } else {1778 xfsbufd_force_sleep = 0;1779 }
···12651266#endif12671268-/* try_to_freeze1269- *1270- * Checks whether we need to enter the refrigerator1271- * and returns 1 if we did so.1272- */1273#ifdef CONFIG_PM1274-extern void refrigerator(unsigned long);00000000000000000000000000000000000000000000001275extern int freeze_processes(void);1276extern void thaw_processes(void);12771278-static inline int try_to_freeze(unsigned long refrigerator_flags)1279{1280- if (unlikely(current->flags & PF_FREEZE)) {1281- refrigerator(refrigerator_flags);1282 return 1;1283 } else1284 return 0;1285}1286#else1287-static inline void refrigerator(unsigned long flag) {}0000001288static inline int freeze_processes(void) { BUG(); return 0; }1289static inline void thaw_processes(void) {}12901291-static inline int try_to_freeze(unsigned long refrigerator_flags)1292-{1293- return 0;1294-}1295#endif /* CONFIG_PM */1296#endif /* __KERNEL__ */1297
···12651266#endif1267000001268#ifdef CONFIG_PM1269+/*1270+ * Check if a process has been frozen1271+ */1272+static inline int frozen(struct task_struct *p)1273+{1274+ return p->flags & PF_FROZEN;1275+}1276+1277+/*1278+ * Check if there is a request to freeze a process1279+ */1280+static inline int freezing(struct task_struct *p)1281+{1282+ return p->flags & PF_FREEZE;1283+}1284+1285+/*1286+ * Request that a process be frozen1287+ * FIXME: SMP problem. We may not modify other process' flags!1288+ */1289+static inline void freeze(struct task_struct *p)1290+{1291+ p->flags |= PF_FREEZE;1292+}1293+1294+/*1295+ * Wake up a frozen process1296+ */1297+static inline int thaw_process(struct task_struct *p)1298+{1299+ if (frozen(p)) {1300+ p->flags &= ~PF_FROZEN;1301+ wake_up_process(p);1302+ return 1;1303+ }1304+ return 0;1305+}1306+1307+/*1308+ * freezing is complete, mark process as frozen1309+ */1310+static inline void frozen_process(struct task_struct *p)1311+{1312+ p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;1313+}1314+1315+extern void refrigerator(void);1316extern int freeze_processes(void);1317extern void thaw_processes(void);13181319+static inline int try_to_freeze(void)1320{1321+ if (freezing(current)) {1322+ refrigerator();1323 return 1;1324 } else1325 return 0;1326}1327#else1328+static inline int frozen(struct task_struct *p) { return 0; }1329+static inline int freezing(struct task_struct *p) { return 0; }1330+static inline void freeze(struct task_struct *p) { BUG(); }1331+static inline int thaw_process(struct task_struct *p) { return 1; }1332+static inline void frozen_process(struct task_struct *p) { BUG(); }1333+1334+static inline void refrigerator(void) {}1335static inline int freeze_processes(void) { BUG(); return 0; }1336static inline void thaw_processes(void) {}13371338+static inline int try_to_freeze(void) { return 0; }1339+001340#endif /* CONFIG_PM */1341#endif /* __KERNEL__ */1342
+10-16
kernel/power/process.c
···32}3334/* Refrigerator is place where frozen processes are stored :-). */35-void refrigerator(unsigned long flag)36{37 /* Hmm, should we be allowed to suspend when there are realtime38 processes around? */···41 current->state = TASK_UNINTERRUPTIBLE;42 pr_debug("%s entered refrigerator\n", current->comm);43 printk("=");44- current->flags &= ~PF_FREEZE;45046 spin_lock_irq(¤t->sighand->siglock);47 recalc_sigpending(); /* We sent fake signal, clean it up */48 spin_unlock_irq(¤t->sighand->siglock);4950- current->flags |= PF_FROZEN;51- while (current->flags & PF_FROZEN)52 schedule();53 pr_debug("%s left refrigerator\n", current->comm);54 current->state = save;···56/* 0 = success, else # of processes that we failed to stop */57int freeze_processes(void)58{59- int todo;60- unsigned long start_time;61 struct task_struct *g, *p;62-63 printk( "Stopping tasks: " );64 start_time = jiffies;65 do {···69 unsigned long flags;70 if (!freezeable(p))71 continue;72- if ((p->flags & PF_FROZEN) ||73 (p->state == TASK_TRACED) ||74 (p->state == TASK_STOPPED))75 continue;7677- /* FIXME: smp problem here: we may not access other process' flags78- without locking */79- p->flags |= PF_FREEZE;80 spin_lock_irqsave(&p->sighand->siglock, flags);81 signal_wake_up(p, 0);82 spin_unlock_irqrestore(&p->sighand->siglock, flags);···88 return todo;89 }90 } while(todo);91-92 printk( "|\n" );93 BUG_ON(in_atomic());94 return 0;···103 do_each_thread(g, p) {104 if (!freezeable(p))105 continue;106- if (p->flags & PF_FROZEN) {107- p->flags &= ~PF_FROZEN;108- wake_up_process(p);109- } else110 printk(KERN_INFO " Strange, %s not stopped\n", p->comm );111 } while_each_thread(g, p);112
···32}3334/* Refrigerator is place where frozen processes are stored :-). */35+void refrigerator(void)36{37 /* Hmm, should we be allowed to suspend when there are realtime38 processes around? */···41 current->state = TASK_UNINTERRUPTIBLE;42 pr_debug("%s entered refrigerator\n", current->comm);43 printk("=");04445+ frozen_process(current);46 spin_lock_irq(¤t->sighand->siglock);47 recalc_sigpending(); /* We sent fake signal, clean it up */48 spin_unlock_irq(¤t->sighand->siglock);4950+ while (frozen(current))051 schedule();52 pr_debug("%s left refrigerator\n", current->comm);53 current->state = save;···57/* 0 = success, else # of processes that we failed to stop */58int freeze_processes(void)59{60+ int todo;61+ unsigned long start_time;62 struct task_struct *g, *p;63+64 printk( "Stopping tasks: " );65 start_time = jiffies;66 do {···70 unsigned long flags;71 if (!freezeable(p))72 continue;73+ if ((frozen(p)) ||74 (p->state == TASK_TRACED) ||75 (p->state == TASK_STOPPED))76 continue;7778+ freeze(p);0079 spin_lock_irqsave(&p->sighand->siglock, flags);80 signal_wake_up(p, 0);81 spin_unlock_irqrestore(&p->sighand->siglock, flags);···91 return todo;92 }93 } while(todo);94+95 printk( "|\n" );96 BUG_ON(in_atomic());97 return 0;···106 do_each_thread(g, p) {107 if (!freezeable(p))108 continue;109+ if (!thaw_process(p))000110 printk(KERN_INFO " Strange, %s not stopped\n", p->comm );111 } while_each_thread(g, p);112