[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7e21e99-8f8a-6f31-601c-a73ad6a0e87f@google.com>
Date: Thu, 13 Jul 2023 20:41:26 -0700 (PDT)
From: Hugh Dickins <hughd@...gle.com>
To: "Yin, Fengwei" <fengwei.yin@...el.com>
cc: Hugh Dickins <hughd@...gle.com>, Yu Zhao <yuzhao@...gle.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org, willy@...radead.org, david@...hat.com,
ryan.roberts@....com, shy828301@...il.com
Subject: Re: [RFC PATCH v2 2/3] mm: handle large folio when large folio in
VM_LOCKED VMA range
On Fri, 14 Jul 2023, Yin, Fengwei wrote:
> On 7/14/2023 10:21 AM, Hugh Dickins wrote:
> > On Wed, 12 Jul 2023, Yin Fengwei wrote:
> >> On 7/12/23 14:23, Yu Zhao wrote:
> >>> On Wed, Jul 12, 2023 at 12:02 AM Yin Fengwei <fengwei.yin@...el.com> wrote:
> >>>> --- a/
> >>>> +++ b/mm/internal.h
> >>>> @@ -643,7 +643,8 @@ static inline void mlock_vma_folio(struct folio *folio,
> >>>> * still be set while VM_SPECIAL bits are added: so ignore it then.
> >>>> */
> >>>> if (unlikely((vma->vm_flags & (VM_LOCKED|VM_SPECIAL)) == VM_LOCKED) &&
> >>>> - (compound || !folio_test_large(folio)))
> >>>> + (compound || !folio_test_large(folio) ||
> >>>> + folio_in_range(folio, vma, vma->vm_start, vma->vm_end)))
> >>>> mlock_folio(folio);
> >>>> }
> >>>
> >>> This can be simplified:
> >>> 1. remove the compound parameter
> >> Yes. There is not difference here for pmd mapping of THPs and pte mappings of THPs
> >> if the only condition need check is whether the folio is within VMA range or not.
> >>
> >> But let me add Huge for confirmation.
> >
> > I'm not sure what it is that you need me to confirm: if the folio fits
> > within the vma, then the folio fits within the vma, pmd-mapped or not.
> Sorry. My bad. I should speak it out for what I want your confirmation:
> Whether we can remove the compound and use whether folio is within
> VMA instead.
>
> I suppose you answer is Yes.
Yes (if it all works out going that way).
>
> >
> > (And I agree with Yu that it's better to drop the folio_test_large()
> > check too.)
> My argument was folio_test_large() can filter the normal 4K page out so
> it doesn't need to call folio_in_range() which looks to me a little bit
> heavy for normal 4K page. And the deal was move folio_test_large()
> to folio_in_range() like function so simplify the code in caller side.
I realized that, but agree with Yu.
It looked a little over-engineered to me, but I didn't spend long enough
looking to understand why there's folio_within_vma() distinct from
folio_in_range(), when everyone(?) calls folio_in_range() with the same
arguments vma->vm_start, vma->vm_end.
>
> >
> > This idea, of counting the folio as mlocked according to whether the
> > whole folio fits within the vma, does seem a good idea to me: worth
> > pursuing. But whether the implementation adds up and works out, I
> > have not checked. It was always difficult to arrive at a satisfactory
> > compromise in mlocking compound pages: I hope this way does work out.
> This is the purpose of this patch. :). Thanks.
>
>
> Regards
> Yin, Fengwei
>
> >
> > Hugh
Powered by blists - more mailing lists