Skip to contentSkip to conversation

sched/numa: initialize numa statistics when forking new task

PATCH Applied Honglei Wang 4 participants 5 messages Jan 13, 2022 – Jan 28, 2022 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/numa: initialize numa statistics when forking new task

The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork.

---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sched/fair.c +2 -0
index 6e476f6d9435..1aa0ec123a4b 100644
@@ -2826,6 +2826,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
 	/* Protect against double add, see task_tick_numa and task_numa_work */
 	p->numa_work.next		= &p->numa_work;
 	p->numa_faults			= NULL;
+	p->numa_pages_migrated		= 0;
+	p->total_numa_faults		= 0;
 	RCU_INIT_POINTER(p->numa_group, NULL);
 	p->last_task_numa_placement	= 0;
 	p->last_sum_exec_runtime	= 0;
Signature · 1 line
2.14.1
#1 lore raw

Hello, friendly ping... any comments about this?

Quoted 26 lines · Honglei Wang

The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork.

---
kernel/sched/fair.c | 2 ++

1 file changed, 2 insertions(+)
kernel/sched/fair.c +2 -0
index 6e476f6d9435..1aa0ec123a4b 100644
@@ -2826,6 +2826,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
 	/* Protect against double add, see task_tick_numa and task_numa_work */
 	p->numa_work.next		= &p->numa_work;
 	p->numa_faults			= NULL;
+	p->numa_pages_migrated		= 0;
+	p->total_numa_faults		= 0;
 	RCU_INIT_POINTER(p->numa_group, NULL);
 	p->last_task_numa_placement	= 0;
 	p->last_sum_exec_runtime	= 0;
Signature · 1 line
2.14.1
#2 lore raw

Hello, friendly ping... any comments about this?

Quoted 26 lines · Honglei Wang

The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork.

---
  kernel/sched/fair.c | 2 ++
  1 file changed, 2 insertions(+)
kernel/sched/fair.c +2 -0
index 6e476f6d9435..1aa0ec123a4b 100644
@@ -2826,6 +2826,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
 	/* Protect against double add, see task_tick_numa and task_numa_work */
 	p->numa_work.next		= &p->numa_work;
 	p->numa_faults			= NULL;
+	p->numa_pages_migrated		= 0;
+	p->total_numa_faults		= 0;
 	RCU_INIT_POINTER(p->numa_group, NULL);
 	p->last_task_numa_placement	= 0;
 	p->last_sum_exec_runtime	= 0;
Signature · 1 line
2.14.1
reviewer Acked-by on v1 1/1
#3 lore raw
In reply to Honglei Wang
Quoted 7 lines · Honglei Wang

The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork.

Signature · 2 lines
Mel Gorman
SUSE Labs
merge bot Applied
#4 lore raw
In reply to Honglei Wang
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     12bf8a7eb84e4d3547ebfd89bb0a9255a0f2acc7
Gitweb:        https://git.kernel.org/tip/12bf8a7eb84e4d3547ebfd89bb0a9255a0f2acc7
Author:        Honglei Wang <[email protected]>
AuthorDate:    Thu, 13 Jan 2022 21:39:20 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 27 Jan 2022 12:57:18 +01:00

sched/numa: initialize numa statistics when forking new task

The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork.

---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sched/fair.c +2 -0
index 095b0aa..5dca13f 100644
@@ -2825,6 +2825,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
 	/* Protect against double add, see task_tick_numa and task_numa_work */
 	p->numa_work.next		= &p->numa_work;
 	p->numa_faults			= NULL;
+	p->numa_pages_migrated		= 0;
+	p->total_numa_faults		= 0;
 	RCU_INIT_POINTER(p->numa_group, NULL);
 	p->last_task_numa_placement	= 0;
 	p->last_sum_exec_runtime	= 0;