[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK1f24nb6FkipH3OZa0uwbBWkefS3f2BrJ_GTxkS2j6+6bgODQ@mail.gmail.com>
Date: Thu, 25 Apr 2024 12:17:36 +0800
From: Lance Yang <ioworker0@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: Zi Yan <ziy@...dia.com>, Matthew Wilcox <willy@...radead.org>, akpm@...ux-foundation.org,
maskray@...gle.com, ryan.roberts@....com, 21cnbao@...il.com, mhocko@...e.com,
fengwei.yin@...el.com, zokeefe@...gle.com, shy828301@...il.com,
xiehuan09@...il.com, wangkefeng.wang@...wei.com, songmuchun@...edance.com,
peterx@...hat.com, minchan@...nel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] mm/vmscan: avoid split PMD-mapped THP during shrink_folio_list()
Hey Zi, David,
Thanks for taking time to review!
On Wed, Apr 24, 2024 at 11:58 PM David Hildenbrand <david@...hat.com> wrote:
>
> On 24.04.24 17:57, Zi Yan wrote:
> > On 24 Apr 2024, at 3:17, David Hildenbrand wrote:
> >
> >> On 24.04.24 06:15, Matthew Wilcox wrote:
> >>> On Mon, Apr 22, 2024 at 01:52:13PM +0800, Lance Yang wrote:
> >>>> When the user no longer requires the pages, they would use
> >>>> madvise(MADV_FREE) to mark the pages as lazy free. IMO, they would not
> >>>> typically rewrite to the given range.
> >>>>
> >>>> At present, PMD-mapped THPs that are marked as lazyfree during
> >>>> shrink_folio_list() are unconditionally split, which may be unnecessary.
> >>>> If the THP is clean, its PMD is also clean, and there are no unexpected
> >>>> references, then we can attempt to remove the PMD mapping from it. This
> >>>> change will improve the efficiency of memory reclamation in this case.
> >>>
> >>> Does this happen outside of benchmarks? I'm really struggling to see
> >>> how we end up in this situation. We have a clean THP without swap
> >>> backing, so it's full of zeroes, but for some reason we haven't used the
> >>> shared huge zero page? What is going on?
> >>
> >> It's not full of zeroes.
> >>
> >> User space called MADV_FREE on a PMD-mapped THP.
> >>
> >> During MADV_FREE, we mark the PTEs as clean, the folio as clean and sd "lazyfree" (no swap backend). If, during memory reclaim, we detect that (a) the folio is still clean (b) the PTEs are still clean and (c) there are no unexpected references (GUP), user space didn't re-write to that memory again, so we can just discard the memory "lazily".
> >
> > It seems that try_to_unmap_one() does not support unmapping PMD-mapped folios.
> > Maybe adding that support instead of a special case handling?
>
> I was thinking the same, and finding a way to avoid TTU_LAZYFREE_THP.
Thanks for the suggestions!
Yep, I completely agreed. Adding support for unmapping PMD-mapped folios to
try_to_unmap_one() would make it more future-proof.
Thanks again for the review!
Lance
>
> --
> Cheers,
>
> David / dhildenb
>
Powered by blists - more mailing lists