[PATCH v5 0/2] sched/numa: add statistics of numa balance task migration

Chen Yu posted 2 patches 6 months, 3 weeks ago
There is a newer version of this series
Documentation/admin-guide/cgroup-v2.rst | 6 ++++++
include/linux/sched.h                   | 4 ++++
include/linux/vm_event_item.h           | 2 ++
kernel/sched/core.c                     | 9 +++++++--
kernel/sched/debug.c                    | 4 ++++
kernel/sched/fair.c                     | 3 ++-
mm/memcontrol.c                         | 2 ++
mm/vmstat.c                             | 2 ++
8 files changed, 29 insertions(+), 3 deletions(-)
[PATCH v5 0/2] sched/numa: add statistics of numa balance task migration
Posted by Chen Yu 6 months, 3 weeks ago
Introducing the task migration and swap statistics in the following places:
/sys/fs/cgroup/{GROUP}/memory.stat
/proc/{PID}/sched
/proc/vmstat

These statistics facilitate a rapid evaluation of the performance and resource
utilization of the target workload.

Patch 1 is a fix from Libo to avoid task swapping for kernel threads
and user thread that does not have mm, because Numa balance only cares
about the user pages via VMA.

Patch 2 is the major change to expose the statistics of task migration and
swapping in corresponding files.

The reason to fold patch 1 and patch 2 into 1 patch set is that patch 1 is
necessary for patch 2 to avoid accessing a NULL mm_struct from a kernel
thread, which causes NULL pointer exception.

Changes since v4:
Skip the kernel thread in patch 1, by checking if the target thread
has PF_KTHREAD(Peter). Besides, remove the check for PF_IDLE, because
idle thread has PF_KTHREAD set already(Prateek).

Previous version:
v4:
https://lore.kernel.org/all/cover.1746611892.git.yu.c.chen@intel.com/
v3:
https://lore.kernel.org/lkml/20250430103623.3349842-1-yu.c.chen@intel.com/
v2:
https://lore.kernel.org/lkml/20250408101444.192519-1-yu.c.chen@intel.com/
v1:
https://lore.kernel.org/lkml/20250402010611.3204674-1-yu.c.chen@intel.com/

Chen Yu (1):
  sched/numa: add statistics of numa balance task

Libo Chen (1):
  sched/numa: fix task swap by skipping kernel threads

 Documentation/admin-guide/cgroup-v2.rst | 6 ++++++
 include/linux/sched.h                   | 4 ++++
 include/linux/vm_event_item.h           | 2 ++
 kernel/sched/core.c                     | 9 +++++++--
 kernel/sched/debug.c                    | 4 ++++
 kernel/sched/fair.c                     | 3 ++-
 mm/memcontrol.c                         | 2 ++
 mm/vmstat.c                             | 2 ++
 8 files changed, 29 insertions(+), 3 deletions(-)

-- 
2.25.1
Re: [PATCH v5 0/2] sched/numa: add statistics of numa balance task migration
Posted by Andrew Morton 6 months, 3 weeks ago
On Fri, 23 May 2025 20:48:02 +0800 Chen Yu <yu.c.chen@intel.com> wrote:

> Introducing the task migration and swap statistics in the following places:
> /sys/fs/cgroup/{GROUP}/memory.stat
> /proc/{PID}/sched
> /proc/vmstat
> 
> These statistics facilitate a rapid evaluation of the performance and resource
> utilization of the target workload.

Thanks.  I added this.

We're late in -rc7 but an earlier verison of this did have a run in
linux-next.  Could reviewers please take a look relatively soon, let us
know whether they believe this looks suitable for 6.16-rc1?
Re: [PATCH v5 0/2] sched/numa: add statistics of numa balance task migration
Posted by Shakeel Butt 6 months, 3 weeks ago
On Fri, May 23, 2025 at 03:06:35PM -0700, Andrew Morton wrote:
> On Fri, 23 May 2025 20:48:02 +0800 Chen Yu <yu.c.chen@intel.com> wrote:
> 
> > Introducing the task migration and swap statistics in the following places:
> > /sys/fs/cgroup/{GROUP}/memory.stat
> > /proc/{PID}/sched
> > /proc/vmstat
> > 
> > These statistics facilitate a rapid evaluation of the performance and resource
> > utilization of the target workload.
> 
> Thanks.  I added this.
> 
> We're late in -rc7 but an earlier verison of this did have a run in
> linux-next.  Could reviewers please take a look relatively soon, let us
> know whether they believe this looks suitable for 6.16-rc1?
> 

The stats seems valuable but I am not convinced that memcg is the right
home for these stats. So, please hold until that is resolved.
Re: [PATCH v5 0/2] sched/numa: add statistics of numa balance task migration
Posted by Andrew Morton 6 months, 2 weeks ago
On Fri, 23 May 2025 16:52:46 -0700 Shakeel Butt <shakeel.butt@linux.dev> wrote:

> On Fri, May 23, 2025 at 03:06:35PM -0700, Andrew Morton wrote:
> > On Fri, 23 May 2025 20:48:02 +0800 Chen Yu <yu.c.chen@intel.com> wrote:
> > 
> > > Introducing the task migration and swap statistics in the following places:
> > > /sys/fs/cgroup/{GROUP}/memory.stat
> > > /proc/{PID}/sched
> > > /proc/vmstat
> > > 
> > > These statistics facilitate a rapid evaluation of the performance and resource
> > > utilization of the target workload.
> > 
> > Thanks.  I added this.
> > 
> > We're late in -rc7 but an earlier verison of this did have a run in
> > linux-next.  Could reviewers please take a look relatively soon, let us
> > know whether they believe this looks suitable for 6.16-rc1?
> > 
> 
> The stats seems valuable but I am not convinced that memcg is the right
> home for these stats. So, please hold until that is resolved.

No probs, I'll keep these in mm-new until something changes.