aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-07-17 07:03:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:02 -0400
commit831441862956fffa17b9801db37e6ea1650b0f69 (patch)
treeb0334921341f8f1734bdd3243de76d676329d21c /drivers
parent787d2214c19bcc9b6ac48af0ce098277a801eded (diff)
Freezer: make kernel threads nonfreezable by default
Currently, the freezer treats all tasks as freezable, except for the kernel threads that explicitly set the PF_NOFREEZE flag for themselves. This approach is problematic, since it requires every kernel thread to either set PF_NOFREEZE explicitly, or call try_to_freeze(), even if it doesn't care for the freezing of tasks at all. It seems better to only require the kernel threads that want to or need to be frozen to use some freezer-related code and to remove any freezer-related code from the other (nonfreezable) kernel threads, which is done in this patch. The patch causes all kernel threads to be nonfreezable by default (ie. to have PF_NOFREEZE set by default) and introduces the set_freezable() function that should be called by the freezable kernel threads in order to unset PF_NOFREEZE. It also makes all of the currently freezable kernel threads call set_freezable(), so it shouldn't cause any (intentional) change of behaviour to appear. Additionally, it updates documentation to describe the freezing of tasks more accurately. [akpm@linux-foundation.org: build fixes] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Nigel Cunningham <nigel@nigel.suspend2.net> Cc: Pavel Machek <pavel@ucw.cz> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Gautham R Shenoy <ego@in.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/loop.c8
-rw-r--r--drivers/block/pktcdvd.c1
-rw-r--r--drivers/char/apm-emulation.c12
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/ieee1394/ieee1394_core.c3
-rw-r--r--drivers/ieee1394/nodemgr.c1
-rw-r--r--drivers/input/gameport/gameport.c1
-rw-r--r--drivers/input/serio/serio.c1
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c1
-rw-r--r--drivers/macintosh/therm_adt746x.c1
-rw-r--r--drivers/macintosh/windfarm_core.c1
-rw-r--r--drivers/md/md.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c1
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c1
-rw-r--r--drivers/media/video/msp3400-kthreads.c6
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/media/video/video-buf-dvb.c1
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/mfd/ucb1x00-ts.c1
-rw-r--r--drivers/mmc/card/queue.c7
-rw-r--r--drivers/mtd/mtd_blkdevs.c3
-rw-r--r--drivers/mtd/ubi/wl.c1
-rw-r--r--drivers/net/wireless/airo.c3
-rw-r--r--drivers/net/wireless/libertas/main.c1
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pnp/pnpbios/core.c1
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c3
-rw-r--r--drivers/scsi/scsi_error.c3
-rw-r--r--drivers/usb/atm/ueagle-atm.c1
-rw-r--r--drivers/usb/core/hub.c1
-rw-r--r--drivers/usb/gadget/file_storage.c3
-rw-r--r--drivers/usb/storage/usb.c3
-rw-r--r--drivers/video/ps3fb.c1
-rw-r--r--drivers/w1/w1.c1
35 files changed, 42 insertions, 37 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 4503290da407..06eaa11cbc2f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -68,6 +68,7 @@
68#include <linux/loop.h> 68#include <linux/loop.h>
69#include <linux/compat.h> 69#include <linux/compat.h>
70#include <linux/suspend.h> 70#include <linux/suspend.h>
71#include <linux/freezer.h>
71#include <linux/writeback.h> 72#include <linux/writeback.h>
72#include <linux/buffer_head.h> /* for invalidate_bdev() */ 73#include <linux/buffer_head.h> /* for invalidate_bdev() */
73#include <linux/completion.h> 74#include <linux/completion.h>
@@ -600,13 +601,6 @@ static int loop_thread(void *data)
600 struct loop_device *lo = data; 601 struct loop_device *lo = data;
601 struct bio *bio; 602 struct bio *bio;
602 603
603 /*
604 * loop can be used in an encrypted device,
605 * hence, it mustn't be stopped at all
606 * because it could be indirectly used during suspension
607 */
608 current->flags |= PF_NOFREEZE;
609
610 set_user_nice(current, -20); 604 set_user_nice(current, -20);
611 605
612 while (!kthread_should_stop() || lo->lo_bio) { 606 while (!kthread_should_stop() || lo->lo_bio) {
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 7c294a40002e..31be33e4f119 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1593,6 +1593,7 @@ static int kcdrwd(void *foobar)
1593 long min_sleep_time, residue; 1593 long min_sleep_time, residue;
1594 1594
1595 set_user_nice(current, -20); 1595 set_user_nice(current, -20);
1596 set_freezable();
1596 1597
1597 for (;;) { 1598 for (;;) {
1598 DECLARE_WAITQUEUE(wait, current); 1599 DECLARE_WAITQUEUE(wait, current);
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 179c7a3b6e75..ec116df919d9 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -20,6 +20,7 @@
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/apm-emulation.h> 22#include <linux/apm-emulation.h>
23#include <linux/freezer.h>
23#include <linux/device.h> 24#include <linux/device.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/list.h> 26#include <linux/list.h>
@@ -329,13 +330,8 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
329 /* 330 /*
330 * Wait for the suspend/resume to complete. If there 331 * Wait for the suspend/resume to complete. If there
331 * are pending acknowledges, we wait here for them. 332 * are pending acknowledges, we wait here for them.
332 *
333 * Note: we need to ensure that the PM subsystem does
334 * not kick us out of the wait when it suspends the
335 * threads.
336 */ 333 */
337 flags = current->flags; 334 flags = current->flags;
338 current->flags |= PF_NOFREEZE;
339 335
340 wait_event(apm_suspend_waitqueue, 336 wait_event(apm_suspend_waitqueue,
341 as->suspend_state == SUSPEND_DONE); 337 as->suspend_state == SUSPEND_DONE);
@@ -365,13 +361,8 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
365 /* 361 /*
366 * Wait for the suspend/resume to complete. If there 362 * Wait for the suspend/resume to complete. If there
367 * are pending acknowledges, we wait here for them. 363 * are pending acknowledges, we wait here for them.
368 *
369 * Note: we need to ensure that the PM subsystem does
370 * not kick us out of the wait when it suspends the
371 * threads.
372 */ 364 */
373 flags = current->flags; 365 flags = current->flags;
374 current->flags |= PF_NOFREEZE;
375 366
376 wait_event_interruptible(apm_suspend_waitqueue, 367 wait_event_interruptible(apm_suspend_waitqueue,
377 as->suspend_state == SUSPEND_DONE); 368 as->suspend_state == SUSPEND_DONE);
@@ -598,7 +589,6 @@ static int __init apm_init(void)
598 kapmd_tsk = NULL; 589 kapmd_tsk = NULL;
599 return ret; 590 return ret;
600 } 591 }
601 kapmd_tsk->flags |= PF_NOFREEZE;
602 wake_up_process(kapmd_tsk); 592 wake_up_process(kapmd_tsk);
603 593
604#ifdef CONFIG_PROC_FS 594#ifdef CONFIG_PROC_FS
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index b3ab42e0dd4a..83c1151ec7a2 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -679,6 +679,7 @@ static int khvcd(void *unused)
679 int poll_mask; 679 int poll_mask;
680 struct hvc_struct *hp; 680 struct hvc_struct *hp;
681 681
682 set_freezable();
682 __set_current_state(TASK_RUNNING); 683 __set_current_state(TASK_RUNNING);
683 do { 684 do {
684 poll_mask = 0; 685 poll_mask = 0;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 7b622300d0e5..804875de5801 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -1906,6 +1906,7 @@ static void do_edac_check(void)
1906 1906
1907static int edac_kernel_thread(void *arg) 1907static int edac_kernel_thread(void *arg)
1908{ 1908{
1909 set_freezable();
1909 while (!kthread_should_stop()) { 1910 while (!kthread_should_stop()) {
1910 do_edac_check(); 1911 do_edac_check();
1911 1912
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 0fc8c6e559e4..ee45259573c8 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -30,6 +30,7 @@
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/kdev_t.h> 32#include <linux/kdev_t.h>
33#include <linux/freezer.h>
33#include <linux/suspend.h> 34#include <linux/suspend.h>
34#include <linux/kthread.h> 35#include <linux/kthread.h>
35#include <linux/preempt.h> 36#include <linux/preempt.h>
@@ -1128,8 +1129,6 @@ static int hpsbpkt_thread(void *__hi)
1128 struct list_head tmp; 1129 struct list_head tmp;
1129 int may_schedule; 1130 int may_schedule;
1130 1131
1131 current->flags |= PF_NOFREEZE;
1132
1133 while (!kthread_should_stop()) { 1132 while (!kthread_should_stop()) {
1134 1133
1135 INIT_LIST_HEAD(&tmp); 1134 INIT_LIST_HEAD(&tmp);
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 51a12062ed36..2ffd53461db6 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -1699,6 +1699,7 @@ static int nodemgr_host_thread(void *__hi)
1699 unsigned int g, generation = 0; 1699 unsigned int g, generation = 0;
1700 int i, reset_cycles = 0; 1700 int i, reset_cycles = 0;
1701 1701
1702 set_freezable();
1702 /* Setup our device-model entries */ 1703 /* Setup our device-model entries */
1703 nodemgr_create_host_dev_files(host); 1704 nodemgr_create_host_dev_files(host);
1704 1705
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index bd686a2a517d..20896d5e5f0e 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -445,6 +445,7 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent)
445 445
446static int gameport_thread(void *nothing) 446static int gameport_thread(void *nothing)
447{ 447{
448 set_freezable();
448 do { 449 do {
449 gameport_handle_event(); 450 gameport_handle_event();
450 wait_event_interruptible(gameport_wait, 451 wait_event_interruptible(gameport_wait,
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index a8f3bc1dff22..372ca4931194 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -384,6 +384,7 @@ static struct serio *serio_get_pending_child(struct serio *parent)
384 384
385static int serio_thread(void *nothing) 385static int serio_thread(void *nothing)
386{ 386{
387 set_freezable();
387 do { 388 do {
388 serio_handle_event(); 389 serio_handle_event();
389 wait_event_interruptible(serio_wait, 390 wait_event_interruptible(serio_wait,
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index f0cbcdb008ed..36f944019158 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -292,6 +292,7 @@ static int ucb1400_ts_thread(void *_ucb)
292 292
293 sched_setscheduler(tsk, SCHED_FIFO, &param); 293 sched_setscheduler(tsk, SCHED_FIFO, &param);
294 294
295 set_freezable();
295 while (!kthread_should_stop()) { 296 while (!kthread_should_stop()) {
296 unsigned int x, y, p; 297 unsigned int x, y, p;
297 long timeout; 298 long timeout;
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index bd55e6ab99fc..f25685b9b7cf 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -335,6 +335,7 @@ static int monitor_task(void *arg)
335{ 335{
336 struct thermostat* th = arg; 336 struct thermostat* th = arg;
337 337
338 set_freezable();
338 while(!kthread_should_stop()) { 339 while(!kthread_should_stop()) {
339 try_to_freeze(); 340 try_to_freeze();
340 msleep_interruptible(2000); 341 msleep_interruptible(2000);
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index 4fcb245ba184..e18d265d5d33 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -92,6 +92,7 @@ static int wf_thread_func(void *data)
92 92
93 DBG("wf: thread started\n"); 93 DBG("wf: thread started\n");
94 94
95 set_freezable();
95 while(!kthread_should_stop()) { 96 while(!kthread_should_stop()) {
96 if (time_after_eq(jiffies, next)) { 97 if (time_after_eq(jiffies, next)) {
97 wf_notify(WF_EVENT_TICK, NULL); 98 wf_notify(WF_EVENT_TICK, NULL);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 33beaa7da085..9aefc4a023df 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4642,7 +4642,6 @@ static int md_thread(void * arg)
4642 * many dirty RAID5 blocks. 4642 * many dirty RAID5 blocks.
4643 */ 4643 */
4644 4644
4645 current->flags |= PF_NOFREEZE;
4646 allow_signal(SIGKILL); 4645 allow_signal(SIGKILL);
4647 while (!kthread_should_stop()) { 4646 while (!kthread_should_stop()) {
4648 4647
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index f4e4ca2dcade..b6c7f6610ec5 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -523,6 +523,7 @@ static int dvb_frontend_thread(void *data)
523 523
524 dvb_frontend_init(fe); 524 dvb_frontend_init(fe);
525 525
526 set_freezable();
526 while (1) { 527 while (1) {
527 up(&fepriv->sem); /* is locked when we enter the thread... */ 528 up(&fepriv->sem); /* is locked when we enter the thread... */
528restart: 529restart:
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 259ea08e784f..1cc2d286a1cb 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -906,6 +906,7 @@ int cx88_audio_thread(void *data)
906 u32 mode = 0; 906 u32 mode = 0;
907 907
908 dprintk("cx88: tvaudio thread started\n"); 908 dprintk("cx88: tvaudio thread started\n");
909 set_freezable();
909 for (;;) { 910 for (;;) {
910 msleep_interruptible(1000); 911 msleep_interruptible(1000);
911 if (kthread_should_stop()) 912 if (kthread_should_stop())
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index e1821eb82fb5..d5ee2629121e 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/freezer.h>
26#include <linux/videodev.h> 27#include <linux/videodev.h>
27#include <linux/videodev2.h> 28#include <linux/videodev2.h>
28#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
@@ -468,6 +469,7 @@ int msp3400c_thread(void *data)
468 469
469 470
470 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n"); 471 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
472 set_freezable();
471 for (;;) { 473 for (;;) {
472 v4l_dbg(2, msp_debug, client, "msp3400 thread: sleep\n"); 474 v4l_dbg(2, msp_debug, client, "msp3400 thread: sleep\n");
473 msp_sleep(state, -1); 475 msp_sleep(state, -1);
@@ -646,7 +648,7 @@ int msp3410d_thread(void *data)
646 int val, i, std, count; 648 int val, i, std, count;
647 649
648 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n"); 650 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
649 651 set_freezable();
650 for (;;) { 652 for (;;) {
651 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n"); 653 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n");
652 msp_sleep(state,-1); 654 msp_sleep(state,-1);
@@ -940,7 +942,7 @@ int msp34xxg_thread(void *data)
940 int val, i; 942 int val, i;
941 943
942 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n"); 944 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
943 945 set_freezable();
944 for (;;) { 946 for (;;) {
945 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n"); 947 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n");
946 msp_sleep(state, -1); 948 msp_sleep(state, -1);
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index c9bf9dbc2ea3..9da338dc4f3b 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -271,7 +271,7 @@ static int chip_thread(void *data)
271 struct CHIPDESC *desc = chiplist + chip->type; 271 struct CHIPDESC *desc = chiplist + chip->type;
272 272
273 v4l_dbg(1, debug, &chip->c, "%s: thread started\n", chip->c.name); 273 v4l_dbg(1, debug, &chip->c, "%s: thread started\n", chip->c.name);
274 274 set_freezable();
275 for (;;) { 275 for (;;) {
276 set_current_state(TASK_INTERRUPTIBLE); 276 set_current_state(TASK_INTERRUPTIBLE);
277 if (!kthread_should_stop()) 277 if (!kthread_should_stop())
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index fcc5467e7636..e617925ba31e 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -47,6 +47,7 @@ static int videobuf_dvb_thread(void *data)
47 int err; 47 int err;
48 48
49 dprintk("dvb thread started\n"); 49 dprintk("dvb thread started\n");
50 set_freezable();
50 videobuf_read_start(&dvb->dvbq); 51 videobuf_read_start(&dvb->dvbq);
51 52
52 for (;;) { 53 for (;;) {
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index f7e1d1910374..3ef4d0159c33 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -573,6 +573,7 @@ static int vivi_thread(void *data)
573 dprintk(1,"thread started\n"); 573 dprintk(1,"thread started\n");
574 574
575 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); 575 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
576 set_freezable();
576 577
577 for (;;) { 578 for (;;) {
578 vivi_sleep(dma_q); 579 vivi_sleep(dma_q);
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 38e815a2e871..fdbaa776f249 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -209,6 +209,7 @@ static int ucb1x00_thread(void *_ts)
209 DECLARE_WAITQUEUE(wait, tsk); 209 DECLARE_WAITQUEUE(wait, tsk);
210 int valid = 0; 210 int valid = 0;
211 211
212 set_freezable();
212 add_wait_queue(&ts->irq_wait, &wait); 213 add_wait_queue(&ts->irq_wait, &wait);
213 while (!kthread_should_stop()) { 214 while (!kthread_should_stop()) {
214 unsigned int x, y, p; 215 unsigned int x, y, p;
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 4fb2089dc690..b53dac8d1b69 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/blkdev.h> 13#include <linux/blkdev.h>
14#include <linux/freezer.h>
14#include <linux/kthread.h> 15#include <linux/kthread.h>
15 16
16#include <linux/mmc/card.h> 17#include <linux/mmc/card.h>
@@ -44,11 +45,7 @@ static int mmc_queue_thread(void *d)
44 struct mmc_queue *mq = d; 45 struct mmc_queue *mq = d;
45 struct request_queue *q = mq->queue; 46 struct request_queue *q = mq->queue;
46 47
47 /* 48 current->flags |= PF_MEMALLOC;
48 * Set iothread to ensure that we aren't put to sleep by
49 * the process freezing. We handle suspension ourselves.
50 */
51 current->flags |= PF_MEMALLOC|PF_NOFREEZE;
52 49
53 down(&mq->thread_sem); 50 down(&mq->thread_sem);
54 do { 51 do {
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 51bc7e2f1f22..ef89780eb9d6 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -16,6 +16,7 @@
16#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
17#include <linux/blkdev.h> 17#include <linux/blkdev.h>
18#include <linux/blkpg.h> 18#include <linux/blkpg.h>
19#include <linux/freezer.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20#include <linux/hdreg.h> 21#include <linux/hdreg.h>
21#include <linux/init.h> 22#include <linux/init.h>
@@ -80,7 +81,7 @@ static int mtd_blktrans_thread(void *arg)
80 struct request_queue *rq = tr->blkcore_priv->rq; 81 struct request_queue *rq = tr->blkcore_priv->rq;
81 82
82 /* we might get involved when memory gets low, so use PF_MEMALLOC */ 83 /* we might get involved when memory gets low, so use PF_MEMALLOC */
83 current->flags |= PF_MEMALLOC | PF_NOFREEZE; 84 current->flags |= PF_MEMALLOC;
84 85
85 spin_lock_irq(rq->queue_lock); 86 spin_lock_irq(rq->queue_lock);
86 while (!kthread_should_stop()) { 87 while (!kthread_should_stop()) {
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 9ecaf77eca9e..ab2174a56bc2 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1346,6 +1346,7 @@ static int ubi_thread(void *u)
1346 ubi_msg("background thread \"%s\" started, PID %d", 1346 ubi_msg("background thread \"%s\" started, PID %d",
1347 ubi->bgt_name, current->pid); 1347 ubi->bgt_name, current->pid);
1348 1348
1349 set_freezable();
1349 for (;;) { 1350 for (;;) {
1350 int err; 1351 int err;
1351 1352
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 1c54908fdc4c..ee1cc14db389 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -3086,7 +3086,8 @@ static int airo_thread(void *data) {
3086 struct net_device *dev = data; 3086 struct net_device *dev = data;
3087 struct airo_info *ai = dev->priv; 3087 struct airo_info *ai = dev->priv;
3088 int locked; 3088 int locked;
3089 3089
3090 set_freezable();
3090 while(1) { 3091 while(1) {
3091 /* make swsusp happy with our thread */ 3092 /* make swsusp happy with our thread */
3092 try_to_freeze(); 3093 try_to_freeze();
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 4a59306a3f05..9f366242c392 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -613,6 +613,7 @@ static int wlan_service_main_thread(void *data)
613 613
614 init_waitqueue_entry(&wait, current); 614 init_waitqueue_entry(&wait, current);
615 615
616 set_freezable();
616 for (;;) { 617 for (;;) {
617 lbs_deb_thread( "main-thread 111: intcounter=%d " 618 lbs_deb_thread( "main-thread 111: intcounter=%d "
618 "currenttxskb=%p dnld_sent=%d\n", 619 "currenttxskb=%p dnld_sent=%d\n",
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 50cad3a59a6c..7c93a108f9b8 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -651,6 +651,7 @@ static int pccardd(void *__skt)
651 add_wait_queue(&skt->thread_wait, &wait); 651 add_wait_queue(&skt->thread_wait, &wait);
652 complete(&skt->thread_done); 652 complete(&skt->thread_done);
653 653
654 set_freezable();
654 for (;;) { 655 for (;;) {
655 unsigned long flags; 656 unsigned long flags;
656 unsigned int events; 657 unsigned int events;
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 3a201b77b963..03baf1c64a2e 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -160,6 +160,7 @@ static int pnp_dock_thread(void * unused)
160{ 160{
161 static struct pnp_docking_station_info now; 161 static struct pnp_docking_station_info now;
162 int docked = -1, d = 0; 162 int docked = -1, d = 0;
163 set_freezable();
163 while (!unloading) 164 while (!unloading)
164 { 165 {
165 int status; 166 int status;
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index d70ddfda93fc..9c5342e7a69c 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -40,6 +40,7 @@
40 40
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/blkdev.h> 42#include <linux/blkdev.h>
43#include <linux/freezer.h>
43#include <linux/scatterlist.h> 44#include <linux/scatterlist.h>
44 45
45/* ---------- SCSI Host glue ---------- */ 46/* ---------- SCSI Host glue ---------- */
@@ -868,8 +869,6 @@ static int sas_queue_thread(void *_sas_ha)
868{ 869{
869 struct sas_ha_struct *sas_ha = _sas_ha; 870 struct sas_ha_struct *sas_ha = _sas_ha;
870 871
871 current->flags |= PF_NOFREEZE;
872
873 while (1) { 872 while (1) {
874 set_current_state(TASK_INTERRUPTIBLE); 873 set_current_state(TASK_INTERRUPTIBLE);
875 schedule(); 874 schedule();
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 9adb64ac054c..8a525abda30f 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -19,6 +19,7 @@
19#include <linux/timer.h> 19#include <linux/timer.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/freezer.h>
22#include <linux/kthread.h> 23#include <linux/kthread.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/blkdev.h> 25#include <linux/blkdev.h>
@@ -1516,8 +1517,6 @@ int scsi_error_handler(void *data)
1516{ 1517{
1517 struct Scsi_Host *shost = data; 1518 struct Scsi_Host *shost = data;
1518 1519
1519 current->flags |= PF_NOFREEZE;
1520
1521 /* 1520 /*
1522 * We use TASK_INTERRUPTIBLE so that the thread is not 1521 * We use TASK_INTERRUPTIBLE so that the thread is not
1523 * counted against the load average as a running process. 1522 * counted against the load average as a running process.
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 4973e147bc79..8f046659b4e9 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1168,6 +1168,7 @@ static int uea_kthread(void *data)
1168 struct uea_softc *sc = data; 1168 struct uea_softc *sc = data;
1169 int ret = -EAGAIN; 1169 int ret = -EAGAIN;
1170 1170
1171 set_freezable();
1171 uea_enters(INS_TO_USBDEV(sc)); 1172 uea_enters(INS_TO_USBDEV(sc));
1172 while (!kthread_should_stop()) { 1173 while (!kthread_should_stop()) {
1173 if (ret < 0 || sc->reset) 1174 if (ret < 0 || sc->reset)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 50e79010401c..fd74c50b1804 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2728,6 +2728,7 @@ loop:
2728 2728
2729static int hub_thread(void *__unused) 2729static int hub_thread(void *__unused)
2730{ 2730{
2731 set_freezable();
2731 do { 2732 do {
2732 hub_events(); 2733 hub_events();
2733 wait_event_interruptible(khubd_wait, 2734 wait_event_interruptible(khubd_wait,
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 8712ef987179..be7a1bd2823b 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3434,6 +3434,9 @@ static int fsg_main_thread(void *fsg_)
3434 allow_signal(SIGKILL); 3434 allow_signal(SIGKILL);
3435 allow_signal(SIGUSR1); 3435 allow_signal(SIGUSR1);
3436 3436
3437 /* Allow the thread to be frozen */
3438 set_freezable();
3439
3437 /* Arrange for userspace references to be interpreted as kernel 3440 /* Arrange for userspace references to be interpreted as kernel
3438 * pointers. That way we can pass a kernel pointer to a routine 3441 * pointers. That way we can pass a kernel pointer to a routine
3439 * that expects a __user pointer and it will work okay. */ 3442 * that expects a __user pointer and it will work okay. */
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index bef8bcd9bd98..28842d208bb0 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -311,8 +311,6 @@ static int usb_stor_control_thread(void * __us)
311 struct Scsi_Host *host = us_to_host(us); 311 struct Scsi_Host *host = us_to_host(us);
312 int autopm_rc; 312 int autopm_rc;
313 313
314 current->flags |= PF_NOFREEZE;
315
316 for(;;) { 314 for(;;) {
317 US_DEBUGP("*** thread sleeping.\n"); 315 US_DEBUGP("*** thread sleeping.\n");
318 if(down_interruptible(&us->sema)) 316 if(down_interruptible(&us->sema))
@@ -920,6 +918,7 @@ static int usb_stor_scan_thread(void * __us)
920 printk(KERN_DEBUG 918 printk(KERN_DEBUG
921 "usb-storage: device found at %d\n", us->pusb_dev->devnum); 919 "usb-storage: device found at %d\n", us->pusb_dev->devnum);
922 920
921 set_freezable();
923 /* Wait for the timeout to expire or for a disconnect */ 922 /* Wait for the timeout to expire or for a disconnect */
924 if (delay_use > 0) { 923 if (delay_use > 0) {
925 printk(KERN_DEBUG "usb-storage: waiting for device " 924 printk(KERN_DEBUG "usb-storage: waiting for device "
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 08b7ffbbbbd8..3972aa8cf859 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -812,6 +812,7 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
812 812
813static int ps3fbd(void *arg) 813static int ps3fbd(void *arg)
814{ 814{
815 set_freezable();
815 while (!kthread_should_stop()) { 816 while (!kthread_should_stop()) {
816 try_to_freeze(); 817 try_to_freeze();
817 set_current_state(TASK_INTERRUPTIBLE); 818 set_current_state(TASK_INTERRUPTIBLE);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f5c5b760ed7b..c6332108f1c5 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -805,6 +805,7 @@ static int w1_control(void *data)
805 struct w1_master *dev, *n; 805 struct w1_master *dev, *n;
806 int have_to_wait = 0; 806 int have_to_wait = 0;
807 807
808 set_freezable();
808 while (!kthread_should_stop() || have_to_wait) { 809 while (!kthread_should_stop() || have_to_wait) {
809 have_to_wait = 0; 810 have_to_wait = 0;
810 811