All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Remove might_sleep from wait_event_cmd
@ 2015-02-02 14:39 Mikulas Patocka
  2015-02-02 22:12 ` NeilBrown
  2015-02-03 11:22 ` [tip:sched/urgent] sched/wait: Remove might_sleep() from wait_event_cmd() tip-bot for Mikulas Patocka
  0 siblings, 2 replies; 5+ messages in thread
From: Mikulas Patocka @ 2015-02-02 14:39 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Zdenek Kabelac, tglx, ilya.dryomov, umgwanakikbuti,
	Oleg Nesterov, Ingo Molnar, Neil Brown, dm-devel, linux-kernel

Hi

Please apply this before 3.19 is released.

Mikulas


The patch e22b886a8a43b147e1994a9f970f678fc0df2033 introduced a bug in the
raid5 subsystem.

The function raid5_quiesce (and resize_stripes) calls 
lock_all_device_hash_locks_irq that disables interrupts and takes a few 
spinlocks, then it calls wait_event_cmd with cmd1 
unlock_all_device_hash_locks_irq(conf) and cmd2 
lock_all_device_hash_locks_irq(conf). cmd1 unlocks the spinlocks and 
enables interrupts, cmd2 disables interrupts and locks the spinlock.

The patch e22b886a8a43b147e1994a9f970f678fc0df2033 adds might_sleep() to a
position where spinlocks are taken, thus it introduces a bug.

This patch removes might_sleep() from wait_event_cmd.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 include/linux/wait.h |    1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6/include/linux/wait.h
===================================================================
--- linux-2.6.orig/include/linux/wait.h	2014-12-30 01:19:25.564231262 +0100
+++ linux-2.6/include/linux/wait.h	2015-02-02 15:30:16.766354658 +0100
@@ -363,7 +363,6 @@ do {									\
  */
 #define wait_event_cmd(wq, condition, cmd1, cmd2)			\
 do {									\
-	might_sleep();							\
 	if (condition)							\
 		break;							\
 	__wait_event_cmd(wq, condition, cmd1, cmd2);			\

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Remove might_sleep from wait_event_cmd
  2015-02-02 14:39 [PATCH] Remove might_sleep from wait_event_cmd Mikulas Patocka
@ 2015-02-02 22:12 ` NeilBrown
  2015-02-03 11:06   ` Peter Zijlstra
  2015-02-03 11:22 ` [tip:sched/urgent] sched/wait: Remove might_sleep() from wait_event_cmd() tip-bot for Mikulas Patocka
  1 sibling, 1 reply; 5+ messages in thread
From: NeilBrown @ 2015-02-02 22:12 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Peter Zijlstra, Zdenek Kabelac, tglx, ilya.dryomov,
	umgwanakikbuti, Oleg Nesterov, Ingo Molnar, dm-devel,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1938 bytes --]

On Mon, 2 Feb 2015 09:39:02 -0500 (EST) Mikulas Patocka <mpatocka@redhat.com>
wrote:

> Hi
> 
> Please apply this before 3.19 is released.
> 
> Mikulas
> 
> 
> The patch e22b886a8a43b147e1994a9f970f678fc0df2033 introduced a bug in the
> raid5 subsystem.
> 
> The function raid5_quiesce (and resize_stripes) calls 
> lock_all_device_hash_locks_irq that disables interrupts and takes a few 
> spinlocks, then it calls wait_event_cmd with cmd1 
> unlock_all_device_hash_locks_irq(conf) and cmd2 
> lock_all_device_hash_locks_irq(conf). cmd1 unlocks the spinlocks and 
> enables interrupts, cmd2 disables interrupts and locks the spinlock.
> 
> The patch e22b886a8a43b147e1994a9f970f678fc0df2033 adds might_sleep() to a
> position where spinlocks are taken, thus it introduces a bug.
> 
> This patch removes might_sleep() from wait_event_cmd.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> ---
>  include/linux/wait.h |    1 -
>  1 file changed, 1 deletion(-)
> 
> Index: linux-2.6/include/linux/wait.h
> ===================================================================
> --- linux-2.6.orig/include/linux/wait.h	2014-12-30 01:19:25.564231262 +0100
> +++ linux-2.6/include/linux/wait.h	2015-02-02 15:30:16.766354658 +0100
> @@ -363,7 +363,6 @@ do {									\
>   */
>  #define wait_event_cmd(wq, condition, cmd1, cmd2)			\
>  do {									\
> -	might_sleep();							\
>  	if (condition)							\
>  		break;							\
>  	__wait_event_cmd(wq, condition, cmd1, cmd2);			\
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


I support this patch.
However in case it doesn't get in, I've queued up a patch to change raid5.c
to use __wait_event_cmd instead...

NeilBrown

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Remove might_sleep from wait_event_cmd
  2015-02-02 22:12 ` NeilBrown
@ 2015-02-03 11:06   ` Peter Zijlstra
  2015-02-03 21:30     ` NeilBrown
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2015-02-03 11:06 UTC (permalink / raw)
  To: NeilBrown
  Cc: Mikulas Patocka, Zdenek Kabelac, tglx, ilya.dryomov,
	umgwanakikbuti, Oleg Nesterov, Ingo Molnar, dm-devel,
	linux-kernel

On Tue, Feb 03, 2015 at 09:12:53AM +1100, NeilBrown wrote:
> I support this patch.

It should hopefully already be en-route to tip.

> However in case it doesn't get in, I've queued up a patch to change raid5.c
> to use __wait_event_cmd instead...

So those primitives are useful in their own; their typical use would be
when you already know @cond to be false and want to avoid the extra
invocation.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:sched/urgent] sched/wait: Remove might_sleep() from wait_event_cmd()
  2015-02-02 14:39 [PATCH] Remove might_sleep from wait_event_cmd Mikulas Patocka
  2015-02-02 22:12 ` NeilBrown
@ 2015-02-03 11:22 ` tip-bot for Mikulas Patocka
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Mikulas Patocka @ 2015-02-03 11:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, mpatocka, peterz, linux-kernel, torvalds, mingo, tglx

Commit-ID:  3e87523897e18a3e17fc8955ed795188be737ff1
Gitweb:     http://git.kernel.org/tip/3e87523897e18a3e17fc8955ed795188be737ff1
Author:     Mikulas Patocka <mpatocka@redhat.com>
AuthorDate: Mon, 2 Feb 2015 09:39:02 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 3 Feb 2015 12:14:25 +0100

sched/wait: Remove might_sleep() from wait_event_cmd()

The patch e22b886a8a43 ("sched/wait: Add might_sleep() checks")
introduced a bug in the raid5 subsystem.

The function raid5_quiesce() (and resize_stripes()) uses the 'cmd'
part to release and acquire a spinlock (so we call the sleep
primitives in atomic context), and therefore we cannot do the
might_sleep() check.

Remove it.

Fixes: e22b886a8a43 ("sched/wait: Add might_sleep() checks")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1502020935580.13510@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/wait.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2232ed1..37423e0 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -363,7 +363,6 @@ do {									\
  */
 #define wait_event_cmd(wq, condition, cmd1, cmd2)			\
 do {									\
-	might_sleep();							\
 	if (condition)							\
 		break;							\
 	__wait_event_cmd(wq, condition, cmd1, cmd2);			\

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Remove might_sleep from wait_event_cmd
  2015-02-03 11:06   ` Peter Zijlstra
@ 2015-02-03 21:30     ` NeilBrown
  0 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2015-02-03 21:30 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Mikulas Patocka, Zdenek Kabelac, tglx, ilya.dryomov,
	umgwanakikbuti, Oleg Nesterov, Ingo Molnar, dm-devel,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

On Tue, 3 Feb 2015 12:06:30 +0100 Peter Zijlstra <peterz@infradead.org> wrote:

> On Tue, Feb 03, 2015 at 09:12:53AM +1100, NeilBrown wrote:
> > I support this patch.
> 
> It should hopefully already be en-route to tip.

Hopefully that means it will be in 3.19-final...

Thanks, I'll drop my __wait_event_cmd patch then.

NeilBrown

> 
> > However in case it doesn't get in, I've queued up a patch to change raid5.c
> > to use __wait_event_cmd instead...
> 
> So those primitives are useful in their own; their typical use would be
> when you already know @cond to be false and want to avoid the extra
> invocation.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-03 21:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 14:39 [PATCH] Remove might_sleep from wait_event_cmd Mikulas Patocka
2015-02-02 22:12 ` NeilBrown
2015-02-03 11:06   ` Peter Zijlstra
2015-02-03 21:30     ` NeilBrown
2015-02-03 11:22 ` [tip:sched/urgent] sched/wait: Remove might_sleep() from wait_event_cmd() tip-bot for Mikulas Patocka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.