Re: [PATCH] blkcg: fix "scheduling while atomic" in blk_queue_bypass_start

2012-10-30 Thread Vivek Goyal
On Tue, Oct 30, 2012 at 11:25:47AM +0900, Jun'ichi Nomura wrote:

[..]
> This patch moves blk_queue_bypass_start() before radix_tree_preload()
> to avoid the sleeping call while preemption is disabled.
> 
>   BUG: scheduling while atomic: multipath/2460/0x0002
>   1 lock held by multipath/2460:
>#0:  (>type_lock){..}, at: [] 
> dm_lock_md_type+0x17/0x19 [dm_mod]
>   Modules linked in: ...
>   Pid: 2460, comm: multipath Tainted: GW3.7.0-rc2 #1
>   Call Trace:
>[] __schedule_bug+0x6a/0x78
>[] __schedule+0xb4/0x5e0
>[] schedule+0x64/0x66
>[] schedule_timeout+0x39/0xf8
>[] ? put_lock_stats+0xe/0x29
>[] ? lock_release_holdtime+0xb6/0xbb
>[] wait_for_common+0x9d/0xee
>[] ? try_to_wake_up+0x206/0x206
>[] ? kfree_call_rcu+0x1c/0x1c
>[] wait_for_completion+0x1d/0x1f
>[] wait_rcu_gp+0x5d/0x7a
>[] ? wait_rcu_gp+0x7a/0x7a
>[] ? complete+0x21/0x53
>[] synchronize_rcu+0x1e/0x20
>[] blk_queue_bypass_start+0x5d/0x62
>[] blkcg_activate_policy+0x73/0x270
>[] ? kmem_cache_alloc_node_trace+0xc7/0x108
>[] cfq_init_queue+0x80/0x28e
>[] ? dm_blk_ioctl+0xa7/0xa7 [dm_mod]
>[] elevator_init+0xe1/0x115
>[] ? blk_queue_make_request+0x54/0x59
>[] blk_init_allocated_queue+0x8c/0x9e
>[] dm_setup_md_queue+0x36/0xaa [dm_mod]
>[] table_load+0x1bd/0x2c8 [dm_mod]
>[] ctl_ioctl+0x1d6/0x236 [dm_mod]
>[] ? table_clear+0xaa/0xaa [dm_mod]
>[] dm_ctl_ioctl+0x13/0x17 [dm_mod]
>[] do_vfs_ioctl+0x3fb/0x441
>[] ? file_has_perm+0x8a/0x99
>[] sys_ioctl+0x5e/0x82
>[] ? trace_hardirqs_on_thunk+0x3a/0x3f
>[] system_call_fastpath+0x16/0x1b
> 
> Signed-off-by: Jun'ichi Nomura 
> Cc: Vivek Goyal 
> Cc: Tejun Heo 
> Cc: Jens Axboe 
> Cc: Alasdair G Kergon 
> ---

Thanks Junichi. This patch looks good to me.

Acked-by: Vivek Goyal 

Vivek

>  block/blk-cgroup.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index d0b7703..954f4be 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -791,10 +791,10 @@ int blkcg_activate_policy(struct request_queue *q,
>   if (!blkg)
>   return -ENOMEM;
>  
> - preloaded = !radix_tree_preload(GFP_KERNEL);
> -
>   blk_queue_bypass_start(q);
>  
> + preloaded = !radix_tree_preload(GFP_KERNEL);
> +
>   /* make sure the root blkg exists and count the existing blkgs */
>   spin_lock_irq(q->queue_lock);
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] blkcg: fix scheduling while atomic in blk_queue_bypass_start

2012-10-30 Thread Vivek Goyal
On Tue, Oct 30, 2012 at 11:25:47AM +0900, Jun'ichi Nomura wrote:

[..]
 This patch moves blk_queue_bypass_start() before radix_tree_preload()
 to avoid the sleeping call while preemption is disabled.
 
   BUG: scheduling while atomic: multipath/2460/0x0002
   1 lock held by multipath/2460:
#0:  (md-type_lock){..}, at: [a019fb05] 
 dm_lock_md_type+0x17/0x19 [dm_mod]
   Modules linked in: ...
   Pid: 2460, comm: multipath Tainted: GW3.7.0-rc2 #1
   Call Trace:
[810723ae] __schedule_bug+0x6a/0x78
[81428ba2] __schedule+0xb4/0x5e0
[814291e6] schedule+0x64/0x66
[8142773a] schedule_timeout+0x39/0xf8
[8108ad5f] ? put_lock_stats+0xe/0x29
[8108ae30] ? lock_release_holdtime+0xb6/0xbb
[814289e3] wait_for_common+0x9d/0xee
[8107526c] ? try_to_wake_up+0x206/0x206
[810c0eb8] ? kfree_call_rcu+0x1c/0x1c
[81428aec] wait_for_completion+0x1d/0x1f
[810611f9] wait_rcu_gp+0x5d/0x7a
[81061216] ? wait_rcu_gp+0x7a/0x7a
[8106fb18] ? complete+0x21/0x53
[810c0556] synchronize_rcu+0x1e/0x20
[811dd903] blk_queue_bypass_start+0x5d/0x62
[811ee109] blkcg_activate_policy+0x73/0x270
[81130521] ? kmem_cache_alloc_node_trace+0xc7/0x108
[811f04b3] cfq_init_queue+0x80/0x28e
[a01a1600] ? dm_blk_ioctl+0xa7/0xa7 [dm_mod]
[811d8c41] elevator_init+0xe1/0x115
[811e229f] ? blk_queue_make_request+0x54/0x59
[811dd743] blk_init_allocated_queue+0x8c/0x9e
[a019ffcd] dm_setup_md_queue+0x36/0xaa [dm_mod]
[a01a60e6] table_load+0x1bd/0x2c8 [dm_mod]
[a01a7026] ctl_ioctl+0x1d6/0x236 [dm_mod]
[a01a5f29] ? table_clear+0xaa/0xaa [dm_mod]
[a01a7099] dm_ctl_ioctl+0x13/0x17 [dm_mod]
[811479fc] do_vfs_ioctl+0x3fb/0x441
[811b643c] ? file_has_perm+0x8a/0x99
[81147aa0] sys_ioctl+0x5e/0x82
[812010be] ? trace_hardirqs_on_thunk+0x3a/0x3f
[814310d9] system_call_fastpath+0x16/0x1b
 
 Signed-off-by: Jun'ichi Nomura j-nom...@ce.jp.nec.com
 Cc: Vivek Goyal vgo...@redhat.com
 Cc: Tejun Heo t...@kernel.org
 Cc: Jens Axboe ax...@kernel.dk
 Cc: Alasdair G Kergon a...@redhat.com
 ---

Thanks Junichi. This patch looks good to me.

Acked-by: Vivek Goyal vgo...@redhat.com

Vivek

  block/blk-cgroup.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
 index d0b7703..954f4be 100644
 --- a/block/blk-cgroup.c
 +++ b/block/blk-cgroup.c
 @@ -791,10 +791,10 @@ int blkcg_activate_policy(struct request_queue *q,
   if (!blkg)
   return -ENOMEM;
  
 - preloaded = !radix_tree_preload(GFP_KERNEL);
 -
   blk_queue_bypass_start(q);
  
 + preloaded = !radix_tree_preload(GFP_KERNEL);
 +
   /* make sure the root blkg exists and count the existing blkgs */
   spin_lock_irq(q-queue_lock);
  
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] blkcg: fix "scheduling while atomic" in blk_queue_bypass_start

2012-10-29 Thread Jun'ichi Nomura
On 10/30/12 02:13, Vivek Goyal wrote:
> On Mon, Oct 29, 2012 at 05:45:15PM +0100, Peter Zijlstra wrote:
>> int radix_tree_preload(gfp_t gfp_mask)
>> {
>> struct radix_tree_preload *rtp;
>> struct radix_tree_node *node;
>> int ret = -ENOMEM;
>> 
>> preempt_disable();
>>
>>
>> Seems obvious why it explodes..
> 
> Oh right. Thanks Peter. So just calling blk_queue_bypass_start() before
> radix_tree_preload() should fix it. Junichi, can you please give it
> a try.

Thank you! It just works.
This is a revised patch.

With 749fefe677 ("block: lift the initial queue bypass mode on
blk_register_queue() instead of blk_init_allocated_queue()"),
the following warning appears when multipath is used with
CONFIG_PREEMPT=y.

This patch moves blk_queue_bypass_start() before radix_tree_preload()
to avoid the sleeping call while preemption is disabled.

  BUG: scheduling while atomic: multipath/2460/0x0002
  1 lock held by multipath/2460:
   #0:  (>type_lock){..}, at: [] 
dm_lock_md_type+0x17/0x19 [dm_mod]
  Modules linked in: ...
  Pid: 2460, comm: multipath Tainted: GW3.7.0-rc2 #1
  Call Trace:
   [] __schedule_bug+0x6a/0x78
   [] __schedule+0xb4/0x5e0
   [] schedule+0x64/0x66
   [] schedule_timeout+0x39/0xf8
   [] ? put_lock_stats+0xe/0x29
   [] ? lock_release_holdtime+0xb6/0xbb
   [] wait_for_common+0x9d/0xee
   [] ? try_to_wake_up+0x206/0x206
   [] ? kfree_call_rcu+0x1c/0x1c
   [] wait_for_completion+0x1d/0x1f
   [] wait_rcu_gp+0x5d/0x7a
   [] ? wait_rcu_gp+0x7a/0x7a
   [] ? complete+0x21/0x53
   [] synchronize_rcu+0x1e/0x20
   [] blk_queue_bypass_start+0x5d/0x62
   [] blkcg_activate_policy+0x73/0x270
   [] ? kmem_cache_alloc_node_trace+0xc7/0x108
   [] cfq_init_queue+0x80/0x28e
   [] ? dm_blk_ioctl+0xa7/0xa7 [dm_mod]
   [] elevator_init+0xe1/0x115
   [] ? blk_queue_make_request+0x54/0x59
   [] blk_init_allocated_queue+0x8c/0x9e
   [] dm_setup_md_queue+0x36/0xaa [dm_mod]
   [] table_load+0x1bd/0x2c8 [dm_mod]
   [] ctl_ioctl+0x1d6/0x236 [dm_mod]
   [] ? table_clear+0xaa/0xaa [dm_mod]
   [] dm_ctl_ioctl+0x13/0x17 [dm_mod]
   [] do_vfs_ioctl+0x3fb/0x441
   [] ? file_has_perm+0x8a/0x99
   [] sys_ioctl+0x5e/0x82
   [] ? trace_hardirqs_on_thunk+0x3a/0x3f
   [] system_call_fastpath+0x16/0x1b

Signed-off-by: Jun'ichi Nomura 
Cc: Vivek Goyal 
Cc: Tejun Heo 
Cc: Jens Axboe 
Cc: Alasdair G Kergon 
---
 block/blk-cgroup.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index d0b7703..954f4be 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -791,10 +791,10 @@ int blkcg_activate_policy(struct request_queue *q,
if (!blkg)
return -ENOMEM;
 
-   preloaded = !radix_tree_preload(GFP_KERNEL);
-
blk_queue_bypass_start(q);
 
+   preloaded = !radix_tree_preload(GFP_KERNEL);
+
/* make sure the root blkg exists and count the existing blkgs */
spin_lock_irq(q->queue_lock);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] blkcg: fix scheduling while atomic in blk_queue_bypass_start

2012-10-29 Thread Jun'ichi Nomura
On 10/30/12 02:13, Vivek Goyal wrote:
 On Mon, Oct 29, 2012 at 05:45:15PM +0100, Peter Zijlstra wrote:
 int radix_tree_preload(gfp_t gfp_mask)
 {
 struct radix_tree_preload *rtp;
 struct radix_tree_node *node;
 int ret = -ENOMEM;
 
 preempt_disable();


 Seems obvious why it explodes..
 
 Oh right. Thanks Peter. So just calling blk_queue_bypass_start() before
 radix_tree_preload() should fix it. Junichi, can you please give it
 a try.

Thank you! It just works.
This is a revised patch.

With 749fefe677 (block: lift the initial queue bypass mode on
blk_register_queue() instead of blk_init_allocated_queue()),
the following warning appears when multipath is used with
CONFIG_PREEMPT=y.

This patch moves blk_queue_bypass_start() before radix_tree_preload()
to avoid the sleeping call while preemption is disabled.

  BUG: scheduling while atomic: multipath/2460/0x0002
  1 lock held by multipath/2460:
   #0:  (md-type_lock){..}, at: [a019fb05] 
dm_lock_md_type+0x17/0x19 [dm_mod]
  Modules linked in: ...
  Pid: 2460, comm: multipath Tainted: GW3.7.0-rc2 #1
  Call Trace:
   [810723ae] __schedule_bug+0x6a/0x78
   [81428ba2] __schedule+0xb4/0x5e0
   [814291e6] schedule+0x64/0x66
   [8142773a] schedule_timeout+0x39/0xf8
   [8108ad5f] ? put_lock_stats+0xe/0x29
   [8108ae30] ? lock_release_holdtime+0xb6/0xbb
   [814289e3] wait_for_common+0x9d/0xee
   [8107526c] ? try_to_wake_up+0x206/0x206
   [810c0eb8] ? kfree_call_rcu+0x1c/0x1c
   [81428aec] wait_for_completion+0x1d/0x1f
   [810611f9] wait_rcu_gp+0x5d/0x7a
   [81061216] ? wait_rcu_gp+0x7a/0x7a
   [8106fb18] ? complete+0x21/0x53
   [810c0556] synchronize_rcu+0x1e/0x20
   [811dd903] blk_queue_bypass_start+0x5d/0x62
   [811ee109] blkcg_activate_policy+0x73/0x270
   [81130521] ? kmem_cache_alloc_node_trace+0xc7/0x108
   [811f04b3] cfq_init_queue+0x80/0x28e
   [a01a1600] ? dm_blk_ioctl+0xa7/0xa7 [dm_mod]
   [811d8c41] elevator_init+0xe1/0x115
   [811e229f] ? blk_queue_make_request+0x54/0x59
   [811dd743] blk_init_allocated_queue+0x8c/0x9e
   [a019ffcd] dm_setup_md_queue+0x36/0xaa [dm_mod]
   [a01a60e6] table_load+0x1bd/0x2c8 [dm_mod]
   [a01a7026] ctl_ioctl+0x1d6/0x236 [dm_mod]
   [a01a5f29] ? table_clear+0xaa/0xaa [dm_mod]
   [a01a7099] dm_ctl_ioctl+0x13/0x17 [dm_mod]
   [811479fc] do_vfs_ioctl+0x3fb/0x441
   [811b643c] ? file_has_perm+0x8a/0x99
   [81147aa0] sys_ioctl+0x5e/0x82
   [812010be] ? trace_hardirqs_on_thunk+0x3a/0x3f
   [814310d9] system_call_fastpath+0x16/0x1b

Signed-off-by: Jun'ichi Nomura j-nom...@ce.jp.nec.com
Cc: Vivek Goyal vgo...@redhat.com
Cc: Tejun Heo t...@kernel.org
Cc: Jens Axboe ax...@kernel.dk
Cc: Alasdair G Kergon a...@redhat.com
---
 block/blk-cgroup.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index d0b7703..954f4be 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -791,10 +791,10 @@ int blkcg_activate_policy(struct request_queue *q,
if (!blkg)
return -ENOMEM;
 
-   preloaded = !radix_tree_preload(GFP_KERNEL);
-
blk_queue_bypass_start(q);
 
+   preloaded = !radix_tree_preload(GFP_KERNEL);
+
/* make sure the root blkg exists and count the existing blkgs */
spin_lock_irq(q-queue_lock);
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/