public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: refactor alloc_extent_buffer() to allocate-then-attach method
Date: Thu, 23 Nov 2023 06:33:57 +1030	[thread overview]
Message-ID: <71d723c9-8f36-4fd1-bea7-7d962da465e2@gmx.com> (raw)
In-Reply-To: <20231122143815.GD11264@twin.jikos.cz>



On 2023/11/23 01:08, David Sterba wrote:
> On Wed, Nov 22, 2023 at 10:05:04AM +1030, Qu Wenruo wrote:
>> -	for (i = 0; i < num_pages; i++, index++) {
>> -		p = find_or_create_page(mapping, index, GFP_NOFS|__GFP_NOFAIL);
>> -		if (!p) {
>> -			exists = ERR_PTR(-ENOMEM);
>> -			btrfs_free_subpage(prealloc);
>> -			goto free_eb;
>> +	/* Alloc all pages. */
>> +	ret = btrfs_alloc_page_array(num_pages, eb->pages);
>
> This looks promising.  Assuming everything else works, this can be
> changed to do:
>
> - alloc_pages(order), the optimistic fast path, contig pages right from
>    the allocator, can fail
> - fall back to btrfs_alloc_page_array(), this fills the array with
>    order-0 pages, similar what we have now, they could be contiguous

Yep, that's the next step planned.

Although I'd prefer to fully migrate to folio interfaces, e.g.
eb::pages[] -> eb::folios[]

But that's not really a big deal considering under most cases
folio/pages are interchangeable.

>
> I wonder if we still can keep the __GFP_NOFAIL for the fallback
> allocation, it's there right now and seems to work on sysmtems under
> stress and does not cause random failures due to ENOMEM.
>
Oh, I forgot the __NOFAIL gfp flags, that's not hard to fix, just
re-introduce the gfp flags to btrfs_alloc_page_array().

Thanks,
Qu

  reply	other threads:[~2023-11-22 20:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21 23:35 [PATCH] btrfs: refactor alloc_extent_buffer() to allocate-then-attach method Qu Wenruo
2023-11-22 14:14 ` Josef Bacik
2023-11-22 20:00   ` Qu Wenruo
2023-11-27 16:28     ` Josef Bacik
2023-11-27 22:17       ` Qu Wenruo
2023-11-22 14:38 ` David Sterba
2023-11-22 20:03   ` Qu Wenruo [this message]
2023-11-27  5:10     ` Should we still go __GFP_NOFAIL? (Was Re: [PATCH] btrfs: refactor alloc_extent_buffer() to allocate-then-attach method) Qu Wenruo
2023-11-27 16:19       ` Josef Bacik
2023-11-28 16:26       ` David Sterba
2023-11-28 20:06         ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71d723c9-8f36-4fd1-bea7-7d962da465e2@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox