sched/numa: Update numa_balancing stats in /proc
cover sched/numa: Update numa_balancing stats in /proc
Recent changes to numa balancing like adding group faults, merging numa_faults and numa_mem_faults have not been reflected in /proc.
Hence some of the numa_balancing information is not exposed or displays wrong info. This patchset tries to correct it.
Before change: /proc/pid/sched
clock-delta : 12 mm->numa_scan_seq : 34
numa_migrations, 1numa_faults_memory, 0, 0, 1, 0, -1numa_faults_memory, 1, 0, 0, 0, -1numa_faults_memory, 0, 1, 0, 0, -1numa_faults_memory, 1, 1, 0, 0, -1numa_faults_memory, 0, 2, 0, 0, -1numa_faults_memory, 1, 2, 0, 0, -1numa_faults_memory, 0, 3, 0, 0, -1numa_faults_memory, 1, 3, 0, 0, -1
After change: /proc/pid/sched
clock-delta : 12 mm->numa_scan_seq : 34 numa_pages_migrated : 1 numa_preferred_nid : 0 total_numa_faults : 2627
current_node=0, numa_group_id=6958numa_faults node=0 task_private=1344 task_shared=0 group_private=1344 group_shared=0 numa_faults node=1 task_private=641 task_shared=65 group_private=641 group_shared=65 numa_faults node=2 task_private=512 task_shared=0 group_private=512 group_shared=0 numa_faults node=3 task_private=64 task_shared=1 group_private=64 group_shared=1
Srikar Dronamraju (3):
sched: Move print_cfs_rq declaration to kernel/sched/sched.h sched/numa: Show numa_group id in sched_debug task listings sched/numa: Fix numabalancing stats in /proc/pid/sched
include/linux/sched.h | 2 -- kernel/sched/debug.c | 40 ++++++++++++++++++---------------------- kernel/sched/fair.c | 22 +++++++++++++++++++++- kernel/sched/sched.h | 13 +++++++++++++ 4 files changed, 52 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 sched: Move print_cfs_rq declaration to kernel/sched/sched.h
Currently print_cfs_rq() is declared in include/linux/sched.h. However its not used outside kernel/sched. Hence move the declaration to kernel/sched/sched.h
Also some functions are only available for CONFIG_SCHED_DEBUG. Hence move the declarations within #ifdef.
--- include/linux/sched.h | 2 -- kernel/sched/sched.h | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/sched.h +0 -2
@@ -191,8 +191,6 @@ struct task_group;#ifdef CONFIG_SCHED_DEBUG extern void proc_sched_show_task (struct task_struct *p,struct seq_file *m);extern void proc_sched_set_task (struct task_struct *p); -extern void -print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq);#endif /*
kernel/sched/sched.h +5 -0
@@ -1689,9 +1689,14 @@ static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2)extern struct sched_entity *__pick_first_entity (struct cfs_rq *cfs_rq);extern struct sched_entity *__pick_last_entity (struct cfs_rq *cfs_rq); + +#ifdef CONFIG_SCHED_DEBUG extern void print_cfs_stats (struct seq_file *m,int cpu);extern void print_rt_stats (struct seq_file *m,int cpu);extern void print_dl_stats (struct seq_file *m,int cpu); +extern void +print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); +#endif extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);
Signature · 1 line
1.8.3.1
Re: [PATCH 1/3] sched: Move print_cfs_rq declaration to kernel/sched/sched.h
Quoted 8 lines · Srikar Dronamraju
Currently
print_cfs_rq()is declared ininclude/linux/sched.h. However its not used outside kernel/sched. Hence move the declaration tokernel/sched/sched.hAlso some functions are only available for
CONFIG_SCHED_DEBUG. Hence move the declarations within #ifdef.Signed-off-by Srikar Dronamraju <[email protected]>
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
In reply to Srikar Dronamrajusched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
Commit-ID: 6e3ecb4945f06ebbf1cf00ec316511c249492b08 Gitweb: http://git.kernel.org/tip/6e3ecb4945f06ebbf1cf00ec316511c249492b08 Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:41 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 1 Jul 2015 10:31:27 +0200
sched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
Currently print_cfs_rq() is declared in include/linux/sched.h. However it's not used outside kernel/sched. Hence move the declaration to kernel/sched/sched.h
Also some functions are only available for CONFIG_SCHED_DEBUG=y. Hence move the declarations to within the #ifdef.
--- include/linux/sched.h | 2 -- kernel/sched/sched.h | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/sched.h +0 -2
@@ -191,8 +191,6 @@ struct task_group;#ifdef CONFIG_SCHED_DEBUG extern void proc_sched_show_task (struct task_struct *p,struct seq_file *m);extern void proc_sched_set_task (struct task_struct *p); -extern void -print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq);#endif /*
kernel/sched/sched.h +5 -0
@@ -1668,9 +1668,14 @@ static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2)extern struct sched_entity *__pick_first_entity (struct cfs_rq *cfs_rq);extern struct sched_entity *__pick_last_entity (struct cfs_rq *cfs_rq); + +#ifdef CONFIG_SCHED_DEBUG extern void print_cfs_stats (struct seq_file *m,int cpu);extern void print_rt_stats (struct seq_file *m,int cpu);extern void print_dl_stats (struct seq_file *m,int cpu); +extern void +print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); +#endif extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
In reply to Srikar Dronamrajusched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
Commit-ID: 6b55c9654fccf69ae7ace23ca101dc37b903181b Gitweb: http://git.kernel.org/tip/6b55c9654fccf69ae7ace23ca101dc37b903181b Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:41 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 4 Jul 2015 10:04:31 +0200
sched/debug: Move print_cfs_rq() declaration to kernel/sched/sched.h
Currently print_cfs_rq() is declared in include/linux/sched.h. However it's not used outside kernel/sched. Hence move the declaration to kernel/sched/sched.h
Also some functions are only available for CONFIG_SCHED_DEBUG=y. Hence move the declarations to within the #ifdef.
--- include/linux/sched.h | 2 -- kernel/sched/sched.h | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/sched.h +0 -2
@@ -191,8 +191,6 @@ struct task_group;#ifdef CONFIG_SCHED_DEBUG extern void proc_sched_show_task (struct task_struct *p,struct seq_file *m);extern void proc_sched_set_task (struct task_struct *p); -extern void -print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq);#endif /*
kernel/sched/sched.h +5 -0
@@ -1668,9 +1668,14 @@ static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2)extern struct sched_entity *__pick_first_entity (struct cfs_rq *cfs_rq);extern struct sched_entity *__pick_last_entity (struct cfs_rq *cfs_rq); + +#ifdef CONFIG_SCHED_DEBUG extern void print_cfs_stats (struct seq_file *m,int cpu);extern void print_rt_stats (struct seq_file *m,int cpu);extern void print_dl_stats (struct seq_file *m,int cpu); +extern void +print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); +#endif extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);
PATCH 2/3 sched/numa: Show numa_group id in sched_debug task listings
In reply to Srikar DronamrajuHaving the numa group id in /proc/sched_debug helps to see how the numa groups have spread across the system.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -142,7 +142,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) 0LL, 0L);#endif #ifdef CONFIG_NUMA_BALANCING -SEQ_printf (m," %d" ,task_node (p)); +SEQ_printf (m," %d %d" ,task_node (p),task_numa_group_id (p));#endif #ifdef CONFIG_CGROUP_SCHED SEQ_printf (m," %s" ,task_group_path (task_group (p)));
Signature · 1 line
1.8.3.1
Re: [PATCH 2/3] sched/numa: Show numa_group id in sched_debug task listings
Quoted 4 lines · Srikar Dronamraju
Having the numa group id in
/proc/sched_debughelps to see how the numa groups have spread across the system.Signed-off-by Srikar Dronamraju <[email protected]>
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/numa: Show numa_group ID in /proc/ sched_debug task listings
In reply to Srikar Dronamrajusched/numa: Show numa_group ID in /proc/sched_debug task listings
Commit-ID: 478fd9ada06ff17ae13a5b7f775346562036127e Gitweb: http://git.kernel.org/tip/478fd9ada06ff17ae13a5b7f775346562036127e Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:42 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 1 Jul 2015 10:31:27 +0200
sched/numa: Show numa_group ID in /proc/sched_debug task listings
Having the numa group ID in /proc/sched_debug helps to see how the numa groups have spread across the system.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -142,7 +142,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) 0LL, 0L);#endif #ifdef CONFIG_NUMA_BALANCING -SEQ_printf (m," %d" ,task_node (p)); +SEQ_printf (m," %d %d" ,task_node (p),task_numa_group_id (p));#endif #ifdef CONFIG_CGROUP_SCHED SEQ_printf (m," %s" ,task_group_path (task_group (p)));
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/numa: Show numa_group ID in /proc/ sched_debug task listings
In reply to Srikar Dronamrajusched/numa: Show numa_group ID in /proc/sched_debug task listings
Commit-ID: e3d24d0a6048a826de5562d75dedb664d3a2a1b2 Gitweb: http://git.kernel.org/tip/e3d24d0a6048a826de5562d75dedb664d3a2a1b2 Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:42 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 4 Jul 2015 10:04:32 +0200
sched/numa: Show numa_group ID in /proc/sched_debug task listings
Having the numa group ID in /proc/sched_debug helps to see how the numa groups have spread across the system.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -142,7 +142,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) 0LL, 0L);#endif #ifdef CONFIG_NUMA_BALANCING -SEQ_printf (m," %d" ,task_node (p)); +SEQ_printf (m," %d %d" ,task_node (p),task_numa_group_id (p));#endif #ifdef CONFIG_CGROUP_SCHED SEQ_printf (m," %s" ,task_group_path (task_group (p)));
PATCH 3/3 sched/numa: Fix numabalancing stats in /proc/pid/sched
In reply to Srikar DronamrajuCommit 44dba3d5d6a1 (sched: Refactor task_struct to use numa_faults instead of numa_* pointers) modified the way tsk->numa_faults stats are accounted. However that commit never touched show_numa_stats() that displays /proc/pid/sched. Now the numbers displayed in /proc/pid/sched dont match the actual numbers.
Fix it by making sure that /proc/pid/sched reflects the task fault numbers Also add group fault stats too.
Also couple of more modifications are added here.
1. Format change.
- Previously we would list two entries per node, one for private and one for shared. Also the home node info was listed in each entry.
- Now preferred node, total_faults and current node are displayed separately.
- Now there is one entry per node, that lists private,shared task and group faults.
2. p->numa_pages_migrated was getting reset after every read of /proc/pid/sched. Its more useful to have absolute numbers since differential migrations between two accesses can be easily calculated.
--- kernel/sched/debug.c | 38 +++++++++++++++++--------------------- kernel/sched/fair.c | 22 +++++++++++++++++++++- kernel/sched/sched.h | 10 +++++++++- 3 files changed, 47 insertions(+), 23 deletions(-)
kernel/sched/debug.c +17 -21
@@ -517,11 +517,21 @@ __initcall(init_sched_debug_procfs); SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) +#ifdef CONFIG_NUMA_BALANCING +void print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf) +{ +SEQ_printf (m,"numa_faults node=%d " , node); +SEQ_printf (m,"task_private=%lu task_shared=%lu " , tsf, tpf); +SEQ_printf (m,"group_private=%lu group_shared=%lu\n" , gsf, gpf); +} +#endif + +static void sched_show_numa (struct task_struct *p,struct seq_file *m) {#ifdef CONFIG_NUMA_BALANCING struct mempolicy *pol; -int node, i;if (p->mm)P (mm->numa_scan_seq);
@@ -533,26 +543,12 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m)mpol_get (pol);task_unlock (p); -SEQ_printf (m,"numa_migrations, %ld\n" ,xchg (&p->numa_pages_migrated,0 )); - -for_each_online_node (node) { -for (i =0 ; i <2 ; i++) { -unsigned long nr_faults =-1 ; -int cpu_current, home_node; - -if (p->numa_faults) - nr_faults = p->numa_faults[2 *node + i]; - - cpu_current = !i ? (task_node (p) == node) : - (pol &&node_isset (node, pol->v.nodes)); - - home_node = (p->numa_preferred_nid == node); - -SEQ_printf (m,"numa_faults_memory, %d, %d, %d, %d, %ld\n" , - i, node, cpu_current, home_node, nr_faults); - } - } - +P (numa_pages_migrated); +P (numa_preferred_nid); +P (total_numa_faults); +SEQ_printf (m,"current_node=%d, numa_group_id=%d\n" , +task_node (p),task_numa_group_id (p)); +show_numa_stats (p, m);mpol_put (pol);#endif }
kernel/sched/fair.c +21 -1
@@ -8473,7 +8473,27 @@ void print_cfs_stats(struct seq_file *m, int cpu)print_cfs_rq (m, cpu, cfs_rq);rcu_read_unlock (); } -#endif + +#ifdef CONFIG_NUMA_BALANCING +void show_numa_stats (struct task_struct *p,struct seq_file *m) +{ +int node; +unsigned long tsf =0 , tpf =0 , gsf =0 , gpf =0 ; + +for_each_online_node (node) { +if (p->numa_faults) { + tsf = p->numa_faults[task_faults_idx (NUMA_MEM , node,0 )]; + tpf = p->numa_faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +if (p->numa_group) { + gsf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,0 )], + gpf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +print_numa_stats (m, node, tsf, tpf, gsf, gpf); + } +} +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ __init void init_sched_fair_class (void ) {
kernel/sched/sched.h +9 -1
@@ -1696,7 +1696,15 @@ extern void print_rt_stats(struct seq_file *m, int cpu);extern void print_dl_stats (struct seq_file *m,int cpu);extern void print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); -#endif + +#ifdef CONFIG_NUMA_BALANCING +extern void +show_numa_stats (struct task_struct *p,struct seq_file *m); +extern void +print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf); +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);
Signature · 1 line
1.8.3.1
Re: [PATCH 3/3] sched/numa: Fix numabalancing stats in /proc/pid/sched
Quoted 18 lines · Srikar Dronamraju
Commit
44dba3d5d6a1(sched: Refactortask_structto usenuma_faultsinstead of numa_* pointers) modified the waytsk->numa_faultsstats are accounted. However that commit never touchedshow_numa_stats()that displays/proc/pid/sched. Now the numbers displayed in/proc/pid/scheddont match the actual numbers.Fix it by making sure that
/proc/pid/schedreflects the task fault numbers Also add group fault stats too.Also couple of more modifications are added here.
1. Format change.
- Previously we would list two entries per node, one for private and one for shared. Also the home node info was listed in each entry.- Now preferred node,
total_faultsand current node are displayed separately.
- Now there is one entry per node, that lists private,shared task and group faults.
Quoted 5 lines
2.
p->numa_pages_migratedwas getting reset after every read of/proc/pid/sched. Its more useful to have absolute numbers since differential migrations between two accesses can be easily calculated.Signed-off-by Srikar Dronamraju <[email protected]>
Thank you for updating the statistics to match what the code does nowadays.
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/numa: Fix numa balancing stats in /proc/ pid/sched
In reply to Srikar Dronamrajusched/numa: Fix numa balancing stats in /proc/pid/sched
Commit-ID: 46fb6b9762d13fdeeefb3a9e9c317ebcd344f578 Gitweb: http://git.kernel.org/tip/46fb6b9762d13fdeeefb3a9e9c317ebcd344f578 Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:43 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 1 Jul 2015 10:31:28 +0200
sched/numa: Fix numa balancing stats in /proc/pid/sched
Commit 44dba3d5d6a1 ("sched: Refactor task_struct to use numa_faults instead of numa_* pointers") modified the way tsk->numa_faults stats are accounted.
However that commit never touched show_numa_stats() that is displayed in /proc/pid/sched and thus the numbers displayed in /proc/pid/sched don't match the actual numbers.
Fix it by making sure that /proc/pid/sched reflects the task fault numbers. Also add group fault stats too.
Also couple of more modifications are added here:
1. Format changes:
- Previously we would list two entries per node, one for private and one for shared. Also the home node info was listed in each entry.
- Now preferred node, total_faults and current node are displayed separately.
- Now there is one entry per node, that lists private,shared task and group faults.
2. Unit changes:
- p->numa_pages_migrated was getting reset after every read of /proc/pid/sched. It's more useful to have absolute numbers since differential migrations between two accesses can be more easily calculated.
--- kernel/sched/debug.c | 38 +++++++++++++++++--------------------- kernel/sched/fair.c | 22 +++++++++++++++++++++- kernel/sched/sched.h | 10 +++++++++- 3 files changed, 47 insertions(+), 23 deletions(-)
kernel/sched/debug.c +17 -21
@@ -517,11 +517,21 @@ __initcall(init_sched_debug_procfs); SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) +#ifdef CONFIG_NUMA_BALANCING +void print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf) +{ +SEQ_printf (m,"numa_faults node=%d " , node); +SEQ_printf (m,"task_private=%lu task_shared=%lu " , tsf, tpf); +SEQ_printf (m,"group_private=%lu group_shared=%lu\n" , gsf, gpf); +} +#endif + +static void sched_show_numa (struct task_struct *p,struct seq_file *m) {#ifdef CONFIG_NUMA_BALANCING struct mempolicy *pol; -int node, i;if (p->mm)P (mm->numa_scan_seq);
@@ -533,26 +543,12 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m)mpol_get (pol);task_unlock (p); -SEQ_printf (m,"numa_migrations, %ld\n" ,xchg (&p->numa_pages_migrated,0 )); - -for_each_online_node (node) { -for (i =0 ; i <2 ; i++) { -unsigned long nr_faults =-1 ; -int cpu_current, home_node; - -if (p->numa_faults) - nr_faults = p->numa_faults[2 *node + i]; - - cpu_current = !i ? (task_node (p) == node) : - (pol &&node_isset (node, pol->v.nodes)); - - home_node = (p->numa_preferred_nid == node); - -SEQ_printf (m,"numa_faults_memory, %d, %d, %d, %d, %ld\n" , - i, node, cpu_current, home_node, nr_faults); - } - } - +P (numa_pages_migrated); +P (numa_preferred_nid); +P (total_numa_faults); +SEQ_printf (m,"current_node=%d, numa_group_id=%d\n" , +task_node (p),task_numa_group_id (p)); +show_numa_stats (p, m);mpol_put (pol);#endif }
kernel/sched/fair.c +21 -1
@@ -8468,7 +8468,27 @@ void print_cfs_stats(struct seq_file *m, int cpu)print_cfs_rq (m, cpu, cfs_rq);rcu_read_unlock (); } -#endif + +#ifdef CONFIG_NUMA_BALANCING +void show_numa_stats (struct task_struct *p,struct seq_file *m) +{ +int node; +unsigned long tsf =0 , tpf =0 , gsf =0 , gpf =0 ; + +for_each_online_node (node) { +if (p->numa_faults) { + tsf = p->numa_faults[task_faults_idx (NUMA_MEM , node,0 )]; + tpf = p->numa_faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +if (p->numa_group) { + gsf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,0 )], + gpf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +print_numa_stats (m, node, tsf, tpf, gsf, gpf); + } +} +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ __init void init_sched_fair_class (void ) {
kernel/sched/sched.h +9 -1
@@ -1675,7 +1675,15 @@ extern void print_rt_stats(struct seq_file *m, int cpu);extern void print_dl_stats (struct seq_file *m,int cpu);extern void print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); -#endif + +#ifdef CONFIG_NUMA_BALANCING +extern void +show_numa_stats (struct task_struct *p,struct seq_file *m); +extern void +print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf); +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);
tip-bot for Srikar Dronamraju
merge bot[tip:sched/urgent] sched/numa: Fix numa balancing stats in /proc/ pid/sched
In reply to Srikar Dronamrajusched/numa: Fix numa balancing stats in /proc/pid/sched
Commit-ID: 397f2378f136128623fc237746157aa2564d1082 Gitweb: http://git.kernel.org/tip/397f2378f136128623fc237746157aa2564d1082 Author: Srikar Dronamraju <[email protected]> AuthorDate: Thu, 25 Jun 2015 22:51:43 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 4 Jul 2015 10:04:33 +0200
sched/numa: Fix numa balancing stats in /proc/pid/sched
Commit 44dba3d5d6a1 ("sched: Refactor task_struct to use numa_faults instead of numa_* pointers") modified the way tsk->numa_faults stats are accounted.
However that commit never touched show_numa_stats() that is displayed in /proc/pid/sched and thus the numbers displayed in /proc/pid/sched don't match the actual numbers.
Fix it by making sure that /proc/pid/sched reflects the task fault numbers. Also add group fault stats too.
Also couple of more modifications are added here:
1. Format changes:
- Previously we would list two entries per node, one for private and one for shared. Also the home node info was listed in each entry.
- Now preferred node, total_faults and current node are displayed separately.
- Now there is one entry per node, that lists private,shared task and group faults.
2. Unit changes:
- p->numa_pages_migrated was getting reset after every read of /proc/pid/sched. It's more useful to have absolute numbers since differential migrations between two accesses can be more easily calculated.
--- kernel/sched/debug.c | 38 +++++++++++++++++--------------------- kernel/sched/fair.c | 22 +++++++++++++++++++++- kernel/sched/sched.h | 10 +++++++++- 3 files changed, 47 insertions(+), 23 deletions(-)
kernel/sched/debug.c +17 -21
@@ -517,11 +517,21 @@ __initcall(init_sched_debug_procfs); SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) +#ifdef CONFIG_NUMA_BALANCING +void print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf) +{ +SEQ_printf (m,"numa_faults node=%d " , node); +SEQ_printf (m,"task_private=%lu task_shared=%lu " , tsf, tpf); +SEQ_printf (m,"group_private=%lu group_shared=%lu\n" , gsf, gpf); +} +#endif + +static void sched_show_numa (struct task_struct *p,struct seq_file *m) {#ifdef CONFIG_NUMA_BALANCING struct mempolicy *pol; -int node, i;if (p->mm)P (mm->numa_scan_seq);
@@ -533,26 +543,12 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m)mpol_get (pol);task_unlock (p); -SEQ_printf (m,"numa_migrations, %ld\n" ,xchg (&p->numa_pages_migrated,0 )); - -for_each_online_node (node) { -for (i =0 ; i <2 ; i++) { -unsigned long nr_faults =-1 ; -int cpu_current, home_node; - -if (p->numa_faults) - nr_faults = p->numa_faults[2 *node + i]; - - cpu_current = !i ? (task_node (p) == node) : - (pol &&node_isset (node, pol->v.nodes)); - - home_node = (p->numa_preferred_nid == node); - -SEQ_printf (m,"numa_faults_memory, %d, %d, %d, %d, %ld\n" , - i, node, cpu_current, home_node, nr_faults); - } - } - +P (numa_pages_migrated); +P (numa_preferred_nid); +P (total_numa_faults); +SEQ_printf (m,"current_node=%d, numa_group_id=%d\n" , +task_node (p),task_numa_group_id (p)); +show_numa_stats (p, m);mpol_put (pol);#endif }
kernel/sched/fair.c +21 -1
@@ -8468,7 +8468,27 @@ void print_cfs_stats(struct seq_file *m, int cpu)print_cfs_rq (m, cpu, cfs_rq);rcu_read_unlock (); } -#endif + +#ifdef CONFIG_NUMA_BALANCING +void show_numa_stats (struct task_struct *p,struct seq_file *m) +{ +int node; +unsigned long tsf =0 , tpf =0 , gsf =0 , gpf =0 ; + +for_each_online_node (node) { +if (p->numa_faults) { + tsf = p->numa_faults[task_faults_idx (NUMA_MEM , node,0 )]; + tpf = p->numa_faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +if (p->numa_group) { + gsf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,0 )], + gpf = p->numa_group->faults[task_faults_idx (NUMA_MEM , node,1 )]; + } +print_numa_stats (m, node, tsf, tpf, gsf, gpf); + } +} +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ __init void init_sched_fair_class (void ) {
kernel/sched/sched.h +9 -1
@@ -1675,7 +1675,15 @@ extern void print_rt_stats(struct seq_file *m, int cpu);extern void print_dl_stats (struct seq_file *m,int cpu);extern void print_cfs_rq (struct seq_file *m,int cpu,struct cfs_rq *cfs_rq); -#endif + +#ifdef CONFIG_NUMA_BALANCING +extern void +show_numa_stats (struct task_struct *p,struct seq_file *m); +extern void +print_numa_stats (struct seq_file *m,int node,unsigned long tsf, +unsigned long tpf,unsigned long gsf,unsigned long gpf); +#endif /* CONFIG_NUMA_BALANCING */ +#endif /* CONFIG_SCHED_DEBUG */ extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq);