[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpFoJmiGYXBLwOjW36iB302=V2_vvbRwQbftr_ix_92uuQ@mail.gmail.com>
Date: Thu, 8 Sep 2022 17:27:06 -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 09/28] mm/mempolicy: mark VMA as locked when
changing protection policy
On Tue, Sep 6, 2022 at 7:48 AM Laurent Dufour <ldufour@...ux.ibm.com> wrote:
>
> Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit :
> > Protect VMA from concurrent page fault handler while performing VMA
> > protection policy changes.
> >
> > Signed-off-by: Suren Baghdasaryan <surenb@...gle.com>
> > ---
> > mm/mempolicy.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> > index b73d3248d976..6be1e5c75556 100644
> > --- a/mm/mempolicy.c
> > +++ b/mm/mempolicy.c
> > @@ -383,8 +383,10 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
> > struct vm_area_struct *vma;
> >
> > mmap_write_lock(mm);
> > - for (vma = mm->mmap; vma; vma = vma->vm_next)
> > + for (vma = mm->mmap; vma; vma = vma->vm_next) {
> > + vma_mark_locked(vma);
> > mpol_rebind_policy(vma->vm_policy, new);
> > + }
> > mmap_write_unlock(mm);
> > }
> >
> > @@ -632,6 +634,7 @@ unsigned long change_prot_numa(struct vm_area_struct *vma,
> > struct mmu_gather tlb;
> > int nr_updated;
> >
> > + vma_mark_locked(vma);
>
> If I understand that corretly, the VMA itself is not impacted, only the
> PMDs/PTEs, and they are protected using the page table locks.
>
> Am I missing something?
I thought we would not want pages faulting in the VMA for which we are
changing the protection. However I think what you are saying is that
page table locks would already provide a more granular synchronization
with page fault handlers, which makes sense to me. Sounds like we can
skip locking the VMA here as well. Nice!
>
> > tlb_gather_mmu(&tlb, vma->vm_mm);
> >
> > nr_updated = change_protection(&tlb, vma, addr, end, PAGE_NONE,
> > @@ -765,6 +768,7 @@ static int vma_replace_policy(struct vm_area_struct *vma,
> > if (IS_ERR(new))
> > return PTR_ERR(new);
> >
> > + vma_mark_locked(vma);
> > if (vma->vm_ops && vma->vm_ops->set_policy) {
> > err = vma->vm_ops->set_policy(vma, new);
> > if (err)
>
Powered by blists - more mailing lists