All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Lance Yang <ioworker0@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: Zi Yan <ziy@nvidia.com>, Matthew Wilcox <willy@infradead.org>,
	akpm@linux-foundation.org,  maskray@google.com,
	ryan.roberts@arm.com, 21cnbao@gmail.com, mhocko@suse.com,
	 fengwei.yin@intel.com, zokeefe@google.com, shy828301@gmail.com,
	 xiehuan09@gmail.com, wangkefeng.wang@huawei.com,
	songmuchun@bytedance.com,  peterx@redhat.com, minchan@kernel.org,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mm/vmscan: avoid split PMD-mapped THP during shrink_folio_list()
Date: Thu, 25 Apr 2024 12:17:36 +0800	[thread overview]
Message-ID: <CAK1f24nb6FkipH3OZa0uwbBWkefS3f2BrJ_GTxkS2j6+6bgODQ@mail.gmail.com> (raw)
In-Reply-To: <51ba6efa-ce5a-49cf-b90e-62310db2c561@redhat.com>

Hey Zi, David,

Thanks for taking time to review!

On Wed, Apr 24, 2024 at 11:58 PM David Hildenbrand <david@redhat.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
>


  reply	other threads:[~2024-04-25  4:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22  5:52 [PATCH v2 1/1] mm/vmscan: avoid split PMD-mapped THP during shrink_folio_list() Lance Yang
2024-04-24  4:15 ` Matthew Wilcox
2024-04-24  7:17   ` David Hildenbrand
2024-04-24 15:57     ` Zi Yan
2024-04-24 15:58       ` David Hildenbrand
2024-04-25  4:17         ` Lance Yang [this message]
2024-04-25  8:50           ` Lance Yang
2024-04-25  9:01             ` David Hildenbrand
2024-04-25  9:21               ` Lance Yang
2024-04-25  9:25                 ` David Hildenbrand
2024-04-25 12:00                   ` Lance Yang
2024-04-24 15:46   ` Lance Yang
2024-04-24 21:20     ` Andrew Morton
2024-04-25  4:19       ` Lance Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK1f24nb6FkipH3OZa0uwbBWkefS3f2BrJ_GTxkS2j6+6bgODQ@mail.gmail.com \
    --to=ioworker0@gmail.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=fengwei.yin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maskray@google.com \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=peterx@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=songmuchun@bytedance.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=xiehuan09@gmail.com \
    --cc=ziy@nvidia.com \
    --cc=zokeefe@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.