From: Dev Jain <dev.jain@arm.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Shivank Garg <shivankg@amd.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Zach O'Keefe <zokeefe@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Branden Moore <Branden.Moore@amd.com>
Subject: Re: [PATCH 1/2] mm/khugepaged: do synchronous writeback for MADV_COLLAPSE
Date: Tue, 11 Nov 2025 09:11:08 +0530 [thread overview]
Message-ID: <a63d5305-2266-4a60-89e5-d737ba6e2f4c@arm.com> (raw)
In-Reply-To: <312bfcbd-d31a-40d3-8b9c-edc7b6166113@lucifer.local>
On 10/11/25 7:06 pm, Lorenzo Stoakes wrote:
> On Mon, Nov 10, 2025 at 06:54:57PM +0530, Dev Jain wrote:
>> On 10/11/25 5:31 pm, Lorenzo Stoakes wrote:
>>> ofc you are addressing this with the !cc->is_khugepaged, but feels like we'd be
>>> better off just doing it in madvise_collapse().
>> I suppose the common case is that writeback is not needed, and I don't know what
>> is the overhead of filemap_write_and_wait_range() in that case, but your
> Low.
>
>> suggestion will force that unconditional overhead and skip all the early exits
>> possible in hpage_collapse_scan_file()?
> Which are?
>
> PMD-mapped folio at start of range, scan abort, non-LRU, spurious ref count
>
> I don't think this matters.
>
> And we're trading for putting _yet more_ logic that belongs elsewhere in the
> wrong place.
>
> I mean I'd actually be pretty good with us putting it literally in madvise.c,
> but since we defer the collapse to khugepaged.c then madvise_collapse().
>
>>> I wonder also if doing I/O without getting the mmap lock again and revalidating
>>> is wise, as the state of things might have changed significantly.
>>>
>>> So maybe need a hugepage_vma_revalidate() as well?
>> The file collapse path (apart from collapse_pte_mapped_thp) is solely concerned
>> about doing the collapse in the page cache, for which information about the mm or
>> the vma is not needed, that is why no locking is required. The get_file() in
> The user has asked specifically to collapse pages in a VMA's range. Yes you can
> go check the mapping of a pinned file which you're keeping pinned during this
> operation (wise? Not sure it is).
>
> This would be the first time in this operation we are doing a _synchronous_ I/O
> operation where we sleep holding a pin.
>
> So no, I think we really do need to revalidate.
>
> 'Collapse some random file we no longer map at this address' is probably not
> great semantics, also of course, we are revalidating at each PMD anyway.
>
> Maybe even do a addr -= HPAGE_PMD_SIZE; continue + take it from the top?
>
> Maybe David has thoughts...
>
>> khugepaged_scan_mm_slot() seems to be serving the same function as maybe_unlock_mmap_for_io().
>> So I don't think this is needed?
> We're talking about the MADV_COLLAPSE case so don't understand this? I may be
> missing something here (happens a lot ;)!
My bad, meant to say madvise_collapse() -> get_file().
>
>
>>>
>>>> +
>>>> result = alloc_charge_folio(&new_folio, mm, cc);
>>>> if (result != SCAN_SUCCEED)
>>>> goto out;
>>>>
>>>> base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
>>>> --
>>>> 2.43.0
>>>>
>>> Thanks, Lorenzo
> Cheers, Lorenzo
next prev parent reply other threads:[~2025-11-11 3:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 11:32 [PATCH 1/2] mm/khugepaged: do synchronous writeback for MADV_COLLAPSE Shivank Garg
2025-11-10 11:32 ` [PATCH 2/2] mm/khugepaged: return EAGAIN for transient dirty pages in MADV_COLLAPSE Shivank Garg
2025-11-10 11:56 ` Lorenzo Stoakes
2025-11-19 10:25 ` Garg, Shivank
2025-11-19 18:16 ` Lorenzo Stoakes
2025-11-20 7:03 ` Garg, Shivank
2025-11-10 13:46 ` Dev Jain
2025-11-19 7:00 ` Garg, Shivank
2025-11-10 12:01 ` [PATCH 1/2] mm/khugepaged: do synchronous writeback for MADV_COLLAPSE Lorenzo Stoakes
2025-11-10 13:07 ` Garg, Shivank
2025-11-10 13:22 ` Lorenzo Stoakes
2025-11-10 16:06 ` Lorenzo Stoakes
2025-11-10 16:55 ` Zi Yan
2025-11-10 19:40 ` Garg, Shivank
2025-11-10 19:48 ` Lorenzo Stoakes
2025-11-10 19:53 ` Lorenzo Stoakes
2025-11-10 21:16 ` Lorenzo Stoakes
2025-11-10 21:56 ` Zi Yan
2025-11-10 22:03 ` Lorenzo Stoakes
2025-11-11 5:26 ` Garg, Shivank
2025-11-10 13:24 ` Dev Jain
2025-11-10 13:36 ` Lorenzo Stoakes
2025-11-11 3:41 ` Dev Jain [this message]
2025-11-10 13:47 ` Matthew Wilcox
2025-11-10 13:52 ` Lorenzo Stoakes
2025-11-10 14:17 ` Matthew Wilcox
2025-11-10 14:20 ` Garg, Shivank
2025-11-10 14:23 ` Lorenzo Stoakes
2025-11-10 14:28 ` Matthew Wilcox
2025-11-11 5:58 ` Garg, Shivank
2025-11-13 15:30 ` David Hildenbrand (Red Hat)
2025-11-10 14:00 ` David Hildenbrand (Red Hat)
2025-11-10 14:03 ` Matthew Wilcox
2025-11-10 14:05 ` Lorenzo Stoakes
2025-11-10 14:54 ` David Hildenbrand (Red Hat)
2025-11-13 14:21 ` kernel test robot
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=a63d5305-2266-4a60-89e5-d737ba6e2f4c@arm.com \
--to=dev.jain@arm.com \
--cc=Branden.Moore@amd.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=npache@redhat.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=shivankg@amd.com \
--cc=ziy@nvidia.com \
--cc=zokeefe@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