mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li Zhe" <lizhe.67@bytedance.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
	<juri.lelli@redhat.com>,  <vincent.guittot@linaro.org>,
	<dietmar.eggemann@arm.com>,  <rostedt@goodmis.org>,
	<bsegall@google.com>, <mgorman@suse.de>,  <vschneid@redhat.com>,
	<kprateek.nayak@amd.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	 <linux-doc@vger.kernel.org>, <lizhe.67@bytedance.com>
Subject: [PATCH 0/4] sched/numa: Add per-process automatic NUMA balancing control
Date: Tue,  8 Sep 2026 20:24:42 +0800	[thread overview]
Message-ID: <20260908122446.56708-1-lizhe.67@bytedance.com> (raw)

Automatic NUMA balancing is controlled globally through the
kernel.numa_balancing sysctl and can be influenced indirectly through
memory policy. That works well as a system default, but it is too coarse
for workloads where a launcher wants most processes to use the default
policy while a selected process opts out because it already manages NUMA
placement or cannot afford the sampling overhead.

A recent per-cgroup proposal tried to address this by adding a
cgroup-local enable knob plus a NUMA_BALANCING_CGROUP mode where
balancing was disabled by default and then enabled for selected cgroups
[1]. The discussion also noted that automatic NUMA balancing already
operates at task/process granularity, that the knob is not a resource
control attribute, and that task/process controls such as sched_setattr()
or prctl() may be a better fit while cgroups and cpusets continue to
describe workload grouping and placement domains.

There is also prior art from 2023 prctl() proposals [2][3]. Those
versions used a per-mm mode with disabled/enabled/default states, added
NumaB_mode to /proc/<pid>/status, and changed the global static key
handling so a per-process enable could override the global sysctl.

This series takes a more conservative variant to preserve existing
administrator and workload expectations. Keeping the global sysctl as a
hard off switch means an administrator can still disable all automatic
NUMA balancing activity with one knob. Using a weak two-state
per-process opt-out/allow ABI avoids exposing a "default" state whose
meaning depends on global policy and is therefore easy to misinterpret.
Storing the configured mode in signal_struct gives the control explicit
thread-group semantics and avoids making unrelated non-thread CLONE_VM
users share the policy merely because they share an mm.

The series implements a per-process interface: a thread group may use
prctl() to set or get its configured automatic NUMA balancing mode. A
process can opt out of new periodic NUMA scan scheduling and NUMA
scheduler accounting, or opt back in. Existing hinting faults and queued
work are allowed to drain naturally as the disabled state takes effect.
When kernel.numa_balancing is 0, a process-local enable request does not
override it.

A separate task_struct scheduler snapshot is used by enqueue/dequeue
accounting so the scheduler can consistently account the state that was
in effect when a task entered the runqueue. This avoids changing
historical task accounting while still allowing a process mode change to
take effect through the normal dequeue/update/enqueue path.

The series also exposes the process NUMA balancing mode in
/proc/<pid>/status and documents the new prctl() ABI and its interaction
with the global sysctl.

[1]: https://lore.kernel.org/all/20250625102337.3128193-1-yu.c.chen@intel.com/
[2]: https://lore.kernel.org/all/20230412140701.58337-1-ligang.bdlg@bytedance.com/
[3]: https://lore.kernel.org/all/20230412141127.59741-1-ligang.bdlg@bytedance.com/

Li Zhe (4):
  sched/numa: Track per-process automatic NUMA balancing mode
  sched/numa: Add prctl controls for process mode
  proc: Report process NUMA balancing mode
  Documentation: Describe per-process NUMA balancing control

 Documentation/admin-guide/sysctl/kernel.rst | 16 ++++++++
 Documentation/filesystems/proc.rst          |  6 +++
 fs/proc/array.c                             | 16 ++++++++
 include/linux/sched.h                       |  6 +++
 include/linux/sched/numa_balancing.h        | 42 +++++++++++++++++++++
 include/linux/sched/signal.h                |  8 ++++
 include/uapi/linux/prctl.h                  |  6 +++
 init/init_task.c                            |  4 ++
 kernel/fork.c                               |  8 ++++
 kernel/sched/core.c                         | 39 +++++++++++++++++++
 kernel/sched/fair.c                         | 36 ++++++++++++++++--
 kernel/sys.c                                | 18 +++++++++
 12 files changed, 201 insertions(+), 4 deletions(-)

-- 
2.20.1

             reply	other threads:[~2026-09-08 12:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 12:24 Li Zhe [this message]
2026-09-08 12:24 ` [PATCH 1/4] sched/numa: Track per-process automatic NUMA balancing mode Li Zhe
2026-10-13  9:54   ` Chen Yu
2026-09-08 12:24 ` [PATCH 2/4] sched/numa: Add prctl controls for process mode Li Zhe
2026-09-08 12:24 ` [PATCH 3/4] proc: Report process NUMA balancing mode Li Zhe
2026-09-08 12:24 ` [PATCH 4/4] Documentation: Describe per-process NUMA balancing control Li Zhe
2026-10-13  7:39 ` [PATCH 0/4] sched/numa: Add per-process automatic " Chen Yu
2026-10-13  9:31   ` Yafang Shao
2026-10-14  7:16     ` Li Zhe
2026-10-15 19:58     ` Tim Chen
2026-10-16  2:53       ` Yafang Shao
2026-10-16  5:38         ` Chen Yu
2026-10-16  7:38           ` Yafang Shao
2026-10-16  8:01             ` Chen, Yu C
2026-10-16  8:18               ` Yafang Shao
2026-10-16 20:32                 ` Tim Chen
2026-10-17  1:59                   ` Yafang Shao
2026-10-14  7:05   ` Li Zhe

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=20260908122446.56708-1-lizhe.67@bytedance.com \
    --to=lizhe.67@bytedance.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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

all inboxes | Powered by JetHome®