From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Pedro Falcato <pfalcato@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6.15] mm/vma: add give_up_on_oom option on modify/merge, use in uffd release
Date: Fri, 21 Mar 2025 17:04:15 +0000 [thread overview]
Message-ID: <d7f8e2e8-1670-49b4-a9a1-2ca236e9d5f9@lucifer.local> (raw)
In-Reply-To: <233o4lohzhriye27szk6mucduneuvosmnp6pmnjepz3enxjgtt@id6kwhjgysbj>
On Fri, Mar 21, 2025 at 11:26:18AM +0000, Pedro Falcato wrote:
> On Fri, Mar 21, 2025 at 10:09:37AM +0000, Lorenzo Stoakes wrote:
> > Currently, if a VMA merge fails due to an OOM condition arising on commit
> > merge or a failure to duplicate anon_vma's, we report this so the caller
> > can handle it.
> >
> > However there are cases where the caller is only ostensibly trying a
> > merge, and doesn't mind if it fails due to this condition.
> >
>
> Ok, so here's my problem with your idea: I don't think merge should be exposed
> to vma_modify() callers. Right now (at least AIUI), you want to modify a given
> VMA, you call vma_modify(), and it gives you a vma you can straight up modify
> without any problems. Essentially breaks down any VMAs necessary. This feels
> contractually simple and easy to use, and I don't think leaking details about
> merging is the correct approach here.
The vmg passed is already 'exposing' merge and has flags you can change. There's
no contract that vma_modify() abstracts this, you're saying you want to modify,
maybe merge if we can.
Uffd is actually calling it in a purely special case - one where you would never
split.
I mean an alternative is to have something not-vma_modify() do it, but then we
end up with code duplication, which is why I made the unregister + clear paths
do the same thing here.
>
> > Since we do not want to introduce an implicit assumption that we only
> > actually modify VMAs after OOM conditions might arise, add a 'give up on
> > oom' option and make an explicit contract that, should this flag be set, we
> > absolutely will not modify any VMAs should OOM arise and just bail out.
> >
>
> Thus, to me the most natural solution is still mine. Do you think it places too
> many constraints on vma_modify()? vma_modify() on a single VMA, without
> splitting, Just Working(tm) is a sensible expectation (and vma_merge being fully
> best-effort). Things like mprotect() failing due to OOM are also pretty disastrous,
> so if we could limit that it'd be great.
I disagree, again for the same reason as stated before, you are making an
implicit assumption that an OOM error means the VMA is not deleted. This only
happens to be true _now_.
Having this implicit assumption there, which later might change, is _precisely_
the kind of thing that led us to this issue in the first place.
So that's just not workable.
A version of your thing that would work is where vma_modify() itself sets the
flag so we -establish this contract-.
But I don't want to infect all other callers who don't have uffd's problem with
this.
Also, again, this is a -uffd- problem. Uffd is calling a function that can
return an error, assuming it must not return an error, and breaking if it does.
We have to on some level have uffd say 'actually we rely on this'.
So, ugly as it is, I feel my approach is the best for now.
But to be revisited!
>
> In any case, your solution looks palatable to me, but I want to make
> sure we're not making this excessively complicated.
Thanks!
I don't think this is any more complicated than it needs to be, as Liam alludes
to in his reply.
But rethinking this whole thing on a deeper level is on my agenda now.
Error paths are an ugly pain anywwhere :(
>
> --
> Pedro
next prev parent reply other threads:[~2025-03-21 17:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 10:09 Lorenzo Stoakes
2025-03-21 11:26 ` Pedro Falcato
2025-03-21 15:27 ` Liam R. Howlett
2025-03-21 17:16 ` Lorenzo Stoakes
2025-03-21 18:11 ` Liam R. Howlett
2025-03-21 21:24 ` Lorenzo Stoakes
2025-03-22 0:30 ` Peter Xu
2025-03-21 17:04 ` Lorenzo Stoakes [this message]
2025-03-31 15:10 ` Lorenzo Stoakes
2025-03-31 15:26 ` Pedro Falcato
2025-04-06 22:43 ` 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=d7f8e2e8-1670-49b4-a9a1-2ca236e9d5f9@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pfalcato@suse.de \
--cc=vbabka@suse.cz \
/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