Michal Nazarewicz 22c43c81a5 wait_event_interruptible_locked() interface
New wait_event_interruptible{,_exclusive}_locked{,_irq} macros added.
They work just like versions without _locked* suffix but require the
wait queue's lock to be held.  Also __wake_up_locked() is now exported
as to pair it with the above macros.

The use case of this new facility is when one uses wait queue's lock
to  protect a data structure.  This may be advantageous if the
structure needs to be protected by a spinlock anyway.  In particular,
with additional spinlock the following code has to be used to wait
for a condition:

spin_lock(&data.lock);
...
for (ret = 0; !ret && !(condition); ) {
	spin_unlock(&data.lock);
	ret = wait_event_interruptible(data.wqh, (condition));
	spin_lock(&data.lock);
}
...
spin_unlock(&data.lock);

This looks bizarre plus wait_event_interruptible() locks the wait
queue's lock anyway so there is a unlock+lock sequence where it could
be avoided.

To avoid those problems and benefit from wait queue's lock, a code
similar to the following should be used:

/* Waiting */
spin_lock(&data.wqh.lock);
...
ret = wait_event_interruptible_locked(data.wqh, (condition));
...
spin_unlock(&data.wqh.lock);

/* Waiting exclusively */
spin_lock(&data.whq.lock);
...
ret = wait_event_interruptible_exclusive_locked(data.whq, (condition));
...
spin_unlock(&data.whq.lock);

/* Waking up */
spin_lock(&data.wqh.lock);
...
wake_up_locked(&data.wqh);
...
spin_unlock(&data.wqh.lock);

When spin_lock_irq() is used matching versions of macros need to be
used (*_locked_irq()).

Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-20 13:21:42 -07:00
..
2009-10-27 16:47:55 -04:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2010-03-12 15:53:10 -08:00
2009-06-17 00:36:36 -04:00
2009-12-16 07:20:13 -08:00
2009-09-08 17:42:50 -07:00
2010-04-25 08:54:42 +02:00
2009-11-20 20:13:39 +01:00
2009-11-20 20:13:39 +01:00
2009-11-20 20:13:39 +01:00
2009-06-11 21:36:09 -04:00
2010-03-12 15:52:32 -08:00
2010-02-05 07:35:05 -08:00
2009-07-12 12:22:34 -07:00
2009-12-10 23:52:01 +00:00
2009-11-04 09:50:58 -08:00
2009-10-01 21:17:49 +02:00
2009-09-14 17:41:42 -07:00
2009-12-15 08:53:33 -08:00
2009-11-04 09:50:58 -08:00
2009-12-23 13:33:54 +01:00
2009-11-04 09:50:58 -08:00
2010-04-23 10:39:48 -07:00
2009-06-18 13:04:05 -07:00
2009-11-04 09:50:58 -08:00
2010-03-16 08:55:32 +01:00
2009-09-01 01:13:31 -07:00
2010-02-09 11:13:56 +01:00
2009-12-14 23:55:34 +01:00
2010-03-07 22:17:09 +01:00
2010-03-02 12:23:42 +01:00
2010-04-01 01:31:13 -07:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2010-02-18 14:08:38 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2010-02-17 16:35:17 -08:00
2010-02-02 07:32:29 -08:00
2010-01-11 16:28:01 -08:00
2010-03-12 15:52:40 -08:00
2010-03-12 15:52:36 -08:00
2009-11-04 09:50:58 -08:00
2010-03-12 15:52:40 -08:00
2009-09-26 10:17:19 -07:00
2009-10-18 18:52:53 -07:00
2009-08-29 15:53:00 +02:00
2010-03-12 15:53:10 -08:00
2009-09-26 10:17:19 -07:00
2009-12-16 06:56:12 -08:00
2009-06-23 20:21:39 +01:00
2009-07-30 16:03:45 +09:30
2010-04-06 10:55:33 -04:00
2009-12-15 08:53:36 -08:00
2009-12-26 20:40:34 -08:00
2010-02-03 17:39:50 +11:00
2010-03-12 15:53:10 -08:00
2010-02-09 11:13:56 +01:00
2010-02-19 03:35:12 -05:00
2009-06-16 19:47:48 -07:00
2010-03-12 15:52:38 -08:00
2009-09-22 07:17:35 -07:00
2009-06-16 08:40:20 +02:00
2009-12-15 08:53:20 -08:00
2010-03-12 15:52:28 -08:00
2010-04-07 08:38:04 -07:00
2009-12-12 13:08:15 +01:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2010-02-10 23:49:08 +09:00
2009-11-04 09:50:58 -08:00
2010-02-03 20:32:28 -08:00
2009-06-17 18:02:11 -07:00
2009-06-17 18:02:11 -07:00
2010-04-12 07:55:15 -04:00
2009-06-17 18:02:11 -07:00
2010-02-19 15:52:40 -05:00
2009-06-15 21:44:43 -07:00
2010-02-14 07:13:47 -07:00
2010-02-23 23:14:47 -08:00
2010-02-04 10:23:02 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2010-03-12 15:53:11 -08:00
2009-12-03 11:43:23 +00:00
2009-06-18 13:04:04 -07:00
2009-07-29 19:10:36 -07:00
2009-09-23 07:39:41 -07:00
2009-06-11 21:36:12 -04:00
2010-03-05 00:20:31 +01:00
2010-02-10 17:47:17 -08:00
2009-10-30 15:06:37 -07:00
2010-03-12 15:52:44 -08:00
2009-06-24 08:17:06 -04:00
2010-03-02 14:28:49 -05:00
2009-11-04 09:50:58 -08:00
2010-03-12 15:53:10 -08:00
2010-03-12 15:52:43 -08:00
2010-01-21 23:55:25 -08:00
2009-08-28 19:57:30 -04:00
2010-02-16 13:38:56 +09:00
2009-11-30 12:02:53 +09:00
2010-03-12 15:52:44 -08:00
2009-12-16 22:32:29 -05:00
2010-01-14 22:38:09 -05:00
2010-03-12 15:52:36 -08:00
2009-07-06 13:57:03 -07:00
2010-02-18 15:43:09 -08:00
2009-11-13 20:46:24 +01:00
2009-08-30 22:26:34 +02:00
2009-10-29 11:17:40 +11:00
2009-11-10 20:54:38 -08:00
2010-05-20 13:21:42 -07:00
2009-09-23 18:13:10 -07:00
2009-08-26 12:39:29 +01:00
2009-09-23 22:26:32 +09:30
2010-01-05 09:17:33 +09:00
2010-03-12 10:03:42 +01:00
2009-12-16 12:16:49 -05:00