All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: limit thread pool size when remounting
@ 2012-09-25  6:48 Liu Bo
  2012-09-25 11:39 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Bo @ 2012-09-25  6:48 UTC (permalink / raw)
  To: linux-btrfs

For some asynchronous threads, such as submit worker and cache worker, we
limit their thread pool size when mounting.

So we also need to do such things when remounting.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/super.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 83d6f9f..a58e834 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1158,17 +1158,20 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
 	printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n",
 	       old_pool_size, new_pool_size);
 
-	btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
+	btrfs_set_max_workers(&fs_info->generic_worker, min(1, new_pool_size));
 	btrfs_set_max_workers(&fs_info->workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
-	btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
-	btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
-	btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
+	btrfs_set_max_workers(&fs_info->submit_workers,
+			      min_t(u64, fs_info->fs_devices->num_devices,
+			      new_pool_size));
+	btrfs_set_max_workers(&fs_info->caching_workers, min(2, new_pool_size));
+	btrfs_set_max_workers(&fs_info->fixup_workers, min(1, new_pool_size));
 	btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size);
-	btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size);
+	btrfs_set_max_workers(&fs_info->endio_freespace_worker,
+			      min(1, new_pool_size));
 	btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size);
 	btrfs_set_max_workers(&fs_info->scrub_workers, new_pool_size);
-- 
1.7.7.6


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

* Re: [PATCH] Btrfs: limit thread pool size when remounting
  2012-09-25  6:48 [PATCH] Btrfs: limit thread pool size when remounting Liu Bo
@ 2012-09-25 11:39 ` David Sterba
  2012-09-25 12:07   ` Liu Bo
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2012-09-25 11:39 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Tue, Sep 25, 2012 at 02:48:33PM +0800, Liu Bo wrote:
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1158,17 +1158,20 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
>  	printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n",
>  	       old_pool_size, new_pool_size);
>  
> -	btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
> +	btrfs_set_max_workers(&fs_info->generic_worker, min(1, new_pool_size));

How could new_pool_size be < 1 ?

There's a check in super.c to pick only values > 0

>  	btrfs_set_max_workers(&fs_info->workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
> -	btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
> -	btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
> -	btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
> +	btrfs_set_max_workers(&fs_info->submit_workers,
> +			      min_t(u64, fs_info->fs_devices->num_devices,
> +			      new_pool_size));

This ask for update also when a new device is added/removed.

> +	btrfs_set_max_workers(&fs_info->caching_workers, min(2, new_pool_size));
> +	btrfs_set_max_workers(&fs_info->fixup_workers, min(1, new_pool_size));

Same as above, is it expected to be < 1 ?

>  	btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size);
> -	btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size);
> +	btrfs_set_max_workers(&fs_info->endio_freespace_worker,
> +			      min(1, new_pool_size));

Not sure, do we actually need more than 1 free space worker?

>  	btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size);
>  	btrfs_set_max_workers(&fs_info->scrub_workers, new_pool_size);

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

* Re: [PATCH] Btrfs: limit thread pool size when remounting
  2012-09-25 11:39 ` David Sterba
@ 2012-09-25 12:07   ` Liu Bo
  2012-09-25 12:50     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Bo @ 2012-09-25 12:07 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On 09/25/2012 07:39 PM, David Sterba wrote:
> On Tue, Sep 25, 2012 at 02:48:33PM +0800, Liu Bo wrote:
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -1158,17 +1158,20 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
>>  	printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n",
>>  	       old_pool_size, new_pool_size);
>>  
>> -	btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
>> +	btrfs_set_max_workers(&fs_info->generic_worker, min(1, new_pool_size));
> 
> How could new_pool_size be < 1 ?
> 
> There's a check in super.c to pick only values > 0
> 

I think we just need only 1 generic_worker

>>  	btrfs_set_max_workers(&fs_info->workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
>> -	btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
>> -	btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
>> -	btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
>> +	btrfs_set_max_workers(&fs_info->submit_workers,
>> +			      min_t(u64, fs_info->fs_devices->num_devices,
>> +			      new_pool_size));
> 
> This ask for update also when a new device is added/removed.
> 

Oh, yes, but we should do it in another new patch instead.

>> +	btrfs_set_max_workers(&fs_info->caching_workers, min(2, new_pool_size));
>> +	btrfs_set_max_workers(&fs_info->fixup_workers, min(1, new_pool_size));
> 
> Same as above, is it expected to be < 1 ?
> 
>>  	btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size);
>> -	btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size);
>> +	btrfs_set_max_workers(&fs_info->endio_freespace_worker,
>> +			      min(1, new_pool_size));
> 
> Not sure, do we actually need more than 1 free space worker?
> 

Same as generic_worker and fixup_workers, I think only one is enough, that' why I make
the minimum limitation, or we can set it as 1 directly.


thanks,
liubo

>>  	btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size);
>>  	btrfs_set_max_workers(&fs_info->scrub_workers, new_pool_size);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH] Btrfs: limit thread pool size when remounting
  2012-09-25 12:07   ` Liu Bo
@ 2012-09-25 12:50     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2012-09-25 12:50 UTC (permalink / raw)
  To: Liu Bo; +Cc: David Sterba, linux-btrfs

On Tue, Sep 25, 2012 at 08:07:00PM +0800, Liu Bo wrote:
> On 09/25/2012 07:39 PM, David Sterba wrote:
> > On Tue, Sep 25, 2012 at 02:48:33PM +0800, Liu Bo wrote:
> >> --- a/fs/btrfs/super.c
> >> +++ b/fs/btrfs/super.c
> >> @@ -1158,17 +1158,20 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
> >>  	printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n",
> >>  	       old_pool_size, new_pool_size);
> >>  
> >> -	btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
> >> +	btrfs_set_max_workers(&fs_info->generic_worker, min(1, new_pool_size));
> > 
> > How could new_pool_size be < 1 ?
> > 
> > There's a check in super.c to pick only values > 0
> 
> I think we just need only 1 generic_worker

I got it reversed, sorry for the noise.

> >>  	btrfs_set_max_workers(&fs_info->workers, new_pool_size);
> >>  	btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
> >> -	btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
> >> -	btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
> >> -	btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
> >> +	btrfs_set_max_workers(&fs_info->submit_workers,
> >> +			      min_t(u64, fs_info->fs_devices->num_devices,
> >> +			      new_pool_size));
> > 
> > This ask for update also when a new device is added/removed.
> > 
> 
> Oh, yes, but we should do it in another new patch instead.

Yes, this was just a hint to pair the remount/thread_pool capabilities.

david

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

end of thread, other threads:[~2012-09-25 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-25  6:48 [PATCH] Btrfs: limit thread pool size when remounting Liu Bo
2012-09-25 11:39 ` David Sterba
2012-09-25 12:07   ` Liu Bo
2012-09-25 12:50     ` 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.