Skip to contentSkip to conversation

Freezer Patches.

PATCH Nigel Cunningham 3 participants 20 messages Jun 1, 2005 – Jun 2, 2005

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

Hi Pavel.

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

Regards,

Nigel

drivers/acpi/osl.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/acpi/osl.c 210-workthreads.patch-new/drivers/acpi/osl.c
@@ -95,7 +95,7 @@ acpi_os_initialize1(void)
 		return AE_NULL_ENTRY;
 	}
 #endif
-	kacpid_wq = create_singlethread_workqueue("kacpid");
+	kacpid_wq = create_singlethread_workqueue("kacpid", PF_NOFREEZE);
 	BUG_ON(!kacpid_wq);
 
 	return AE_OK;
drivers/block/ll_rw_blk.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/block/ll_rw_blk.c 210-workthreads.patch-new/drivers/block/ll_rw_blk.c
@@ -3266,7 +3266,7 @@ EXPORT_SYMBOL(kblockd_flush);
 
 int __init blk_dev_init(void)
 {
-	kblockd_workqueue = create_workqueue("kblockd");
+	kblockd_workqueue = create_workqueue("kblockd", PF_NOFREEZE);
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");
 
drivers/block/pktcdvd.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/block/pktcdvd.c 210-workthreads.patch-new/drivers/block/pktcdvd.c
@@ -2366,7 +2366,7 @@ static int pkt_new_dev(struct pktcdvd_de
 	pkt_init_queue(pd);
 
 	atomic_set(&pd->cdrw.pending_bios, 0);
-	pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name);
+	pd->cdrw.thread = kthread_run(kcdrwd, pd, 0, "%s", pd->name);
 	if (IS_ERR(pd->cdrw.thread)) {
 		printk("pktcdvd: can't start kernel thread\n");
 		ret = -ENOMEM;
drivers/char/hvc_console.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/char/hvc_console.c 210-workthreads.patch-new/drivers/char/hvc_console.c
@@ -709,7 +709,7 @@ int __init hvc_init(void)
 
 	/* Always start the kthread because there can be hotplug vty adapters
 	 * added later. */
-	hvc_task = kthread_run(khvcd, NULL, "khvcd");
+	hvc_task = kthread_run(khvcd, NULL, PF_NOFREEZE, "khvcd");
 	if (IS_ERR(hvc_task)) {
 		panic("Couldn't create kthread for console.\n");
 		put_tty_driver(hvc_driver);
drivers/char/hvcs.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/char/hvcs.c 210-workthreads.patch-new/drivers/char/hvcs.c
@@ -1403,7 +1403,7 @@ static int __init hvcs_module_init(void)
 		return -ENOMEM;
 	}
 
-	hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
+	hvcs_task = kthread_run(khvcsd, NULL, PF_NOFREEZE, "khvcsd");
 	if (IS_ERR(hvcs_task)) {
 		printk(KERN_ERR "HVCS: khvcsd creation failed.  Driver not loaded.\n");
 		kfree(hvcs_pi_buff);
drivers/infiniband/core/fmr_pool.c +1 -0
diff -ruNp 210-workthreads.patch-old/drivers/infiniband/core/fmr_pool.c 210-workthreads.patch-new/drivers/infiniband/core/fmr_pool.c
@@ -266,6 +266,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 
 	pool->thread = kthread_create(ib_fmr_cleanup_thread,
 				      pool,
+				      0,
 				      "ib_fmr(%s)",
 				      device->name);
 	if (IS_ERR(pool->thread)) {
drivers/infiniband/core/mad.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/infiniband/core/mad.c 210-workthreads.patch-new/drivers/infiniband/core/mad.c
@@ -2502,7 +2502,7 @@ static int ib_mad_port_open(struct ib_de
 		goto error7;
 
 	snprintf(name, sizeof name, "ib_mad%d", port_num);
-	port_priv->wq = create_singlethread_workqueue(name);
+	port_priv->wq = create_singlethread_workqueue(name, 0);
 	if (!port_priv->wq) {
 		ret = -ENOMEM;
 		goto error8;
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/infiniband/ulp/ipoib/ipoib_main.c 210-workthreads.patch-new/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1070,7 +1070,7 @@ static int __init ipoib_init_module(void
 	 * so flush_scheduled_work() can deadlock during device
 	 * removal.
 	 */
-	ipoib_workqueue = create_singlethread_workqueue("ipoib");
+	ipoib_workqueue = create_singlethread_workqueue("ipoib", 0);
 	if (!ipoib_workqueue) {
 		ret = -ENOMEM;
 		goto err_fs;
drivers/macintosh/therm_adt746x.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/macintosh/therm_adt746x.c 210-workthreads.patch-new/drivers/macintosh/therm_adt746x.c
@@ -438,7 +438,7 @@ static int attach_one_thermostat(struct 
 		write_both_fan_speed(th, -1);
 	}
 	
-	thread_therm = kthread_run(monitor_task, th, "kfand");
+	thread_therm = kthread_run(monitor_task, th, 0, "kfand");
 
 	if (thread_therm == ERR_PTR(-ENOMEM)) {
 		printk(KERN_INFO "adt746x: Kthread creation failed\n");
drivers/md/dm-crypt.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/md/dm-crypt.c 210-workthreads.patch-new/drivers/md/dm-crypt.c
@@ -936,7 +936,7 @@ static int __init dm_crypt_init(void)
 	if (!_crypt_io_pool)
 		return -ENOMEM;
 
-	_kcryptd_workqueue = create_workqueue("kcryptd");
+	_kcryptd_workqueue = create_workqueue("kcryptd", PF_NOFREEZE);
 	if (!_kcryptd_workqueue) {
 		r = -ENOMEM;
 		DMERR(PFX "couldn't create kcryptd");
drivers/md/dm-raid1.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/md/dm-raid1.c 210-workthreads.patch-new/drivers/md/dm-raid1.c
@@ -1229,7 +1229,7 @@ static int __init dm_mirror_init(void)
 	if (r)
 		return r;
 
-	_kmirrord_wq = create_workqueue("kmirrord");
+	_kmirrord_wq = create_workqueue("kmirrord", PF_SYNCTHREAD);
 	if (!_kmirrord_wq) {
 		DMERR("couldn't start kmirrord");
 		dm_dirty_log_exit();
drivers/md/kcopyd.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/md/kcopyd.c 210-workthreads.patch-new/drivers/md/kcopyd.c
@@ -609,7 +609,7 @@ static int kcopyd_init(void)
 		return r;
 	}
 
-	_kcopyd_wq = create_singlethread_workqueue("kcopyd");
+	_kcopyd_wq = create_singlethread_workqueue("kcopyd", PF_SYNCTHREAD);
 	if (!_kcopyd_wq) {
 		jobs_exit();
 		up(&kcopyd_init_lock);
drivers/media/video/cx88/cx88-video.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/media/video/cx88/cx88-video.c 210-workthreads.patch-new/drivers/media/video/cx88/cx88-video.c
@@ -2121,7 +2121,7 @@ static int __devinit cx8800_initdev(stru
 
 	/* start tvaudio thread */
 	if (core->tuner_type != TUNER_ABSENT)
-		core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
+		core->kthread = kthread_run(cx88_audio_thread, core, 0, "cx88 tvaudio");
 	return 0;
 
 fail_unreg:
drivers/media/video/msp3400.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/media/video/msp3400.c 210-workthreads.patch-new/drivers/media/video/msp3400.c
@@ -1555,7 +1555,7 @@ static int msp_attach(struct i2c_adapter
 
 	/* startup control thread if needed */
 	if (thread_func) {
-		msp->kthread = kthread_run(thread_func, c, "msp34xx");
+		msp->kthread = kthread_run(thread_func, c, 0, "msp34xx");
 		if (NULL == msp->kthread)
 			printk(KERN_WARNING "msp34xx: kernel_thread() failed\n");
 		msp_wake_thread(c);
drivers/media/video/video-buf-dvb.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/media/video/video-buf-dvb.c 210-workthreads.patch-new/drivers/media/video/video-buf-dvb.c
@@ -104,7 +104,7 @@ static int videobuf_dvb_start_feed(struc
 	if (NULL != dvb->thread)
 		goto out;
 	dvb->thread = kthread_run(videobuf_dvb_thread,
-				  dvb, "%s dvb", dvb->name);
+				  dvb, 0, "%s dvb", dvb->name);
 	if (IS_ERR(dvb->thread)) {
 		rc = PTR_ERR(dvb->thread);
 		dvb->thread = NULL;
drivers/message/i2o/driver.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/message/i2o/driver.c 210-workthreads.patch-new/drivers/message/i2o/driver.c
@@ -79,7 +79,7 @@ int i2o_driver_register(struct i2o_drive
 	pr_debug("i2o: Register driver %s\n", drv->name);
 
 	if (drv->event) {
-		drv->event_queue = create_workqueue(drv->name);
+		drv->event_queue = create_workqueue(drv->name, 0);
 		if (!drv->event_queue) {
 			printk(KERN_ERR "i2o: Could not initialize event queue "
 			       "for driver %s\n", drv->name);
drivers/net/wan/sdlamain.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/net/wan/sdlamain.c 210-workthreads.patch-new/drivers/net/wan/sdlamain.c
@@ -240,7 +240,7 @@ static int __init wanpipe_init(void)
 	printk(KERN_INFO "%s v%u.%u %s\n",
 		fullname, DRV_VERSION, DRV_RELEASE, copyright);
 
-	wanpipe_wq = create_workqueue("wanpipe_wq");
+	wanpipe_wq = create_workqueue("wanpipe_wq", 0);
 	if (!wanpipe_wq)
 		return -ENOMEM;
 
drivers/s390/cio/device.c +4 -3
diff -ruNp 210-workthreads.patch-old/drivers/s390/cio/device.c 210-workthreads.patch-new/drivers/s390/cio/device.c
@@ -148,15 +148,16 @@ init_ccw_bus_type (void)
 	init_waitqueue_head(&ccw_device_init_wq);
 	atomic_set(&ccw_device_init_count, 0);
 
-	ccw_device_work = create_singlethread_workqueue("cio");
+	ccw_device_work = create_singlethread_workqueue("cio", 0);
 	if (!ccw_device_work)
 		return -ENOMEM; /* FIXME: better errno ? */
-	ccw_device_notify_work = create_singlethread_workqueue("cio_notify");
+	ccw_device_notify_work = create_singlethread_workqueue("cio_notify",
+			0);
 	if (!ccw_device_notify_work) {
 		ret = -ENOMEM; /* FIXME: better errno ? */
 		goto out_err;
 	}
-	slow_path_wq = create_singlethread_workqueue("kslowcrw");
+	slow_path_wq = create_singlethread_workqueue("kslowcrw", 0);
 	if (!slow_path_wq) {
 		ret = -ENOMEM; /* FIXME: better errno ? */
 		goto out_err;
drivers/scsi/hosts.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/scsi/hosts.c 210-workthreads.patch-new/drivers/scsi/hosts.c
@@ -133,7 +133,7 @@ int scsi_add_host(struct Scsi_Host *shos
 		snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
 			shost->host_no);
 		shost->work_q = create_singlethread_workqueue(
-					shost->work_q_name);
+					shost->work_q_name, PF_NOFREEZE);
 		if (!shost->work_q)
 			goto out_free_shost_data;
 	}
drivers/scsi/libata-core.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/scsi/libata-core.c 210-workthreads.patch-new/drivers/scsi/libata-core.c
@@ -3951,7 +3951,7 @@ int pci_test_config_bits(struct pci_dev 
 
 static int __init ata_init(void)
 {
-	ata_wq = create_workqueue("ata");
+	ata_wq = create_workqueue("ata", 0);
 	if (!ata_wq)
 		return -ENOMEM;
 
drivers/usb/net/pegasus.c +1 -1
diff -ruNp 210-workthreads.patch-old/drivers/usb/net/pegasus.c 210-workthreads.patch-new/drivers/usb/net/pegasus.c
@@ -1412,7 +1412,7 @@ static struct usb_driver pegasus_driver 
 static int __init pegasus_init(void)
 {
 	pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION);
-	pegasus_workqueue = create_singlethread_workqueue("pegasus");
+	pegasus_workqueue = create_singlethread_workqueue("pegasus", PF_NOFREEZE);
 	if (!pegasus_workqueue)
 		return -ENOMEM;
 	return usb_register(&pegasus_driver);
fs/aio.c +1 -1
diff -ruNp 210-workthreads.patch-old/fs/aio.c 210-workthreads.patch-new/fs/aio.c
@@ -73,7 +73,7 @@ static int __init aio_setup(void)
 	kioctx_cachep = kmem_cache_create("kioctx", sizeof(struct kioctx),
 				0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
 
-	aio_wq = create_workqueue("aio");
+	aio_wq = create_workqueue("aio", 0);
 
 	pr_debug("aio_setup: sizeof(struct page) = %d\n", (int)sizeof(struct page));
 
fs/nfsd/nfs4state.c +1 -1
diff -ruNp 210-workthreads.patch-old/fs/nfsd/nfs4state.c 210-workthreads.patch-new/fs/nfsd/nfs4state.c
@@ -1356,7 +1356,7 @@ void nfsd_break_deleg_cb(struct file_loc
 	/* XXX need to merge NFSD_LEASE_TIME with fs/locks.c:lease_break_time */
 	fl->fl_break_time = jiffies + NFSD_LEASE_TIME * HZ;
 
-	t = kthread_run(do_recall, dp, "%s", "nfs4_cb_recall");
+	t = kthread_run(do_recall, dp, 0, "%s", "nfs4_cb_recall");
 	if (IS_ERR(t)) {
 		struct nfs4_client *clp = dp->dl_client;
 
fs/reiserfs/journal.c +1 -1
diff -ruNp 210-workthreads.patch-old/fs/reiserfs/journal.c 210-workthreads.patch-new/fs/reiserfs/journal.c
@@ -2512,7 +2512,7 @@ int journal_init(struct super_block *p_s
 
   reiserfs_mounted_fs_count++ ;
   if (reiserfs_mounted_fs_count <= 1)
-    commit_wq = create_workqueue("reiserfs");
+    commit_wq = create_workqueue("reiserfs", PF_SYNCTHREAD);
 
   INIT_WORK(&journal->j_work, flush_async_commits, p_s_sb);
   return 0 ;
fs/xfs/linux-2.6/xfs_buf.c +2 -2
diff -ruNp 210-workthreads.patch-old/fs/xfs/linux-2.6/xfs_buf.c 210-workthreads.patch-new/fs/xfs/linux-2.6/xfs_buf.c
@@ -1895,11 +1895,11 @@ pagebuf_daemon_start(void)
 {
 	int		rval;
 
-	pagebuf_logio_workqueue = create_workqueue("xfslogd");
+	pagebuf_logio_workqueue = create_workqueue("xfslogd", PF_SYNCTHREAD);
 	if (!pagebuf_logio_workqueue)
 		return -ENOMEM;
 
-	pagebuf_dataio_workqueue = create_workqueue("xfsdatad");
+	pagebuf_dataio_workqueue = create_workqueue("xfsdatad", PF_SYNCTHREAD);
 	if (!pagebuf_dataio_workqueue) {
 		destroy_workqueue(pagebuf_logio_workqueue);
 		return -ENOMEM;
include/linux/kthread.h +8 -2
diff -ruNp 210-workthreads.patch-old/include/linux/kthread.h 210-workthreads.patch-new/include/linux/kthread.h
@@ -25,20 +25,26 @@
  */
 struct task_struct *kthread_create(int (*threadfn)(void *data),
 				   void *data,
+				   unsigned long freezer_flags,
 				   const char namefmt[], ...);
 
 /**
  * kthread_run: create and wake a thread.
  * @threadfn: the function to run until signal_pending(current).
  * @data: data ptr for @threadfn.
+ * @freezer_flags: process flags that should be used for freezing.
+ * 	PF_SYNCTHREAD if needed for syncing data to disk.
+ * 	PF_NOFREEZE if also needed for writing the image.
+ * 	0 otherwise.
  * @namefmt: printf-style name for the thread.
  *
  * Description: Convenient wrapper for kthread_create() followed by
  * wake_up_process().  Returns the kthread, or ERR_PTR(-ENOMEM). */
-#define kthread_run(threadfn, data, namefmt, ...)			   \
+#define kthread_run(threadfn, data, freezer_flags, namefmt, ...)	   \
 ({									   \
 	struct task_struct *__k						   \
-		= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
+		= kthread_create(threadfn, data, freezer_flags, 	   \
+			namefmt, ## __VA_ARGS__);			   \
 	if (!IS_ERR(__k))						   \
 		wake_up_process(__k);					   \
 	__k;								   \
include/linux/workqueue.h +4 -3
diff -ruNp 210-workthreads.patch-old/include/linux/workqueue.h 210-workthreads.patch-new/include/linux/workqueue.h
@@ -51,9 +51,10 @@ struct work_struct {
 	} while (0)
 
 extern struct workqueue_struct *__create_workqueue(const char *name,
-						    int singlethread);
-#define create_workqueue(name) __create_workqueue((name), 0)
-#define create_singlethread_workqueue(name) __create_workqueue((name), 1)
+						    int singlethread,
+						    unsigned long freezer_flag);
+#define create_workqueue(name, flags) __create_workqueue((name), 0, flags)
+#define create_singlethread_workqueue(name, flags) __create_workqueue((name), 1, flags)
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
kernel/kmod.c +1 -1
diff -ruNp 210-workthreads.patch-old/kernel/kmod.c 210-workthreads.patch-new/kernel/kmod.c
@@ -251,6 +251,6 @@ EXPORT_SYMBOL(call_usermodehelper);
 
 void __init usermodehelper_init(void)
 {
-	khelper_wq = create_singlethread_workqueue("khelper");
+	khelper_wq = create_singlethread_workqueue("khelper", 0);
 	BUG_ON(!khelper_wq);
 }
kernel/kthread.c +8 -1
diff -ruNp 210-workthreads.patch-old/kernel/kthread.c 210-workthreads.patch-new/kernel/kthread.c
@@ -25,6 +25,7 @@ struct kthread_create_info
 	/* Information passed to kthread() from keventd. */
 	int (*threadfn)(void *data);
 	void *data;
+	unsigned long freezer_flags;
 	struct completion started;
 
 	/* Result passed back to kthread_create() from keventd. */
@@ -86,6 +87,10 @@ static int kthread(void *_create)
 	/* By default we can run anywhere, unlike keventd. */
 	set_cpus_allowed(current, CPU_MASK_ALL);
 
+	/* Set our freezer flags */
+	current->flags &= ~(PF_SYNCTHREAD | PF_NOFREEZE);
+	current->flags |= create->freezer_flags;
+
 	/* OK, tell user we're spawned, wait for stop or wakeup */
 	__set_current_state(TASK_INTERRUPTIBLE);
 	complete(&create->started);
@@ -121,6 +126,7 @@ static void keventd_create_kthread(void 
 
 struct task_struct *kthread_create(int (*threadfn)(void *data),
 				   void *data,
+				   unsigned long freezer_flags,
 				   const char namefmt[],
 				   ...)
 {
@@ -129,6 +135,7 @@ struct task_struct *kthread_create(int (
 
 	create.threadfn = threadfn;
 	create.data = data;
+	create.freezer_flags = freezer_flags;
 	init_completion(&create.started);
 	init_completion(&create.done);
 
@@ -193,7 +200,7 @@ EXPORT_SYMBOL(kthread_stop);
 
 static __init int helper_init(void)
 {
-	helper_wq = create_singlethread_workqueue("kthread");
+	helper_wq = create_singlethread_workqueue("kthread", 0);
 	BUG_ON(!helper_wq);
 
 	return 0;
kernel/sched.c +2 -2
diff -ruNp 210-workthreads.patch-old/kernel/sched.c 210-workthreads.patch-new/kernel/sched.c
@@ -4379,10 +4379,10 @@ static int migration_call(struct notifie
 
 	switch (action) {
 	case CPU_UP_PREPARE:
-		p = kthread_create(migration_thread, hcpu, "migration/%d",cpu);
+		p = kthread_create(migration_thread, hcpu, 0,
+				"migration/%d",cpu);
 		if (IS_ERR(p))
 			return NOTIFY_BAD;
-		p->flags |= PF_NOFREEZE;
 		kthread_bind(p, cpu);
 		/* Must be high prio: stop_machine expects to yield to it. */
 		rq = task_rq_lock(p, &flags);
kernel/softirq.c +3 -2
diff -ruNp 210-workthreads.patch-old/kernel/softirq.c 210-workthreads.patch-new/kernel/softirq.c
@@ -350,7 +350,6 @@ void __init softirq_init(void)
 static int ksoftirqd(void * __bind_cpu)
 {
 	set_user_nice(current, 19);
-	current->flags |= PF_NOFREEZE;
 
 	set_current_state(TASK_INTERRUPTIBLE);
 
@@ -364,6 +363,8 @@ static int ksoftirqd(void * __bind_cpu)
 
 		__set_current_state(TASK_RUNNING);
 
+		try_to_freeze(PF_FREEZE);
+
 		while (local_softirq_pending()) {
 			/* Preempt disable stops cpu going offline.
 			   If already offline, we'll be on wrong CPU:
@@ -456,7 +457,7 @@ static int __devinit cpu_callback(struct
 	case CPU_UP_PREPARE:
 		BUG_ON(per_cpu(tasklet_vec, hotcpu).list);
 		BUG_ON(per_cpu(tasklet_hi_vec, hotcpu).list);
-		p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
+		p = kthread_create(ksoftirqd, hcpu, PF_NOFREEZE, "ksoftirqd/%d", hotcpu);
 		if (IS_ERR(p)) {
 			printk("ksoftirqd for %i failed\n", hotcpu);
 			return NOTIFY_BAD;
kernel/stop_machine.c +1 -1
diff -ruNp 210-workthreads.patch-old/kernel/stop_machine.c 210-workthreads.patch-new/kernel/stop_machine.c
@@ -184,7 +184,7 @@ struct task_struct *__stop_machine_run(i
 	if (cpu == NR_CPUS)
 		cpu = _smp_processor_id();
 
-	p = kthread_create(do_stop, &smdata, "kstopmachine");
+	p = kthread_create(do_stop, &smdata, 0, "kstopmachine");
 	if (!IS_ERR(p)) {
 		kthread_bind(p, cpu);
 		wake_up_process(p);
kernel/workqueue.c +12 -9
diff -ruNp 210-workthreads.patch-old/kernel/workqueue.c 210-workthreads.patch-new/kernel/workqueue.c
@@ -186,8 +186,6 @@ static int worker_thread(void *__cwq)
 	struct k_sigaction sa;
 	sigset_t blocked;
 
-	current->flags |= PF_NOFREEZE;
-
 	set_user_nice(current, -5);
 
 	/* Block and flush all signals */
@@ -208,6 +206,7 @@ static int worker_thread(void *__cwq)
 			schedule();
 		else
 			__set_current_state(TASK_RUNNING);
+		try_to_freeze(PF_FREEZE);
 		remove_wait_queue(&cwq->more_work, &wait);
 
 		if (!list_empty(&cwq->worklist))
@@ -277,7 +276,8 @@ void fastcall flush_workqueue(struct wor
 }
 
 static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
-						   int cpu)
+						   int cpu,
+						   unsigned long freezer_flags)
 {
 	struct cpu_workqueue_struct *cwq = wq->cpu_wq + cpu;
 	struct task_struct *p;
@@ -292,9 +292,11 @@ static struct task_struct *create_workqu
 	init_waitqueue_head(&cwq->work_done);
 
 	if (is_single_threaded(wq))
-		p = kthread_create(worker_thread, cwq, "%s", wq->name);
+		p = kthread_create(worker_thread, cwq, freezer_flags, 
+				"%s", wq->name);
 	else
-		p = kthread_create(worker_thread, cwq, "%s/%d", wq->name, cpu);
+		p = kthread_create(worker_thread, cwq, freezer_flags,
+				"%s/%d", wq->name, cpu);
 	if (IS_ERR(p))
 		return NULL;
 	cwq->thread = p;
@@ -302,7 +304,8 @@ static struct task_struct *create_workqu
 }
 
 struct workqueue_struct *__create_workqueue(const char *name,
-					    int singlethread)
+					    int singlethread,
+					    unsigned long freezer_flags)
 {
 	int cpu, destroy = 0;
 	struct workqueue_struct *wq;
@@ -320,7 +323,7 @@ struct workqueue_struct *__create_workqu
 	lock_cpu_hotplug();
 	if (singlethread) {
 		INIT_LIST_HEAD(&wq->list);
-		p = create_workqueue_thread(wq, 0);
+		p = create_workqueue_thread(wq, 0, freezer_flags);
 		if (!p)
 			destroy = 1;
 		else
@@ -330,7 +333,7 @@ struct workqueue_struct *__create_workqu
 		list_add(&wq->list, &workqueues);
 		spin_unlock(&workqueue_lock);
 		for_each_online_cpu(cpu) {
-			p = create_workqueue_thread(wq, cpu);
+			p = create_workqueue_thread(wq, cpu, freezer_flags);
 			if (p) {
 				kthread_bind(p, cpu);
 				wake_up_process(p);
@@ -540,7 +543,7 @@ static int __devinit workqueue_cpu_callb
 void init_workqueues(void)
 {
 	hotcpu_notifier(workqueue_cpu_callback, 0);
-	keventd_wq = create_workqueue("events");
+	keventd_wq = create_workqueue("events", PF_NOFREEZE);
 	BUG_ON(!keventd_wq);
 }
 
mm/pdflush.c +1 -1
diff -ruNp 210-workthreads.patch-old/mm/pdflush.c 210-workthreads.patch-new/mm/pdflush.c
@@ -213,7 +213,7 @@ int pdflush_operation(void (*fn)(unsigne
 
 static void start_one_pdflush_thread(void)
 {
-	kthread_run(pdflush, NULL, "pdflush");
+	kthread_run(pdflush, NULL, PF_SYNCTHREAD, "pdflush");
 }
 
 static int __init pdflush_init(void)
net/sunrpc/sched.c +1 -1
diff -ruNp 210-workthreads.patch-old/net/sunrpc/sched.c 210-workthreads.patch-new/net/sunrpc/sched.c
@@ -1003,7 +1003,7 @@ rpciod_up(void)
 	 * Create the rpciod thread and wait for it to start.
 	 */
 	error = -ENOMEM;
-	wq = create_workqueue("rpciod");
+	wq = create_workqueue("rpciod", 0);
 	if (wq == NULL) {
 		printk(KERN_WARNING "rpciod_up: create workqueue failed, error=%d\n", error);
 		rpciod_users--;
include/linux/sched.h +2 -0
diff -ruNp 211-refrigerator.patch-old/include/linux/sched.h 211-refrigerator.patch-new/include/linux/sched.h
@@ -1248,6 +1248,7 @@ extern void normalize_rt_tasks(void);
 extern void refrigerator(unsigned long);
 extern int freeze_processes(void);
 extern void thaw_processes(void);
+extern unsigned int refrigerator_on;
 
 static inline int try_to_freeze(unsigned long refrigerator_flags)
 {
@@ -1261,6 +1262,7 @@ static inline int try_to_freeze(unsigned
 static inline void refrigerator(unsigned long flag) {}
 static inline int freeze_processes(void) { BUG(); return 0; }
 static inline void thaw_processes(void) {}
+#define refrigerator_on (0)
 
 static inline int try_to_freeze(unsigned long refrigerator_flags)
 {
kernel/exit.c +2 -0
diff -ruNp 211-refrigerator.patch-old/kernel/exit.c 211-refrigerator.patch-new/kernel/exit.c
@@ -789,6 +789,8 @@ fastcall NORET_TYPE void do_exit(long co
 		panic("Attempted to kill init!");
 	if (tsk->io_context)
 		exit_io_context();
+	if (unlikely(refrigerator_on))
+		refrigerator(0);
 
 	if (unlikely(current->ptrace & PT_TRACE_EXIT)) {
 		current->ptrace_message = code;
kernel/fork.c +3 -0
diff -ruNp 211-refrigerator.patch-old/kernel/fork.c 211-refrigerator.patch-new/kernel/fork.c
@@ -1200,6 +1200,9 @@ long do_fork(unsigned long clone_flags,
 	int trace = 0;
 	long pid = alloc_pidmap();
 
+	if (unlikely(refrigerator_on))
+		refrigerator(0);
+
 	if (pid < 0)
 		return -EAGAIN;
 	if (unlikely(current->ptrace)) {
kernel/kmod.c +1 -1
diff -ruNp 211-refrigerator.patch-old/kernel/kmod.c 211-refrigerator.patch-new/kernel/kmod.c
@@ -237,7 +237,7 @@ int call_usermodehelper(char *path, char
 	};
 	DECLARE_WORK(work, __call_usermodehelper, &sub_info);
 
-	if (!khelper_wq)
+	if ((!khelper_wq) || (refrigerator_on))
 		return -EBUSY;
 
 	if (path[0] == '\0')
kernel/power/process.c +266 -70

387 lines not on this page · raw message

fs/buffer.c +30 -2
diff -ruNp 214-syncthreads-old/fs/buffer.c 214-syncthreads-new/fs/buffer.c
@@ -171,6 +171,10 @@ EXPORT_SYMBOL(sync_blockdev);
  */
 int fsync_super(struct super_block *sb)
 {
+	int ret;
+
+	current->flags |= PF_SYNCTHREAD;
+
 	sync_inodes_sb(sb, 0);
 	DQUOT_SYNC(sb);
 	lock_super(sb);
@@ -182,7 +186,10 @@ int fsync_super(struct super_block *sb)
 	sync_blockdev(sb->s_bdev);
 	sync_inodes_sb(sb, 1);
 
-	return sync_blockdev(sb->s_bdev);
+	ret = sync_blockdev(sb->s_bdev);
+
+	current->flags &= ~PF_SYNCTHREAD;
+	return ret;
 }
 
 /*
@@ -193,12 +200,19 @@ int fsync_super(struct super_block *sb)
 int fsync_bdev(struct block_device *bdev)
 {
 	struct super_block *sb = get_super(bdev);
+	int ret;
+
+	current->flags |= PF_SYNCTHREAD;
+
 	if (sb) {
 		int res = fsync_super(sb);
 		drop_super(sb);
+		current->flags &= ~PF_SYNCTHREAD;
 		return res;
 	}
-	return sync_blockdev(bdev);
+	ret = sync_blockdev(bdev);
+	current->flags &= ~PF_SYNCTHREAD;
+	return ret;
 }
 
 /**
@@ -278,6 +292,8 @@ EXPORT_SYMBOL(thaw_bdev);
  */
 static void do_sync(unsigned long wait)
 {
+	current->flags |= PF_SYNCTHREAD;
+
 	wakeup_bdflush(0);
 	sync_inodes(0);		/* All mappings, inodes and their blockdevs */
 	DQUOT_SYNC(NULL);
@@ -289,6 +305,8 @@ static void do_sync(unsigned long wait)
 		printk("Emergency Sync complete\n");
 	if (unlikely(laptop_mode))
 		laptop_sync_completion();
+
+	current->flags &= ~PF_SYNCTHREAD;
 }
 
 asmlinkage long sys_sync(void)
@@ -314,6 +332,8 @@ int file_fsync(struct file *filp, struct
 	struct super_block * sb;
 	int ret, err;
 
+	current->flags |= PF_SYNCTHREAD;
+
 	/* sync the inode to buffers */
 	ret = write_inode_now(inode, 0);
 
@@ -328,6 +348,8 @@ int file_fsync(struct file *filp, struct
 	err = sync_blockdev(sb->s_bdev);
 	if (!ret)
 		ret = err;
+
+	current->flags &= ~PF_SYNCTHREAD;
 	return ret;
 }
 
@@ -337,6 +359,8 @@ asmlinkage long sys_fsync(unsigned int f
 	struct address_space *mapping;
 	int ret, err;
 
+	current->flags |= PF_SYNCTHREAD;
+
 	ret = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -370,6 +394,7 @@ asmlinkage long sys_fsync(unsigned int f
 out_putf:
 	fput(file);
 out:
+	current->flags &= ~PF_SYNCTHREAD;
 	return ret;
 }
 
@@ -379,6 +404,8 @@ asmlinkage long sys_fdatasync(unsigned i
 	struct address_space *mapping;
 	int ret, err;
 
+	current->flags |= PF_SYNCTHREAD;
+
 	ret = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -405,6 +432,7 @@ asmlinkage long sys_fdatasync(unsigned i
 out_putf:
 	fput(file);
 out:
+	current->flags &= ~PF_SYNCTHREAD;
 	return ret;
 }
 
fs/jbd/journal.c +1 -0
diff -ruNp 214-syncthreads-old/fs/jbd/journal.c 214-syncthreads-new/fs/jbd/journal.c
@@ -130,6 +130,7 @@ int kjournald(void *arg)
 	current_journal = journal;
 
 	daemonize("kjournald");
+	current->flags |= PF_SYNCTHREAD;
 
 	/* Set up an interval timer which can be used to trigger a
            commit wakeup after the commit interval expires */
fs/jffs/intrep.c +4 -0
diff -ruNp 214-syncthreads-old/fs/jffs/intrep.c 214-syncthreads-new/fs/jffs/intrep.c
@@ -3364,6 +3364,7 @@ jffs_garbage_collect_thread(void *ptr)
 	D1(int i = 1);
 
 	daemonize("jffs_gcd");
+	current->flags |= PF_SYNCTHREAD;
 
 	c->gc_task = current;
 
@@ -3399,6 +3400,9 @@ jffs_garbage_collect_thread(void *ptr)
 			siginfo_t info;
 			unsigned long signr = 0;
 
+			if (try_to_freeze(PF_FREEZE))
+				continue;
+
 			spin_lock_irq(&current->sighand->siglock);
 			signr = dequeue_signal(current, &current->blocked, &info);
 			spin_unlock_irq(&current->sighand->siglock);
fs/jfs/jfs_logmgr.c +1 -0
diff -ruNp 214-syncthreads-old/fs/jfs/jfs_logmgr.c 214-syncthreads-new/fs/jfs/jfs_logmgr.c
@@ -2321,6 +2321,7 @@ int jfsIOWait(void *arg)
 	struct lbuf *bp;
 
 	daemonize("jfsIO");
+	current->flags |= PF_SYNCTHREAD;
 
 	complete(&jfsIOwait);
 
fs/jfs/jfs_txnmgr.c +1 -1
diff -ruNp 214-syncthreads-old/fs/jfs/jfs_txnmgr.c 214-syncthreads-new/fs/jfs/jfs_txnmgr.c
@@ -47,7 +47,6 @@
 #include <linux/vmalloc.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
-#include <linux/suspend.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include "jfs_incore.h"
@@ -2750,6 +2749,7 @@ int jfs_lazycommit(void *arg)
 	struct jfs_sb_info *sbi;
 
 	daemonize("jfsCommit");
+	current->flags |= PF_SYNCTHREAD;
 
 	complete(&jfsIOwait);
 
fs/lockd/clntlock.c +2 -0
diff -ruNp 214-syncthreads-old/fs/lockd/clntlock.c 214-syncthreads-new/fs/lockd/clntlock.c
@@ -200,6 +200,7 @@ reclaimer(void *ptr)
 	struct inode *inode;
 
 	daemonize("%s-reclaim", host->h_name);
+	current->flags |= PF_SYNCTHREAD;
 	allow_signal(SIGKILL);
 
 	/* This one ensures that our parent doesn't terminate while the
@@ -222,6 +223,7 @@ restart:
 
 		fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM;
 		nlmclnt_reclaim(host, fl);
+		try_to_freeze(PF_FREEZE);
 		if (signalled())
 			break;
 		goto restart;
fs/lockd/svc.c +3 -0
diff -ruNp 214-syncthreads-old/fs/lockd/svc.c 214-syncthreads-new/fs/lockd/svc.c
@@ -115,6 +115,7 @@ lockd(struct svc_rqst *rqstp)
 	up(&lockd_start);
 
 	daemonize("lockd");
+	current->flags |= PF_SYNCTHREAD;
 
 	/* Process request with signals blocked, but allow SIGKILL.  */
 	allow_signal(SIGKILL);
@@ -138,6 +139,8 @@ lockd(struct svc_rqst *rqstp)
 	while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) {
 		long timeout = MAX_SCHEDULE_TIMEOUT;
 
+		try_to_freeze(PF_SYNCTHREAD);
+
 		if (signalled()) {
 			flush_signals(current);
 			if (nlmsvc_ops) {
fs/nfsd/nfssvc.c +1 -0
diff -ruNp 214-syncthreads-old/fs/nfsd/nfssvc.c 214-syncthreads-new/fs/nfsd/nfssvc.c
@@ -182,6 +182,7 @@ nfsd(struct svc_rqst *rqstp)
 	/* Lock module and set up kernel thread */
 	lock_kernel();
 	daemonize("nfsd");
+	current->flags |= PF_SYNCTHREAD;
 
 	/* After daemonize() this kernel thread shares current->fs
 	 * with the init process. We need to create files with a
fs/xfs/linux-2.6/xfs_buf.c +1 -1
diff -ruNp 214-syncthreads-old/fs/xfs/linux-2.6/xfs_buf.c 214-syncthreads-new/fs/xfs/linux-2.6/xfs_buf.c
@@ -1770,7 +1770,7 @@ pagebuf_daemon(
 
 	/*  Set up the thread  */
 	daemonize("xfsbufd");
-	current->flags |= PF_MEMALLOC;
+	current->flags |= PF_MEMALLOC | PF_SYNCTHREAD;
 
 	pagebuf_daemon_task = current;
 	pagebuf_daemon_active = 1;
fs/xfs/linux-2.6/xfs_super.c +1 -0
diff -ruNp 214-syncthreads-old/fs/xfs/linux-2.6/xfs_super.c 214-syncthreads-new/fs/xfs/linux-2.6/xfs_super.c
@@ -471,6 +471,7 @@ xfssyncd(
 	struct vfs_sync_work	*work, *n;
 
 	daemonize("xfssyncd");
+	current->flags |= PF_SYNCTHREAD;
 
 	vfsp->vfs_sync_work.w_vfs = vfsp;
 	vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
include/linux/sched.h +2 -0
diff -ruNp 214-syncthreads-old/include/linux/sched.h 214-syncthreads-new/include/linux/sched.h
@@ -788,6 +788,8 @@ do { if (atomic_dec_and_test(&(tsk)->usa
 #define PF_SYNCWRITE	0x00200000	/* I am doing a sync write */
 #define PF_BORROWED_MM	0x00400000	/* I am a kthread doing use_mm */
 #define PF_RANDOMIZE	0x00800000	/* randomize virtual address space */
+#define PF_SYNCTHREAD	0x01000000	/* this thread can start activity during the 
++ 					   early part of freezing processes */
 
 /*
  * Only the _current_ task can read/write to tsk->flags, but other
mm/pdflush.c +1 -1
diff -ruNp 214-syncthreads-old/mm/pdflush.c 214-syncthreads-new/mm/pdflush.c
@@ -89,7 +89,7 @@ struct pdflush_work {
 
 static int __pdflush(struct pdflush_work *my_work)
 {
-	current->flags |= PF_FLUSHER;
+	current->flags |= (PF_FLUSHER | PF_SYNCTHREAD);
 	my_work->fn = NULL;
 	my_work->who = current;
 	INIT_LIST_HEAD(&my_work->list);
#1 lore raw

Hi!

Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

304 seems ugly and completely useless for mainline 300: stopping softirqd seems dangerous to me... are you sure? 301: patching exit should not be neccessary. Why do you need it?
Pavel

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#2 lore raw
Quoted 7 lines · Pavel Machek

Hi!

Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

300: stopping softirqd seems dangerous to me... are you sure?

That sounds bogus indeed.

#5 lore raw
In reply to Pavel Machek

Morning.

Quoted 7 lines · Pavel Machek

Hi!

Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

304 seems ugly and completely useless for mainline

That's because you don't understand what it's doing.

The new refrigerator implementation works like this:

Userspace processes that begin a sys_*sync gain the process flag PF_SYNCTHREAD for the duration of their syscall.

We then freeze processes in three distinct groups.

1. Userspace processes (p->mm) that don't have PF_SYNCTHREAD set are signalled first. This causes them to enter the refrigerator, thereby stopping them from submitting further I/O that could cause the syncing threads to potentially spin for ever.

2. Syncing threads are signalled so that when they finish syncing (if they haven't already), they also enter the refrigerator. Any processes that were in group 2 but are now in group 1 are also signalled.

It is possible that no process was syncing data. We thus now call sys_sync ourselves, to flush remaining dirty data to disk.

3. Kernel threads not needed during suspend (kjournald, eg) are frozen.

Quoted 1 line

300: stopping softirqd seems dangerous to me... are you sure?

It's been that way for ages without any reports of deadlocks. I'm happy to change it if it really was dangerous for some reason.

Quoted 1 line

301: patching exit should not be neccessary. Why do you need it?

Maybe you're right. I think it's a left over from the old implementation. I'll try removing the call and see how the freezer survives some stress testing.

Regards,

Nigel

#3 lore raw
In reply to Benjamin Herrenschmidt

Hi.

Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Pavel Machek

Hi!

Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

300: stopping softirqd seems dangerous to me... are you sure?

That sounds bogus indeed.

Ok. Bogus but harmless. I'll try removing it.

Regards,

Nigel

#4 lore raw
Quoted 10 lines · Nigel Cunningham

Hi.

Quoted 7 lines · Benjamin Herrenschmidt
Quoted 5 lines · Pavel Machek

Hi!

Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

300: stopping softirqd seems dangerous to me... are you sure?

That sounds bogus indeed.

Ok. Bogus but harmless. I'll try removing it.

Not really harmless, you happen to be lucky :)

Ben.

#6 lore raw
In reply to Nigel Cunningham

Hi!

(Well, it is just after midnight here :-).

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

Quoted 8 lines
Quoted 1 line

304 seems ugly and completely useless for mainline

That's because you don't understand what it's doing.

The new refrigerator implementation works like this:

Userspace processes that begin a sys_*sync gain the process flag PF_SYNCTHREAD for the duration of their syscall.

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

Pavel

#7 lore raw
Quoted 12 lines · Pavel Machek

Hi!

(Well, it is just after midnight here :-).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

304 seems ugly and completely useless for mainline

That's because you don't understand what it's doing.

Quoted 8 lines
Quoted 4 lines

The new refrigerator implementation works like this:

Userspace processes that begin a sys_*sync gain the process flag PF_SYNCTHREAD for the duration of their syscall.

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

It's still quite nice to have ... I put it in my pre-freeze callback in fact for both STR and STD :) We really want it for STD but I think it doesn't work properly after freeze.

Ben.

#8 lore raw
Quoted 18 lines · Benjamin Herrenschmidt
Quoted 17 lines · Pavel Machek

Hi!

(Well, it is just after midnight here :-).

Quoted 12 lines
Quoted 5 lines
Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

304 seems ugly and completely useless for mainline

That's because you don't understand what it's doing.

The new refrigerator implementation works like this:

Userspace processes that begin a sys_*sync gain the process flag PF_SYNCTHREAD for the duration of their syscall.

Quoted 7 lines
Quoted 3 lines

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

It's still quite nice to have ... I put it in my pre-freeze callback in fact for both STR and STD :) We really want it for STD but I think it doesn't work properly after freeze.

I agree that sync() is nice to have, but I'm not going to slow down fork/exit for it. And besides, sys_sync() just before suspend works just fine.

Pavel

#9 lore raw
Quoted 4 lines

I agree that sync() is nice to have, but I'm not going to slow down fork/exit for it. And besides, sys_sync() just before suspend works just fine.

Yes, that's why I put it in my pre-freeze :)

I'll see about making my pre/post freeze stuff (APM emu + sync basically now) generic to avoid the callbacks.

Ben.

#12 lore raw
In reply to Pavel Machek

Hi.

Quoted 14 lines · Pavel Machek
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 12 lines · Pavel Machek

Hi!

(Well, it is just after midnight here :-).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Here are the freezer patches. They were prepared against rc3, but I think they still apply fine against rc5. (Ben, these are the same ones I sent you the other day).

304 seems ugly and completely useless for mainline

That's because you don't understand what it's doing.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

The new refrigerator implementation works like this:

Userspace processes that begin a sys_*sync gain the process flag PF_SYNCTHREAD for the duration of their syscall.

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

Wrong. I guess you're only trying it on a machine that isn't actually doing anything :). I've forgotten whether it was this freezer implementation or the last, but we've been testing freezing processes when the load average exceeds 100. If you have a thread that is syncing and another that's submitting I/O continually (think dd, for example), you want this.

Quoted 7 lines
Quoted 3 lines

It's still quite nice to have ... I put it in my pre-freeze callback in fact for both STR and STD :) We really want it for STD but I think it doesn't work properly after freeze.

I agree that sync() is nice to have, but I'm not going to slow down fork/exit for it. And besides, sys_sync() just before suspend works just fine.

Again, try it under load... and stop talking about fork and exit like they're real hot paths. (Unless you regularly submit your machines to fork bombs :)).

Regards,

Nigel

#10 lore raw
In reply to Benjamin Herrenschmidt

Hi.

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 3 lines

I agree that sync() is nice to have, but I'm not going to slow down fork/exit for it. And besides, sys_sync() just before suspend works just fine.

Yes, that's why I put it in my pre-freeze :)

I'll see about making my pre/post freeze stuff (APM emu + sync basically now) generic to avoid the callbacks.

Ummm. Don't do it if kthreads are already frozen. You'll deadlock against kjournald.

Regards,

Nigel

#11 lore raw
In reply to Nigel Cunningham
Quoted 7 lines · Nigel Cunningham

Hi.

Quoted 4 lines · Benjamin Herrenschmidt
Quoted 3 lines

I agree that sync() is nice to have, but I'm not going to slow down fork/exit for it. And besides, sys_sync() just before suspend works just fine.

Quoted 6 lines
Quoted 4 lines

Yes, that's why I put it in my pre-freeze :)

I'll see about making my pre/post freeze stuff (APM emu + sync basically now) generic to avoid the callbacks.

Ummm. Don't do it if kthreads are already frozen. You'll deadlock against kjournald.

Which is why I do it pre-freeze.

With a 2 stage freezing though, it would make sense to first freeze userland, then sync, then freeze kthreads. That would make the sync faster (as it won't be "blocked" by pending userland IOs as I experience regulary here) and more reliable.

Ben.

#14 lore raw
In reply to Nigel Cunningham

Hi!

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

Wrong. I guess you're only trying it on a machine that isn't actually doing anything :). I've forgotten whether it was this freezer implementation or the last, but we've been testing freezing processes when the load average exceeds 100. If you have a thread that is syncing and another that's submitting I/O continually (think dd, for example), you want this.

If sys_sync() is not working, *fix sys_sync()*. [BTW I see that problem before and I think it is being worked on.] I'm *not* going to work around it in refrigerator.

Pavel

#15 lore raw

Hi.

Quoted 13 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

swsusp1 should not need any special casing of sync, right? We can simply do sys_sync(), then freeze, or something like that. We could even remove sys_sync() completely; it is not needed for correctness.

Wrong. I guess you're only trying it on a machine that isn't actually doing anything :). I've forgotten whether it was this freezer implementation or the last, but we've been testing freezing processes when the load average exceeds 100. If you have a thread that is syncing and another that's submitting I/O continually (think dd, for example), you want this.

Quoted 3 lines

If sys_sync() is not working, *fix sys_sync()*. [BTW I see that problem before and I think it is being worked on.] I'm *not* going to work around it in refrigerator.

I'm not saying sys_sync is broken. I _am_ saying that if you have processes submitting I/O while you're trying to sync, syncing will take longer and you may well still end up with dirty buffers at the end. On top of this, you may think freezing has failed because processes don't enter the refrigerator within your timelimit (assuming you have one).

The simple, logic solution is to stop threads that are submitting I/O before you stop threads that are syncing I/O.

Regards,

Nigel

#16 lore raw

Hi!

Quoted 10 lines
Quoted 3 lines

If sys_sync() is not working, *fix sys_sync()*. [BTW I see that problem before and I think it is being worked on.] I'm *not* going to work around it in refrigerator.

I'm not saying sys_sync is broken. I _am_ saying that if you have processes submitting I/O while you're trying to sync, syncing will take longer and you may well still end up with dirty buffers at the end. On top of this, you may think freezing has failed because processes don't enter the refrigerator within your timelimit (assuming you have one).

Then simple launch sys_sync(), let it finish, *then* do refrigeration. That way sys_sync() does not count to the timelimit.

Now, sys_sync() takes too long on some setups. That needs to be fixed, anyway; users don't like to wait for 15 minutes after typing "sync". Do not work around it in refrigerator.
Pavel

#17 lore raw
Quoted 13 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 3 lines

If sys_sync() is not working, *fix sys_sync()*. [BTW I see that problem before and I think it is being worked on.] I'm *not* going to work around it in refrigerator.

I'm not saying sys_sync is broken. I _am_ saying that if you have processes submitting I/O while you're trying to sync, syncing will take longer and you may well still end up with dirty buffers at the end. On top of this, you may think freezing has failed because processes don't enter the refrigerator within your timelimit (assuming you have one).

Quoted 6 lines

Then simple launch sys_sync(), let it finish, *then* do refrigeration. That way sys_sync() does not count to the timelimit.

Now, sys_sync() takes too long on some setups. That needs to be fixed, anyway; users don't like to wait for 15 minutes after typing "sync". Do not work around it in refrigerator.

Whatever you guys decide to do (I actually do sys_sync() before freezing on pmac and yes, it takes sometimes way too long), to be uber-safe, we could/should _also_ do sync after freezing userland processes and before freezing kernel threads (that is, splitting here). In fact, that would help also avoid deadlocks where a frozen kernel thread is holding a semaphore preventing a process from freezing.

That way, if we sys_sync() once processes are sleeping and before kernel threads are, we pretty-much make sure no new dirty buffer will appear.

Anyway, that's mostly food for thoughts at this point

Ben.

#18 lore raw

Hi Ben.

Quoted 11 lines · Benjamin Herrenschmidt

Whatever you guys decide to do (I actually do sys_sync() before freezing on pmac and yes, it takes sometimes way too long), to be uber-safe, we could/should _also_ do sync after freezing userland processes and before freezing kernel threads (that is, splitting here). In fact, that would help also avoid deadlocks where a frozen kernel thread is holding a semaphore preventing a process from freezing.

That way, if we sys_sync() once processes are sleeping and before kernel threads are, we pretty-much make sure no new dirty buffer will appear.

Anyway, that's mostly food for thoughts at this point

I fully agree, and that's what I'm already doing. Nothing I can do about Pavel not seeing logic, so guess I just have to hope everyone else does :)

Regards,

Nigel

#19 lore raw

Hi!

Quoted 7 lines
Quoted 7 lines

Whatever you guys decide to do (I actually do sys_sync() before freezing on pmac and yes, it takes sometimes way too long), to be uber-safe, we could/should _also_ do sync after freezing userland processes and before freezing kernel threads (that is, splitting here). In fact, that would help also avoid deadlocks where a frozen kernel thread is holding a semaphore preventing a process from freezing.

Quoted 8 lines
Quoted 4 lines

That way, if we sys_sync() once processes are sleeping and before kernel threads are, we pretty-much make sure no new dirty buffer will appear.

Anyway, that's mostly food for thoughts at this point

I fully agree, and that's what I'm already doing. Nothing I can do about Pavel not seeing logic, so guess I just have to hope everyone else does :)

I think I see your logic, and it is wrong. Anyway, just do not touch fork/exit hot paths.
Pavel