diff mbox series

btrfs: do not sleep unnecessary on successful batch page allocation

Message ID 1c7f75c138cba65d0af23ad4eda7c1bab1cc21fe.1649666810.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: do not sleep unnecessary on successful batch page allocation | expand

Commit Message

Naohiro Aota April 11, 2022, 9:02 a.m. UTC
After commit 727fd577af04 ("btrfs: wait between incomplete batch memory
allocations"), fstests btrfs/187 becomes incredibly slow. Before the commit
it takes 335 seconds to run the test on 8GB ZRAM device running on QEMU.
But, after that patch, it never finish after 4 hours.

This is because of unnecessary memalloc_retry_wait() call. If
alloc_pages_bulk_array() successfully allocated all the requested pages, it
is no use to call memalloc_retry_wait() to wait for retrying.

I confirmed the test run time back to 353 seconds with this patch applied.

Link: https://lore.kernel.org/linux-btrfs/20220411071124.zwtcarqngqqkdd6q@naota-xeon/
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/extent_io.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nikolay Borisov April 11, 2022, 11:14 a.m. UTC | #1
On 11.04.22 г. 12:02 ч., Naohiro Aota wrote:
> After commit 727fd577af04 ("btrfs: wait between incomplete batch memory
> allocations"), fstests btrfs/187 becomes incredibly slow. Before the commit
> it takes 335 seconds to run the test on 8GB ZRAM device running on QEMU.
> But, after that patch, it never finish after 4 hours.
> 
> This is because of unnecessary memalloc_retry_wait() call. If
> alloc_pages_bulk_array() successfully allocated all the requested pages, it
> is no use to call memalloc_retry_wait() to wait for retrying.
> 
> I confirmed the test run time back to 353 seconds with this patch applied.
> 
> Link: https://lore.kernel.org/linux-btrfs/20220411071124.zwtcarqngqqkdd6q@naota-xeon/
> Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>   fs/btrfs/extent_io.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 1a5a7ded3175..2681a998ee1c 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3150,6 +3150,9 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array)
>   
>   		allocated = alloc_pages_bulk_array(GFP_NOFS, nr_pages, page_array);
>   
> +		if (allocated == nr_pages)
> +			return 0;
> +
>   		/*
>   		 * During this iteration, no page could be allocated, even
>   		 * though alloc_pages_bulk_array() falls back to alloc_page()
David Sterba April 11, 2022, 1:56 p.m. UTC | #2
On Mon, Apr 11, 2022 at 06:02:52PM +0900, Naohiro Aota wrote:
> After commit 727fd577af04 ("btrfs: wait between incomplete batch memory
> allocations"), fstests btrfs/187 becomes incredibly slow. Before the commit
> it takes 335 seconds to run the test on 8GB ZRAM device running on QEMU.
> But, after that patch, it never finish after 4 hours.
> 
> This is because of unnecessary memalloc_retry_wait() call. If
> alloc_pages_bulk_array() successfully allocated all the requested pages, it
> is no use to call memalloc_retry_wait() to wait for retrying.
> 
> I confirmed the test run time back to 353 seconds with this patch applied.

Thanks, I've folded the fixup to the patch.
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 1a5a7ded3175..2681a998ee1c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3150,6 +3150,9 @@  int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array)
 
 		allocated = alloc_pages_bulk_array(GFP_NOFS, nr_pages, page_array);
 
+		if (allocated == nr_pages)
+			return 0;
+
 		/*
 		 * During this iteration, no page could be allocated, even
 		 * though alloc_pages_bulk_array() falls back to alloc_page()