[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250515133519.2779639-1-usamaarif642@gmail.com>
Date: Thu, 15 May 2025 14:33:29 +0100
From: Usama Arif <usamaarif642@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
david@...hat.com,
linux-mm@...ck.org
Cc: hannes@...xchg.org,
shakeel.butt@...ux.dev,
riel@...riel.com,
ziy@...dia.com,
laoar.shao@...il.com,
baolin.wang@...ux.alibaba.com,
lorenzo.stoakes@...cle.com,
Liam.Howlett@...cle.com,
npache@...hat.com,
ryan.roberts@....com,
linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
kernel-team@...a.com,
Usama Arif <usamaarif642@...il.com>
Subject: [PATCH 0/6] prctl: introduce PR_SET/GET_THP_POLICY
This allows to change the THP policy of a process, according to the value
set in arg2, all of which will be inherited during fork+exec:
- PR_THP_POLICY_DEFAULT_HUGE: This will set the MMF2_THP_VMA_DEFAULT_HUGE
process flag which changes the default of new VMAs to be VM_HUGEPAGE. The
call also modifies all existing VMAs that are not VM_NOHUGEPAGE
to be VM_HUGEPAGE.
This allows systems where the global policy is set to "madvise"
to effectively have THPs always for the process. In an environment
where different types of workloads are stacked on the same machine
whose global policy is set to "madvise", this will allow workloads
that benefit from always having hugepages to do so, without regressing
those that don't.
- PR_THP_POLICY_DEFAULT_NOHUGE: This will set the MMF2_THP_VMA_DEFAULT_NOHUGE
process flag which changes the default of new VMAs to be VM_NOHUGEPAGE.
The call also modifies all existing VMAs that are not VM_HUGEPAGE
to be VM_NOHUGEPAGE.
This allows systems where the global policy is set to "always"
to effectively have THPs on madvise only for the process. In an
environment where different types of workloads are stacked on the
same machine whose global policy is set to "always", this will allow
workloads that benefit from having hugepages on an madvise basis only
to do so, without regressing those that benefit from having hugepages
always.
- PR_THP_POLICY_DEFAULT_SYSTEM: This will clear the MMF2_THP_VMA_DEFAULT_HUGE
and MMF2_THP_VMA_DEFAULT_NOHUGE process flags.
These patches are required in rolling out hugepages in hyperscaler
configurations for workloads that benefit from them, where workloads are
stacked anda single THP global policy is likely to be used across the entire
fleet, and prctl will help override it.
v1->v2:
- change from modifying the THP decision making for the process, to modifying
VMA flags only. This prevents further complicating the logic used to
determine THP order (Thanks David!)
- change from using a prctl per policy change to just using PR_SET_THP_POLICY
and arg2 to set the policy. (Zi Yan)
- Introduce PR_THP_POLICY_DEFAULT_NOHUGE and PR_THP_POLICY_DEFAULT_SYSTEM
- Add selftests and documentation.
Usama Arif (6):
prctl: introduce PR_THP_POLICY_DEFAULT_HUGE for the process
prctl: introduce PR_THP_POLICY_DEFAULT_NOHUGE for the process
prctl: introduce PR_THP_POLICY_SYSTEM for the process
selftests: prctl: introduce tests for PR_THP_POLICY_DEFAULT_NOHUGE
selftests: prctl: introduce tests for PR_THP_POLICY_DEFAULT_HUGE
docs: transhuge: document process level THP controls
Documentation/admin-guide/mm/transhuge.rst | 40 +++
include/linux/huge_mm.h | 4 +
include/linux/mm_types.h | 14 +
include/uapi/linux/prctl.h | 6 +
kernel/fork.c | 1 +
kernel/sys.c | 35 +++
mm/huge_memory.c | 56 ++++
mm/vma.c | 2 +
tools/include/uapi/linux/prctl.h | 6 +
.../trace/beauty/include/uapi/linux/prctl.h | 6 +
tools/testing/selftests/prctl/Makefile | 2 +-
tools/testing/selftests/prctl/thp_policy.c | 286 ++++++++++++++++++
12 files changed, 457 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/prctl/thp_policy.c
--
2.47.1
Powered by blists - more mailing lists