Re: [PATCH tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-23 Thread Eric Dumazet
On Sun, 2014-11-23 at 07:21 -0500, Pranith Kumar wrote:

> I am not sure we should be taking rcu_read_lock() there as I am not
> sure how long that critical section might last. Can someone who is
> more familiar with the code take a look?
> 
> I will try to look for a solution too in the mean time.

I am sending a fix.


--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-23 Thread Pranith Kumar
On Fri, Nov 21, 2014 at 9:58 AM, Kirill A. Shutemov
 wrote:
> On Fri, Nov 21, 2014 at 09:30:36AM -0500, Pranith Kumar wrote:
>> On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
>> > On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
>> >> From: Pranith Kumar 
>> >>
>> >> Got Paul's email wrong the first time.
>> >>
>> >> The map field in 'struct mapped_device' is an rcu pointer. Use 
>> >> rcu_dereference()
>> >> while accessing it.
>> >>
>> >> Signed-off-by: Pranith Kumar 
>> >> Signed-off-by: Paul E. McKenney 
>> >
>> > On current -next I see this:
>> >
>> > [6.388264] ===
>> > [6.389571] [ INFO: suspicious RCU usage. ]
>> > [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
>> > [6.392185] ---
>> > [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
>> > rcu_dereference_check() usage!
>> > [6.394801]
>> > other info that might help us debug this:
>> >
>>
>> Hi Kirill,
>>
>> We are dereferencing an RCU pointer with the suspend_lock held which is 
>> causing this warning.
>>
>> Can you please check if the following patch helps? Thanks!
>
> Nope. The same issue.
>
> IIUC, the problem is that you dereference pointer outside rcu_read_lock()
> section, not that suspend_lock is held.
>

I am not sure we should be taking rcu_read_lock() there as I am not
sure how long that critical section might last. Can someone who is
more familiar with the code take a look?

I will try to look for a solution too in the mean time.

Thanks!
-- 
Pranith
--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-23 Thread Pranith Kumar
On Fri, Nov 21, 2014 at 9:58 AM, Kirill A. Shutemov
kir...@shutemov.name wrote:
 On Fri, Nov 21, 2014 at 09:30:36AM -0500, Pranith Kumar wrote:
 On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
  On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
  From: Pranith Kumar bobby.pr...@gmail.com
 
  Got Paul's email wrong the first time.
 
  The map field in 'struct mapped_device' is an rcu pointer. Use 
  rcu_dereference()
  while accessing it.
 
  Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
  Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
 
  On current -next I see this:
 
  [6.388264] ===
  [6.389571] [ INFO: suspicious RCU usage. ]
  [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
  [6.392185] ---
  [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
  rcu_dereference_check() usage!
  [6.394801]
  other info that might help us debug this:
 

 Hi Kirill,

 We are dereferencing an RCU pointer with the suspend_lock held which is 
 causing this warning.

 Can you please check if the following patch helps? Thanks!

 Nope. The same issue.

 IIUC, the problem is that you dereference pointer outside rcu_read_lock()
 section, not that suspend_lock is held.


I am not sure we should be taking rcu_read_lock() there as I am not
sure how long that critical section might last. Can someone who is
more familiar with the code take a look?

I will try to look for a solution too in the mean time.

Thanks!
-- 
Pranith
--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-23 Thread Eric Dumazet
On Sun, 2014-11-23 at 07:21 -0500, Pranith Kumar wrote:

 I am not sure we should be taking rcu_read_lock() there as I am not
 sure how long that critical section might last. Can someone who is
 more familiar with the code take a look?
 
 I will try to look for a solution too in the mean time.

I am sending a fix.


--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Kirill A. Shutemov
On Fri, Nov 21, 2014 at 09:30:36AM -0500, Pranith Kumar wrote:
> On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
> > On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
> >> From: Pranith Kumar 
> >>
> >> Got Paul's email wrong the first time.
> >>
> >> The map field in 'struct mapped_device' is an rcu pointer. Use 
> >> rcu_dereference()
> >> while accessing it.
> >>
> >> Signed-off-by: Pranith Kumar 
> >> Signed-off-by: Paul E. McKenney 
> > 
> > On current -next I see this:
> > 
> > [6.388264] ===
> > [6.389571] [ INFO: suspicious RCU usage. ]
> > [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
> > [6.392185] ---
> > [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
> > rcu_dereference_check() usage!
> > [6.394801] 
> > other info that might help us debug this:
> > 
> 
> Hi Kirill,
> 
> We are dereferencing an RCU pointer with the suspend_lock held which is 
> causing this warning.
> 
> Can you please check if the following patch helps? Thanks!

Nope. The same issue.

IIUC, the problem is that you dereference pointer outside rcu_read_lock()
section, not that suspend_lock is held.

-- 
 Kirill A. Shutemov
--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Pranith Kumar
On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
> On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
>> From: Pranith Kumar 
>>
>> Got Paul's email wrong the first time.
>>
>> The map field in 'struct mapped_device' is an rcu pointer. Use 
>> rcu_dereference()
>> while accessing it.
>>
>> Signed-off-by: Pranith Kumar 
>> Signed-off-by: Paul E. McKenney 
> 
> On current -next I see this:
> 
> [6.388264] ===
> [6.389571] [ INFO: suspicious RCU usage. ]
> [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
> [6.392185] ---
> [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
> rcu_dereference_check() usage!
> [6.394801] 
> other info that might help us debug this:
> 

Hi Kirill,

We are dereferencing an RCU pointer with the suspend_lock held which is causing 
this warning.

Can you please check if the following patch helps? Thanks!

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a0ece87..e584e66 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2830,7 +2830,7 @@ static int __dm_suspend(struct mapped_device *md, struct 
dm_table *map,
  */
 int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
 {
-   struct dm_table *map = NULL;
+   struct dm_table *map = rcu_dereference(md->map);
int r = 0;
 
 retry:
@@ -2850,8 +2850,6 @@ retry:
goto retry;
}
 
-   map = rcu_dereference(md->map);
-
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE);
if (r)
goto out_unlock;



> [6.398714] 
> rcu_scheduler_active = 1, debug_locks = 0
> [6.401247] 1 lock held by cryptsetup/159:
> [6.402522]  #0:  (>suspend_lock/1){+.+...}, at: [] 
> dm_suspend+0x3d/0x140
> [6.403848] 
> stack backtrace:
> [6.406448] CPU: 3 PID: 159 Comm: cryptsetup Not tainted 
> 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2
> [6.407726] Hardware name: LENOVO 3460CC6/3460CC6, BIOS G6ET93WW (2.53 ) 
> 02/04/2013
> [6.408982]  0001 8800d3ac7c38 81b00bbd 
> 0011
> [6.410249]  8800d301a560 8800d3ac7c68 81153be7 
> 8800d3928800
> [6.411548]  8800d3928970 8800d3928aa0 0001 
> 8800d3ac7ca8
> [6.412780] Call Trace:
> [6.413980]  [] dump_stack+0x4c/0x6e
> [6.415178]  [] lockdep_rcu_suspicious+0xe7/0x120
> [6.416364]  [] dm_suspend+0x13d/0x140
> [6.417535]  [] ? table_load+0x340/0x340
> [6.418749]  [] dev_suspend+0x1ab/0x260
> [6.419901]  [] ? table_load+0x340/0x340
> [6.421038]  [] ctl_ioctl+0x251/0x540
> [6.422164]  [] ? mntput_no_expire+0x5/0x360
> [6.423280]  [] dm_ctl_ioctl+0x13/0x20
> [6.424389]  [] do_vfs_ioctl+0x308/0x540
> [6.425515]  [] ? rcu_read_lock_held+0x6d/0x70
> [6.426601]  [] ? __fget_light+0xbe/0xd0
> [6.427686]  [] SyS_ioctl+0x81/0xa0
> [6.428760]  [] system_call_fastpath+0x16/0x1b
> 

--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Kirill A. Shutemov
On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
> From: Pranith Kumar 
> 
> Got Paul's email wrong the first time.
> 
> The map field in 'struct mapped_device' is an rcu pointer. Use 
> rcu_dereference()
> while accessing it.
> 
> Signed-off-by: Pranith Kumar 
> Signed-off-by: Paul E. McKenney 

On current -next I see this:

[6.388264] ===
[6.389571] [ INFO: suspicious RCU usage. ]
[6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
[6.392185] ---
[6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
rcu_dereference_check() usage!
[6.394801] 
other info that might help us debug this:

[6.398714] 
rcu_scheduler_active = 1, debug_locks = 0
[6.401247] 1 lock held by cryptsetup/159:
[6.402522]  #0:  (>suspend_lock/1){+.+...}, at: [] 
dm_suspend+0x3d/0x140
[6.403848] 
stack backtrace:
[6.406448] CPU: 3 PID: 159 Comm: cryptsetup Not tainted 
3.18.0-rc5-next-20141121-08303-g44cae4530372 #2
[6.407726] Hardware name: LENOVO 3460CC6/3460CC6, BIOS G6ET93WW (2.53 ) 
02/04/2013
[6.408982]  0001 8800d3ac7c38 81b00bbd 
0011
[6.410249]  8800d301a560 8800d3ac7c68 81153be7 
8800d3928800
[6.411548]  8800d3928970 8800d3928aa0 0001 
8800d3ac7ca8
[6.412780] Call Trace:
[6.413980]  [] dump_stack+0x4c/0x6e
[6.415178]  [] lockdep_rcu_suspicious+0xe7/0x120
[6.416364]  [] dm_suspend+0x13d/0x140
[6.417535]  [] ? table_load+0x340/0x340
[6.418749]  [] dev_suspend+0x1ab/0x260
[6.419901]  [] ? table_load+0x340/0x340
[6.421038]  [] ctl_ioctl+0x251/0x540
[6.422164]  [] ? mntput_no_expire+0x5/0x360
[6.423280]  [] dm_ctl_ioctl+0x13/0x20
[6.424389]  [] do_vfs_ioctl+0x308/0x540
[6.425515]  [] ? rcu_read_lock_held+0x6d/0x70
[6.426601]  [] ? __fget_light+0xbe/0xd0
[6.427686]  [] SyS_ioctl+0x81/0xa0
[6.428760]  [] system_call_fastpath+0x16/0x1b
-- 
 Kirill A. Shutemov
--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Kirill A. Shutemov
On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
 From: Pranith Kumar bobby.pr...@gmail.com
 
 Got Paul's email wrong the first time.
 
 The map field in 'struct mapped_device' is an rcu pointer. Use 
 rcu_dereference()
 while accessing it.
 
 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com

On current -next I see this:

[6.388264] ===
[6.389571] [ INFO: suspicious RCU usage. ]
[6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
[6.392185] ---
[6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
rcu_dereference_check() usage!
[6.394801] 
other info that might help us debug this:

[6.398714] 
rcu_scheduler_active = 1, debug_locks = 0
[6.401247] 1 lock held by cryptsetup/159:
[6.402522]  #0:  (md-suspend_lock/1){+.+...}, at: [8179dd1d] 
dm_suspend+0x3d/0x140
[6.403848] 
stack backtrace:
[6.406448] CPU: 3 PID: 159 Comm: cryptsetup Not tainted 
3.18.0-rc5-next-20141121-08303-g44cae4530372 #2
[6.407726] Hardware name: LENOVO 3460CC6/3460CC6, BIOS G6ET93WW (2.53 ) 
02/04/2013
[6.408982]  0001 8800d3ac7c38 81b00bbd 
0011
[6.410249]  8800d301a560 8800d3ac7c68 81153be7 
8800d3928800
[6.411548]  8800d3928970 8800d3928aa0 0001 
8800d3ac7ca8
[6.412780] Call Trace:
[6.413980]  [81b00bbd] dump_stack+0x4c/0x6e
[6.415178]  [81153be7] lockdep_rcu_suspicious+0xe7/0x120
[6.416364]  [8179de1d] dm_suspend+0x13d/0x140
[6.417535]  [817a2d80] ? table_load+0x340/0x340
[6.418749]  [817a2f2b] dev_suspend+0x1ab/0x260
[6.419901]  [817a2d80] ? table_load+0x340/0x340
[6.421038]  [817a3781] ctl_ioctl+0x251/0x540
[6.422164]  [812b6415] ? mntput_no_expire+0x5/0x360
[6.423280]  [817a3a83] dm_ctl_ioctl+0x13/0x20
[6.424389]  [812a6f98] do_vfs_ioctl+0x308/0x540
[6.425515]  [81175d2d] ? rcu_read_lock_held+0x6d/0x70
[6.426601]  [812b324e] ? __fget_light+0xbe/0xd0
[6.427686]  [812a7251] SyS_ioctl+0x81/0xa0
[6.428760]  [81b0d6ad] system_call_fastpath+0x16/0x1b
-- 
 Kirill A. Shutemov
--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Pranith Kumar
On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
 On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
 From: Pranith Kumar bobby.pr...@gmail.com

 Got Paul's email wrong the first time.

 The map field in 'struct mapped_device' is an rcu pointer. Use 
 rcu_dereference()
 while accessing it.

 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
 
 On current -next I see this:
 
 [6.388264] ===
 [6.389571] [ INFO: suspicious RCU usage. ]
 [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
 [6.392185] ---
 [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
 rcu_dereference_check() usage!
 [6.394801] 
 other info that might help us debug this:
 

Hi Kirill,

We are dereferencing an RCU pointer with the suspend_lock held which is causing 
this warning.

Can you please check if the following patch helps? Thanks!

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a0ece87..e584e66 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2830,7 +2830,7 @@ static int __dm_suspend(struct mapped_device *md, struct 
dm_table *map,
  */
 int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
 {
-   struct dm_table *map = NULL;
+   struct dm_table *map = rcu_dereference(md-map);
int r = 0;
 
 retry:
@@ -2850,8 +2850,6 @@ retry:
goto retry;
}
 
-   map = rcu_dereference(md-map);
-
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE);
if (r)
goto out_unlock;



 [6.398714] 
 rcu_scheduler_active = 1, debug_locks = 0
 [6.401247] 1 lock held by cryptsetup/159:
 [6.402522]  #0:  (md-suspend_lock/1){+.+...}, at: [8179dd1d] 
 dm_suspend+0x3d/0x140
 [6.403848] 
 stack backtrace:
 [6.406448] CPU: 3 PID: 159 Comm: cryptsetup Not tainted 
 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2
 [6.407726] Hardware name: LENOVO 3460CC6/3460CC6, BIOS G6ET93WW (2.53 ) 
 02/04/2013
 [6.408982]  0001 8800d3ac7c38 81b00bbd 
 0011
 [6.410249]  8800d301a560 8800d3ac7c68 81153be7 
 8800d3928800
 [6.411548]  8800d3928970 8800d3928aa0 0001 
 8800d3ac7ca8
 [6.412780] Call Trace:
 [6.413980]  [81b00bbd] dump_stack+0x4c/0x6e
 [6.415178]  [81153be7] lockdep_rcu_suspicious+0xe7/0x120
 [6.416364]  [8179de1d] dm_suspend+0x13d/0x140
 [6.417535]  [817a2d80] ? table_load+0x340/0x340
 [6.418749]  [817a2f2b] dev_suspend+0x1ab/0x260
 [6.419901]  [817a2d80] ? table_load+0x340/0x340
 [6.421038]  [817a3781] ctl_ioctl+0x251/0x540
 [6.422164]  [812b6415] ? mntput_no_expire+0x5/0x360
 [6.423280]  [817a3a83] dm_ctl_ioctl+0x13/0x20
 [6.424389]  [812a6f98] do_vfs_ioctl+0x308/0x540
 [6.425515]  [81175d2d] ? rcu_read_lock_held+0x6d/0x70
 [6.426601]  [812b324e] ? __fget_light+0xbe/0xd0
 [6.427686]  [812a7251] SyS_ioctl+0x81/0xa0
 [6.428760]  [81b0d6ad] system_call_fastpath+0x16/0x1b
 

--
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 tip/core/rcu 3/9] drivers/md: Use rcu_dereference() for accessing rcu pointer

2014-11-21 Thread Kirill A. Shutemov
On Fri, Nov 21, 2014 at 09:30:36AM -0500, Pranith Kumar wrote:
 On 11/21/2014 08:31 AM, Kirill A. Shutemov wrote:
  On Tue, Oct 28, 2014 at 03:09:56PM -0700, Paul E. McKenney wrote:
  From: Pranith Kumar bobby.pr...@gmail.com
 
  Got Paul's email wrong the first time.
 
  The map field in 'struct mapped_device' is an rcu pointer. Use 
  rcu_dereference()
  while accessing it.
 
  Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
  Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
  
  On current -next I see this:
  
  [6.388264] ===
  [6.389571] [ INFO: suspicious RCU usage. ]
  [6.390869] 3.18.0-rc5-next-20141121-08303-g44cae4530372 #2 Not tainted
  [6.392185] ---
  [6.393479] /home/kas/git/public/linux/drivers/md/dm.c:2853 suspicious 
  rcu_dereference_check() usage!
  [6.394801] 
  other info that might help us debug this:
  
 
 Hi Kirill,
 
 We are dereferencing an RCU pointer with the suspend_lock held which is 
 causing this warning.
 
 Can you please check if the following patch helps? Thanks!

Nope. The same issue.

IIUC, the problem is that you dereference pointer outside rcu_read_lock()
section, not that suspend_lock is held.

-- 
 Kirill A. Shutemov
--
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/