From: Pedro Falcato <pfalcato@suse.de>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Barry Song <21cnbao@gmail.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Barry Song <v-songbaohua@oppo.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
David Hildenbrand <david@redhat.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Suren Baghdasaryan <surenb@google.com>,
Lokesh Gidra <lokeshgidra@google.com>,
Tangquan Zheng <zhengtangquan@oppo.com>
Subject: Re: [PATCH RFC v2] mm: use per_vma lock for MADV_DONTNEED
Date: Tue, 3 Jun 2025 21:59:46 +0100 [thread overview]
Message-ID: <hafjpizztpwazia2ubkieavxw375pb3ziwhd7bfq24i4gv5ayn@ah4zz2zy2lhv> (raw)
In-Reply-To: <0b96ce61-a52c-4036-b5b6-5c50783db51f@lucifer.local>
On Tue, Jun 03, 2025 at 07:43:04PM +0100, Lorenzo Stoakes wrote:
> Hi Barry,
>
> As promised, I enclose a patch to give a sense of how I think we might
> thread state through this operation.
>
> There's a todo on the untagged stuff so you can figure that out. This is
> based on the v1 so it might not encompass everything you addressed in the
> v2.
>
> Passing in madv_behavior to madvise_walk_vmas() twice kinda sucks, I
> _despise_ the void *arg function ptr stuff there added just for the anon
> vma name stuff (ughhh) so might be the only sensible way of threading
> state.
>
> I don't need any attribution, so please use this patch as you see
> fit/adapt/delete/do whatever with it, just an easier way for me to show the
> idea!
>
> I did some very basic testing and it seems to work, but nothing deeper.
>
> Cheers, Lorenzo
>
> ----8<----
> >From ff4ba0115cb31a0630b6f8c02c68f11b3fb71f7a Mon Sep 17 00:00:00 2001
> From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Date: Tue, 3 Jun 2025 18:22:55 +0100
> Subject: [PATCH] mm/madvise: support VMA read locks for MADV_DONTNEED[_LOCKED]
>
> Refactor the madvise() code to retain state about the locking mode utilised
> for traversing VMAs.
>
> Then use this mechanism to permit VMA locking to be done later in the
> madvise() logic and also to allow altering of the locking mode to permit
> falling back to an mmap read lock if required.
>
Just as a quick drive-by comment: I was playing around with using per-vma locks
for GUP and mm_populate a few weeks ago. I never actually finished the work (and I
still plan on getting around doing it Eventually(tm)), but my final concept of an
approach was to simply read-lock every VMA in a range (if that fails, go back
to the mmap_lock).
I *think* it works, and doesn't have the same limitation for single VMAs.
I understand this is a super handwavy suggestion, but I know this discussion has
been happening and I just wanted to get this idea out of obscure IRC logs :)
--
Pedro
next prev parent reply other threads:[~2025-06-03 20:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 10:44 Barry Song
2025-05-30 14:06 ` Jann Horn
2025-05-30 14:34 ` Lorenzo Stoakes
2025-05-30 20:17 ` Barry Song
2025-06-02 17:35 ` SeongJae Park
2025-06-02 17:53 ` SeongJae Park
2025-05-30 20:40 ` Jann Horn
2025-06-02 11:50 ` Lorenzo Stoakes
2025-06-03 1:06 ` Barry Song
2025-06-03 9:48 ` Lorenzo Stoakes
2025-06-03 7:06 ` Barry Song
2025-06-03 16:52 ` Jann Horn
2025-06-05 10:27 ` Barry Song
2025-05-30 22:00 ` Barry Song
2025-06-02 14:55 ` Jann Horn
2025-06-03 7:51 ` Barry Song
2025-06-03 7:24 ` Qi Zheng
2025-06-03 9:54 ` Lorenzo Stoakes
2025-06-04 6:02 ` Qi Zheng
2025-06-04 17:50 ` Lorenzo Stoakes
2025-06-05 3:23 ` Qi Zheng
2025-06-05 14:04 ` Lorenzo Stoakes
2025-06-06 3:55 ` Qi Zheng
2025-06-06 10:44 ` Lorenzo Stoakes
2025-06-09 6:40 ` Qi Zheng
2025-06-09 15:08 ` Lorenzo Stoakes
2025-06-10 7:20 ` David Hildenbrand
2025-06-06 11:07 ` Jann Horn
2025-06-03 18:43 ` Lorenzo Stoakes
2025-06-03 20:17 ` Suren Baghdasaryan
2025-06-04 5:22 ` Lorenzo Stoakes
2025-06-06 7:18 ` Barry Song
2025-06-06 10:16 ` Lorenzo Stoakes
2025-06-03 20:59 ` Pedro Falcato [this message]
2025-06-04 5:23 ` Lorenzo Stoakes
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=hafjpizztpwazia2ubkieavxw375pb3ziwhd7bfq24i4gv5ayn@ah4zz2zy2lhv \
--to=pfalcato@suse.de \
--cc=21cnbao@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=surenb@google.com \
--cc=v-songbaohua@oppo.com \
--cc=vbabka@suse.cz \
--cc=zhengtangquan@oppo.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