* [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 23:04 ` Daniel Walker
2009-07-27 15:24 ` Christoph Hellwig
2009-07-26 8:17 ` [Patch RFC 02/37] input: keyboard/hil_kbd: semaphore cleanup Thomas Gleixner
` (35 subsequent siblings)
36 siblings, 2 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra
[-- Attachment #1: semaphore-add-define-semaphore.patch --]
[-- Type: text/plain, Size: 1443 bytes --]
The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
done. Some of the users are real semaphores and we should name them as
such instead of confusing everyone with "MUTEX".
Provide the infrastructure to get finally rid of init_MUTEX[_LOCKED]
and DECLARE_MUTEX.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/semaphore.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Index: linux-2.6-tip/include/linux/semaphore.h
===================================================================
--- linux-2.6-tip.orig/include/linux/semaphore.h
+++ linux-2.6-tip/include/linux/semaphore.h
@@ -26,6 +26,9 @@ struct semaphore {
.wait_list = LIST_HEAD_INIT((name).wait_list), \
}
+#define DEFINE_SEMAPHORE(name) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+
#define DECLARE_MUTEX(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
@@ -36,6 +39,20 @@ static inline void sema_init(struct sema
lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
}
+static inline void semaphore_init(struct semanphore *sem)
+{
+ sema_init(sem, 1);
+}
+
+/*
+ * semaphore_init_locked() is mostly a sign for a mutex which is
+ * abused as completion.
+ */
+static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
+{
+ sema_init(sem, 0);
+}
+
#define init_MUTEX(sem) sema_init(sem, 1)
#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
2009-07-26 8:17 ` [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked Thomas Gleixner
@ 2009-07-26 23:04 ` Daniel Walker
2009-07-27 15:25 ` Christoph Hellwig
2009-07-27 15:24 ` Christoph Hellwig
1 sibling, 1 reply; 60+ messages in thread
From: Daniel Walker @ 2009-07-26 23:04 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, 2009-07-26 at 08:17 +0000, Thomas Gleixner wrote:
> +static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
> +{
> + sema_init(sem, 0);
> +}
> +
> #define init_MUTEX(sem) sema_init(sem, 1)
> #define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
Maybe you could introduce this _after_ you do the semaphore to
completion cleanup .. This init_locked is just adding a bunch of code
flux on top of that..
Daniel
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
2009-07-26 23:04 ` Daniel Walker
@ 2009-07-27 15:25 ` Christoph Hellwig
2009-07-27 15:32 ` Thomas Gleixner
0 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-27 15:25 UTC (permalink / raw)
To: Daniel Walker
Cc: Thomas Gleixner, LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, Jul 26, 2009 at 04:04:49PM -0700, Daniel Walker wrote:
> Maybe you could introduce this _after_ you do the semaphore to
> completion cleanup .. This init_locked is just adding a bunch of code
> flux on top of that..
I agree. For these 36 patches we should first check if they can
be trivially converted to mutexes or completions and only change them
away to the semaphore named initializers.
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
2009-07-27 15:25 ` Christoph Hellwig
@ 2009-07-27 15:32 ` Thomas Gleixner
0 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-27 15:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Daniel Walker, LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Mon, 27 Jul 2009, Christoph Hellwig wrote:
> On Sun, Jul 26, 2009 at 04:04:49PM -0700, Daniel Walker wrote:
> > Maybe you could introduce this _after_ you do the semaphore to
> > completion cleanup .. This init_locked is just adding a bunch of code
> > flux on top of that..
>
> I agree. For these 36 patches we should first check if they can
> be trivially converted to mutexes or completions and only change them
> away to the semaphore named initializers.
I have already converted some of the users to mutexes where it was
obvious. It's part of the series.
Thanks,
tglx
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
2009-07-26 8:17 ` [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked Thomas Gleixner
2009-07-26 23:04 ` Daniel Walker
@ 2009-07-27 15:24 ` Christoph Hellwig
1 sibling, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-27 15:24 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, Jul 26, 2009 at 08:17:11AM -0000, Thomas Gleixner wrote:
> The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
> done. Some of the users are real semaphores and we should name them as
> such instead of confusing everyone with "MUTEX".
> +#define DEFINE_SEMAPHORE(name) \
> + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
> +
> +static inline void semaphore_init(struct semanphore *sem)
> +{
> + sema_init(sem, 1);
> +}
> +
> +/*
> + * semaphore_init_locked() is mostly a sign for a mutex which is
> + * abused as completion.
> + */
> +static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
> +{
> + sema_init(sem, 0);
> +}
The CS literature doesn't really know about a default value for counting
semaphores. I think you're better off converting init_MUTEX and
init_MUTEX_locked to explicit sema_init use than adding these and
introducing another semaphore_* namespace in addition to the sema_* we
already have. Adding a DEFINE_SEMAPHORE makes sense, but it should take
a second argument for it's initial value.
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 02/37] input: keyboard/hil_kbd: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-28 7:36 ` Dmitry Torokhov
2009-07-26 8:17 ` [Patch RFC 03/37] input: misc/hp_sdc_rtc: " Thomas Gleixner
` (34 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Dmitry Torokhov
[-- Attachment #1: drivers-input-keyboard-hil-kbd-sema-cleanup.patch --]
[-- Type: text/plain, Size: 797 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/keyboard/hil_kbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/input/keyboard/hil_kbd.c
===================================================================
--- linux-2.6-tip.orig/drivers/input/keyboard/hil_kbd.c
+++ linux-2.6-tip/drivers/input/keyboard/hil_kbd.c
@@ -277,7 +277,7 @@ static int hil_kbd_connect(struct serio
serio_set_drvdata(serio, kbd);
kbd->serio = serio;
- init_MUTEX_LOCKED(&kbd->sem);
+ semaphore_init_locked(&kbd->sem);
/* Get device info. MLC driver supplies devid/status/etc. */
serio->write(serio, 0);
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 02/37] input: keyboard/hil_kbd: semaphore cleanup
2009-07-26 8:17 ` [Patch RFC 02/37] input: keyboard/hil_kbd: semaphore cleanup Thomas Gleixner
@ 2009-07-28 7:36 ` Dmitry Torokhov
0 siblings, 0 replies; 60+ messages in thread
From: Dmitry Torokhov @ 2009-07-28 7:36 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, Jul 26, 2009 at 08:17:15AM -0000, Thomas Gleixner wrote:
> The usage of this "mutex" is non obvious and probably a completion in
> some places. Make it a semaphore.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> ---
> drivers/input/keyboard/hil_kbd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6-tip/drivers/input/keyboard/hil_kbd.c
> ===================================================================
> --- linux-2.6-tip.orig/drivers/input/keyboard/hil_kbd.c
> +++ linux-2.6-tip/drivers/input/keyboard/hil_kbd.c
> @@ -277,7 +277,7 @@ static int hil_kbd_connect(struct serio
> serio_set_drvdata(serio, kbd);
> kbd->serio = serio;
>
> - init_MUTEX_LOCKED(&kbd->sem);
> + semaphore_init_locked(&kbd->sem);
>
I started working on conversion of that into a completion, I'll
commit as soon as I get someone to test it.
--
Dmitry
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 03/37] input: misc/hp_sdc_rtc: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 02/37] input: keyboard/hil_kbd: semaphore cleanup Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 04/37] input: mouse/hil_ptr: " Thomas Gleixner
` (33 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Dmitry Torokhov
[-- Attachment #1: driver-input-misc-hp-sdc-rtc-sema-cleanup.patch --]
[-- Type: text/plain, Size: 983 bytes --]
The usage of these "mutex"es is non obvious and probably a completion in
some places. Make them semaphores.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/misc/hp_sdc_rtc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/drivers/input/misc/hp_sdc_rtc.c
===================================================================
--- linux-2.6-tip.orig/drivers/input/misc/hp_sdc_rtc.c
+++ linux-2.6-tip/drivers/input/misc/hp_sdc_rtc.c
@@ -104,7 +104,7 @@ static int hp_sdc_rtc_do_read_bbrtc (str
t.endidx = 91;
t.seq = tseq;
t.act.semaphore = &tsem;
- init_MUTEX_LOCKED(&tsem);
+ semaphore_init_locked(&tsem);
if (hp_sdc_enqueue_transaction(&t)) return -1;
@@ -686,7 +686,7 @@ static int __init hp_sdc_rtc_init(void)
return -ENODEV;
#endif
- init_MUTEX(&i8042tregs);
+ semaphore_init(&i8042tregs);
if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
return ret;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 04/37] input: mouse/hil_ptr: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (2 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 03/37] input: misc/hp_sdc_rtc: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 05/37] input: serio/hil_mlc: " Thomas Gleixner
` (32 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Dmitry Torokhov
[-- Attachment #1: driver-input-mouse-hil-ptr-sema-cleanup.patch --]
[-- Type: text/plain, Size: 785 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/mouse/hil_ptr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/input/mouse/hil_ptr.c
===================================================================
--- linux-2.6-tip.orig/drivers/input/mouse/hil_ptr.c
+++ linux-2.6-tip/drivers/input/mouse/hil_ptr.c
@@ -270,7 +270,7 @@ static int hil_ptr_connect(struct serio
serio_set_drvdata(serio, ptr);
ptr->serio = serio;
- init_MUTEX_LOCKED(&ptr->sem);
+ semaphore_init_locked(&ptr->sem);
/* Get device info. MLC driver supplies devid/status/etc. */
serio->write(serio, 0);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 05/37] input: serio/hil_mlc: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (3 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 04/37] input: mouse/hil_ptr: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 06/37] input: serio/hp_sdc: " Thomas Gleixner
` (31 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Dmitry Torokhov
[-- Attachment #1: driver-input-serio-hil-mlc-sema-cleanup.patch --]
[-- Type: text/plain, Size: 931 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/serio/hil_mlc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: linux-2.6-tip/drivers/input/serio/hil_mlc.c
===================================================================
--- linux-2.6-tip.orig/drivers/input/serio/hil_mlc.c
+++ linux-2.6-tip/drivers/input/serio/hil_mlc.c
@@ -914,15 +914,15 @@ int hil_mlc_register(hil_mlc *mlc)
mlc->ostarted = 0;
rwlock_init(&mlc->lock);
- init_MUTEX(&mlc->osem);
+ semaphore_init(&mlc->osem);
- init_MUTEX(&mlc->isem);
+ semaphore_init(&mlc->isem);
mlc->icount = -1;
mlc->imatch = 0;
mlc->opercnt = 0;
- init_MUTEX_LOCKED(&(mlc->csem));
+ semaphore_init(&(mlc->csem));
hil_mlc_clear_di_scratch(mlc);
hil_mlc_clear_di_map(mlc, 0);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 06/37] input: serio/hp_sdc: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (4 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 05/37] input: serio/hil_mlc: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 07/37] net: 3c527: " Thomas Gleixner
` (30 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Dmitry Torokhov
[-- Attachment #1: driver-input-serio-hp-sdc-sema-cleanup.patch --]
[-- Type: text/plain, Size: 709 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/serio/hp_sdc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/input/serio/hp_sdc.c
===================================================================
--- linux-2.6-tip.orig/drivers/input/serio/hp_sdc.c
+++ linux-2.6-tip/drivers/input/serio/hp_sdc.c
@@ -1039,7 +1039,7 @@ static int __init hp_sdc_register(void)
return hp_sdc.dev_err;
}
- init_MUTEX_LOCKED(&tq_init_sem);
+ semaphore_init(&tq_init_sem);
tq_init.actidx = 0;
tq_init.idx = 1;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 07/37] net: 3c527: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (5 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 06/37] input: serio/hp_sdc: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 08/37] hamradio: 6pack: " Thomas Gleixner
` (29 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David Miller
[-- Attachment #1: driver-net-3c527-sema-cleanup.patch --]
[-- Type: text/plain, Size: 826 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Miller <davem@davemloft.net>
---
drivers/net/3c527.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/3c527.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/3c527.c
+++ linux-2.6-tip/drivers/net/3c527.c
@@ -521,7 +521,7 @@ static int __init mc32_probe1(struct net
lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */
lp->rx_len = lp->exec_box->data[11]; /* Receive list count */
- init_MUTEX_LOCKED(&lp->cmd_mutex);
+ semaphore_init_locked(&lp->cmd_mutex);
init_completion(&lp->execution_cmd);
init_completion(&lp->xceiver_cmd);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 08/37] hamradio: 6pack: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (6 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 07/37] net: 3c527: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 09/37] hamradio: mkiss: " Thomas Gleixner
` (28 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David Miller
[-- Attachment #1: driver-nethamradio-6pack-sema-cleanup.patch --]
[-- Type: text/plain, Size: 772 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Miller <davem@davemloft.net>
---
drivers/net/hamradio/6pack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/hamradio/6pack.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/hamradio/6pack.c
+++ linux-2.6-tip/drivers/net/hamradio/6pack.c
@@ -606,7 +606,7 @@ static int sixpack_open(struct tty_struc
spin_lock_init(&sp->lock);
atomic_set(&sp->refcnt, 1);
- init_MUTEX_LOCKED(&sp->dead_sem);
+ semaphore_init_locked(&sp->dead_sem);
/* !!! length of the buffers. MTU is IP MTU, not PACLEN! */
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 09/37] hamradio: mkiss: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (7 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 08/37] hamradio: 6pack: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:17 ` [Patch RFC 10/37] net: ppp_async: " Thomas Gleixner
` (27 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David Miller
[-- Attachment #1: driver-nethamradio-mkiss-sema-cleanup.patch --]
[-- Type: text/plain, Size: 750 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Miller <davem@davemloft.net>
---
drivers/net/hamradio/mkiss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/hamradio/mkiss.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/hamradio/mkiss.c
+++ linux-2.6-tip/drivers/net/hamradio/mkiss.c
@@ -745,7 +745,7 @@ static int mkiss_open(struct tty_struct
spin_lock_init(&ax->buflock);
atomic_set(&ax->refcnt, 1);
- init_MUTEX_LOCKED(&ax->dead_sem);
+ semaphore_init_locked(&ax->dead_sem);
ax->tty = tty;
tty->disc_data = ax;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 10/37] net: ppp_async: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (8 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 09/37] hamradio: mkiss: " Thomas Gleixner
@ 2009-07-26 8:17 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 11/37] parport: " Thomas Gleixner
` (26 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:17 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David Miller
[-- Attachment #1: driver-net-ppp-async-cleanup.patch --]
[-- Type: text/plain, Size: 777 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Miller <davem@davemloft.net>
---
drivers/net/ppp_async.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/ppp_async.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/ppp_async.c
+++ linux-2.6-tip/drivers/net/ppp_async.c
@@ -183,7 +183,7 @@ ppp_asynctty_open(struct tty_struct *tty
tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap);
atomic_set(&ap->refcnt, 1);
- init_MUTEX_LOCKED(&ap->dead_sem);
+ semaphore_init_locked(&ap->dead_sem);
ap->chan.private = ap;
ap->chan.ops = &async_ops;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 11/37] parport: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (9 preceding siblings ...)
2009-07-26 8:17 ` [Patch RFC 10/37] net: ppp_async: " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 12/37] ibmphp-hpc: " Thomas Gleixner
` (25 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Alan Cox
[-- Attachment #1: driver-parport-share-cleanup.patch --]
[-- Type: text/plain, Size: 913 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
---
drivers/parport/share.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/parport/share.c
===================================================================
--- linux-2.6-tip.orig/drivers/parport/share.c
+++ linux-2.6-tip/drivers/parport/share.c
@@ -306,7 +306,7 @@ struct parport *parport_register_port(un
spin_lock_init(&tmp->pardevice_lock);
tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
- init_MUTEX_LOCKED (&tmp->ieee1284.irq); /* actually a semaphore at 0 */
+ semaphore_init_locked(&tmp->ieee1284.irq);
tmp->spintime = parport_default_spintime;
atomic_set (&tmp->ref_count, 1);
INIT_LIST_HEAD(&tmp->full_list);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 12/37] ibmphp-hpc: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (10 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 11/37] parport: " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 13/37] s390: cio/crw: " Thomas Gleixner
` (24 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman
[-- Attachment #1: driver-pci-hotplug-ibmphp-hpc-sema-share-cleanup.patch --]
[-- Type: text/plain, Size: 845 bytes --]
The usage of this "mutex"es is non obvious and probably a completion
in some places. Make them semaphores.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/hotplug/ibmphp_hpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/drivers/pci/hotplug/ibmphp_hpc.c
===================================================================
--- linux-2.6-tip.orig/drivers/pci/hotplug/ibmphp_hpc.c
+++ linux-2.6-tip/drivers/pci/hotplug/ibmphp_hpc.c
@@ -132,8 +132,8 @@ void __init ibmphp_hpc_initvars (void)
debug ("%s - Entry\n", __func__);
mutex_init(&sem_hpcaccess);
- init_MUTEX (&semOperations);
- init_MUTEX_LOCKED (&sem_exit);
+ semaphore_init(&semOperations);
+ semaphore_init_locked(&sem_exit);
to_debug = 0;
debug ("%s - Exit\n", __func__);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 13/37] s390: cio/crw: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (11 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 12/37] ibmphp-hpc: " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-27 11:45 ` Martin Schwidefsky
2009-07-26 8:18 ` [Patch RFC 14/37] scsi: aacraid " Thomas Gleixner
` (23 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Martin Schwidefsky
[-- Attachment #1: driver-s390-cio-crw-sema-cleanup.patch --]
[-- Type: text/plain, Size: 730 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
drivers/s390/cio/crw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/s390/cio/crw.c
===================================================================
--- linux-2.6-tip.orig/drivers/s390/cio/crw.c
+++ linux-2.6-tip/drivers/s390/cio/crw.c
@@ -137,7 +137,7 @@ void crw_handle_channel_report(void)
*/
static int __init crw_init_semaphore(void)
{
- init_MUTEX_LOCKED(&crw_semaphore);
+ semaphore_init_locked(&crw_semaphore);
return 0;
}
pure_initcall(crw_init_semaphore);
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 13/37] s390: cio/crw: semaphore cleanup
2009-07-26 8:18 ` [Patch RFC 13/37] s390: cio/crw: " Thomas Gleixner
@ 2009-07-27 11:45 ` Martin Schwidefsky
0 siblings, 0 replies; 60+ messages in thread
From: Martin Schwidefsky @ 2009-07-27 11:45 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, 26 Jul 2009 08:18:10 -0000
Thomas Gleixner <tglx@linutronix.de> wrote:
> The usage of this "mutex" is non obvious and probably a completion in
> some places. Make it a semaphore.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> ---
> drivers/s390/cio/crw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6-tip/drivers/s390/cio/crw.c
> ===================================================================
> --- linux-2.6-tip.orig/drivers/s390/cio/crw.c
> +++ linux-2.6-tip/drivers/s390/cio/crw.c
> @@ -137,7 +137,7 @@ void crw_handle_channel_report(void)
> */
> static int __init crw_init_semaphore(void)
> {
> - init_MUTEX_LOCKED(&crw_semaphore);
> + semaphore_init_locked(&crw_semaphore);
> return 0;
> }
> pure_initcall(crw_init_semaphore);
>
>
The crw_semaphore is a real semaphore and the init_MUTEX_LOCKED is
indeed confusing. semaphore_init_locked is a more sensible name even if
the end result is in both cases just a sema_init(sem, 0). Anyway, fine
with me:
Acked-By: Martin Schwidefsky <schwidefsky@de.ibm.com>
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 14/37] scsi: aacraid semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (12 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 13/37] s390: cio/crw: " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 20:11 ` James Bottomley
2009-07-26 8:18 ` [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex Thomas Gleixner
` (22 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, James Bottomley
[-- Attachment #1: driver-scsi-aacraid-sema-cleanup.patch --]
[-- Type: text/plain, Size: 1563 bytes --]
The usage of these "mutex"es is non obvious and probably completions
in some places. Make it them semaphores.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
---
drivers/scsi/aacraid/commctrl.c | 2 +-
drivers/scsi/aacraid/commsup.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/drivers/scsi/aacraid/commctrl.c
===================================================================
--- linux-2.6-tip.orig/drivers/scsi/aacraid/commctrl.c
+++ linux-2.6-tip/drivers/scsi/aacraid/commctrl.c
@@ -190,7 +190,7 @@ static int open_getadapter_fib(struct aa
/*
* Initialize the mutex used to wait for the next AIF.
*/
- init_MUTEX_LOCKED(&fibctx->wait_sem);
+ semaphore_init_locked(&fibctx->wait_sem);
fibctx->wait = 0;
/*
* Initialize the fibs and set the count of fibs on
Index: linux-2.6-tip/drivers/scsi/aacraid/commsup.c
===================================================================
--- linux-2.6-tip.orig/drivers/scsi/aacraid/commsup.c
+++ linux-2.6-tip/drivers/scsi/aacraid/commsup.c
@@ -124,7 +124,7 @@ int aac_fib_setup(struct aac_dev * dev)
fibptr->hw_fib_va = hw_fib;
fibptr->data = (void *) fibptr->hw_fib_va->data;
fibptr->next = fibptr+1; /* Forward chain the fibs */
- init_MUTEX_LOCKED(&fibptr->event_wait);
+ semaphore_init_locked(&fibptr->event_wait);
spin_lock_init(&fibptr->event_lock);
hw_fib->header.XferState = cpu_to_le32(0xffffffff);
hw_fib->header.SenderSize = cpu_to_le16(dev->max_fib_size);
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 14/37] scsi: aacraid semaphore cleanup
2009-07-26 8:18 ` [Patch RFC 14/37] scsi: aacraid " Thomas Gleixner
@ 2009-07-26 20:11 ` James Bottomley
2009-07-26 22:21 ` Thomas Gleixner
0 siblings, 1 reply; 60+ messages in thread
From: James Bottomley @ 2009-07-26 20:11 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, linux-scsi
cc linux-scsi added
On Sun, 2009-07-26 at 08:18 +0000, Thomas Gleixner wrote:
> plain text document attachment
> (driver-scsi-aacraid-sema-cleanup.patch)
> The usage of these "mutex"es is non obvious and probably completions
> in some places. Make it them semaphores.
-ENOCONTEXT on this ... I assume this is just a global
s/init_MUTEX/semaphore_init/?
I think both are really just mutexes; no need for a counting semaphore.
There's no stack declaration issues (the fibs are long lived entities)
that would necessitate a completion.
James
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
> ---
> drivers/scsi/aacraid/commctrl.c | 2 +-
> drivers/scsi/aacraid/commsup.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> Index: linux-2.6-tip/drivers/scsi/aacraid/commctrl.c
> ===================================================================
> --- linux-2.6-tip.orig/drivers/scsi/aacraid/commctrl.c
> +++ linux-2.6-tip/drivers/scsi/aacraid/commctrl.c
> @@ -190,7 +190,7 @@ static int open_getadapter_fib(struct aa
> /*
> * Initialize the mutex used to wait for the next AIF.
> */
> - init_MUTEX_LOCKED(&fibctx->wait_sem);
> + semaphore_init_locked(&fibctx->wait_sem);
> fibctx->wait = 0;
> /*
> * Initialize the fibs and set the count of fibs on
> Index: linux-2.6-tip/drivers/scsi/aacraid/commsup.c
> ===================================================================
> --- linux-2.6-tip.orig/drivers/scsi/aacraid/commsup.c
> +++ linux-2.6-tip/drivers/scsi/aacraid/commsup.c
> @@ -124,7 +124,7 @@ int aac_fib_setup(struct aac_dev * dev)
> fibptr->hw_fib_va = hw_fib;
> fibptr->data = (void *) fibptr->hw_fib_va->data;
> fibptr->next = fibptr+1; /* Forward chain the fibs */
> - init_MUTEX_LOCKED(&fibptr->event_wait);
> + semaphore_init_locked(&fibptr->event_wait);
> spin_lock_init(&fibptr->event_lock);
> hw_fib->header.XferState = cpu_to_le32(0xffffffff);
> hw_fib->header.SenderSize = cpu_to_le16(dev->max_fib_size);
>
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 14/37] scsi: aacraid semaphore cleanup
2009-07-26 20:11 ` James Bottomley
@ 2009-07-26 22:21 ` Thomas Gleixner
0 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 22:21 UTC (permalink / raw)
To: James Bottomley
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, linux-scsi
On Sun, 26 Jul 2009, James Bottomley wrote:
> cc linux-scsi added
>
> On Sun, 2009-07-26 at 08:18 +0000, Thomas Gleixner wrote:
> > plain text document attachment
> > (driver-scsi-aacraid-sema-cleanup.patch)
> > The usage of these "mutex"es is non obvious and probably completions
> > in some places. Make it them semaphores.
>
> -ENOCONTEXT on this ... I assume this is just a global
> s/init_MUTEX/semaphore_init/?
Well, in cases where the mutex use case is obvious it's a semaphore to
mutex conversion. But this one is definitly not.
> I think both are really just mutexes; no need for a counting semaphore.
> There's no stack declaration issues (the fibs are long lived entities)
> that would necessitate a completion.
It's not about stack declaration. These semaphores can not be
converted to mutexes for following reasons:
1) there is no mutex_init_locked() and there never will be one
2) the sem is taken from context A and released from context B. That
violates the mutex semantics where the lock/unlock has to happen in
the same thread context.
i.e. wait_sem is taken from
aac_do_ioctl()
next_getadapter_fib()
but release from
aac_check_health() or aac_command_thread()
I have no idea how that hell of code works, but wait_sem is definitely
not a mutex and neither is event_wait. The beasts might serialize
stuff as well, but they are also (ab)used as a completion to wait for
whatever.
Thanks,
tglx
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (13 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 14/37] scsi: aacraid " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 21:36 ` Marcel Holtmann
2009-07-26 8:18 ` [Patch RFC 16/37] smbfs: Convert server->sem " Thomas Gleixner
` (21 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Marcel Holtmann
[-- Attachment #1: bluetooth-convert-semaphore-to-mutex.patch --]
[-- Type: text/plain, Size: 1550 bytes --]
hdev->req_lock is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 6 +++---
net/bluetooth/hci_core.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-tip/include/net/bluetooth/hci_core.h
===================================================================
--- linux-2.6-tip.orig/include/net/bluetooth/hci_core.h
+++ linux-2.6-tip/include/net/bluetooth/hci_core.h
@@ -117,7 +117,7 @@ struct hci_dev {
struct sk_buff *sent_cmd;
struct sk_buff *reassembly[3];
- struct semaphore req_lock;
+ struct mutex req_lock;
wait_queue_head_t req_wait_q;
__u32 req_status;
__u32 req_result;
@@ -700,8 +700,8 @@ struct hci_sec_filter {
#define HCI_REQ_PEND 1
#define HCI_REQ_CANCELED 2
-#define hci_req_lock(d) down(&d->req_lock)
-#define hci_req_unlock(d) up(&d->req_lock)
+#define hci_req_lock(d) mutex_lock(&d->req_lock)
+#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
void hci_req_complete(struct hci_dev *hdev, int result);
Index: linux-2.6-tip/net/bluetooth/hci_core.c
===================================================================
--- linux-2.6-tip.orig/net/bluetooth/hci_core.c
+++ linux-2.6-tip/net/bluetooth/hci_core.c
@@ -911,7 +911,7 @@ int hci_register_dev(struct hci_dev *hde
hdev->reassembly[i] = NULL;
init_waitqueue_head(&hdev->req_wait_q);
- init_MUTEX(&hdev->req_lock);
+ mutex_init(&hdev->req_lock);
inquiry_cache_init(hdev);
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex
2009-07-26 8:18 ` [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex Thomas Gleixner
@ 2009-07-26 21:36 ` Marcel Holtmann
2009-07-26 22:04 ` Thomas Gleixner
0 siblings, 1 reply; 60+ messages in thread
From: Marcel Holtmann @ 2009-07-26 21:36 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
Hi Thomas,
> hdev->req_lock is used as mutex so make it a mutex.
no idea why we never changed this before.
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
In case this one is going via someone else's tree. Do you have any
preference how this gets merged. I can also take it via my tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex
2009-07-26 21:36 ` Marcel Holtmann
@ 2009-07-26 22:04 ` Thomas Gleixner
0 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 22:04 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra
On Sun, 26 Jul 2009, Marcel Holtmann wrote:
> Hi Thomas,
>
> > hdev->req_lock is used as mutex so make it a mutex.
>
> no idea why we never changed this before.
:)
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Marcel Holtmann <marcel@holtmann.org>
>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
>
> In case this one is going via someone else's tree. Do you have any
> preference how this gets merged. I can also take it via my tree.
Please take it. It does not depend on anything else. It's a straight
forward conversion to existing infrastructore.
Thanks,
tglx
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 16/37] smbfs: Convert server->sem to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (14 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 15/37] bluetooth: Convert hdev->req_lock to mutex Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 17/37] hpfs: Convert sbi->hpfs_creation_de " Thomas Gleixner
` (20 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: convert-smbfs-inode-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 1718 bytes --]
server->sem is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/smbfs/inode.c | 2 +-
include/linux/smb_fs_sb.h | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
Index: linux-2.6-tip/fs/smbfs/inode.c
===================================================================
--- linux-2.6-tip.orig/fs/smbfs/inode.c
+++ linux-2.6-tip/fs/smbfs/inode.c
@@ -536,7 +536,7 @@ static int smb_fill_super(struct super_b
server->mnt = NULL;
server->sock_file = NULL;
init_waitqueue_head(&server->conn_wq);
- init_MUTEX(&server->sem);
+ mutex_init(&server->mutex);
INIT_LIST_HEAD(&server->entry);
INIT_LIST_HEAD(&server->xmitq);
INIT_LIST_HEAD(&server->recvq);
Index: linux-2.6-tip/include/linux/smb_fs_sb.h
===================================================================
--- linux-2.6-tip.orig/include/linux/smb_fs_sb.h
+++ linux-2.6-tip/include/linux/smb_fs_sb.h
@@ -57,7 +57,7 @@ struct smb_sb_info {
struct smb_conn_opt opt;
wait_queue_head_t conn_wq;
int conn_complete;
- struct semaphore sem;
+ struct mutex mutex;
unsigned char header[SMB_HEADER_LEN + 20*2 + 2];
u32 header_len;
@@ -79,19 +79,19 @@ struct smb_sb_info {
static inline int
smb_lock_server_interruptible(struct smb_sb_info *server)
{
- return down_interruptible(&(server->sem));
+ return mutex_lock_interruptible(&server->mutex);
}
static inline void
smb_lock_server(struct smb_sb_info *server)
{
- down(&(server->sem));
+ mutex_lock(&server->mutex);
}
static inline void
smb_unlock_server(struct smb_sb_info *server)
{
- up(&(server->sem));
+ mutex_unlock(&server->mutex);
}
#endif
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 17/37] hpfs: Convert sbi->hpfs_creation_de to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (15 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 16/37] smbfs: Convert server->sem " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 18/37] hpfsplus: Convert tree_lock " Thomas Gleixner
` (19 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: hpfs-convert-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 2043 bytes --]
sbi->hpfs_creation_de is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/hpfs/buffer.c | 4 ++--
fs/hpfs/hpfs_fn.h | 2 +-
fs/hpfs/super.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-tip/fs/hpfs/buffer.c
===================================================================
--- linux-2.6-tip.orig/fs/hpfs/buffer.c
+++ linux-2.6-tip/fs/hpfs/buffer.c
@@ -13,7 +13,7 @@ void hpfs_lock_creation(struct super_blo
#ifdef DEBUG_LOCKS
printk("lock creation\n");
#endif
- down(&hpfs_sb(s)->hpfs_creation_de);
+ mutex_lock(&hpfs_sb(s)->hpfs_creation_de);
}
void hpfs_unlock_creation(struct super_block *s)
@@ -21,7 +21,7 @@ void hpfs_unlock_creation(struct super_b
#ifdef DEBUG_LOCKS
printk("unlock creation\n");
#endif
- up(&hpfs_sb(s)->hpfs_creation_de);
+ mutex_unlock(&hpfs_sb(s)->hpfs_creation_de);
}
/* Map a sector into a buffer and return pointers to it and to the buffer. */
Index: linux-2.6-tip/fs/hpfs/hpfs_fn.h
===================================================================
--- linux-2.6-tip.orig/fs/hpfs/hpfs_fn.h
+++ linux-2.6-tip/fs/hpfs/hpfs_fn.h
@@ -87,7 +87,7 @@ struct hpfs_sb_info {
unsigned *sb_bmp_dir; /* main bitmap directory */
unsigned sb_c_bitmap; /* current bitmap */
unsigned sb_max_fwd_alloc; /* max forwad allocation */
- struct semaphore hpfs_creation_de; /* when creating dirents, nobody else
+ struct mutex hpfs_creation_de; /* when creating dirents, nobody else
can alloc blocks */
/*unsigned sb_mounting : 1;*/
int sb_timeshift;
Index: linux-2.6-tip/fs/hpfs/super.c
===================================================================
--- linux-2.6-tip.orig/fs/hpfs/super.c
+++ linux-2.6-tip/fs/hpfs/super.c
@@ -487,7 +487,7 @@ static int hpfs_fill_super(struct super_
sbi->sb_bmp_dir = NULL;
sbi->sb_cp_table = NULL;
- init_MUTEX(&sbi->hpfs_creation_de);
+ mutex_init(&sbi->hpfs_creation_de);
uid = current_uid();
gid = current_gid();
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 18/37] hpfsplus: Convert tree_lock to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (16 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 17/37] hpfs: Convert sbi->hpfs_creation_de " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 19/37] hfs: " Thomas Gleixner
` (18 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: hpfsplus-convert-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 1904 bytes --]
tree_lock is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/hfsplus/bfind.c | 4 ++--
fs/hfsplus/btree.c | 2 +-
fs/hfsplus/hfsplus_fs.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-tip/fs/hfsplus/bfind.c
===================================================================
--- linux-2.6-tip.orig/fs/hfsplus/bfind.c
+++ linux-2.6-tip/fs/hfsplus/bfind.c
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
- down(&tree->tree_lock);
+ mutex_lock(&tree->tree_lock);
return 0;
}
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data
hfs_bnode_put(fd->bnode);
kfree(fd->search_key);
dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
- up(&fd->tree->tree_lock);
+ mutex_unlock(&fd->tree->tree_lock);
fd->tree = NULL;
}
Index: linux-2.6-tip/fs/hfsplus/btree.c
===================================================================
--- linux-2.6-tip.orig/fs/hfsplus/btree.c
+++ linux-2.6-tip/fs/hfsplus/btree.c
@@ -30,7 +30,7 @@ struct hfs_btree *hfs_btree_open(struct
if (!tree)
return NULL;
- init_MUTEX(&tree->tree_lock);
+ mutex_init(&tree->tree_lock);
spin_lock_init(&tree->hash_lock);
tree->sb = sb;
tree->cnid = id;
Index: linux-2.6-tip/fs/hfsplus/hfsplus_fs.h
===================================================================
--- linux-2.6-tip.orig/fs/hfsplus/hfsplus_fs.h
+++ linux-2.6-tip/fs/hfsplus/hfsplus_fs.h
@@ -62,7 +62,7 @@ struct hfs_btree {
unsigned int depth;
//unsigned int map1_size, map_size;
- struct semaphore tree_lock;
+ struct mutex tree_lock;
unsigned int pages_per_bnode;
spinlock_t hash_lock;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 19/37] hfs: Convert tree_lock to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (17 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 18/37] hpfsplus: Convert tree_lock " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 20/37] cifs: convert semaphore " Thomas Gleixner
` (17 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: hfs-convert-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 1848 bytes --]
tree_lock is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/hfs/bfind.c | 4 ++--
fs/hfs/btree.c | 2 +-
fs/hfs/btree.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-tip/fs/hfs/bfind.c
===================================================================
--- linux-2.6-tip.orig/fs/hfs/bfind.c
+++ linux-2.6-tip/fs/hfs/bfind.c
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
- down(&tree->tree_lock);
+ mutex_lock(&tree->tree_lock);
return 0;
}
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data
hfs_bnode_put(fd->bnode);
kfree(fd->search_key);
dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
- up(&fd->tree->tree_lock);
+ mutex_unlock(&fd->tree->tree_lock);
fd->tree = NULL;
}
Index: linux-2.6-tip/fs/hfs/btree.c
===================================================================
--- linux-2.6-tip.orig/fs/hfs/btree.c
+++ linux-2.6-tip/fs/hfs/btree.c
@@ -26,7 +26,7 @@ struct hfs_btree *hfs_btree_open(struct
if (!tree)
return NULL;
- init_MUTEX(&tree->tree_lock);
+ mutex_init(&tree->tree_lock);
spin_lock_init(&tree->hash_lock);
/* Set the correct compare function */
tree->sb = sb;
Index: linux-2.6-tip/fs/hfs/btree.h
===================================================================
--- linux-2.6-tip.orig/fs/hfs/btree.h
+++ linux-2.6-tip/fs/hfs/btree.h
@@ -33,7 +33,7 @@ struct hfs_btree {
unsigned int depth;
//unsigned int map1_size, map_size;
- struct semaphore tree_lock;
+ struct mutex tree_lock;
unsigned int pages_per_bnode;
spinlock_t hash_lock;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 20/37] cifs: convert semaphore to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (18 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 19/37] hfs: " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-27 1:14 ` Jeff Layton
2009-07-30 21:09 ` Christoph Hellwig
2009-07-26 8:18 ` [Patch RFC 21/37] affs: use semaphore_init instead of init_MUTEX Thomas Gleixner
` (16 subsequent siblings)
36 siblings, 2 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Steve French
[-- Attachment #1: cifs-convert-sema-to-mutex.patch --]
[-- Type: text/plain, Size: 5108 bytes --]
pSesInfo->sesSem is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Steve French <sfrench@us.ibm.com>
---
fs/cifs/cifsglob.h | 2 +-
fs/cifs/cifssmb.c | 18 +++++++++---------
fs/cifs/connect.c | 8 ++++----
fs/cifs/misc.c | 2 +-
4 files changed, 15 insertions(+), 15 deletions(-)
Index: linux-2.6-tip/fs/cifs/cifsglob.h
===================================================================
--- linux-2.6-tip.orig/fs/cifs/cifsglob.h
+++ linux-2.6-tip/fs/cifs/cifsglob.h
@@ -203,7 +203,7 @@ struct cifsUidInfo {
struct cifsSesInfo {
struct list_head smb_ses_list;
struct list_head tcon_list;
- struct semaphore sesSem;
+ struct mutex sesSem;
#if 0
struct cifsUidInfo *uidInfo; /* pointer to user info */
#endif
Index: linux-2.6-tip/fs/cifs/cifssmb.c
===================================================================
--- linux-2.6-tip.orig/fs/cifs/cifssmb.c
+++ linux-2.6-tip/fs/cifs/cifssmb.c
@@ -154,7 +154,7 @@ small_smb_init(int smb_command, int wct,
nls_codepage = load_nls_default();
/* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */
- down(&tcon->ses->sesSem);
+ mutex_lock(&tcon->ses->sesSem);
if (tcon->ses->need_reconnect)
rc = cifs_setup_session(0, tcon->ses,
nls_codepage);
@@ -162,7 +162,7 @@ small_smb_init(int smb_command, int wct,
mark_open_files_invalid(tcon);
rc = CIFSTCon(0, tcon->ses, tcon->treeName,
tcon, nls_codepage);
- up(&tcon->ses->sesSem);
+ mutex_unlock(&tcon->ses->sesSem);
/* BB FIXME add code to check if wsize needs
update due to negotiated smb buffer size
shrinking */
@@ -196,7 +196,7 @@ small_smb_init(int smb_command, int wct,
}
}
} else {
- up(&tcon->ses->sesSem);
+ mutex_unlock(&tcon->ses->sesSem);
}
unload_nls(nls_codepage);
@@ -301,7 +301,7 @@ smb_init(int smb_command, int wct, struc
nls_codepage = load_nls_default();
/* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */
- down(&tcon->ses->sesSem);
+ mutex_lock(&tcon->ses->sesSem);
if (tcon->ses->need_reconnect)
rc = cifs_setup_session(0, tcon->ses,
nls_codepage);
@@ -309,7 +309,7 @@ smb_init(int smb_command, int wct, struc
mark_open_files_invalid(tcon);
rc = CIFSTCon(0, tcon->ses, tcon->treeName,
tcon, nls_codepage);
- up(&tcon->ses->sesSem);
+ mutex_unlock(&tcon->ses->sesSem);
/* BB FIXME add code to check if wsize needs
update due to negotiated smb buffer size
shrinking */
@@ -343,7 +343,7 @@ smb_init(int smb_command, int wct, struc
}
}
} else {
- up(&tcon->ses->sesSem);
+ mutex_unlock(&tcon->ses->sesSem);
}
unload_nls(nls_codepage);
@@ -765,13 +765,13 @@ CIFSSMBLogoff(const int xid, struct cifs
if (!ses || !ses->server)
return -EIO;
- down(&ses->sesSem);
+ mutex_lock(&ses->sesSem);
if (ses->need_reconnect)
goto session_already_dead; /* no need to send SMBlogoff if uid
already closed due to reconnect */
rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB);
if (rc) {
- up(&ses->sesSem);
+ mutex_unlock(&ses->sesSem);
return rc;
}
@@ -786,7 +786,7 @@ CIFSSMBLogoff(const int xid, struct cifs
pSMB->AndXCommand = 0xFF;
rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0);
session_already_dead:
- up(&ses->sesSem);
+ mutex_unlock(&ses->sesSem);
/* if session dead then we do not need to do ulogoff,
since server closed smb session, no sense reporting
Index: linux-2.6-tip/fs/cifs/connect.c
===================================================================
--- linux-2.6-tip.orig/fs/cifs/connect.c
+++ linux-2.6-tip/fs/cifs/connect.c
@@ -2331,13 +2331,13 @@ try_mount_again:
*/
cifs_put_tcp_session(srvTcp);
- down(&pSesInfo->sesSem);
+ mutex_lock(&pSesInfo->sesSem);
if (pSesInfo->need_reconnect) {
cFYI(1, ("Session needs reconnect"));
rc = cifs_setup_session(xid, pSesInfo,
cifs_sb->local_nls);
}
- up(&pSesInfo->sesSem);
+ mutex_unlock(&pSesInfo->sesSem);
} else if (!rc) {
cFYI(1, ("Existing smb sess not found"));
pSesInfo = sesInfoAlloc();
@@ -2380,12 +2380,12 @@ try_mount_again:
}
pSesInfo->linux_uid = volume_info->linux_uid;
pSesInfo->overrideSecFlg = volume_info->secFlg;
- down(&pSesInfo->sesSem);
+ mutex_lock(&pSesInfo->sesSem);
/* BB FIXME need to pass vol->secFlgs BB */
rc = cifs_setup_session(xid, pSesInfo,
cifs_sb->local_nls);
- up(&pSesInfo->sesSem);
+ mutex_unlock(&pSesInfo->sesSem);
}
/* search for existing tcon to this server share */
Index: linux-2.6-tip/fs/cifs/misc.c
===================================================================
--- linux-2.6-tip.orig/fs/cifs/misc.c
+++ linux-2.6-tip/fs/cifs/misc.c
@@ -80,7 +80,7 @@ sesInfoAlloc(void)
++ret_buf->ses_count;
INIT_LIST_HEAD(&ret_buf->smb_ses_list);
INIT_LIST_HEAD(&ret_buf->tcon_list);
- init_MUTEX(&ret_buf->sesSem);
+ mutex_init(&ret_buf->sesSem);
}
return ret_buf;
}
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 20/37] cifs: convert semaphore to mutex
2009-07-26 8:18 ` [Patch RFC 20/37] cifs: convert semaphore " Thomas Gleixner
@ 2009-07-27 1:14 ` Jeff Layton
2009-07-30 21:09 ` Christoph Hellwig
1 sibling, 0 replies; 60+ messages in thread
From: Jeff Layton @ 2009-07-27 1:14 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Steve French
On Sun, 26 Jul 2009 08:18:39 -0000
Thomas Gleixner <tglx@linutronix.de> wrote:
> pSesInfo->sesSem is used as mutex so make it a mutex.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Steve French <sfrench@us.ibm.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 20/37] cifs: convert semaphore to mutex
2009-07-26 8:18 ` [Patch RFC 20/37] cifs: convert semaphore " Thomas Gleixner
2009-07-27 1:14 ` Jeff Layton
@ 2009-07-30 21:09 ` Christoph Hellwig
2009-07-30 22:43 ` Steven French
1 sibling, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-30 21:09 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Steve French
On Sun, Jul 26, 2009 at 08:18:39AM -0000, Thomas Gleixner wrote:
> - struct semaphore sesSem;
> + struct mutex sesSem;
If we touch every user of this anyway any chance we could give it a sane
name, e.g. session_mutex?
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 20/37] cifs: convert semaphore to mutex
2009-07-30 21:09 ` Christoph Hellwig
@ 2009-07-30 22:43 ` Steven French
0 siblings, 0 replies; 60+ messages in thread
From: Steven French @ 2009-07-30 22:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, LKML, Ingo Molnar, Peter Zijlstra, Thomas Gleixner
Christoph Hellwig <hch@infradead.org> wrote on 07/30/2009 04:09:46 PM:
> On Sun, Jul 26, 2009 at 08:18:39AM -0000, Thomas Gleixner wrote:
> > - struct semaphore sesSem;
> > + struct mutex sesSem;
>
> If we touch every user of this anyway any chance we could give it a sane
> name, e.g. session_mutex?
>
Sounds like a good idea. Might as well make the name change - since it is
easier to read.
Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench at-sign us dot ibm dot com
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 21/37] affs: use semaphore_init instead of init_MUTEX
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (19 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 20/37] cifs: convert semaphore " Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-30 21:14 ` Christoph Hellwig
2009-07-26 8:18 ` [Patch RFC 22/37] usb: ftdi-elan: Convert "mutex" to semaphore Thomas Gleixner
` (15 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: affs-use-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 758 bytes --]
The usage of these "mutex" is non obvious and probably a completion
in some places. Make it them semaphores.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/affs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/fs/affs/super.c
===================================================================
--- linux-2.6-tip.orig/fs/affs/super.c
+++ linux-2.6-tip/fs/affs/super.c
@@ -113,8 +113,8 @@ static void init_once(void *foo)
{
struct affs_inode_info *ei = (struct affs_inode_info *) foo;
- init_MUTEX(&ei->i_link_lock);
- init_MUTEX(&ei->i_ext_lock);
+ semaphore_init(&ei->i_link_lock);
+ semaphore_init(&ei->i_ext_lock);
inode_init_once(&ei->vfs_inode);
}
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 21/37] affs: use semaphore_init instead of init_MUTEX
2009-07-26 8:18 ` [Patch RFC 21/37] affs: use semaphore_init instead of init_MUTEX Thomas Gleixner
@ 2009-07-30 21:14 ` Christoph Hellwig
0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-30 21:14 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
On Sun, Jul 26, 2009 at 08:18:45AM -0000, Thomas Gleixner wrote:
> The usage of these "mutex" is non obvious and probably a completion
> in some places. Make it them semaphores.
Except for the obsfucation by the wrappers it's clearly obvious that
these are plain binary mutexes, so they should be converted. Note that
this will trigger some lockdep warnings as we sometimes hold the same
lock for parent and child. Maybe we can use this as a check if any
users of affs are left :)
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 22/37] usb: ftdi-elan: Convert "mutex" to semaphore
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (20 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 21/37] affs: use semaphore_init instead of init_MUTEX Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 8:18 ` [Patch RFC 23/37] usb: gadgetfs: Convert semaphore to mutex Thomas Gleixner
` (14 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman
[-- Attachment #1: usb-ftdi-elan-use-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 920 bytes --]
The "mutex" ftdi->sw_lock is used as a lock and a completion. Convert
it to a real semaphore which allows both.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/misc/ftdi-elan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/usb/misc/ftdi-elan.c
===================================================================
--- linux-2.6-tip.orig/drivers/usb/misc/ftdi-elan.c
+++ linux-2.6-tip/drivers/usb/misc/ftdi-elan.c
@@ -2766,7 +2766,7 @@ static int ftdi_elan_probe(struct usb_in
ftdi->sequence_num = ++ftdi_instances;
mutex_unlock(&ftdi_module_lock);
ftdi_elan_init_kref(ftdi);
- init_MUTEX(&ftdi->sw_lock);
+ semaphore_init(&ftdi->sw_lock);
ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
ftdi->interface = interface;
mutex_init(&ftdi->u132_lock);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 23/37] usb: gadgetfs: Convert semaphore to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (21 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 22/37] usb: ftdi-elan: Convert "mutex" to semaphore Thomas Gleixner
@ 2009-07-26 8:18 ` Thomas Gleixner
2009-07-26 22:56 ` Daniel Walker
2009-07-26 8:19 ` [Patch RFC 24/37] xfs: semaphore cleanup Thomas Gleixner
` (13 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:18 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman
[-- Attachment #1: usb-gadget-inode-convert-semaphore-to-mutex.patch --]
[-- Type: text/plain, Size: 4544 bytes --]
The semaphore is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/gadget/inode.c | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
Index: linux-2.6-tip/drivers/usb/gadget/inode.c
===================================================================
--- linux-2.6-tip.orig/drivers/usb/gadget/inode.c
+++ linux-2.6-tip/drivers/usb/gadget/inode.c
@@ -193,7 +193,7 @@ enum ep_state {
};
struct ep_data {
- struct semaphore lock;
+ struct mutex lock;
enum ep_state state;
atomic_t count;
struct dev_data *dev;
@@ -297,10 +297,10 @@ get_ready_ep (unsigned f_flags, struct e
int val;
if (f_flags & O_NONBLOCK) {
- if (down_trylock (&epdata->lock) != 0)
+ if (mutex_trylock(&epdata->lock) != 0)
goto nonblock;
if (epdata->state != STATE_EP_ENABLED) {
- up (&epdata->lock);
+ mutex_unlock(&epdata->lock);
nonblock:
val = -EAGAIN;
} else
@@ -308,7 +308,8 @@ nonblock:
return val;
}
- if ((val = down_interruptible (&epdata->lock)) < 0)
+ val = mutex_lock_interruptible(&epdata->lock);
+ if (val < 0)
return val;
switch (epdata->state) {
@@ -322,7 +323,7 @@ nonblock:
// FALLTHROUGH
case STATE_EP_UNBOUND: /* clean disconnect */
val = -ENODEV;
- up (&epdata->lock);
+ mutex_unlock(&epdata->lock);
}
return val;
}
@@ -392,7 +393,7 @@ ep_read (struct file *fd, char __user *b
if (likely (data->ep != NULL))
usb_ep_set_halt (data->ep);
spin_unlock_irq (&data->dev->lock);
- up (&data->lock);
+ mutex_unlock(&data->lock);
return -EBADMSG;
}
@@ -410,7 +411,7 @@ ep_read (struct file *fd, char __user *b
value = -EFAULT;
free1:
- up (&data->lock);
+ mutex_unlock(&data->lock);
kfree (kbuf);
return value;
}
@@ -435,7 +436,7 @@ ep_write (struct file *fd, const char __
if (likely (data->ep != NULL))
usb_ep_set_halt (data->ep);
spin_unlock_irq (&data->dev->lock);
- up (&data->lock);
+ mutex_unlock(&data->lock);
return -EBADMSG;
}
@@ -454,7 +455,7 @@ ep_write (struct file *fd, const char __
VDEBUG (data->dev, "%s write %zu IN, status %d\n",
data->name, len, (int) value);
free1:
- up (&data->lock);
+ mutex_unlock(&data->lock);
kfree (kbuf);
return value;
}
@@ -465,7 +466,8 @@ ep_release (struct inode *inode, struct
struct ep_data *data = fd->private_data;
int value;
- if ((value = down_interruptible(&data->lock)) < 0)
+ value = mutex_lock_interruptible(&data->lock);
+ if (value < 0)
return value;
/* clean up if this can be reopened */
@@ -475,7 +477,7 @@ ep_release (struct inode *inode, struct
data->hs_desc.bDescriptorType = 0;
usb_ep_disable(data->ep);
}
- up (&data->lock);
+ mutex_unlock(&data->lock);
put_ep (data);
return 0;
}
@@ -506,7 +508,7 @@ static long ep_ioctl(struct file *fd, un
} else
status = -ENODEV;
spin_unlock_irq (&data->dev->lock);
- up (&data->lock);
+ mutex_unlock(&data->lock);
return status;
}
@@ -672,7 +674,7 @@ fail:
value = -ENODEV;
spin_unlock_irq(&epdata->dev->lock);
- up(&epdata->lock);
+ mutex_unlock(&epdata->lock);
if (unlikely(value)) {
kfree(priv);
@@ -764,7 +766,8 @@ ep_config (struct file *fd, const char _
u32 tag;
int value, length = len;
- if ((value = down_interruptible (&data->lock)) < 0)
+ value = mutex_lock_interruptible(&data->lock);
+ if (value < 0)
return value;
if (data->state != STATE_EP_READY) {
@@ -853,7 +856,7 @@ fail:
data->desc.bDescriptorType = 0;
data->hs_desc.bDescriptorType = 0;
}
- up (&data->lock);
+ mutex_unlock(&data->lock);
return value;
fail0:
value = -EINVAL;
@@ -869,7 +872,7 @@ ep_open (struct inode *inode, struct fil
struct ep_data *data = inode->i_private;
int value = -EBUSY;
- if (down_interruptible (&data->lock) != 0)
+ if (mutex_lock_interruptible(&data->lock) != 0)
return -EINTR;
spin_lock_irq (&data->dev->lock);
if (data->dev->state == STATE_DEV_UNBOUND)
@@ -884,7 +887,7 @@ ep_open (struct inode *inode, struct fil
DBG (data->dev, "%s state %d\n",
data->name, data->state);
spin_unlock_irq (&data->dev->lock);
- up (&data->lock);
+ mutex_unlock(&data->lock);
return value;
}
@@ -1630,7 +1633,7 @@ static int activate_ep_files (struct dev
if (!data)
goto enomem0;
data->state = STATE_EP_DISABLED;
- init_MUTEX (&data->lock);
+ mutex_init(&data->lock);
init_waitqueue_head (&data->wait);
strncpy (data->name, ep->name, sizeof (data->name) - 1);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 24/37] xfs: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (22 preceding siblings ...)
2009-07-26 8:18 ` [Patch RFC 23/37] usb: gadgetfs: Convert semaphore to mutex Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-27 15:25 ` Christoph Hellwig
2009-07-26 8:19 ` [Patch RFC 25/37] net: wan/cosa.c: Convert "mutex" to semaphore Thomas Gleixner
` (12 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Christoph Hellwig
[-- Attachment #1: xfs-semaphore-cleanup.patch --]
[-- Type: text/plain, Size: 840 bytes --]
bp->b_sema claims to be a mutex, but it is a semaphore with non
obvious semantics. Make it a real semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Christoph Hellwig <hch@lst.de>
---
fs/xfs/linux-2.6/xfs_buf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- linux-2.6-tip.orig/fs/xfs/linux-2.6/xfs_buf.c
+++ linux-2.6-tip/fs/xfs/linux-2.6/xfs_buf.c
@@ -263,7 +263,7 @@ _xfs_buf_initialize(
init_completion(&bp->b_iowait);
INIT_LIST_HEAD(&bp->b_list);
INIT_LIST_HEAD(&bp->b_hash_list);
- init_MUTEX_LOCKED(&bp->b_sema); /* held, no waiters */
+ semaphore_init_locked(&bp->b_sema); /* held, no waiters */
XB_SET_OWNER(bp);
bp->b_target = target;
bp->b_file_offset = range_base;
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 24/37] xfs: semaphore cleanup
2009-07-26 8:19 ` [Patch RFC 24/37] xfs: semaphore cleanup Thomas Gleixner
@ 2009-07-27 15:25 ` Christoph Hellwig
0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-27 15:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra,
Christoph Hellwig
On Sun, Jul 26, 2009 at 08:19:03AM -0000, Thomas Gleixner wrote:
> bp->b_sema claims to be a mutex, but it is a semaphore with non
> obvious semantics. Make it a real semaphore.
It is a binary mutex in the classical CS sense, just not unlocked by
the same thread as expected by the Linux mutexes..
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 25/37] net: wan/cosa.c: Convert "mutex" to semaphore
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (23 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 24/37] xfs: semaphore cleanup Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 26/37] irda: semaphore cleanup Thomas Gleixner
` (11 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David S. Miller
[-- Attachment #1: drivers-net-wan-cosa-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 777 bytes --]
The usage of this "mutex" is non obvious and probably a completions in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David S. Miller <davem@davemloft.net>
---
drivers/net/wan/cosa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/wan/cosa.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/wan/cosa.c
+++ linux-2.6-tip/drivers/net/wan/cosa.c
@@ -574,7 +574,7 @@ static int cosa_probe(int base, int irq,
/* Initialize the chardev data structures */
mutex_init(&chan->rlock);
- init_MUTEX(&chan->wsem);
+ semaphore_init(&chan->wsem);
/* Register the network interface */
if (!(chan->netdev = alloc_hdlcdev(chan))) {
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 26/37] irda: semaphore cleanup
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (24 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 25/37] net: wan/cosa.c: Convert "mutex" to semaphore Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 27/37] mmc: Convert "mutex" to semaphore Thomas Gleixner
` (10 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, David S. Miller
[-- Attachment #1: drivers-net-irda-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 724 bytes --]
The usage of this "mutex" is non obvious and probably a completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David S. Miller <davem@davemloft.net>
---
drivers/net/irda/sir_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/net/irda/sir_dev.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/irda/sir_dev.c
+++ linux-2.6-tip/drivers/net/irda/sir_dev.c
@@ -908,7 +908,7 @@ struct sir_dev * sirdev_get_instance(con
dev->tx_skb = NULL;
spin_lock_init(&dev->tx_lock);
- init_MUTEX(&dev->fsm.sem);
+ semaphore_init(&dev->fsm.sem);
dev->drv = drv;
dev->netdev = ndev;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 27/37] mmc: Convert "mutex" to semaphore
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (25 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 26/37] irda: semaphore cleanup Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 28/37] dvb: " Thomas Gleixner
` (9 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Pierre Ossman
[-- Attachment #1: drivers-mmc-card-queue-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 759 bytes --]
The usage of this "mutex" is non obvious and probably a completions in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Pierre Ossman <drzeus@drzeus.cx>
---
drivers/mmc/card/queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/mmc/card/queue.c
===================================================================
--- linux-2.6-tip.orig/drivers/mmc/card/queue.c
+++ linux-2.6-tip/drivers/mmc/card/queue.c
@@ -194,7 +194,7 @@ int mmc_init_queue(struct mmc_queue *mq,
sg_init_table(mq->sg, host->max_phys_segs);
}
- init_MUTEX(&mq->thread_sem);
+ semaphore_init(&mq->thread_sem);
mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
if (IS_ERR(mq->thread)) {
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 28/37] dvb: Convert "mutex" to semaphore
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (26 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 27/37] mmc: Convert "mutex" to semaphore Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one Thomas Gleixner
` (8 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Mauro Carvalho Chehab
[-- Attachment #1: drivers-media-dvb-dvb-core-dvb-frontend-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 1104 bytes --]
The usage of this "mutex" is non obvious and probably a completions in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
---
drivers/media/dvb/dvb-core/dvb_frontend.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/drivers/media/dvb/dvb-core/dvb_frontend.c
===================================================================
--- linux-2.6-tip.orig/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ linux-2.6-tip/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -678,7 +678,7 @@ static void dvb_frontend_stop(struct dvb
kthread_stop(fepriv->thread);
- init_MUTEX (&fepriv->sem);
+ semaphore_init(&fepriv->sem);
fepriv->state = FESTATE_IDLE;
/* paranoia check in case a signal arrived */
@@ -1909,7 +1909,7 @@ int dvb_register_frontend(struct dvb_ada
}
fepriv = fe->frontend_priv;
- init_MUTEX (&fepriv->sem);
+ semaphore_init(&fepriv->sem);
init_waitqueue_head (&fepriv->wait_queue);
init_waitqueue_head (&fepriv->events.wait_queue);
mutex_init(&fepriv->events.mtx);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (27 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 28/37] dvb: " Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-27 16:26 ` Roland Dreier
2009-07-26 8:19 ` [Patch RFC 30/37] drivers/base: Convert dev->sem to mutex Thomas Gleixner
` (7 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Roland Dreier
[-- Attachment #1: drivers-infiniband-core-user-mad-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 743 bytes --]
The usage of this "mutex" is non obvious. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Roland Dreier <rolandd@cisco.com>
---
drivers/infiniband/core/user_mad.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/infiniband/core/user_mad.c
===================================================================
--- linux-2.6-tip.orig/drivers/infiniband/core/user_mad.c
+++ linux-2.6-tip/drivers/infiniband/core/user_mad.c
@@ -1003,7 +1003,7 @@ static int ib_umad_init_port(struct ib_d
port->ib_dev = device;
port->port_num = port_num;
- init_MUTEX(&port->sm_sem);
+ semaphore_init(&port->sm_sem);
mutex_init(&port->file_mutex);
INIT_LIST_HEAD(&port->file_list);
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one
2009-07-26 8:19 ` [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one Thomas Gleixner
@ 2009-07-27 16:26 ` Roland Dreier
2009-07-27 16:28 ` Thomas Gleixner
0 siblings, 1 reply; 60+ messages in thread
From: Roland Dreier @ 2009-07-27 16:26 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Roland Dreier
> - init_MUTEX(&port->sm_sem);
> + semaphore_init(&port->sm_sem);
OK by me -- although I'm not clear what's wrong with using existing
sema_init().
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one
2009-07-27 16:26 ` Roland Dreier
@ 2009-07-27 16:28 ` Thomas Gleixner
0 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-27 16:28 UTC (permalink / raw)
To: Roland Dreier
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Roland Dreier
On Mon, 27 Jul 2009, Roland Dreier wrote:
>
> > - init_MUTEX(&port->sm_sem);
> > + semaphore_init(&port->sm_sem);
>
> OK by me -- although I'm not clear what's wrong with using existing
> sema_init().
I'm happy do redo the series with sema_init(sem, x) :)
tglx
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 30/37] drivers/base: Convert dev->sem to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (28 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 29/37] infiniband: Make user_mad semaphore a real one Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 31/37] ia64: salinfo: semaphore_init instead of init_MUTEX Thomas Gleixner
` (6 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra
[-- Attachment #1: drivers-base-convert-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 16605 bytes --]
The semaphore is used as mutex so make it a mutex. Clean up all
users outside of drivers/base as well.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/base/bus.c | 20 ++++++++++----------
drivers/base/core.c | 3 +--
drivers/base/dd.c | 38 +++++++++++++++++++-------------------
drivers/base/power/main.c | 20 ++++++++++----------
drivers/firewire/core-device.c | 4 ++--
drivers/ieee1394/nodemgr.c | 4 ++--
drivers/net/mlx4/mlx4.h | 1 +
drivers/pci/bus.c | 4 ++--
drivers/pci/pci.c | 4 ++--
drivers/pcmcia/ds.c | 8 ++++----
drivers/usb/core/driver.c | 4 ++--
drivers/uwb/umc-bus.c | 4 ++--
drivers/uwb/uwb-internal.h | 4 ++--
include/linux/device.h | 5 ++---
include/linux/usb.h | 6 +++---
15 files changed, 64 insertions(+), 65 deletions(-)
Index: linux-2.6-tip/drivers/base/bus.c
===================================================================
--- linux-2.6-tip.orig/drivers/base/bus.c
+++ linux-2.6-tip/drivers/base/bus.c
@@ -173,10 +173,10 @@ static ssize_t driver_unbind(struct devi
dev = bus_find_device_by_name(bus, NULL, buf);
if (dev && dev->driver == drv) {
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
+ mutex_lock(&dev->parent->mutex);
device_release_driver(dev);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
err = count;
}
put_device(dev);
@@ -200,12 +200,12 @@ static ssize_t driver_bind(struct device
dev = bus_find_device_by_name(bus, NULL, buf);
if (dev && dev->driver == NULL && driver_match_device(drv, dev)) {
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
- down(&dev->sem);
+ mutex_lock(&dev->parent->mutex);
+ mutex_lock(&dev->mutex);
err = driver_probe_device(drv, dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
if (err > 0) {
/* success */
@@ -742,10 +742,10 @@ static int __must_check bus_rescan_devic
if (!dev->driver) {
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
+ mutex_lock(&dev->parent->mutex);
ret = device_attach(dev);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
}
return ret < 0 ? ret : 0;
}
@@ -777,10 +777,10 @@ int device_reprobe(struct device *dev)
{
if (dev->driver) {
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
+ mutex_lock(&dev->parent->mutex);
device_release_driver(dev);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
}
return bus_rescan_devices_helper(dev, NULL);
}
Index: linux-2.6-tip/drivers/base/core.c
===================================================================
--- linux-2.6-tip.orig/drivers/base/core.c
+++ linux-2.6-tip/drivers/base/core.c
@@ -20,7 +20,6 @@
#include <linux/notifier.h>
#include <linux/genhd.h>
#include <linux/kallsyms.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/async.h>
@@ -550,7 +549,7 @@ void device_initialize(struct device *de
dev->kobj.kset = devices_kset;
kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools);
- init_MUTEX(&dev->sem);
+ mutex_init(&dev->mutex);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_init_wakeup(dev, 0);
Index: linux-2.6-tip/drivers/base/dd.c
===================================================================
--- linux-2.6-tip.orig/drivers/base/dd.c
+++ linux-2.6-tip/drivers/base/dd.c
@@ -84,7 +84,7 @@ static void driver_sysfs_remove(struct d
* for before calling this. (It is ok to call with no other effort
* from a driver's probe() method.)
*
- * This function must be called with @dev->sem held.
+ * This function must be called with @dev->mutex held.
*/
int device_bind_driver(struct device *dev)
{
@@ -189,8 +189,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe)
* This function returns -ENODEV if the device is not registered,
* 1 if the device is bound sucessfully and 0 otherwise.
*
- * This function must be called with @dev->sem held. When called for a
- * USB interface, @dev->parent->sem must be held as well.
+ * This function must be called with @dev->mutex held. When called for a
+ * USB interface, @dev->parent->mutex must be held as well.
*/
int driver_probe_device(struct device_driver *drv, struct device *dev)
{
@@ -229,13 +229,13 @@ static int __device_attach(struct device
* 0 if no matching driver was found;
* -ENODEV if the device is not registered.
*
- * When called for a USB interface, @dev->parent->sem must be held.
+ * When called for a USB interface, @dev->parent->mutex must be held.
*/
int device_attach(struct device *dev)
{
int ret = 0;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (dev->driver) {
ret = device_bind_driver(dev);
if (ret == 0)
@@ -247,7 +247,7 @@ int device_attach(struct device *dev)
} else {
ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
}
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return ret;
}
EXPORT_SYMBOL_GPL(device_attach);
@@ -270,13 +270,13 @@ static int __driver_attach(struct device
return 0;
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
- down(&dev->sem);
+ mutex_lock(&dev->parent->mutex);
+ mutex_lock(&dev->mutex);
if (!dev->driver)
driver_probe_device(drv, dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
return 0;
}
@@ -297,8 +297,8 @@ int driver_attach(struct device_driver *
EXPORT_SYMBOL_GPL(driver_attach);
/*
- * __device_release_driver() must be called with @dev->sem held.
- * When called for a USB interface, @dev->parent->sem must be held as well.
+ * __device_release_driver() must be called with @dev->mutex held.
+ * When called for a USB interface, @dev->parent->mutex must be held as well.
*/
static void __device_release_driver(struct device *dev)
{
@@ -332,7 +332,7 @@ static void __device_release_driver(stru
* @dev: device.
*
* Manually detach device from driver.
- * When called for a USB interface, @dev->parent->sem must be held.
+ * When called for a USB interface, @dev->parent->mutex must be held.
*/
void device_release_driver(struct device *dev)
{
@@ -341,9 +341,9 @@ void device_release_driver(struct device
* within their ->remove callback for the same device, they
* will deadlock right here.
*/
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
__device_release_driver(dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
EXPORT_SYMBOL_GPL(device_release_driver);
@@ -370,13 +370,13 @@ void driver_detach(struct device_driver
spin_unlock(&drv->p->klist_devices.k_lock);
if (dev->parent) /* Needed for USB */
- down(&dev->parent->sem);
- down(&dev->sem);
+ mutex_lock(&dev->parent->mutex);
+ mutex_lock(&dev->mutex);
if (dev->driver == drv)
__device_release_driver(dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
if (dev->parent)
- up(&dev->parent->sem);
+ mutex_unlock(&dev->parent->mutex);
put_device(dev);
}
}
Index: linux-2.6-tip/drivers/base/power/main.c
===================================================================
--- linux-2.6-tip.orig/drivers/base/power/main.c
+++ linux-2.6-tip/drivers/base/power/main.c
@@ -33,8 +33,8 @@
* because children are guaranteed to be discovered after parents, and
* are inserted at the back of the list on discovery.
*
- * Since device_pm_add() may be called with a device semaphore held,
- * we must never try to acquire a device semaphore while holding
+ * Since device_pm_add() may be called with a device mutex held,
+ * we must never try to acquire a device mutex while holding
* dpm_list_mutex.
*/
@@ -381,7 +381,7 @@ static int device_resume(struct device *
TRACE_DEVICE(dev);
TRACE_RESUME(0);
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (dev->bus) {
if (dev->bus->pm) {
@@ -414,7 +414,7 @@ static int device_resume(struct device *
}
}
End:
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
TRACE_RESUME(error);
return error;
@@ -468,7 +468,7 @@ static void dpm_resume(pm_message_t stat
*/
static void device_complete(struct device *dev, pm_message_t state)
{
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (dev->class && dev->class->pm && dev->class->pm->complete) {
pm_dev_dbg(dev, state, "completing class ");
@@ -485,7 +485,7 @@ static void device_complete(struct devic
dev->bus->pm->complete(dev);
}
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
/**
@@ -619,7 +619,7 @@ static int device_suspend(struct device
{
int error = 0;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (dev->class) {
if (dev->class->pm) {
@@ -654,7 +654,7 @@ static int device_suspend(struct device
}
}
End:
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return error;
}
@@ -705,7 +705,7 @@ static int device_prepare(struct device
{
int error = 0;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) {
pm_dev_dbg(dev, state, "preparing ");
@@ -729,7 +729,7 @@ static int device_prepare(struct device
suspend_report_result(dev->class->pm->prepare, error);
}
End:
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return error;
}
Index: linux-2.6-tip/drivers/firewire/core-device.c
===================================================================
--- linux-2.6-tip.orig/drivers/firewire/core-device.c
+++ linux-2.6-tip/drivers/firewire/core-device.c
@@ -762,9 +762,9 @@ static int update_unit(struct device *de
struct fw_driver *driver = (struct fw_driver *)dev->driver;
if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) {
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
driver->update(unit);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
return 0;
Index: linux-2.6-tip/drivers/ieee1394/nodemgr.c
===================================================================
--- linux-2.6-tip.orig/drivers/ieee1394/nodemgr.c
+++ linux-2.6-tip/drivers/ieee1394/nodemgr.c
@@ -1397,9 +1397,9 @@ static int update_pdrv(struct device *de
pdrv = container_of(drv, struct hpsb_protocol_driver,
driver);
if (pdrv->update) {
- down(&ud->device.sem);
+ mutex_lock(&ud->device.mutex);
error = pdrv->update(ud);
- up(&ud->device.sem);
+ mutex_unlock(&ud->device.mutex);
}
if (error)
device_release_driver(&ud->device);
Index: linux-2.6-tip/drivers/net/mlx4/mlx4.h
===================================================================
--- linux-2.6-tip.orig/drivers/net/mlx4/mlx4.h
+++ linux-2.6-tip/drivers/net/mlx4/mlx4.h
@@ -40,6 +40,7 @@
#include <linux/mutex.h>
#include <linux/radix-tree.h>
#include <linux/timer.h>
+#include <linux/semaphore.h>
#include <linux/workqueue.h>
#include <linux/mlx4/device.h>
Index: linux-2.6-tip/drivers/pci/bus.c
===================================================================
--- linux-2.6-tip.orig/drivers/pci/bus.c
+++ linux-2.6-tip/drivers/pci/bus.c
@@ -240,9 +240,9 @@ void pci_walk_bus(struct pci_bus *top, i
next = dev->bus_list.next;
/* Run device routines with the device locked */
- down(&dev->dev.sem);
+ mutex_lock(&dev->dev.mutex);
retval = cb(dev, userdata);
- up(&dev->dev.sem);
+ mutex_unlock(&dev->dev.mutex);
if (retval)
break;
}
Index: linux-2.6-tip/drivers/pci/pci.c
===================================================================
--- linux-2.6-tip.orig/drivers/pci/pci.c
+++ linux-2.6-tip/drivers/pci/pci.c
@@ -2211,7 +2211,7 @@ static int pci_dev_reset(struct pci_dev
if (!probe) {
pci_block_user_cfg_access(dev);
/* block PM suspend, driver probe, etc. */
- down(&dev->dev.sem);
+ mutex_lock(&dev->dev.mutex);
}
rc = pcie_flr(dev, probe);
@@ -2229,7 +2229,7 @@ static int pci_dev_reset(struct pci_dev
rc = pci_parent_bus_reset(dev, probe);
done:
if (!probe) {
- up(&dev->dev.sem);
+ mutex_unlock(&dev->dev.mutex);
pci_unblock_user_cfg_access(dev);
}
Index: linux-2.6-tip/drivers/pcmcia/ds.c
===================================================================
--- linux-2.6-tip.orig/drivers/pcmcia/ds.c
+++ linux-2.6-tip/drivers/pcmcia/ds.c
@@ -1082,9 +1082,9 @@ static int runtime_suspend(struct device
{
int rc;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return rc;
}
@@ -1092,9 +1092,9 @@ static void runtime_resume(struct device
{
int rc;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
rc = pcmcia_dev_resume(dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
/************************ per-device sysfs output ***************************/
Index: linux-2.6-tip/drivers/usb/core/driver.c
===================================================================
--- linux-2.6-tip.orig/drivers/usb/core/driver.c
+++ linux-2.6-tip/drivers/usb/core/driver.c
@@ -391,10 +391,10 @@ void usb_driver_release_interface(struct
if (device_is_registered(dev)) {
device_release_driver(dev);
} else {
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
usb_unbind_interface(dev);
dev->driver = NULL;
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
}
EXPORT_SYMBOL_GPL(usb_driver_release_interface);
Index: linux-2.6-tip/drivers/uwb/umc-bus.c
===================================================================
--- linux-2.6-tip.orig/drivers/uwb/umc-bus.c
+++ linux-2.6-tip/drivers/uwb/umc-bus.c
@@ -62,12 +62,12 @@ int umc_controller_reset(struct umc_dev
struct device *parent = umc->dev.parent;
int ret = 0;
- if(down_trylock(&parent->sem))
+ if (mutex_trylock(&parent->mutex))
return -EAGAIN;
ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper);
if (ret >= 0)
device_for_each_child(parent, parent, umc_bus_post_reset_helper);
- up(&parent->sem);
+ mutex_unlock(&parent->mutex);
return ret;
}
Index: linux-2.6-tip/drivers/uwb/uwb-internal.h
===================================================================
--- linux-2.6-tip.orig/drivers/uwb/uwb-internal.h
+++ linux-2.6-tip/drivers/uwb/uwb-internal.h
@@ -366,12 +366,12 @@ struct dentry *uwb_dbg_create_pal_dir(st
static inline void uwb_dev_lock(struct uwb_dev *uwb_dev)
{
- down(&uwb_dev->dev.sem);
+ mutex_lock(&uwb_dev->dev.mutex);
}
static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev)
{
- up(&uwb_dev->dev.sem);
+ mutex_unlock(&uwb_dev->dev.mutex);
}
#endif /* #ifndef __UWB_INTERNAL_H__ */
Index: linux-2.6-tip/include/linux/device.h
===================================================================
--- linux-2.6-tip.orig/include/linux/device.h
+++ linux-2.6-tip/include/linux/device.h
@@ -21,7 +21,6 @@
#include <linux/types.h>
#include <linux/module.h>
#include <linux/pm.h>
-#include <linux/semaphore.h>
#include <asm/atomic.h>
#include <asm/device.h>
@@ -105,7 +104,7 @@ extern int bus_unregister_notifier(struc
/* All 4 notifers below get called with the target struct device *
* as an argument. Note that those functions are likely to be called
- * with the device semaphore held in the core, so be careful.
+ * with the device mutex held in the core, so be careful.
*/
#define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */
#define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */
@@ -373,7 +372,7 @@ struct device {
const char *init_name; /* initial name of the device */
struct device_type *type;
- struct semaphore sem; /* semaphore to synchronize calls to
+ struct mutex mutex; /* mutex to synchronize calls to
* its driver.
*/
Index: linux-2.6-tip/include/linux/usb.h
===================================================================
--- linux-2.6-tip.orig/include/linux/usb.h
+++ linux-2.6-tip/include/linux/usb.h
@@ -529,9 +529,9 @@ extern struct usb_device *usb_get_dev(st
extern void usb_put_dev(struct usb_device *dev);
/* USB device locking */
-#define usb_lock_device(udev) down(&(udev)->dev.sem)
-#define usb_unlock_device(udev) up(&(udev)->dev.sem)
-#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem)
+#define usb_lock_device(udev) mutex_lock(&(udev)->dev.mutex)
+#define usb_unlock_device(udev) mutex_unlock(&(udev)->dev.mutex)
+#define usb_trylock_device(udev) mutex_trylock(&(udev)->dev.mutex)
extern int usb_lock_device_for_reset(struct usb_device *udev,
const struct usb_interface *iface);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 31/37] ia64: salinfo: semaphore_init instead of init_MUTEX
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (29 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 30/37] drivers/base: Convert dev->sem to mutex Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:19 ` [Patch RFC 32/37] drivers/macintosh/adb: Do not claim that the semaphore is a mutex Thomas Gleixner
` (5 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Tony Luck
[-- Attachment #1: ia64-salinfo-semaphore-init-instead-of-init-MUTEX.patch --]
[-- Type: text/plain, Size: 778 bytes --]
The usage of this "mutex" is non obvious and used as completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
---
arch/ia64/kernel/salinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/arch/ia64/kernel/salinfo.c
===================================================================
--- linux-2.6-tip.orig/arch/ia64/kernel/salinfo.c
+++ linux-2.6-tip/arch/ia64/kernel/salinfo.c
@@ -643,7 +643,7 @@ salinfo_init(void)
for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
data = salinfo_data + i;
data->type = i;
- init_MUTEX(&data->mutex);
+ semaphore_init(&data->mutex);
dir = proc_mkdir(salinfo_log_name[i], salinfo_dir);
if (!dir)
continue;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 32/37] drivers/macintosh/adb: Do not claim that the semaphore is a mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (30 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 31/37] ia64: salinfo: semaphore_init instead of init_MUTEX Thomas Gleixner
@ 2009-07-26 8:19 ` Thomas Gleixner
2009-07-26 8:20 ` [Patch RFC 33/37] arm: w90x900: convert semaphore to mutex Thomas Gleixner
` (4 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:19 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra,
Benjamin Herrenschmidt
[-- Attachment #1: drivers-macintosh-adb-sema-no-mutex.patch --]
[-- Type: text/plain, Size: 813 bytes --]
The usage of this "mutex" is non obvious and used as completion in
some places. Make it a semaphore.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/macintosh/adb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/macintosh/adb.c
===================================================================
--- linux-2.6-tip.orig/drivers/macintosh/adb.c
+++ linux-2.6-tip/drivers/macintosh/adb.c
@@ -83,7 +83,7 @@ static struct adb_driver *adb_controller
BLOCKING_NOTIFIER_HEAD(adb_client_list);
static int adb_got_sleep;
static int adb_inited;
-static DECLARE_MUTEX(adb_probe_mutex);
+static DEFINE_SEMAPHORE(adb_probe_mutex);
static int sleepy_trackpad;
static int autopoll_devs;
int __adb_probe_sync;
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 33/37] arm: w90x900: convert semaphore to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (31 preceding siblings ...)
2009-07-26 8:19 ` [Patch RFC 32/37] drivers/macintosh/adb: Do not claim that the semaphore is a mutex Thomas Gleixner
@ 2009-07-26 8:20 ` Thomas Gleixner
2009-07-27 3:11 ` Wan ZongShun
2009-07-26 8:20 ` [Patch RFC 34/37] printk: Make console_sem a semaphore not a pseudo mutex Thomas Gleixner
` (3 subsequent siblings)
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:20 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Wan ZongShun
[-- Attachment #1: arm-w90x900-mfp-convert-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 1666 bytes --]
The semaphore is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Wan ZongShun <mcuos.com@gmail.com>
---
arch/arm/mach-w90x900/mfp-w90p910.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6-tip/arch/arm/mach-w90x900/mfp-w90p910.c
===================================================================
--- linux-2.6-tip.orig/arch/arm/mach-w90x900/mfp-w90p910.c
+++ linux-2.6-tip/arch/arm/mach-w90x900/mfp-w90p910.c
@@ -34,7 +34,7 @@
#define GPSELEI0 (0x01 << 26)
#define GPSELEI1 (0x01 << 27)
-static DECLARE_MUTEX(mfp_sem);
+static DEFINE_MUTEX(mfp_sem);
void mfp_set_groupf(struct device *dev)
{
@@ -43,7 +43,7 @@ void mfp_set_groupf(struct device *dev)
BUG_ON(!dev);
- down(&mfp_sem);
+ mutex_lock(&mfp_sem);
dev_id = dev_name(dev);
@@ -56,7 +56,7 @@ void mfp_set_groupf(struct device *dev)
__raw_writel(mfpen, REG_MFSEL);
- up(&mfp_sem);
+ mutex_unlock(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupf);
@@ -67,7 +67,7 @@ void mfp_set_groupc(struct device *dev)
BUG_ON(!dev);
- down(&mfp_sem);
+ mutex_lock(&mfp_sem);
dev_id = dev_name(dev);
@@ -86,7 +86,7 @@ void mfp_set_groupc(struct device *dev)
__raw_writel(mfpen, REG_MFSEL);
- up(&mfp_sem);
+ mutex_unlock(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupc);
@@ -97,7 +97,7 @@ void mfp_set_groupi(struct device *dev,
BUG_ON(!dev);
- down(&mfp_sem);
+ mutex_lock(&mfp_sem);
dev_id = dev_name(dev);
@@ -110,7 +110,7 @@ void mfp_set_groupi(struct device *dev,
__raw_writel(mfpen, REG_MFSEL);
- up(&mfp_sem);
+ mutex_unlock(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupi);
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 34/37] printk: Make console_sem a semaphore not a pseudo mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (32 preceding siblings ...)
2009-07-26 8:20 ` [Patch RFC 33/37] arm: w90x900: convert semaphore to mutex Thomas Gleixner
@ 2009-07-26 8:20 ` Thomas Gleixner
2009-07-26 8:20 ` [Patch RFC 35/37] staging: Bulk convert the semaphore mess Thomas Gleixner
` (2 subsequent siblings)
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:20 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra
[-- Attachment #1: printk-sema-no-mutex.patch --]
[-- Type: text/plain, Size: 1005 bytes --]
It needs to be investigated whether it can be replaced by a real
mutex, but that needs more thought and investigation.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/printk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6-tip/kernel/printk.c
===================================================================
--- linux-2.6-tip.orig/kernel/printk.c
+++ linux-2.6-tip/kernel/printk.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(oops_in_progress);
* provides serialisation for access to the entire console
* driver system.
*/
-static DECLARE_MUTEX(console_sem);
+static DEFINE_SEMAPHORE(console_sem);
struct console *console_drivers;
EXPORT_SYMBOL_GPL(console_drivers);
@@ -529,7 +529,7 @@ static void zap_locks(void)
/* If a crash is occurring, make sure we can't deadlock */
spin_lock_init(&logbuf_lock);
/* And make sure that we print immediately */
- init_MUTEX(&console_sem);
+ semaphore_init(&console_sem);
}
#if defined(CONFIG_PRINTK_TIME)
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 35/37] staging: Bulk convert the semaphore mess
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (33 preceding siblings ...)
2009-07-26 8:20 ` [Patch RFC 34/37] printk: Make console_sem a semaphore not a pseudo mutex Thomas Gleixner
@ 2009-07-26 8:20 ` Thomas Gleixner
2009-07-26 8:20 ` [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex Thomas Gleixner
2009-07-26 8:20 ` [Patch RFC 37/37] semaphore: Remove mutex emulation Thomas Gleixner
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:20 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman
[-- Attachment #1: staging-bulkconvert-the-semaphore-mess.patch --]
[-- Type: text/plain, Size: 11438 bytes --]
init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert
staging users.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/staging/comedi/drivers/dt9812.c | 4 ++--
drivers/staging/comedi/drivers/usbdux.c | 4 ++--
drivers/staging/comedi/drivers/usbduxfast.c | 4 ++--
drivers/staging/cpc-usb/cpc-usb_drv.c | 4 ++--
drivers/staging/frontier/alphatrack.c | 2 +-
drivers/staging/frontier/tranzport.c | 2 +-
drivers/staging/go7007/go7007-driver.c | 2 +-
drivers/staging/go7007/go7007-i2c.c | 2 +-
drivers/staging/go7007/go7007-usb.c | 2 +-
drivers/staging/go7007/go7007-v4l2.c | 2 +-
drivers/staging/go7007/s2250-loader.c | 2 +-
drivers/staging/mimio/mimio.c | 2 +-
drivers/staging/octeon/ethernet-mdio.c | 2 +-
drivers/staging/otus/wwrap.c | 2 +-
drivers/staging/p9auth/p9auth.c | 2 +-
drivers/staging/rspiusb/rspiusb.c | 2 +-
drivers/staging/rt2870/common/2870_rtmp_init.c | 6 +++---
17 files changed, 23 insertions(+), 23 deletions(-)
Index: linux-2.6-tip/drivers/staging/comedi/drivers/dt9812.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/comedi/drivers/dt9812.c
+++ linux-2.6-tip/drivers/staging/comedi/drivers/dt9812.c
@@ -262,7 +262,7 @@ struct dt9812_usb_cmd {
#define DT9812_NUM_SLOTS 16
-static DECLARE_MUTEX(dt9812_mutex);
+static DEFINE_SEMAPHORE(dt9812_mutex);
static struct usb_device_id dt9812_table[] = {
{USB_DEVICE(0x0867, 0x9812)},
@@ -1121,7 +1121,7 @@ static int __init usb_dt9812_init(void)
/* Initialize all driver slots */
for (i = 0; i < DT9812_NUM_SLOTS; i++) {
- init_MUTEX(&dt9812[i].mutex);
+ semaphore_init(&dt9812[i].mutex);
dt9812[i].serial = 0;
dt9812[i].usb = NULL;
dt9812[i].comedi = NULL;
Index: linux-2.6-tip/drivers/staging/comedi/drivers/usbdux.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/comedi/drivers/usbdux.c
+++ linux-2.6-tip/drivers/staging/comedi/drivers/usbdux.c
@@ -307,7 +307,7 @@ struct usbduxsub {
*/
static struct usbduxsub usbduxsub[NUMUSBDUX];
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
/*
* Stops the data acquision
@@ -2349,7 +2349,7 @@ static int usbduxsub_probe(struct usb_in
dev_dbg(dev, "comedi_: usbdux: "
"usbduxsub[%d] is ready to connect to comedi.\n", index);
- init_MUTEX(&(usbduxsub[index].sem));
+ semaphore_init(&(usbduxsub[index].sem));
/* save a pointer to the usb device */
usbduxsub[index].usbdev = udev;
Index: linux-2.6-tip/drivers/staging/comedi/drivers/usbduxfast.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/comedi/drivers/usbduxfast.c
+++ linux-2.6-tip/drivers/staging/comedi/drivers/usbduxfast.c
@@ -201,7 +201,7 @@ struct usbduxfastsub_s {
*/
static struct usbduxfastsub_s usbduxfastsub[NUMUSBDUXFAST];
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
/*
* bulk transfers to usbduxfast
@@ -1500,7 +1500,7 @@ static int usbduxfastsub_probe(struct us
"connect to comedi.\n", index);
#endif
- init_MUTEX(&(usbduxfastsub[index].sem));
+ semaphore_init(&(usbduxfastsub[index].sem));
/* save a pointer to the usb device */
usbduxfastsub[index].usbdev = udev;
Index: linux-2.6-tip/drivers/staging/cpc-usb/cpc-usb_drv.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/cpc-usb/cpc-usb_drv.c
+++ linux-2.6-tip/drivers/staging/cpc-usb/cpc-usb_drv.c
@@ -83,7 +83,7 @@ static CPC_USB_T *CPCUSB_Table[CPC_USB_C
static unsigned int CPCUsbCnt;
/* prevent races between open() and disconnect() */
-static DECLARE_MUTEX(disconnect_sem);
+static DEFINE_SEMAPHORE(disconnect_sem);
/* local function prototypes */
static ssize_t cpcusb_read(struct file *file, char *buffer, size_t count,
@@ -903,7 +903,7 @@ static int cpcusb_probe(struct usb_inter
memset(chan, 0, sizeof(CPC_CHAN_T));
ResetBuffer(chan);
- init_MUTEX(&card->sem);
+ semaphore_init(&card->sem);
spin_lock_init(&card->slock);
card->udev = udev;
Index: linux-2.6-tip/drivers/staging/frontier/alphatrack.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/frontier/alphatrack.c
+++ linux-2.6-tip/drivers/staging/frontier/alphatrack.c
@@ -678,7 +678,7 @@ static int usb_alphatrack_probe(struct u
dev_err(&intf->dev, "Out of memory\n");
goto exit;
}
- init_MUTEX(&dev->sem);
+ semaphore_init(&dev->sem);
dev->intf = intf;
init_waitqueue_head(&dev->read_wait);
init_waitqueue_head(&dev->write_wait);
Index: linux-2.6-tip/drivers/staging/frontier/tranzport.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/frontier/tranzport.c
+++ linux-2.6-tip/drivers/staging/frontier/tranzport.c
@@ -800,7 +800,7 @@ static int usb_tranzport_probe(struct us
dev_err(&intf->dev, "Out of memory\n");
goto exit;
}
- init_MUTEX(&dev->sem);
+ semaphore_init(&dev->sem);
dev->intf = intf;
init_waitqueue_head(&dev->read_wait);
init_waitqueue_head(&dev->write_wait);
Index: linux-2.6-tip/drivers/staging/go7007/go7007-driver.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/go7007/go7007-driver.c
+++ linux-2.6-tip/drivers/staging/go7007/go7007-driver.c
@@ -604,7 +604,7 @@ struct go7007 *go7007_alloc(struct go700
go->tuner_type = -1;
go->channel_number = 0;
go->name[0] = 0;
- init_MUTEX(&go->hw_lock);
+ semaphore_init(&go->hw_lock);
init_waitqueue_head(&go->frame_waitq);
spin_lock_init(&go->spinlock);
go->video_dev = NULL;
Index: linux-2.6-tip/drivers/staging/go7007/go7007-i2c.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/go7007/go7007-i2c.c
+++ linux-2.6-tip/drivers/staging/go7007/go7007-i2c.c
@@ -48,7 +48,7 @@
/* There is only one I2C port on the TW2804 that feeds all four GO7007 VIPs
* on the Adlink PCI-MPG24, so access is shared between all of them. */
-static DECLARE_MUTEX(adlink_mpg24_i2c_lock);
+static DEFINE_SEMAPHORE(adlink_mpg24_i2c_lock);
static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
u16 command, int flags, u8 *data)
Index: linux-2.6-tip/drivers/staging/go7007/go7007-usb.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/go7007/go7007-usb.c
+++ linux-2.6-tip/drivers/staging/go7007/go7007-usb.c
@@ -1065,7 +1065,7 @@ static int go7007_usb_probe(struct usb_i
if (board->flags & GO7007_USB_EZUSB_I2C) {
memcpy(&go->i2c_adapter, &go7007_usb_adap_templ,
sizeof(go7007_usb_adap_templ));
- init_MUTEX(&usb->i2c_lock);
+ semaphore_init(&usb->i2c_lock);
go->i2c_adapter.dev.parent = go->dev;
i2c_set_adapdata(&go->i2c_adapter, go);
if (i2c_add_adapter(&go->i2c_adapter) < 0) {
Index: linux-2.6-tip/drivers/staging/go7007/go7007-v4l2.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/go7007/go7007-v4l2.c
+++ linux-2.6-tip/drivers/staging/go7007/go7007-v4l2.c
@@ -101,7 +101,7 @@ static int go7007_open(struct file *file
return -ENOMEM;
++go->ref_count;
gofh->go = go;
- init_MUTEX(&gofh->lock);
+ semaphore_init(&gofh->lock);
gofh->buf_count = 0;
file->private_data = gofh;
return 0;
Index: linux-2.6-tip/drivers/staging/go7007/s2250-loader.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/go7007/s2250-loader.c
+++ linux-2.6-tip/drivers/staging/go7007/s2250-loader.c
@@ -35,7 +35,7 @@ typedef struct device_extension_s {
#define MAX_DEVICES 256
static pdevice_extension_t s2250_dev_table[MAX_DEVICES];
-static DECLARE_MUTEX(s2250_dev_table_mutex);
+static DEFINE_SEMAPHORE(s2250_dev_table_mutex);
#define to_s2250loader_dev_common(d) container_of(d, device_extension_t, kref)
static void s2250loader_delete(struct kref *kref)
Index: linux-2.6-tip/drivers/staging/mimio/mimio.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/mimio/mimio.c
+++ linux-2.6-tip/drivers/staging/mimio/mimio.c
@@ -160,7 +160,7 @@ static struct usb_driver mimio_driver =
.id_table = mimio_table,
};
-static DECLARE_MUTEX(disconnect_sem);
+static DEFINE_SEMAPHORE(disconnect_sem);
static void mimio_close(struct input_dev *idev)
{
Index: linux-2.6-tip/drivers/staging/octeon/ethernet-mdio.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/octeon/ethernet-mdio.c
+++ linux-2.6-tip/drivers/staging/octeon/ethernet-mdio.c
@@ -39,7 +39,7 @@
#include "cvmx-smix-defs.h"
-DECLARE_MUTEX(mdio_sem);
+DEFINE_SEMAPHORE(mdio_sem);
/**
* Perform an MII read. Called by the generic MII routines
Index: linux-2.6-tip/drivers/staging/otus/wwrap.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/otus/wwrap.c
+++ linux-2.6-tip/drivers/staging/otus/wwrap.c
@@ -1066,7 +1066,7 @@ u8_t zfLnxCreateThread(zdev_t *dev)
/* Create Mutex and keventd */
INIT_WORK(&macp->kevent, kevent);
- init_MUTEX(&macp->ioctl_sem);
+ semaphore_init(&macp->ioctl_sem);
return 0;
}
Index: linux-2.6-tip/drivers/staging/p9auth/p9auth.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/p9auth/p9auth.c
+++ linux-2.6-tip/drivers/staging/p9auth/p9auth.c
@@ -388,7 +388,7 @@ static int cap_init_module(void)
/* Initialize each device. */
for (i = 0; i < cap_nr_devs; i++) {
cap_devices[i].node_size = cap_node_size;
- init_MUTEX(&cap_devices[i].sem);
+ semaphore_init(&cap_devices[i].sem);
cap_setup_cdev(&cap_devices[i], i);
}
Index: linux-2.6-tip/drivers/staging/rspiusb/rspiusb.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/rspiusb/rspiusb.c
+++ linux-2.6-tip/drivers/staging/rspiusb/rspiusb.c
@@ -63,7 +63,7 @@ static int debug;
#endif
/* prevent races between open() and disconnect() */
-static DECLARE_MUTEX(disconnect_sem);
+static DEFINE_SEMAPHORE(disconnect_sem);
/* Structure to hold all of our device specific stuff */
struct device_extension {
Index: linux-2.6-tip/drivers/staging/rt2870/common/2870_rtmp_init.c
===================================================================
--- linux-2.6-tip.orig/drivers/staging/rt2870/common/2870_rtmp_init.c
+++ linux-2.6-tip/drivers/staging/rt2870/common/2870_rtmp_init.c
@@ -751,13 +751,13 @@ NDIS_STATUS CreateThreads(
//init_MUTEX(&(pAd->usbdev_semaphore));
- init_MUTEX_LOCKED(&(pAd->mlme_semaphore));
+ semaphore_init_locked(&(pAd->mlme_semaphore));
init_completion (&pAd->mlmeComplete);
- init_MUTEX_LOCKED(&(pAd->RTUSBCmd_semaphore));
+ semaphore_init_locked(&(pAd->RTUSBCmd_semaphore));
init_completion (&pAd->CmdQComplete);
- init_MUTEX_LOCKED(&(pAd->RTUSBTimer_semaphore));
+ semaphore_init_locked(&(pAd->RTUSBTimer_semaphore));
init_completion (&pAd->TimerQComplete);
// Creat MLME Thread
^ permalink raw reply [flat|nested] 60+ messages in thread* [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (34 preceding siblings ...)
2009-07-26 8:20 ` [Patch RFC 35/37] staging: Bulk convert the semaphore mess Thomas Gleixner
@ 2009-07-26 8:20 ` Thomas Gleixner
2009-07-27 15:26 ` Christoph Hellwig
2009-07-26 8:20 ` [Patch RFC 37/37] semaphore: Remove mutex emulation Thomas Gleixner
36 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:20 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
[-- Attachment #1: fs-convert-bd-mount-sem-to-mutex.patch --]
[-- Type: text/plain, Size: 2566 bytes --]
bd_mount_sem is used as mutex so make it a mutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/block_dev.c | 8 ++++----
fs/super.c | 4 ++--
include/linux/fs.h | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6-tip/fs/block_dev.c
===================================================================
--- linux-2.6-tip.orig/fs/block_dev.c
+++ linux-2.6-tip/fs/block_dev.c
@@ -240,7 +240,7 @@ struct super_block *freeze_bdev(struct b
}
bdev->bd_fsfreeze_count++;
- down(&bdev->bd_mount_sem);
+ mutex_lock(&bdev->bd_mount_sem);
sb = get_super(bdev);
if (sb && !(sb->s_flags & MS_RDONLY)) {
sb->s_frozen = SB_FREEZE_WRITE;
@@ -260,7 +260,7 @@ struct super_block *freeze_bdev(struct b
"VFS:Filesystem freeze failed\n");
sb->s_frozen = SB_UNFROZEN;
drop_super(sb);
- up(&bdev->bd_mount_sem);
+ mutex_unlock(&bdev->bd_mount_sem);
bdev->bd_fsfreeze_count--;
mutex_unlock(&bdev->bd_fsfreeze_mutex);
return ERR_PTR(error);
@@ -321,7 +321,7 @@ int thaw_bdev(struct block_device *bdev,
drop_super(sb);
}
- up(&bdev->bd_mount_sem);
+ mutex_unlock(&bdev->bd_mount_sem);
mutex_unlock(&bdev->bd_fsfreeze_mutex);
return 0;
}
@@ -431,7 +431,7 @@ static void init_once(void *foo)
memset(bdev, 0, sizeof(*bdev));
mutex_init(&bdev->bd_mutex);
- sema_init(&bdev->bd_mount_sem, 1);
+ mutex_init(&bdev->bd_mount_sem);
INIT_LIST_HEAD(&bdev->bd_inodes);
INIT_LIST_HEAD(&bdev->bd_list);
#ifdef CONFIG_SYSFS
Index: linux-2.6-tip/fs/super.c
===================================================================
--- linux-2.6-tip.orig/fs/super.c
+++ linux-2.6-tip/fs/super.c
@@ -740,9 +740,9 @@ int get_sb_bdev(struct file_system_type
* will protect the lockfs code from trying to start a snapshot
* while we are mounting
*/
- down(&bdev->bd_mount_sem);
+ mutex_lock(&bdev->bd_mount_sem);
s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
- up(&bdev->bd_mount_sem);
+ mutex_unlock(&bdev->bd_mount_sem);
if (IS_ERR(s))
goto error_s;
Index: linux-2.6-tip/include/linux/fs.h
===================================================================
--- linux-2.6-tip.orig/include/linux/fs.h
+++ linux-2.6-tip/include/linux/fs.h
@@ -640,7 +640,7 @@ struct block_device {
struct super_block * bd_super;
int bd_openers;
struct mutex bd_mutex; /* open/close mutex */
- struct semaphore bd_mount_sem;
+ struct mutex bd_mount_sem;
struct list_head bd_inodes;
void * bd_holder;
int bd_holders;
^ permalink raw reply [flat|nested] 60+ messages in thread* Re: [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex
2009-07-26 8:20 ` [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex Thomas Gleixner
@ 2009-07-27 15:26 ` Christoph Hellwig
2009-07-27 15:30 ` Thomas Gleixner
0 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2009-07-27 15:26 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
On Sun, Jul 26, 2009 at 08:20:38AM -0000, Thomas Gleixner wrote:
> bd_mount_sem is used as mutex so make it a mutex.
Actually we may return to userspace with it held, so the conversion
is a bad idea. But I have a patch I need to post to completely get
rid of it.
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex
2009-07-27 15:26 ` Christoph Hellwig
@ 2009-07-27 15:30 ` Thomas Gleixner
2009-07-27 16:42 ` Daniel Walker
0 siblings, 1 reply; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-27 15:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: LKML, Andrew Morton, Ingo Molnar, Peter Zijlstra, Al Viro
On Mon, 27 Jul 2009, Christoph Hellwig wrote:
> On Sun, Jul 26, 2009 at 08:20:38AM -0000, Thomas Gleixner wrote:
> > bd_mount_sem is used as mutex so make it a mutex.
>
> Actually we may return to userspace with it held, so the conversion
> is a bad idea. But I have a patch I need to post to completely get
> rid of it.
That's why it's RFC :)
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex
2009-07-27 15:30 ` Thomas Gleixner
@ 2009-07-27 16:42 ` Daniel Walker
0 siblings, 0 replies; 60+ messages in thread
From: Daniel Walker @ 2009-07-27 16:42 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Christoph Hellwig, LKML, matthias, Andrew Morton, Ingo Molnar,
Peter Zijlstra, Al Viro
On Mon, 2009-07-27 at 17:30 +0200, Thomas Gleixner wrote:
> On Mon, 27 Jul 2009, Christoph Hellwig wrote:
>
> > On Sun, Jul 26, 2009 at 08:20:38AM -0000, Thomas Gleixner wrote:
> > > bd_mount_sem is used as mutex so make it a mutex.
> >
> > Actually we may return to userspace with it held, so the conversion
> > is a bad idea. But I have a patch I need to post to completely get
> > rid of it.
>
> That's why it's RFC :)
You better inspect these at much greater detail.. Matthias (added to the
CC) , and I did a great number of semaphore to mutex changes and I don't
recall there being too many clear easy ones remaining .. So unless the
semaphore was added in the past 12 months or so , I'd treat it as likely
unsafe for converting to a mutex..
Daniel
^ permalink raw reply [flat|nested] 60+ messages in thread
* [Patch RFC 37/37] semaphore: Remove mutex emulation
2009-07-26 8:17 [Patch RFC 00/37] Cleanup init_MUTEX[_LOCKED] / DECLARE_MUTEX Thomas Gleixner
` (35 preceding siblings ...)
2009-07-26 8:20 ` [Patch RFC 36/37] fs: Convert bd_mount_sem to mutex Thomas Gleixner
@ 2009-07-26 8:20 ` Thomas Gleixner
36 siblings, 0 replies; 60+ messages in thread
From: Thomas Gleixner @ 2009-07-26 8:20 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Ingo Molnar, Peter Zijlstra
[-- Attachment #1: semaphore-remove-mutex-emulation.patch --]
[-- Type: text/plain, Size: 2164 bytes --]
Semaphores used as mutexes have been deprecated for years. Now that
all users are either converted to real semaphores or to mutexes remove
the cruft.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/semaphore.h | 6 ------
scripts/checkpatch.pl | 9 +++------
2 files changed, 3 insertions(+), 12 deletions(-)
Index: linux-2.6-tip/include/linux/semaphore.h
===================================================================
--- linux-2.6-tip.orig/include/linux/semaphore.h
+++ linux-2.6-tip/include/linux/semaphore.h
@@ -29,9 +29,6 @@ struct semaphore {
#define DEFINE_SEMAPHORE(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#define DECLARE_MUTEX(name) \
- struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
static inline void sema_init(struct semaphore *sem, int val)
{
static struct lock_class_key __key;
@@ -53,9 +50,6 @@ static inline void __deprecated semaphor
sema_init(sem, 0);
}
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
-
extern void down(struct semaphore *sem);
extern int __must_check down_interruptible(struct semaphore *sem);
extern int __must_check down_killable(struct semaphore *sem);
Index: linux-2.6-tip/scripts/checkpatch.pl
===================================================================
--- linux-2.6-tip.orig/scripts/checkpatch.pl
+++ linux-2.6-tip/scripts/checkpatch.pl
@@ -2512,14 +2512,11 @@ sub process {
WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
}
-# check for semaphores used as mutexes
- if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
- WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
- }
-# check for semaphores used as mutexes
- if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
+# check for semaphores initialized locked
+ if ($line =~ /^.\s*semaphore_init_locked\s*\(/) {
WARN("consider using a completion\n" . $herecurr);
}
+
# recommend strict_strto* over simple_strto*
if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr);
^ permalink raw reply [flat|nested] 60+ messages in thread