From: Yafang Shao <laoar.shao@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
Yafang Shao <laoar.shao@gmail.com>, Zi Yan <ziy@nvidia.com>,
akpm@linux-foundation.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, David Hildenbrand <david@redhat.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
bpf@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC PATCH 0/4] mm, bpf: BPF based THP adjustment
Date: Wed, 30 Apr 2025 22:49:05 +0800 [thread overview]
Message-ID: <CALOAHbDWusEwZ-sBRwcDC3CJQdfQGeLZetuSGxUphj7=8o2M1A@mail.gmail.com> (raw)
In-Reply-To: <rp3izx7uzdwzn2n4z37yaeqff7xkmz2xbshlqmgy2d5ucuzpeo@wfel6273tlg6>
On Wed, Apr 30, 2025 at 10:40 PM Liam R. Howlett
<Liam.Howlett@oracle.com> wrote:
>
> * Yafang Shao <laoar.shao@gmail.com> [250429 22:34]:
> > On Tue, Apr 29, 2025 at 11:09 PM Zi Yan <ziy@nvidia.com> wrote:
> > >
> > > Hi Yafang,
> > >
> > > We recently added a new THP entry in MAINTAINERS file[1], do you mind ccing
> > > people there in your next version? (I added them here)
> > >
> > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/tree/MAINTAINERS?h=mm-everything#n15589
> >
> > Thanks for your reminder.
> > I will add the maintainers and reviewers in the next version.
> >
> > >
> > > On Mon Apr 28, 2025 at 10:41 PM EDT, Yafang Shao wrote:
> > > > In our container environment, we aim to enable THP selectively—allowing
> > > > specific services to use it while restricting others. This approach is
> > > > driven by the following considerations:
> > > >
> > > > 1. Memory Fragmentation
> > > > THP can lead to increased memory fragmentation, so we want to limit its
> > > > use across services.
> > > > 2. Performance Impact
> > > > Some services see no benefit from THP, making its usage unnecessary.
> > > > 3. Performance Gains
> > > > Certain workloads, such as machine learning services, experience
> > > > significant performance improvements with THP, so we enable it for them
> > > > specifically.
> > > >
> > > > Since multiple services run on a single host in a containerized environment,
> > > > enabling THP globally is not ideal. Previously, we set THP to madvise,
> > > > allowing selected services to opt in via MADV_HUGEPAGE. However, this
> > > > approach had limitation:
> > > >
> > > > - Some services inadvertently used madvise(MADV_HUGEPAGE) through
> > > > third-party libraries, bypassing our restrictions.
> > >
> > > Basically, you want more precise control of THP enablement and the
> > > ability of overriding madvise() from userspace.
> > >
> > > In terms of overriding madvise(), do you have any concrete example of
> > > these third-party libraries? madvise() users are supposed to know what
> > > they are doing, so I wonder why they are causing trouble in your
> > > environment.
> >
> > To my knowledge, jemalloc [0] supports THP.
> > Applications using jemalloc typically rely on its default
> > configurations rather than explicitly enabling or disabling THP. If
> > the system is configured with THP=madvise, these applications may
> > automatically leverage THP where appropriate
>
> Isn't jemalloc THP aware and can be configured to always, never, or
> "default to the system setting" use THP for both metadata and
> allocations? It seems like this is an example of a thrid party library
> that knows what it is doing in regards to THP. [1]
Thanks for your explanation.
>
> If jemalloc is not following its own settings then it is an issue in
> jemalloc and not a reason for a kernel change.
We don’t change the kernel to accommodate specific userspace
settings—we change it only when it benefits users more broadly.
By the way, this patchset isn’t intended to address that issue. If
it’s causing confusion about the problem this patchset is trying to
solve, I’ll remove that part from the commit log in the next version.
>
> If you are relying on the default configuration of jemalloc and it
> doesn't work as you expect, then maybe try the thp settings?
>
> >
> > [0]. https://github.com/jemalloc/jemalloc
>
> ...
>
> Thanks,
> Liam
>
> [1]. https://jemalloc.net/jemalloc.3.html
--
Regards
Yafang
prev parent reply other threads:[~2025-04-30 14:49 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 2:41 [RFC PATCH 0/4] mm, bpf: BPF based THP adjustment Yafang Shao
2025-04-29 2:41 ` [RFC PATCH 1/4] mm: move hugepage_global_{enabled,always}() to internal.h Yafang Shao
2025-04-29 15:13 ` Zi Yan
2025-04-30 2:40 ` Yafang Shao
2025-04-30 12:11 ` Zi Yan
2025-04-30 14:43 ` Yafang Shao
2025-04-29 2:41 ` [RFC PATCH 2/4] mm: pass VMA parameter to hugepage_global_{enabled,always}() Yafang Shao
2025-04-29 15:31 ` Zi Yan
2025-04-30 2:46 ` Yafang Shao
2025-04-29 2:41 ` [RFC PATCH 3/4] mm: add BPF hook for THP adjustment Yafang Shao
2025-04-29 15:19 ` Alexei Starovoitov
2025-04-30 2:48 ` Yafang Shao
2025-04-29 2:41 ` [RFC PATCH 4/4] selftests/bpf: Add selftest " Yafang Shao
2025-04-29 3:11 ` [RFC PATCH 0/4] mm, bpf: BPF based " Matthew Wilcox
2025-04-29 4:53 ` Yafang Shao
2025-04-29 15:09 ` Zi Yan
2025-04-30 2:33 ` Yafang Shao
2025-04-30 13:19 ` Zi Yan
2025-04-30 14:38 ` Yafang Shao
2025-04-30 15:00 ` Zi Yan
2025-04-30 15:16 ` Yafang Shao
2025-04-30 15:21 ` Liam R. Howlett
2025-04-30 15:37 ` Yafang Shao
2025-04-30 15:53 ` Liam R. Howlett
2025-04-30 16:06 ` Yafang Shao
2025-04-30 17:45 ` Johannes Weiner
2025-04-30 17:53 ` Zi Yan
2025-05-01 19:36 ` Gutierrez Asier
2025-05-02 5:48 ` Yafang Shao
2025-05-02 12:00 ` Zi Yan
2025-05-02 12:18 ` Yafang Shao
2025-05-02 13:04 ` David Hildenbrand
2025-05-02 13:06 ` Matthew Wilcox
2025-05-02 13:34 ` Zi Yan
2025-05-05 2:35 ` Yafang Shao
2025-05-05 9:11 ` Gutierrez Asier
2025-05-05 9:38 ` Yafang Shao
2025-04-30 17:59 ` Johannes Weiner
2025-05-01 0:40 ` Yafang Shao
2025-04-30 14:40 ` Liam R. Howlett
2025-04-30 14:49 ` Yafang Shao [this message]
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='CALOAHbDWusEwZ-sBRwcDC3CJQdfQGeLZetuSGxUphj7=8o2M1A@mail.gmail.com' \
--to=laoar.shao@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).