···1212 do {1313 hub_events();1414 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));1515- if (current->flags & PF_FREEZE)1616- refrigerator(PF_FREEZE);1515+ try_to_freeze();1716 } while (!signal_pending(current));18171918from drivers/usb/core/hub.c::hub_thread()
+1-1
Documentation/power/swsusp.txt
···164164should be held at that point and it must be safe to sleep there), and165165add:166166167167- try_to_freeze(PF_FREEZE);167167+ try_to_freeze();168168169169If the thread is needed for writing the image to storage, you should170170instead set the PF_NOFREEZE process flag when creating the thread (and
+1-3
arch/frv/kernel/signal.c
···536536 if (!user_mode(regs))537537 return 1;538538539539- if (current->flags & PF_FREEZE) {540540- refrigerator(0);539539+ if (try_to_freeze())541540 goto no_signal;542542- }543541544542 if (!oldset)545543 oldset = ¤t->blocked;
+1-3
arch/h8300/kernel/signal.c
···517517 if ((regs->ccr & 0x10))518518 return 1;519519520520- if (current->flags & PF_FREEZE) {521521- refrigerator(0);520520+ if (try_to_freeze())522521 goto no_signal;523523- }524522525523 current->thread.esp0 = (unsigned long) regs;526524
+1-1
arch/i386/kernel/io_apic.c
···573573 for ( ; ; ) {574574 set_current_state(TASK_INTERRUPTIBLE);575575 time_remaining = schedule_timeout(time_remaining);576576- try_to_freeze(PF_FREEZE);576576+ try_to_freeze();577577 if (time_after(jiffies,578578 prev_balance_time+balanced_irq_interval)) {579579 preempt_disable();
+1-3
arch/i386/kernel/signal.c
···608608 if (!user_mode(regs))609609 return 1;610610611611- if (current->flags & PF_FREEZE) {612612- refrigerator(0);611611+ if (try_to_freeze)613612 goto no_signal;614614- }615613616614 if (!oldset)617615 oldset = ¤t->blocked;
+1-3
arch/m32r/kernel/signal.c
···371371 if (!user_mode(regs))372372 return 1;373373374374- if (current->flags & PF_FREEZE) {375375- refrigerator(0);374374+ if (try_to_freeze()) 376375 goto no_signal;377377- }378376379377 if (!oldset)380378 oldset = ¤t->blocked;
+1-2
arch/ppc/kernel/signal.c
···705705 unsigned long frame, newsp;706706 int signr, ret;707707708708- if (current->flags & PF_FREEZE) {709709- refrigerator(PF_FREEZE);708708+ if (try_to_freeze()) {710709 signr = 0;711710 if (!signal_pending(current))712711 goto no_signal;
···12511251 VPRINTK("kcdrwd: wake up\n");1252125212531253 /* make swsusp happy with our thread */12541254- if (current->flags & PF_FREEZE)12551255- refrigerator(PF_FREEZE);12541254+ try_to_freeze();1256125512571256 list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {12581257 if (!pkt->sleep_time)
+1-3
drivers/ieee1394/ieee1394_core.c
···1041104110421042 while (1) {10431043 if (down_interruptible(&khpsbpkt_sig)) {10441044- if (current->flags & PF_FREEZE) {10451045- refrigerator(0);10441044+ if (try_to_freeze())10461045 continue;10471047- }10481046 printk("khpsbpkt: received unexpected signal?!\n" );10491047 break;10501048 }
+1-1
drivers/ieee1394/nodemgr.c
···1510151015111511 if (down_interruptible(&hi->reset_sem) ||15121512 down_interruptible(&nodemgr_serialize)) {15131513- if (try_to_freeze(PF_FREEZE))15131513+ if (try_to_freeze())15141514 continue;15151515 printk("NodeMgr: received unexpected signal?!\n" );15161516 break;
+1-1
drivers/input/gameport/gameport.c
···439439 do {440440 gameport_handle_events();441441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));442442- try_to_freeze(PF_FREEZE);442442+ try_to_freeze();443443 } while (!signal_pending(current));444444445445 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
+1-1
drivers/input/serio/serio.c
···344344 do {345345 serio_handle_events();346346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));347347- try_to_freeze(PF_FREEZE);347347+ try_to_freeze();348348 } while (!signal_pending(current));349349350350 printk(KERN_DEBUG "serio: kseriod exiting\n");
···6262 break;6363 if (kthread_should_stop())6464 break;6565- if (current->flags & PF_FREEZE)6666- refrigerator(PF_FREEZE);6565+ try_to_freeze();67666867 /* feed buffer data to demux */6968 if (buf->state == STATE_DONE)
+1-1
drivers/net/8139too.c
···16061606 do {16071607 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);16081608 /* make swsusp happy with our thread */16091609- try_to_freeze(PF_FREEZE);16091609+ try_to_freeze();16101610 } while (!signal_pending (current) && (timeout > 0));1611161116121612 if (signal_pending (current)) {
+1-2
drivers/net/irda/sir_kthread.c
···135135 remove_wait_queue(&irda_rq_queue.kick, &wait);136136137137 /* make swsusp happy with our thread */138138- if (current->flags & PF_FREEZE)139139- refrigerator(PF_FREEZE);138138+ try_to_freeze();140139141140 run_irda_queue();142141 }
+2-2
drivers/net/irda/stir4200.c
···763763 {764764#ifdef CONFIG_PM765765 /* if suspending, then power off and wait */766766- if (unlikely(current->flags & PF_FREEZE)) {766766+ if (unlikely(freezing(current))) {767767 if (stir->receiving)768768 receive_stop(stir);769769 else···771771772772 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);773773774774- refrigerator(PF_FREEZE);774774+ refrigerator();775775776776 if (change_speed(stir, stir->speed))777777 break;
···847847 wait_event_interruptible_timeout(us->delay_wait,848848 test_bit(US_FLIDX_DISCONNECTING, &us->flags),849849 delay_use * HZ);850850- if (current->flags & PF_FREEZE) {851851- refrigerator(PF_FREEZE);850850+ if (try_to_freeze())852851 goto retry;853853- }854852 }855853856854 /* If the device is still connected, perform the scanning */
+2-2
drivers/w1/w1.c
···646646 while (!control_needs_exit || have_to_wait) {647647 have_to_wait = 0;648648649649- try_to_freeze(PF_FREEZE);649649+ try_to_freeze();650650 msleep_interruptible(w1_timeout * 1000);651651652652 if (signal_pending(current))···725725 allow_signal(SIGTERM);726726727727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {728728- try_to_freeze(PF_FREEZE);728728+ try_to_freeze();729729 msleep_interruptible(w1_timeout * 1000);730730731731 if (signal_pending(current))
···167167 }168168169169 wake_up(&journal->j_wait_done_commit);170170- if (current->flags & PF_FREEZE) {170170+ if (freezing(current)) {171171 /*172172 * The simpler the better. Flushing journal isn't a173173 * good idea, because that depends on threads that may···175175 */176176 jbd_debug(1, "Now suspending kjournald\n");177177 spin_unlock(&journal->j_state_lock);178178- refrigerator(PF_FREEZE);178178+ refrigerator();179179 spin_lock(&journal->j_state_lock);180180 } else {181181 /*
···27882788 /* In case a wakeup came while all threads were active */27892789 jfs_commit_thread_waking = 0;2790279027912791- if (current->flags & PF_FREEZE) {27912791+ if (freezing(current)) {27922792 LAZY_UNLOCK(flags);27932793- refrigerator(PF_FREEZE);27932793+ refrigerator();27942794 } else {27952795 DECLARE_WAITQUEUE(wq, current);27962796···29872987 /* Add anon_list2 back to anon_list */29882988 list_splice_init(&TxAnchor.anon_list2, &TxAnchor.anon_list);2989298929902990- if (current->flags & PF_FREEZE) {29902990+ if (freezing(current)) {29912991 TXN_UNLOCK();29922992- refrigerator(PF_FREEZE);29922992+ refrigerator();29932993 } else {29942994 DECLARE_WAITQUEUE(wq, current);29952995
+1-1
fs/lockd/clntproc.c
···313313 prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);314314 if (!signalled ()) {315315 schedule_timeout(NLMCLNT_GRACE_WAIT);316316- try_to_freeze(PF_FREEZE);316316+ try_to_freeze();317317 if (!signalled ())318318 status = 0;319319 }
+2-2
fs/xfs/linux-2.6/xfs_buf.c
···1771177117721772 INIT_LIST_HEAD(&tmp);17731773 do {17741774- if (unlikely(current->flags & PF_FREEZE)) {17741774+ if (unlikely(freezing(current))) {17751775 xfsbufd_force_sleep = 1;17761776- refrigerator(PF_FREEZE);17761776+ refrigerator();17771777 } else {17781778 xfsbufd_force_sleep = 0;17791779 }
···1265126512661266#endif1267126712681268-/* try_to_freeze12691269- *12701270- * Checks whether we need to enter the refrigerator12711271- * and returns 1 if we did so.12721272- */12731268#ifdef CONFIG_PM12741274-extern void refrigerator(unsigned long);12691269+/*12701270+ * Check if a process has been frozen12711271+ */12721272+static inline int frozen(struct task_struct *p)12731273+{12741274+ return p->flags & PF_FROZEN;12751275+}12761276+12771277+/*12781278+ * Check if there is a request to freeze a process12791279+ */12801280+static inline int freezing(struct task_struct *p)12811281+{12821282+ return p->flags & PF_FREEZE;12831283+}12841284+12851285+/*12861286+ * Request that a process be frozen12871287+ * FIXME: SMP problem. We may not modify other process' flags!12881288+ */12891289+static inline void freeze(struct task_struct *p)12901290+{12911291+ p->flags |= PF_FREEZE;12921292+}12931293+12941294+/*12951295+ * Wake up a frozen process12961296+ */12971297+static inline int thaw_process(struct task_struct *p)12981298+{12991299+ if (frozen(p)) {13001300+ p->flags &= ~PF_FROZEN;13011301+ wake_up_process(p);13021302+ return 1;13031303+ }13041304+ return 0;13051305+}13061306+13071307+/*13081308+ * freezing is complete, mark process as frozen13091309+ */13101310+static inline void frozen_process(struct task_struct *p)13111311+{13121312+ p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;13131313+}13141314+13151315+extern void refrigerator(void);12751316extern int freeze_processes(void);12761317extern void thaw_processes(void);1277131812781278-static inline int try_to_freeze(unsigned long refrigerator_flags)13191319+static inline int try_to_freeze(void)12791320{12801280- if (unlikely(current->flags & PF_FREEZE)) {12811281- refrigerator(refrigerator_flags);13211321+ if (freezing(current)) {13221322+ refrigerator();12821323 return 1;12831324 } else12841325 return 0;12851326}12861327#else12871287-static inline void refrigerator(unsigned long flag) {}13281328+static inline int frozen(struct task_struct *p) { return 0; }13291329+static inline int freezing(struct task_struct *p) { return 0; }13301330+static inline void freeze(struct task_struct *p) { BUG(); }13311331+static inline int thaw_process(struct task_struct *p) { return 1; }13321332+static inline void frozen_process(struct task_struct *p) { BUG(); }13331333+13341334+static inline void refrigerator(void) {}12881335static inline int freeze_processes(void) { BUG(); return 0; }12891336static inline void thaw_processes(void) {}1290133712911291-static inline int try_to_freeze(unsigned long refrigerator_flags)12921292-{12931293- return 0;12941294-}13381338+static inline int try_to_freeze(void) { return 0; }13391339+12951340#endif /* CONFIG_PM */12961341#endif /* __KERNEL__ */12971342
+10-16
kernel/power/process.c
···3232}33333434/* Refrigerator is place where frozen processes are stored :-). */3535-void refrigerator(unsigned long flag)3535+void refrigerator(void)3636{3737 /* Hmm, should we be allowed to suspend when there are realtime3838 processes around? */···4141 current->state = TASK_UNINTERRUPTIBLE;4242 pr_debug("%s entered refrigerator\n", current->comm);4343 printk("=");4444- current->flags &= ~PF_FREEZE;45444545+ frozen_process(current);4646 spin_lock_irq(¤t->sighand->siglock);4747 recalc_sigpending(); /* We sent fake signal, clean it up */4848 spin_unlock_irq(¤t->sighand->siglock);49495050- current->flags |= PF_FROZEN;5151- while (current->flags & PF_FROZEN)5050+ while (frozen(current))5251 schedule();5352 pr_debug("%s left refrigerator\n", current->comm);5453 current->state = save;···5657/* 0 = success, else # of processes that we failed to stop */5758int freeze_processes(void)5859{5959- int todo;6060- unsigned long start_time;6060+ int todo;6161+ unsigned long start_time;6162 struct task_struct *g, *p;6262-6363+6364 printk( "Stopping tasks: " );6465 start_time = jiffies;6566 do {···6970 unsigned long flags;7071 if (!freezeable(p))7172 continue;7272- if ((p->flags & PF_FROZEN) ||7373+ if ((frozen(p)) ||7374 (p->state == TASK_TRACED) ||7475 (p->state == TASK_STOPPED))7576 continue;76777777- /* FIXME: smp problem here: we may not access other process' flags7878- without locking */7979- p->flags |= PF_FREEZE;7878+ freeze(p);8079 spin_lock_irqsave(&p->sighand->siglock, flags);8180 signal_wake_up(p, 0);8281 spin_unlock_irqrestore(&p->sighand->siglock, flags);···8891 return todo;8992 }9093 } while(todo);9191-9494+9295 printk( "|\n" );9396 BUG_ON(in_atomic());9497 return 0;···103106 do_each_thread(g, p) {104107 if (!freezeable(p))105108 continue;106106- if (p->flags & PF_FROZEN) {107107- p->flags &= ~PF_FROZEN;108108- wake_up_process(p);109109- } else109109+ if (!thaw_process(p))110110 printk(KERN_INFO " Strange, %s not stopped\n", p->comm );111111 } while_each_thread(g, p);112112