All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06  6:52 ` madhuparnabhowmik10
  0 siblings, 0 replies; 12+ messages in thread
From: madhuparnabhowmik10 @ 2020-03-06  6:52 UTC (permalink / raw)
  To: clm, josef, dsterba
  Cc: linux-btrfs, linux-kernel, joel, linux-kernel-mentees, paulmck,
	frextrite, linux, Madhuparna Bhowmik

From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

The space_info list is rcu protected.
Hence, it should be traversed with rcu_read_lock held.

Warning:
[   29.104591] =============================
[   29.104756] WARNING: suspicious RCU usage
[   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
[   29.105231] -----------------------------
[   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
 fs/btrfs/block-group.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 404e050ce8ee..9cabeef66f5b 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 		btrfs_release_path(path);
 	}
 
+	rcu_read_lock();
 	list_for_each_entry_rcu(space_info, &info->space_info, list) {
 		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
 		      (BTRFS_BLOCK_GROUP_RAID10 |
@@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 				list)
 			inc_block_group_ro(cache, 1);
 	}
-
+	rcu_read_unlock();
+		
 	btrfs_init_global_block_rsv(info);
 	ret = check_chunk_block_group_mappings(info);
 error:
-- 
2.17.1


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

* [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06  6:52 ` madhuparnabhowmik10
  0 siblings, 0 replies; 12+ messages in thread
From: madhuparnabhowmik10 @ 2020-03-06  6:52 UTC (permalink / raw)
  To: clm, josef, dsterba
  Cc: paulmck, linux-kernel, Madhuparna Bhowmik, linux, joel,
	linux-kernel-mentees, linux-btrfs

From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

The space_info list is rcu protected.
Hence, it should be traversed with rcu_read_lock held.

Warning:
[   29.104591] =============================
[   29.104756] WARNING: suspicious RCU usage
[   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
[   29.105231] -----------------------------
[   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
 fs/btrfs/block-group.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 404e050ce8ee..9cabeef66f5b 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 		btrfs_release_path(path);
 	}
 
+	rcu_read_lock();
 	list_for_each_entry_rcu(space_info, &info->space_info, list) {
 		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
 		      (BTRFS_BLOCK_GROUP_RAID10 |
@@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 				list)
 			inc_block_group_ro(cache, 1);
 	}
-
+	rcu_read_unlock();
+		
 	btrfs_init_global_block_rsv(info);
 	ret = check_chunk_block_group_mappings(info);
 error:
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
  2020-03-06  6:52 ` [Linux-kernel-mentees] " madhuparnabhowmik10
@ 2020-03-06  7:16   ` Qu Wenruo
  -1 siblings, 0 replies; 12+ messages in thread
From: Qu Wenruo @ 2020-03-06  7:16 UTC (permalink / raw)
  To: madhuparnabhowmik10, clm, josef, dsterba
  Cc: linux-btrfs, linux-kernel, joel, linux-kernel-mentees, paulmck,
	frextrite, linux


[-- Attachment #1.1: Type: text/plain, Size: 1636 bytes --]



On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> The space_info list is rcu protected.
> Hence, it should be traversed with rcu_read_lock held.
> 
> Warning:
> [   29.104591] =============================
> [   29.104756] WARNING: suspicious RCU usage
> [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> [   29.105231] -----------------------------
> [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
>  fs/btrfs/block-group.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 404e050ce8ee..9cabeef66f5b 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)

This function is only triggered at mount time, where no other rcu
operation can happen.

Thanks,
Qu
>  		btrfs_release_path(path);
>  	}
>  
> +	rcu_read_lock();
>  	list_for_each_entry_rcu(space_info, &info->space_info, list) {
>  		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
>  		      (BTRFS_BLOCK_GROUP_RAID10 |
> @@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
>  				list)
>  			inc_block_group_ro(cache, 1);
>  	}
> -
> +	rcu_read_unlock();
> +		
>  	btrfs_init_global_block_rsv(info);
>  	ret = check_chunk_block_group_mappings(info);
>  error:
> 


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

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

* Re: [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06  7:16   ` Qu Wenruo
  0 siblings, 0 replies; 12+ messages in thread
From: Qu Wenruo @ 2020-03-06  7:16 UTC (permalink / raw)
  To: madhuparnabhowmik10, clm, josef, dsterba
  Cc: paulmck, linux-kernel, linux, joel, linux-kernel-mentees, linux-btrfs


[-- Attachment #1.1.1: Type: text/plain, Size: 1636 bytes --]



On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> The space_info list is rcu protected.
> Hence, it should be traversed with rcu_read_lock held.
> 
> Warning:
> [   29.104591] =============================
> [   29.104756] WARNING: suspicious RCU usage
> [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> [   29.105231] -----------------------------
> [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
>  fs/btrfs/block-group.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 404e050ce8ee..9cabeef66f5b 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)

This function is only triggered at mount time, where no other rcu
operation can happen.

Thanks,
Qu
>  		btrfs_release_path(path);
>  	}
>  
> +	rcu_read_lock();
>  	list_for_each_entry_rcu(space_info, &info->space_info, list) {
>  		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
>  		      (BTRFS_BLOCK_GROUP_RAID10 |
> @@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
>  				list)
>  			inc_block_group_ro(cache, 1);
>  	}
> -
> +	rcu_read_unlock();
> +		
>  	btrfs_init_global_block_rsv(info);
>  	ret = check_chunk_block_group_mappings(info);
>  error:
> 


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

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
  2020-03-06  7:16   ` [Linux-kernel-mentees] " Qu Wenruo
@ 2020-03-06 14:00     ` Madhuparna Bhowmik
  -1 siblings, 0 replies; 12+ messages in thread
From: Madhuparna Bhowmik @ 2020-03-06 14:00 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: madhuparnabhowmik10, clm, josef, dsterba, linux-btrfs,
	linux-kernel, joel, linux-kernel-mentees, paulmck, frextrite,
	linux

On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> 
> 
> On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > 
> > The space_info list is rcu protected.
> > Hence, it should be traversed with rcu_read_lock held.
> > 
> > Warning:
> > [   29.104591] =============================
> > [   29.104756] WARNING: suspicious RCU usage
> > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > [   29.105231] -----------------------------
> > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > 
> > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > ---
> >  fs/btrfs/block-group.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > index 404e050ce8ee..9cabeef66f5b 100644
> > --- a/fs/btrfs/block-group.c
> > +++ b/fs/btrfs/block-group.c
> > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> 
> This function is only triggered at mount time, where no other rcu
> operation can happen.
>
Thanks Qu.

Joel and Paul, what should we do in this case?
Should we just pass cond = true or use list_for_each_entry instead?

Thank you,
Madhuparna

> Thanks,
> Qu
> >  		btrfs_release_path(path);
> >  	}
> >  
> > +	rcu_read_lock();
> >  	list_for_each_entry_rcu(space_info, &info->space_info, list) {
> >  		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
> >  		      (BTRFS_BLOCK_GROUP_RAID10 |
> > @@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> >  				list)
> >  			inc_block_group_ro(cache, 1);
> >  	}
> > -
> > +	rcu_read_unlock();
> > +		
> >  	btrfs_init_global_block_rsv(info);
> >  	ret = check_chunk_block_group_mappings(info);
> >  error:
> > 
> 




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

* Re: [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06 14:00     ` Madhuparna Bhowmik
  0 siblings, 0 replies; 12+ messages in thread
From: Madhuparna Bhowmik @ 2020-03-06 14:00 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: paulmck, clm, linux-kernel, joel, josef, madhuparnabhowmik10,
	linux, dsterba, linux-kernel-mentees, linux-btrfs

On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> 
> 
> On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > 
> > The space_info list is rcu protected.
> > Hence, it should be traversed with rcu_read_lock held.
> > 
> > Warning:
> > [   29.104591] =============================
> > [   29.104756] WARNING: suspicious RCU usage
> > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > [   29.105231] -----------------------------
> > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > 
> > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > ---
> >  fs/btrfs/block-group.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > index 404e050ce8ee..9cabeef66f5b 100644
> > --- a/fs/btrfs/block-group.c
> > +++ b/fs/btrfs/block-group.c
> > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> 
> This function is only triggered at mount time, where no other rcu
> operation can happen.
>
Thanks Qu.

Joel and Paul, what should we do in this case?
Should we just pass cond = true or use list_for_each_entry instead?

Thank you,
Madhuparna

> Thanks,
> Qu
> >  		btrfs_release_path(path);
> >  	}
> >  
> > +	rcu_read_lock();
> >  	list_for_each_entry_rcu(space_info, &info->space_info, list) {
> >  		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
> >  		      (BTRFS_BLOCK_GROUP_RAID10 |
> > @@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> >  				list)
> >  			inc_block_group_ro(cache, 1);
> >  	}
> > -
> > +	rcu_read_unlock();
> > +		
> >  	btrfs_init_global_block_rsv(info);
> >  	ret = check_chunk_block_group_mappings(info);
> >  error:
> > 
> 



_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
  2020-03-06 14:00     ` [Linux-kernel-mentees] " Madhuparna Bhowmik
@ 2020-03-06 15:25       ` David Sterba
  -1 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2020-03-06 15:25 UTC (permalink / raw)
  To: Madhuparna Bhowmik
  Cc: Qu Wenruo, clm, josef, dsterba, linux-btrfs, linux-kernel, joel,
	linux-kernel-mentees, paulmck, frextrite, linux

On Fri, Mar 06, 2020 at 07:30:24PM +0530, Madhuparna Bhowmik wrote:
> On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> > 
> > 
> > On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > 
> > > The space_info list is rcu protected.
> > > Hence, it should be traversed with rcu_read_lock held.
> > > 
> > > Warning:
> > > [   29.104591] =============================
> > > [   29.104756] WARNING: suspicious RCU usage
> > > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > > [   29.105231] -----------------------------
> > > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > > 
> > > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > ---
> > >  fs/btrfs/block-group.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > > index 404e050ce8ee..9cabeef66f5b 100644
> > > --- a/fs/btrfs/block-group.c
> > > +++ b/fs/btrfs/block-group.c
> > > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> > 
> > This function is only triggered at mount time, where no other rcu
> > operation can happen.
> >
> Thanks Qu.
> 
> Joel and Paul, what should we do in this case?
> Should we just pass cond = true or use list_for_each_entry instead?

I think we can afford to add rcu lock/unlock, even if it's not strictly
necessary due to the single threaded context where the function is run.
There are some lightweight operations inside and inc_block_group starts
with two spin locks so there's nothing we'd be losing with disabled
preemption from the caller.

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

* Re: [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06 15:25       ` David Sterba
  0 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2020-03-06 15:25 UTC (permalink / raw)
  To: Madhuparna Bhowmik
  Cc: joel, paulmck, josef, Qu Wenruo, linux-kernel, clm, linux,
	dsterba, linux-kernel-mentees, linux-btrfs

On Fri, Mar 06, 2020 at 07:30:24PM +0530, Madhuparna Bhowmik wrote:
> On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> > 
> > 
> > On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > 
> > > The space_info list is rcu protected.
> > > Hence, it should be traversed with rcu_read_lock held.
> > > 
> > > Warning:
> > > [   29.104591] =============================
> > > [   29.104756] WARNING: suspicious RCU usage
> > > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > > [   29.105231] -----------------------------
> > > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > > 
> > > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > ---
> > >  fs/btrfs/block-group.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > > index 404e050ce8ee..9cabeef66f5b 100644
> > > --- a/fs/btrfs/block-group.c
> > > +++ b/fs/btrfs/block-group.c
> > > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> > 
> > This function is only triggered at mount time, where no other rcu
> > operation can happen.
> >
> Thanks Qu.
> 
> Joel and Paul, what should we do in this case?
> Should we just pass cond = true or use list_for_each_entry instead?

I think we can afford to add rcu lock/unlock, even if it's not strictly
necessary due to the single threaded context where the function is run.
There are some lightweight operations inside and inc_block_group starts
with two spin locks so there's nothing we'd be losing with disabled
preemption from the caller.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
  2020-03-06  6:52 ` [Linux-kernel-mentees] " madhuparnabhowmik10
@ 2020-03-06 19:37   ` David Sterba
  -1 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2020-03-06 19:37 UTC (permalink / raw)
  To: madhuparnabhowmik10
  Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, joel,
	linux-kernel-mentees, paulmck, frextrite, linux

On Fri, Mar 06, 2020 at 12:22:43PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> The space_info list is rcu protected.
> Hence, it should be traversed with rcu_read_lock held.
> 
> Warning:
> [   29.104591] =============================
> [   29.104756] WARNING: suspicious RCU usage
> [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> [   29.105231] -----------------------------
> [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

I've updated the changelog based on comments from the mail thread and
applied the patch. Thanks.

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

* Re: [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06 19:37   ` David Sterba
  0 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2020-03-06 19:37 UTC (permalink / raw)
  To: madhuparnabhowmik10
  Cc: paulmck, josef, joel, linux-kernel, clm, linux, dsterba,
	linux-kernel-mentees, linux-btrfs

On Fri, Mar 06, 2020 at 12:22:43PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> The space_info list is rcu protected.
> Hence, it should be traversed with rcu_read_lock held.
> 
> Warning:
> [   29.104591] =============================
> [   29.104756] WARNING: suspicious RCU usage
> [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> [   29.105231] -----------------------------
> [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

I've updated the changelog based on comments from the mail thread and
applied the patch. Thanks.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
  2020-03-06 15:25       ` [Linux-kernel-mentees] " David Sterba
@ 2020-03-06 19:53         ` Joel Fernandes
  -1 siblings, 0 replies; 12+ messages in thread
From: Joel Fernandes @ 2020-03-06 19:53 UTC (permalink / raw)
  To: dsterba, Madhuparna Bhowmik, Qu Wenruo, clm, josef, dsterba,
	linux-btrfs, linux-kernel, linux-kernel-mentees, paulmck,
	frextrite, linux

On Fri, Mar 06, 2020 at 04:25:27PM +0100, David Sterba wrote:
> On Fri, Mar 06, 2020 at 07:30:24PM +0530, Madhuparna Bhowmik wrote:
> > On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> > > 
> > > 
> > > On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > > > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > > 
> > > > The space_info list is rcu protected.
> > > > Hence, it should be traversed with rcu_read_lock held.
> > > > 
> > > > Warning:
> > > > [   29.104591] =============================
> > > > [   29.104756] WARNING: suspicious RCU usage
> > > > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > > > [   29.105231] -----------------------------
> > > > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > > > 
> > > > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > > > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > > ---
> > > >  fs/btrfs/block-group.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > > > index 404e050ce8ee..9cabeef66f5b 100644
> > > > --- a/fs/btrfs/block-group.c
> > > > +++ b/fs/btrfs/block-group.c
> > > > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> > > 
> > > This function is only triggered at mount time, where no other rcu
> > > operation can happen.
> > >
> > Thanks Qu.
> > 
> > Joel and Paul, what should we do in this case?
> > Should we just pass cond = true or use list_for_each_entry instead?
> 
> I think we can afford to add rcu lock/unlock, even if it's not strictly
> necessary due to the single threaded context where the function is run.
> There are some lightweight operations inside and inc_block_group starts
> with two spin locks so there's nothing we'd be losing with disabled
> preemption from the caller.

I think use list_for_each_entry().

thanks,

 - Joel


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

* Re: [Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning
@ 2020-03-06 19:53         ` Joel Fernandes
  0 siblings, 0 replies; 12+ messages in thread
From: Joel Fernandes @ 2020-03-06 19:53 UTC (permalink / raw)
  To: dsterba, Madhuparna Bhowmik, Qu Wenruo, clm, josef, dsterba,
	linux-btrfs, linux-kernel, linux-kernel-mentees, paulmck,
	frextrite, linux

On Fri, Mar 06, 2020 at 04:25:27PM +0100, David Sterba wrote:
> On Fri, Mar 06, 2020 at 07:30:24PM +0530, Madhuparna Bhowmik wrote:
> > On Fri, Mar 06, 2020 at 03:16:53PM +0800, Qu Wenruo wrote:
> > > 
> > > 
> > > On 2020/3/6 下午2:52, madhuparnabhowmik10@gmail.com wrote:
> > > > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > > 
> > > > The space_info list is rcu protected.
> > > > Hence, it should be traversed with rcu_read_lock held.
> > > > 
> > > > Warning:
> > > > [   29.104591] =============================
> > > > [   29.104756] WARNING: suspicious RCU usage
> > > > [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> > > > [   29.105231] -----------------------------
> > > > [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> > > > 
> > > > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > > > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > > > ---
> > > >  fs/btrfs/block-group.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> > > > index 404e050ce8ee..9cabeef66f5b 100644
> > > > --- a/fs/btrfs/block-group.c
> > > > +++ b/fs/btrfs/block-group.c
> > > > @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
> > > 
> > > This function is only triggered at mount time, where no other rcu
> > > operation can happen.
> > >
> > Thanks Qu.
> > 
> > Joel and Paul, what should we do in this case?
> > Should we just pass cond = true or use list_for_each_entry instead?
> 
> I think we can afford to add rcu lock/unlock, even if it's not strictly
> necessary due to the single threaded context where the function is run.
> There are some lightweight operations inside and inc_block_group starts
> with two spin locks so there's nothing we'd be losing with disabled
> preemption from the caller.

I think use list_for_each_entry().

thanks,

 - Joel

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2020-03-06 20:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-06  6:52 [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning madhuparnabhowmik10
2020-03-06  6:52 ` [Linux-kernel-mentees] " madhuparnabhowmik10
2020-03-06  7:16 ` Qu Wenruo
2020-03-06  7:16   ` [Linux-kernel-mentees] " Qu Wenruo
2020-03-06 14:00   ` Madhuparna Bhowmik
2020-03-06 14:00     ` [Linux-kernel-mentees] " Madhuparna Bhowmik
2020-03-06 15:25     ` David Sterba
2020-03-06 15:25       ` [Linux-kernel-mentees] " David Sterba
2020-03-06 19:53       ` Joel Fernandes
2020-03-06 19:53         ` [Linux-kernel-mentees] " Joel Fernandes
2020-03-06 19:37 ` David Sterba
2020-03-06 19:37   ` [Linux-kernel-mentees] " David Sterba

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.