From: Michal Hocko <mhocko@suse.com>
To: Lance Yang <ioworker0@gmail.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: Thu, 18 Jan 2024 14:40:19 +0100 [thread overview]
Message-ID: <ZakqQyL9t2ffNUIf@tiehlicka> (raw)
In-Reply-To: <20240118120347.61817-1-ioworker0@gmail.com>
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
around by process_madvise and performing the operation from a different
context? Are there any other reasons to have a different mode?
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.
> [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
next prev parent reply other threads:[~2024-01-18 13:40 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 [this message]
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
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=ZakqQyL9t2ffNUIf@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=ioworker0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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