Skip to contentSkip to conversation

Add missing refrigerator support.

PATCH In review Nigel Cunningham 2 participants 3 messages Jul 28, 2004

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add missing refrigerator support.

Hi.

Some kernel threads currently lack refrigerator support. This patch fills in the gaps.

Regards,

Nigel

arch/i386/kernel/io_apic.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/arch/i386/kernel/io_apic.c software-suspend-linux-2.6.8-rc1-mm1-rev1/arch/i386/kernel/io_apic.c
@@ -571,6 +573,8 @@
 	for ( ; ; ) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		time_remaining = schedule_timeout(time_remaining);
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
 		if (time_after(jiffies,
 				prev_balance_time+balanced_irq_interval)) {
 			do_irq_balance();
drivers/char/hvc_console.c +1 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/char/hvc_console.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/char/hvc_console.c
@@ -270,6 +270,7 @@
 	int i;
 
 	daemonize("khvcd");
+	current->flags |= PF_NOFREEZE;
 
 	for (;;) {
 		if (cpus_empty(cpus_in_xmon)) {
drivers/ieee1394/nodemgr.c +5 -1
diff -ruN linux-2.6.8-rc1-mm1/drivers/ieee1394/nodemgr.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/ieee1394/nodemgr.c
@@ -1482,7 +1481,7 @@
 		if (down_interruptible(&hi->reset_sem) ||
 		    down_interruptible(&nodemgr_serialize)) {
 			if (current->flags & PF_FREEZE) {
-				refrigerator(0);
+				refrigerator(PF_FREEZE);
 				continue;
 			}
 			printk("NodeMgr: received unexpected signal?!\n" );
@@ -1497,6 +1496,10 @@
 		for (i = 0; i < 4 ; i++) {
 			set_current_state(TASK_INTERRUPTIBLE);
 			if (schedule_timeout(HZ/16)) {
+				if (current->flags & PF_FREEZE) {
+					refrigerator(PF_FREEZE);
+					continue;
+				}
 				up(&nodemgr_serialize);
 				goto caught_signal;
 			}
drivers/md/md.c +1 -2
diff -ruN linux-2.6.8-rc1-mm1/drivers/md/md.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/md/md.c
@@ -2832,6 +2831,7 @@
 	 */
 
 	daemonize(thread->name, mdname(thread->mddev));
+	current->flags |= PF_NOFREEZE;
 
 	current->exit_signal = SIGCHLD;
 	allow_signal(SIGKILL);
@@ -2856,8 +2856,6 @@
 
 		wait_event_interruptible(thread->wqueue,
 					 test_bit(THREAD_WAKEUP, &thread->flags));
-		if (current->flags & PF_FREEZE)
-			refrigerator(PF_FREEZE);
 
 		clear_bit(THREAD_WAKEUP, &thread->flags);
 
drivers/media/video/msp3400.c +7 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/media/video/msp3400.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/media/video/msp3400.c
@@ -738,6 +738,7 @@
 {
 	DECLARE_WAITQUEUE(wait, current);
 
+again:
 	add_wait_queue(&msp->wq, &wait);
 	if (!msp->rmmod) {
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -747,6 +748,12 @@
 			schedule_timeout(timeout);
 	}
 	remove_wait_queue(&msp->wq, &wait);
+	
+	if (current->flags & PF_FREEZE) {
+		refrigerator(PF_FREEZE);
+		goto again;
+	}
+
 	return msp->rmmod || signal_pending(current);
 }
 
drivers/media/video/tvaudio.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/media/video/tvaudio.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/media/video/tvaudio.c
@@ -285,6 +285,8 @@
 			schedule();
 		}
 		remove_wait_queue(&chip->wq, &wait);
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
 		if (chip->done || signal_pending(current))
 			break;
 		dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c));
drivers/message/i2o/i2o_block.c +5 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/message/i2o/i2o_block.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/message/i2o/i2o_block.c
@@ -615,6 +615,11 @@
 	{
 		if(down_interruptible(&i2ob_evt_sem))
 		{
+			if (current->flags & PF_FREEZE) {
+				refrigerator(PF_FREEZE);
+				continue;
+			}
+
 			evt_running = 0;
 			printk("exiting...");
 			break;
drivers/message/i2o/i2o_core.c +10 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/message/i2o/i2o_core.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/message/i2o/i2o_core.c
@@ -1027,6 +1027,11 @@
 	{
 		if(down_interruptible(&evt_sem))
 		{
+			if (current->flags & PF_FREEZE) {
+				refrigerator(PF_FREEZE);
+				continue;
+			}
+
 			dprintk(KERN_INFO "I2O event thread dead\n");
 			printk("exiting...");
 			evt_running = 0;
@@ -1195,6 +1200,11 @@
 		down_interruptible(&c->lct_sem);
 		if(signal_pending(current))
 		{
+			if (current->flags & PF_FREEZE) {
+				refrigerator(PF_FREEZE);
+				continue;
+			}
+
 			dprintk(KERN_ERR "%s: LCT thread dead\n", c->name);
 			c->lct_running = 0;
 			return 0;
drivers/net/irda/sir_kthread.c +1 -4
diff -ruN linux-2.6.8-rc1-mm1/drivers/net/irda/sir_kthread.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/net/irda/sir_kthread.c
@@ -113,6 +112,7 @@
 	DECLARE_WAITQUEUE(wait, current);
 
 	daemonize("kIrDAd");
+	current->flags |= PF_NOFREEZE;
 
 	irda_rq_queue.thread = current;
 
@@ -135,10 +135,6 @@
 			__set_task_state(current, TASK_RUNNING);
 		remove_wait_queue(&irda_rq_queue.kick, &wait);
 
-		/* make swsusp happy with our thread */
-		if (current->flags & PF_FREEZE)
-			refrigerator(PF_FREEZE);
-
 		run_irda_queue();
 	}
 
drivers/pnp/pnpbios/core.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/drivers/pnp/pnpbios/core.c software-suspend-linux-2.6.8-rc1-mm1-rev1/drivers/pnp/pnpbios/core.c
@@ -179,6 +179,8 @@
 		 */
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ*2);
+		if(current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
 		if(signal_pending(current))
 			break;
 
fs/jffs/intrep.c +5 -0
diff -ruN linux-2.6.8-rc1-mm1/fs/jffs/intrep.c software-suspend-linux-2.6.8-rc1-mm1-rev1/fs/jffs/intrep.c
@@ -3373,6 +3374,11 @@
 			siginfo_t info;
 			unsigned long signr = 0;
 
+			if (current->flags & PF_FREEZE) {
+				refrigerator(PF_FREEZE);
+				continue;
+			}
+
 			spin_lock_irq(&current->sighand->siglock);
 			signr = dequeue_signal(current, &current->blocked, &info);
 			spin_unlock_irq(&current->sighand->siglock);
fs/lockd/clntlock.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/fs/lockd/clntlock.c software-suspend-linux-2.6.8-rc1-mm1-rev1/fs/lockd/clntlock.c
@@ -222,6 +223,8 @@
 
 		fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM;
 		nlmclnt_reclaim(host, fl);
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
 		if (signalled())
 			break;
 		goto restart;
fs/lockd/clntproc.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/fs/lockd/clntproc.c software-suspend-linux-2.6.8-rc1-mm1-rev1/fs/lockd/clntproc.c
@@ -310,6 +310,8 @@
 	prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);
 	if (!signalled ()) {
 		schedule_timeout(NLMCLNT_GRACE_WAIT);
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
 		if (!signalled ())
 			status = 0;
 	}
fs/lockd/svc.c +3 -0
diff -ruN linux-2.6.8-rc1-mm1/fs/lockd/svc.c software-suspend-linux-2.6.8-rc1-mm1-rev1/fs/lockd/svc.c
@@ -135,6 +136,9 @@
 	while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) {
 		long timeout = MAX_SCHEDULE_TIMEOUT;
 
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_SYNCTHREAD);
+
 		if (signalled()) {
 			flush_signals(current);
 			if (nlmsvc_ops) {
net/bluetooth/rfcomm/core.c +3 -0
diff -ruN linux-2.6.8-rc1-mm1/net/bluetooth/rfcomm/core.c software-suspend-linux-2.6.8-rc1-mm1-rev1/net/bluetooth/rfcomm/core.c
@@ -1738,6 +1738,9 @@
 			schedule();
 		}
 
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
+
 		/* Process stuff */
 		clear_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
 		rfcomm_process_sessions();
net/sunrpc/svcsock.c +2 -0
diff -ruN linux-2.6.8-rc1-mm1/net/sunrpc/svcsock.c software-suspend-linux-2.6.8-rc1-mm1-rev1/net/sunrpc/svcsock.c
@@ -1192,6 +1192,8 @@
 	arg->len = (pages-1)*PAGE_SIZE;
 	arg->tail[0].iov_len = 0;
 	
+	if (current->flags & PF_FREEZE)
+		refrigerator(PF_FREEZE);
 	if (signalled())
 		return -EINTR;
 
#1 lore raw

drivers/ieee1394/nodemgr.c line 1502

Quoted 5 lines · Nigel Cunningham
drivers/ieee1394/nodemgr.c +4 -0
+				if (current->flags & PF_FREEZE) {
+					refrigerator(PF_FREEZE);
+					continue;
+				}

This seems excessively verbose. Why not do:

	if (try_to_freeze())
		continue;

/*
* Comment goes here
*/
static inline int try_to_freeze(void)

{
	/* I think the compiler propagates likeliness to the inline's caller */
	if (unlikely(current->flags & PF_FREEZE)) {
		refrigerator(PF_FREEZE);
		return 1;
	}
	return 0;
}
#2 lore raw

Hi.

Quoted 17 lines · Andrew Morton

drivers/ieee1394/nodemgr.c line 1502

Quoted 5 lines · Nigel Cunningham
drivers/ieee1394/nodemgr.c +4 -0
+				if (current->flags & PF_FREEZE) {
+					refrigerator(PF_FREEZE);
+					continue;
+				}

This seems excessively verbose. Why not do:

	if (try_to_freeze())
		continue;

/*
* Comment goes here
*/
static inline int try_to_freeze(void)

Quoted 8 lines
{
	/* I think the compiler propagates likeliness to the inline's caller */
	if (unlikely(current->flags & PF_FREEZE)) {
		refrigerator(PF_FREEZE);
		return 1;
	}
	return 0;
}

Probably because I haven't seen that macro before. Looks good. I'll make use of it and add it to suspend2 too, so that whenever we get the merge done, it doesn't disappear.

Regards.

Nigel