Re: [PATCH] mm: madvise: drop MADV_PAGEOUT folios at swap writeback completion

From: David Hildenbrand (Arm)

Date: Tue Sep 22 2026 - 06:56:51 EST


On 9/21/26 23:56, Barry Song wrote:
> On Mon, Sep 21, 2026 at 11:37 PM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
>>
>> On 9/21/26 17:24, Alexandre Ghiti wrote:
>>> On an asynchronous swap device MADV_PAGEOUT only marks the folio
>>> PG_reclaim and rotates it to the tail of the inactive list once its
>>> writeback completes, so the memory is not actually freed until a later
>>> reclaim scan removes the by then clean swap cache folio.
>> But we have the same behavior when just reclaiming memory ordinarily? It's added
>> to the swapcache and only the next scan actually frees up the memory.
>>
>> Wouldn't we memory we reclaim ... just gone, like in the sync case?
>
> For synchronous I/O, such as zswap and zram, the memory is released
> immediately after sync I/O is done.
>
> For asynchronous I/O, such as NVMe, the swapcache is currently
> expected to be rotated back to the tail of the LRU and wait for
> another scan. Alexandre once mentioned that when he tried handling
> async I/O the same way as sync I/O—releasing the memory once the I/O
> completed—he saw some regression. So, delaying the release until a
> later scan may allow swapcache hits before the folios are eventually
> reclaimed.

"may", do we have any evidence that this actually is relevant in practice?

We asked to reclaim memory. We wrote the memory out to disk. We unmapped it from
the page tables. We made the workload the could, access the page immediately
again suffer already.

We should just evict them as soon as possible to free up memory.

--
Cheers,

David