From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Matthew Wilcox <willy@infradead.org>,
Salvatore Dipietro <dipiets@amazon.it>
Cc: linux-kernel@vger.kernel.org, alisaidi@amazon.com,
blakgeof@amazon.com, abuehaze@amazon.de,
dipietro.salvatore@gmail.com, stable@vger.kernel.org,
Christian Brauner <brauner@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH 1/1] iomap: avoid compaction for costly folio order allocation
Date: Thu, 16 Apr 2026 20:44:05 +0530 [thread overview]
Message-ID: <ldenszsy.ritesh.list@gmail.com> (raw)
In-Reply-To: <5x66n04a.ritesh.list@gmail.com>
Ritesh Harjani (IBM) <ritesh.list@gmail.com> writes:
> Matthew Wilcox <willy@infradead.org> writes:
>
>> On Fri, Apr 03, 2026 at 07:35:34PM +0000, Salvatore Dipietro wrote:
>>> Commit 5d8edfb900d5 ("iomap: Copy larger chunks from userspace")
>>> introduced high-order folio allocations in the buffered write
>>> path. When memory is fragmented, each failed allocation triggers
>>> compaction and drain_all_pages() via __alloc_pages_slowpath(),
>>> causing a 0.75x throughput drop on pgbench (simple-update) with
>>> 1024 clients on a 96-vCPU arm64 system.
>>>
>>> Strip __GFP_DIRECT_RECLAIM from folio allocations in
>>> iomap_get_folio() when the order exceeds PAGE_ALLOC_COSTLY_ORDER,
>>> making them purely opportunistic.
>>
>> If you look at __filemap_get_folio_mpol(), that's kind of being tried
>> already:
>>
>> if (order > min_order)
>> alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN;
>>
>> * %__GFP_NORETRY: The VM implementation will try only very lightweight
>> * memory direct reclaim to get some memory under memory pressure (thus
>> * it can sleep). It will avoid disruptive actions like OOM killer. The
>> * caller must handle the failure which is quite likely to happen under
>> * heavy memory pressure. The flag is suitable when failure can easily be
>> * handled at small cost, such as reduced throughput.
>>
>> which, from the description, seemed like the right approach. So either
>> the description or the implementation should be updated, I suppose?
>>
>> Now, what happens if you change those two lines to:
>>
>> if (order > min_order) {
>> alloc_gfp &= ~__GFP_DIRECT_RECLAIM;
>> alloc_gfp |= __GFP_NOWARN;
>> }
>
> Hi Matthew,
>
> Shouldn't we try this instead? This would still allows us to keep
> __GFP_NORETRY and hence light weight direct reclaim/compaction for
> atleast the non-costly order allocations, right?
>
> if (order > min_order) {
> alloc_gfp |= __GFP_NOWARN;
> if (order > PAGE_ALLOC_COSTLY_ORDER)
> alloc_gfp &= ~__GFP_DIRECT_RECLAIM;
> else
> alloc_gfp |= __GFP_NORETRY;
> }
>
Hi Salvatore,
Did you get a chance to test the above two options (shared by Matthew
and me)? And were you able to recover the performance back with those?
So, in a longer run, as Dave suggested, we might need to fix this by
maybe considering removing compaction in the direct reclaim path. But I
guess for fixing it in older kernel releases, we might need a quick fix
,so maybe worth trying the above suggested changes, perhaps.
Also, I am somehow not able to hit this problem at my end (even after
creating a bit of memory fragmentation). So please also feel free to
share the steps, if you have a setup to re-create it easily.
-ritesh
prev parent reply other threads:[~2026-04-17 1:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260403193535.9970-1-dipiets@amazon.it>
[not found] ` <20260403193535.9970-2-dipiets@amazon.it>
2026-04-04 1:13 ` Ritesh Harjani
2026-04-04 4:15 ` Matthew Wilcox
2026-04-04 16:47 ` Ritesh Harjani
2026-04-04 20:46 ` Matthew Wilcox
2026-04-16 15:14 ` Ritesh Harjani [this message]
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=ldenszsy.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=abuehaze@amazon.de \
--cc=alisaidi@amazon.com \
--cc=blakgeof@amazon.com \
--cc=brauner@kernel.org \
--cc=dipietro.salvatore@gmail.com \
--cc=dipiets@amazon.it \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=willy@infradead.org \
/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