[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 8 Sep 2022 17:51:23 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: Laurent Dufour <ldufour@...ux.ibm.com>
Cc: akpm@...ux-foundation.org, michel@...pinasse.org,
jglisse@...gle.com, mhocko@...e.com, vbabka@...e.cz,
hannes@...xchg.org, mgorman@...e.de, dave@...olabs.net,
willy@...radead.org, liam.howlett@...cle.com, peterz@...radead.org,
laurent.dufour@...ibm.com, paulmck@...nel.org, luto@...nel.org,
songliubraving@...com, peterx@...hat.com, david@...hat.com,
dhowells@...hat.com, hughd@...gle.com, bigeasy@...utronix.de,
kent.overstreet@...ux.dev, rientjes@...gle.com,
axelrasmussen@...gle.com, joelaf@...gle.com, minchan@...gle.com,
kernel-team@...roid.com, linux-mm@...ck.org,
linux-arm-kernel@...ts.infradead.org,
linuxppc-dev@...ts.ozlabs.org, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH RESEND 10/28] mm/mmap: mark VMAs as locked in vma_adjust
On Tue, Sep 6, 2022 at 8:35 AM Laurent Dufour <ldufour@...ux.ibm.com> wrote:
>
> Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit :
> > vma_adjust modifies a VMA and possibly its neighbors. Mark them as locked
> > before making the modifications.
> >
> > Signed-off-by: Suren Baghdasaryan <surenb@...gle.com>
> > ---
> > mm/mmap.c | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/mmap.c b/mm/mmap.c
> > index f89c9b058105..ed58cf0689b2 100644
> > --- a/mm/mmap.c
> > +++ b/mm/mmap.c
> > @@ -710,6 +710,10 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
> > long adjust_next = 0;
> > int remove_next = 0;
> >
> > + vma_mark_locked(vma);
> > + if (next)
> > + vma_mark_locked(next);
> > +
>
> I was wondering if the VMAs insert and expand should be locked too.
>
> For expand, I can't see any valid reason, but for insert, I'm puzzled.
> I would think that it is better to lock the VMA to be inserted but I can't
> really justify that.
>
> It may be nice to detail why this is not need to lock insert and expand here.
'expand' is always locked before it's passed to __vma_adjust() by
vma_merge(). It has to be locked before we decide "Can it merge with
the predecessor?" here
https://elixir.bootlin.com/linux/latest/source/mm/mmap.c#L1201 because
a change in VMA can affect that decision. I spent many hours tracking
the issue caused by not locking the VMA before making this decision.
It might be good to add a comment about this...
AFAIKT 'insert' is only used by __split_vma() and it's always a brand
new VMA which is not yet linked into mm->mmap. Any reason
__vma_adjust() should lock it?
>
> > if (next && !insert) {
> > struct vm_area_struct *exporter = NULL, *importer = NULL;
> >
> > @@ -754,8 +758,11 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
> > * If next doesn't have anon_vma, import from vma after
> > * next, if the vma overlaps with it.
> > */
> > - if (remove_next == 2 && !next->anon_vma)
> > + if (remove_next == 2 && !next->anon_vma) {
> > exporter = next->vm_next;
> > + if (exporter)
> > + vma_mark_locked(exporter);
> > + }
> >
> > } else if (end > next->vm_start) {
> > /*
> > @@ -931,6 +938,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
> > * "vma->vm_next" gap must be updated.
> > */
> > next = vma->vm_next;
> > + if (next)
> > + vma_mark_locked(next);
> > } else {
> > /*
> > * For the scope of the comment "next" and
>
> --
> To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@...roid.com.
>
Powered by blists - more mailing lists