Re: [PATCH 7/8] Clean up workqueue.c with respect to the freezer based cpu-hotplug

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oleg Nesterov
Date: Tuesday, April 3, 2007 - 4:47 am

> On 04/02, Gautham R Shenoy wrote:

I'll study these patches later, a couple of comments after the quick reading.


We can't freeze workqueue if some work_struct continuously re-queues itself.
Perhaps this is not a problem (I don't see a good reason for such a behaviour),
but this should be documented.


I still think that wait_to_die + bind_cpu is unneeded complication.
Why can't we do the following:

	static int worker_thread(void *__cwq)
	{
		...

		for (;;) {
			try_to_freeze();

			prepare_to_wait(&cwq->more_work, &wait, TASK_INTERRUPTIBLE);
			if (!kthread_should_stop() && list_empty(&cwq->worklist))
				schedule();
			finish_wait(&cwq->more_work, &wait);

			if (kthread_should_stop(cwq))
				break;

			run_workqueue(cwq);
		}

		return 0;
	}

?


Hm... I can't understand this change. I believe it is wrong.


Well, this is a matter of taste, but I don't like this change. Now we
should add kthread_bind/wake_up_process calls to __create_workqueue()
and workqueue_cpu_callback(). I won't persist though.


This is wrong. CPU_UP_PREPARE doesn't call init_cpu_workqueue().
Easy to fix, but I personally think is is better to initialize
the whole cpu_possible_map.


Deadlockable. Suppose that the freezing is in progress, cwq->thread is not
frozen yet. cleanup_workqueue_thread() calls thaw_process(cwq->thread),
then cwq->thread() goes to refrigerator, kthread_stop() blocks forever.


This CPU is dead (or cancelled), we don't need cwq->lock.


This means that the work_struct on single_threaded wq can't use any of

	__create_workqueue()
	destroy_workqueue()
	flush_workqueue()
	cancel_work_sync()

, they are all racy wrt workqueue_cpu_callback(), and we don't freeze
single_threaded workqueues. This is bad.

Probaly we should:

	- freeze all workqueues, even the single_threaded ones.

	- helper_init() explicitely does __create_workqueue(FE_ALL).
	  this means that we should never use the functions above
	  with this workqueue.

Oleg.

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Sun Apr 1, 10:34 pm)
[PATCH 2/8] Make process freezer reentrant, Gautham R Shenoy, (Sun Apr 1, 10:37 pm)
[PATCH 3/8] Use process freezer for cpu-hotplug, Gautham R Shenoy, (Sun Apr 1, 10:38 pm)
[PATCH 4/8] Rip out lock_cpu_hotplug(), Gautham R Shenoy, (Sun Apr 1, 10:39 pm)
[PATCH 5/8] __cpu_up: use singlethreaded workqueue, Gautham R Shenoy, (Sun Apr 1, 10:40 pm)
[PATCH 6/8] Make non-singlethreaded workqueues freezeable ..., Gautham R Shenoy, (Sun Apr 1, 10:41 pm)
[PATCH 8/8] Make kernel threads freezeable for cpu-hotplug, Gautham R Shenoy, (Sun Apr 1, 10:42 pm)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Srivatsa Vaddagiri, (Mon Apr 2, 2:28 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Mon Apr 2, 4:19 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Srivatsa Vaddagiri, (Mon Apr 2, 5:42 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Mon Apr 2, 7:16 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Rafael J. Wysocki, (Mon Apr 2, 3:12 pm)
Re: [PATCH 7/8] Clean up workqueue.c with respect to the f ..., Oleg Nesterov, (Tue Apr 3, 4:47 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Tue Apr 3, 5:01 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Srivatsa Vaddagiri, (Tue Apr 3, 5:56 am)
Re: [PATCH 7/8] Clean up workqueue.c with respect to the f ..., Srivatsa Vaddagiri, (Tue Apr 3, 6:59 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Tue Apr 3, 7:01 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Tue Apr 3, 7:15 am)
Re: [PATCH 7/8] Clean up workqueue.c with respect to the f ..., Srivatsa Vaddagiri, (Tue Apr 3, 10:18 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Rafael J. Wysocki, (Tue Apr 3, 12:34 pm)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Andrew Morton, (Tue Apr 3, 1:24 pm)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Srivatsa Vaddagiri, (Tue Apr 3, 8:15 pm)
Re: utrace merge, Ingo Molnar, (Wed Apr 4, 3:06 am)
Re: utrace merge, Christoph Hellwig, (Wed Apr 4, 3:36 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Wed Apr 4, 3:41 am)
Re: [RFC] Cpu-hotplug: Using the Process Freezer (try2), Gautham R Shenoy, (Wed Apr 4, 5:24 am)
Re: [PATCH 7/8] Clean up workqueue.c with respect to the f ..., Srivatsa Vaddagiri, (Wed Apr 4, 10:49 am)
Re: utrace merge, Andrew Morton, (Wed Apr 4, 11:41 am)
Re: [PATCH 2/8] Make process freezer reentrant, Oleg Nesterov, (Thu Apr 5, 2:53 am)
Re: [PATCH 2/8] Make process freezer reentrant, Gautham R Shenoy, (Thu Apr 5, 3:19 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Oleg Nesterov, (Thu Apr 5, 3:53 am)
Re: [PATCH 5/8] __cpu_up: use singlethreaded workqueue, Oleg Nesterov, (Thu Apr 5, 5:08 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Gautham R Shenoy, (Thu Apr 5, 5:14 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Oleg Nesterov, (Thu Apr 5, 6:34 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Nathan Lynch, (Fri Apr 6, 10:27 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Ingo Molnar, (Fri Apr 6, 10:34 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Nathan Lynch, (Fri Apr 6, 10:47 am)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Nigel Cunningham, (Fri Apr 6, 3:22 pm)
Re: [PATCH 7/8] Clean up workqueue.c with respect to the f ..., Srivatsa Vaddagiri, (Wed Apr 11, 7:22 pm)
Re: [PATCH 3/8] Use process freezer for cpu-hotplug, Pavel Machek, (Sat Apr 14, 11:48 am)