From: Lance Yang <ioworker0@gmail.com>
To: Michal Hocko <mhocko@suse.com>
Cc: akpm@linux-foundation.org, zokeefe@google.com, david@redhat.com,
songmuchun@bytedance.com, shy828301@gmail.com,
peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] mm/khugepaged: skip copying lazyfree pages on collapse
Date: Fri, 2 Feb 2024 22:52:49 +0800 [thread overview]
Message-ID: <CAK1f24nHmvqm1XD_UkWUB7DmNdH0NEOKzpLgKDJ=UuPWO=rEHw@mail.gmail.com> (raw)
In-Reply-To: <Zbz_ao0uBKabzKB1@tiehlicka>
How about blocking khugepaged from
collapsing lazyfree pages? This way,
is it not better to keep the semantics
of MADV_FREE?
What do you think?
Thanks,
Lance
On Fri, Feb 2, 2024 at 10:42 PM Michal Hocko <mhocko@suse.com> wrote:
>
> On Fri 02-02-24 21:46:45, Lance Yang wrote:
> > Here is a part from the man page explaining
> > the MADV_FREE semantics:
> >
> > The kernel can thus free thesepages, but the
> > freeing could be delayed until memory pressure
> > occurs. For each of the pages that has been
> > marked to be freed but has not yet been freed,
> > the free operation will be canceled if the caller
> > writes into the page. If there is no subsequent
> > write, the kernel can free the pages at any time.
> >
> > IIUC, if there is no subsequent write, lazyfree
> > pages will eventually be reclaimed.
>
> If there is no memory pressure then this might not
> ever happen. User cannot make any assumption about
> their content once madvise call has been done. The
> content has to be considered lost. Sure the userspace
> might have means to tell those pages from zero pages
> and recheck after the write but that is about it.
>
> > khugepaged
> > treats lazyfree pages the same as pte_none,
> > avoiding copying them to the new huge page
> > during collapse. It seems that lazyfree pages
> > are reclaimed before khugepaged collapses them.
> > This aligns with user expectations.
> >
> > However, IMO, if the content of MADV_FREE pages
> > remains valid during collapse, then khugepaged
> > treating lazyfree pages the same as pte_none
> > might not be suitable.
>
> Why?
>
> Unless I am missing something (which is possible of
> course) I do not really see why dropping the content
> of those pages and replacing them with a THP is any
> difference from reclaiming those pages and then faulting
> in a non-THP zero page.
>
> Now, if khugepaged reused the original content of MADV_FREE
> pages that would be a slightly different story. I can
> see why users would expect zero pages to back madvised
> area.
> --
> Michal Hocko
> SUSE Labs
next prev parent reply other threads:[~2024-02-02 14:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 12:52 Lance Yang
2024-02-01 13:49 ` Lance Yang
2024-02-01 20:37 ` Yang Shi
2024-02-02 11:23 ` Lance Yang
2024-02-02 17:43 ` Yang Shi
2024-02-02 10:06 ` Michal Hocko
2024-02-02 11:18 ` Lance Yang
2024-02-02 12:27 ` Michal Hocko
2024-02-02 12:52 ` Lance Yang
2024-02-02 12:57 ` Michal Hocko
2024-02-02 13:46 ` Lance Yang
2024-02-02 14:20 ` Lance Yang
2024-02-02 14:42 ` Michal Hocko
2024-02-02 14:52 ` Lance Yang [this message]
2024-02-02 15:26 ` David Hildenbrand
2024-02-02 15:38 ` Michal Hocko
2024-02-02 17:42 ` Yang Shi
2024-02-03 4:17 ` Lance Yang
2024-02-05 19:41 ` Yang Shi
2024-02-05 9:45 ` Michal Hocko
2024-02-05 19:43 ` Yang Shi
2024-02-05 20:26 ` Zach O'Keefe
2024-02-20 10:15 ` 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='CAK1f24nHmvqm1XD_UkWUB7DmNdH0NEOKzpLgKDJ=UuPWO=rEHw@mail.gmail.com' \
--to=ioworker0@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=songmuchun@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox