public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: 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: Wed, 22 Nov 2023 15:38:15 +0100	[thread overview]
Message-ID: <20231122143815.GD11264@twin.jikos.cz> (raw)
In-Reply-To: <ffeb6b667a9ff0cf161f7dcd82899114782c0834.1700609426.git.wqu@suse.com>

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

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.

  parent reply	other threads:[~2023-11-22 14:45 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 [this message]
2023-11-22 20:03   ` Qu Wenruo
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=20231122143815.GD11264@twin.jikos.cz \
    --to=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