mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhang Peng <zippermonkey@icloud.com>
To: david@kernel.org
Cc: akpm@linux-foundation.org, axelrasmussen@google.com,
	baohua@kernel.org, bruzzhang@tencent.com, hannes@cmpxchg.org,
	kasong@tencent.com, liam@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org,
	mhocko@kernel.org, mhocko@suse.com, qi.zheng@linux.dev,
	rppt@kernel.org, shakeel.butt@linux.dev, surenb@google.com,
	vbabka@kernel.org, weixugc@google.com, yuanchu@google.com,
	zippermonkey@icloud.com
Subject: Re: [PATCH v4 5/5] mm/vmscan: flush TLB for every 31 folios evictions
Date: Mon, 29 Jun 2026 00:11:27 +0800	[thread overview]
Message-ID: <57110a3c-8c09-4f13-b6fa-903155af2a74@icloud.com> (raw)
In-Reply-To: <0ea1abc4-ff2c-4070-8bfa-67f6892aaca7@kernel.org>

On Wed, Jun 17, 2026 at 02:47:36PM +0200, David Hildenbrand wrote:
 > Two tabs. But this is starting to look a bit messy. Could a helper
 > struct be used to reduce the parameter count to something readable?

Yeah, 7 args is too many.  For v5 I'll bundle the plumbing into a
small struct.

 > That looks rather hacky. You reinit the batch to then traverse the
 > batch? There must be a cleaner way.

It works because reinit only zeros ->nr and ->i, the folios[] array
stays intact — saved count lets you walk it while folio_batch_add()
rebuilds.  But I agree it's too subtle. Maybe I will use a local temp
array insteand.

 > Took me a second to understand why exactly you test for these
 > properties. Can you add a comment how these check here mimic what
 > we checked earlier, before dropping the lock?

Will do.  The three checks correspond to what shrink_folio_list() did
before the unlock: writeback may have started, swapin may have
remapped the folio, a GUP may have pinned it.  Anything that fails
goes back via ret_folios.

 > So, IIUC, what could have happened after dropping the folio lock is
 > that someone would have remapped the folio to user space?
 >
 > Either from the pagecache or from the swap PTE -> swapcache.
 >
 > From there, it could have gotten pinned through the page tables.
 >
 > Is that correct?

Yes, exactly.  A swapin (or a page cache lookup for file-backed)
can find the folio while it's unlocked, remap it into some process's
page tables, and from there a GUP — O_DIRECT, vmsplice, RDMA, etc. —
can pin it.  That's precisely why pageout_batch() rechecks mapped
and dma_pinned before doing the TLB flush and writeout.  Any folio
that got remapped or pinned in the window goes back via ret_folios
instead.

 > What would happen if page migration finds the folio, locks it and
 > wants to migrate it?

Migration can't find it.  The folio is off the LRU (isolated) and
out of page tables (unmapped) — migration's two entry points.
Compaction walks PFNs but skips !PageLRU pages.NUMA hinting faults
walk page tables and won't find a folio with no PTEs.


  reply	other threads:[~2026-06-28 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25 14:57 [PATCH v4 0/5] mm: batch TLB flushing for dirty folios in vmscan Zhang Peng
2026-05-25 14:57 ` [PATCH v4 1/5] mm/vmscan: introduce folio_activate_locked() helper Zhang Peng
2026-06-17 11:59   ` David Hildenbrand (Arm)
2026-06-28 16:09     ` Zhang Peng
2026-05-25 14:57 ` [PATCH v4 2/5] mm/vmscan: extract folio_free() from shrink_folio_list() Zhang Peng
2026-06-17 12:17   ` David Hildenbrand (Arm)
2026-06-17 12:24     ` David Hildenbrand (Arm)
2026-06-28 16:09     ` Zhang Peng
2026-05-25 14:57 ` [PATCH v4 3/5] mm/vmscan: extract pageout_one() " Zhang Peng
2026-06-17 12:19   ` David Hildenbrand (Arm)
2026-06-17 12:25     ` David Hildenbrand (Arm)
2026-06-28 16:10     ` Zhang Peng
2026-05-25 14:57 ` [PATCH v4 4/5] mm/vmscan: extract folio unmap logic into folio_try_unmap() Zhang Peng
2026-06-17 12:28   ` David Hildenbrand (Arm)
2026-06-28 16:10     ` Zhang Peng
2026-05-25 14:57 ` [PATCH v4 5/5] mm/vmscan: flush TLB for every 31 folios evictions Zhang Peng
2026-06-17 12:47   ` David Hildenbrand (Arm)
2026-06-28 16:11     ` Zhang Peng [this message]
2026-05-25 18:58 ` [PATCH v4 0/5] mm: batch TLB flushing for dirty folios in vmscan Andrew Morton

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=57110a3c-8c09-4f13-b6fa-903155af2a74@icloud.com \
    --to=zippermonkey@icloud.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=bruzzhang@tencent.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.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®