linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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,  mknyszek@google.com, minchan@kernel.org,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mm/madvise: add MADV_F_COLLAPSE_LIGHT to process_madvise()
Date: Fri, 19 Jan 2024 10:03:05 +0800	[thread overview]
Message-ID: <CAK1f24k+=Sskotbct+yGxpDKNv=qyXPkww5i2kaqfzwaUVO_GQ@mail.gmail.com> (raw)
In-Reply-To: <ZakqQyL9t2ffNUIf@tiehlicka>

Hey Michal,

Thanks for taking the time to review!

On Thu, Jan 18, 2024 at 9:40 PM Michal Hocko <mhocko@suse.com> wrote:
>
> On Thu 18-01-24 20:03:46, Lance Yang wrote:
> [...]
>
> before we discuss the semantic, let's focus on the usecase.
>
> > Use Cases
> >
> > An immediate user of this new functionality is the Go runtime heap allocator
> > that manages memory in hugepage-sized chunks. In the past, whether it was a
> > newly allocated chunk through mmap() or a reused chunk released by
> > madvise(MADV_DONTNEED), the allocator attempted to eagerly back memory with
> > huge pages using madvise(MADV_HUGEPAGE)[2] and madvise(MADV_COLLAPSE)[3]
> > respectively. However, both approaches resulted in performance issues; for
> > both scenarios, there could be entries into direct reclaim and/or compaction,
> > leading to unpredictable stalls[4]. Now, the allocator can confidently use
> > process_madvise(MADV_F_COLLAPSE_LIGHT) to attempt the allocation of huge pages.
>
> IIUC the primary reason is the cost of the huge page allocation which
> can be really high if the memory is heavily fragmented and it is called
> synchronously from the process directly, correct? Can that be worked

Yes, that's correct.

> around by process_madvise and performing the operation from a different
> context? Are there any other reasons to have a different mode?

In latency-sensitive scenarios, some applications aim to enhance performance
by utilizing huge pages as much as possible. At the same time, in case of
allocation failure, they prefer a quick return without triggering direct memory
reclamation and compaction.

>
> I mean I can think of a more relaxed (opportunistic) MADV_COLLAPSE -
> e.g. non blocking one to make sure that the caller doesn't really block
> on resource contention (be it locks or memory availability) because that
> matches our non-blocking interface in other areas but having a LIGHT
> operation sounds really vague and the exact semantic would be
> implementation specific and might change over time. Non-blocking has a
> clear semantic but it is not really clear whether that is what you
> really need/want.

Could you provide me with some suggestions regarding the naming of a
more relaxed (opportunistic) MADV_COLLAPSE?

Thanks again for your review and your suggestion!
Lance

>
> > [1] https://github.com/torvalds/linux/commit/7d8faaf155454f8798ec56404faca29a82689c77
> > [2] https://github.com/golang/go/commit/8fa9e3beee8b0e6baa7333740996181268b60a3a
> > [3] https://github.com/golang/go/commit/9f9bb26880388c5bead158e9eca3be4b3a9bd2af
> > [4] https://github.com/golang/go/issues/63334
> >
> > [v1] https://lore.kernel.org/lkml/20240117050217.43610-1-ioworker0@gmail.com/
> --
> Michal Hocko
> SUSE Labs


  parent reply	other threads:[~2024-01-19  2:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18 12:03 Lance Yang
2024-01-18 13:28 ` Michal Hocko
2024-01-18 13:40 ` Michal Hocko
2024-01-18 13:43   ` Michal Hocko
2024-01-18 14:58     ` Zach O'Keefe
2024-01-18 19:00       ` Yang Shi
2024-01-19  2:37         ` Lance Yang
2024-01-19  1:46       ` Lance Yang
2024-01-19  2:03   ` Lance Yang [this message]
2024-01-19 12:51     ` Michal Hocko
2024-01-19 14:08       ` Lance Yang
2024-01-20  2:09       ` Lance Yang
2024-01-22 13:50         ` Michal Hocko
2024-01-22 14:14           ` Lance Yang
2024-01-22 14:34             ` Lance Yang
2024-01-26 23:26               ` Zach O'Keefe
2024-01-27  8:06                 ` Lance Yang
2024-01-21  3:12 ` Lance Yang
2024-01-26  6:16   ` Lance Yang
2024-01-26 10:15     ` Lance Yang
2024-01-26 12:52       ` Lance Yang
2024-01-26 23:46         ` Zach O'Keefe
2024-01-27  8:03           ` 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='CAK1f24k+=Sskotbct+yGxpDKNv=qyXPkww5i2kaqfzwaUVO_GQ@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=mknyszek@google.com \
    --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