[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpFYOrJQqyAw4wKgBS-X2iLh2+h9Hyc6mawYV+RPD8eDSA@mail.gmail.com>
Date: Fri, 12 Apr 2024 06:46:14 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Peter Xu <peterx@...hat.com>, "Liam R. Howlett" <Liam.Howlett@...cle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>, Lokesh Gidra <lokeshgidra@...gle.com>,
Alistair Popple <apopple@...dia.com>
Subject: Re: [PATCH] mm: Always sanity check anon_vma first for per-vma locks
On Fri, Apr 12, 2024 at 6:32 AM Matthew Wilcox <willy@...radead.org> wrote:
>
> On Fri, Apr 12, 2024 at 05:46:52AM -0700, Suren Baghdasaryan wrote:
> > On Thu, Apr 11, 2024 at 8:14 PM Matthew Wilcox <willy@...radeadorg> wrote:
> > About the code, I'll take a closer look once I'm back from vacation
> > this weekend but I think you will also have to modify
> > do_anonymous_page() to use vmf_anon_prepare() instead of
> > anon_vma_prepare().
>
> Ah yes. Also do_huge_pmd_anonymous_page(). And we should do this:
>
> +++ b/mm/rmap.c
> @@ -182,8 +182,6 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
> * for the new allocation. At the same time, we do not want
> * to do any locking for the common case of already having
> * an anon_vma.
> - *
> - * This must be called with the mmap_lock held for reading.
> */
> int __anon_vma_prepare(struct vm_area_struct *vma)
> {
> @@ -191,6 +189,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma)
> struct anon_vma *anon_vma, *allocated;
> struct anon_vma_chain *avc;
>
> + mmap_assert_locked(mm);
> might_sleep();
>
> avc = anon_vma_chain_alloc(GFP_KERNEL);
>
Yes.
> > > We could even eagerly initialise vma->anon_vma for anon vmas. I don't
> > > know why we don't do that.
> >
> > You found the answer to that question a long time ago and IIRC it was
> > because in many cases we end up not needing to set vma->anon_vma at
> > all. So, this is an optimization to try avoiding extra operations
> > whenever we can. I'll try to find your comment on this.
>
> I thought that was file VMAs that I found the answer to that question?
I'll try to find that discussion once I get back to my workstation this weekend.
Powered by blists - more mailing lists