mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Kairui Song <ryncsn@gmail.com>
Cc: Barry Song <baohua@kernel.org>, Alexandre Ghiti <alex@ghiti.fr>,
	akpm@linux-foundation.org, willy@infradead.org, jack@suse.cz,
	liam@infradead.org, ljs@kernel.org, vbabka@kernel.org,
	jannh@google.com, chrisl@kernel.org, shikemeng@huaweicloud.com,
	nphamcs@gmail.com, baoquan.he@linux.dev, youngjun.park@lge.com,
	qi.zheng@linux.dev, shakeel.butt@linux.dev,
	axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
	hannes@cmpxchg.org, mhocko@kernel.org, yosry@kernel.org,
	chengming.zhou@linux.dev, kunwu.chan@gmail.com,
	tz2294@columbia.edu, hch@lst.de, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: madvise: drop MADV_PAGEOUT folios at swap writeback completion
Date: Wed, 23 Sep 2026 11:46:55 +0200	[thread overview]
Message-ID: <d9a77381-cf88-4726-9223-c16a5c6608c2@kernel.org> (raw)
In-Reply-To: <CAMgjq7DeYsJxG_VCf2KnViV5nd10m-PPYzXRD1fi8QcGWwD0qw@mail.gmail.com>

On 9/23/26 11:35, Kairui Song wrote:
> On Wed, Sep 23, 2026 at 10:46 AM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 9/22/26 22:55, Barry Song wrote:
>>> On Tue, Sep 22, 2026 at 7:26 PM David Hildenbrand (Arm)
>>> <david@kernel.org> wrote:
>>>
>>> I guess that's because the LRU is not always accurate. There are cases
>>> where our prediction of future access patterns may be wrong, resulting
>>> in refaults?
> 
> Hi All,
> 
>>
>> Right. But these would happen in both the SYNC and the ASYNC case. Which seems
>> to indicate that making the SYNC case behave like the ASYNC case (keep in
>> swapcache before evicting) could actually improve performance?
>>
>> Or is the SYNC case in general so fast that it is not a problem and the
>> swapcache is just not a good use?
> 
> I think the problem is not LRU being inaccurate, but ASYNC case could
> overshoot the anon reclaim very easily. File folios can be simply
> dropped, and increase nr_reclaimed, but anon writeback (swap) can't be
> done durig the reclaim iteration so nr_reclaimed never increase during
> the scan iteration. So the scan tries hard to scan and reclaim more
> anon folios, more than it really needed.
> 
> I think the real fix is some kind of different watermark, throttling,
> or a different counter to limit the scan of async swap. I mentioned
> this at LSFMM this year but I guess I presented too much at the same
> time so few people remembered it :D.

:D

> 
>>
>>>
>>> Even on Android, which uses zram with very fast synchronous swap-out,
>>> I can still hit the swapcache from time to time. So perhaps with a
>>> slower device, such as an HDD, keeping the swapcache around for longer
>>> could allow applications to hit it more often?
>>
>> Why is that specific for HDD? It's the exact same app behavior independent of
>> the underlying swap technology.
> 
> If you have a shared folio, you must use swap cache, and even for
> single used folios swap cache is the way to do synchronization,
> regardless of the device.
> 
>>>
>>> I don't know. Maybe Alexandre can share more details about this
>>> benchmark. I'm also a little surprised by the 15% regression in
>>> Sysbench OLTP. My initial feeling was the same as yours: we should
>>> release the memory immediately after writeback completes, for both
>>> synchronous and asynchronous I/O.
>>
>> Right. And see if we can identify why we are swapping out the wrong things :)
> 
> I think we are not? It's about over-reclaim. In the worst case we
> might put every anon folio under writeback, while no folio is
> reclaimed, if the device is super slow.
Ah, that hints at the real problem then? How confident are we that that's what's
happening?

-- 
Cheers,

David

  reply	other threads:[~2026-09-23  9:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 15:24 Alexandre Ghiti
2026-09-21 15:37 ` David Hildenbrand (Arm)
2026-09-21 21:56   ` Barry Song
2026-09-22  8:56     ` Kairui Song
2026-09-22 10:20     ` David Hildenbrand (Arm)
2026-09-22 10:37       ` Barry Song
2026-09-22 10:47         ` Lorenzo Stoakes (ARM)
2026-09-22 11:10           ` Barry Song
2026-09-22 11:15             ` Lorenzo Stoakes (ARM)
2026-09-22 11:36               ` Barry Song
2026-09-22 11:26         ` David Hildenbrand (Arm)
2026-09-22 20:55           ` Barry Song
2026-09-23  8:44             ` David Hildenbrand (Arm)
2026-09-23  9:35               ` Kairui Song
2026-09-23  9:46                 ` David Hildenbrand (Arm) [this message]
2026-09-23 10:14                   ` Kairui Song
2026-09-23 16:21                     ` KunWu Chan
2026-09-24  9:19                       ` Alexandre Ghiti
2026-09-24  9:10                   ` Alexandre Ghiti
2026-09-22 10:44 ` Lorenzo Stoakes (ARM)
2026-09-22 13:22   ` Alexandre Ghiti
2026-09-22 15:22   ` Gregory Price

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=d9a77381-cf88-4726-9223-c16a5c6608c2@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=kunwu.chan@gmail.com \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=ryncsn@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=tz2294@columbia.edu \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=willy@infradead.org \
    --cc=yosry@kernel.org \
    --cc=youngjun.park@lge.com \
    --cc=yuanchu@google.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

all inboxes | Powered by JetHome®