sched: Add new tracepoints required for EAS testing
v3 cover sched: Add new tracepoints required for EAS testing
Changes in v3:
- Split pelt_rq TP into pelt_cfs, pelt_rq, pelt_dl and pelt_irq
- Replace the fatty preprocessing wrappers with exported helper functions to access data in unexported structures.
- Remove the now unnecessary headers that were introduced in the previous versions.
- Postfix the tracepoints with '_tp' to make them standout more in the code as bare tracepoints with no events associated.
- Updated the example module in [2]
- It demonstrates now how to convert the tracepoints into trace events that extend the sched events subsystem in tracefs.
Changes in v2:
- Add include guards to the newly added headers
- Rename tracepoints:
sched_load_rq -> pelt_rq
sched_load_se -> pelt_se
- Rename helper functions: s/sched_tp/sched_trace/
- Make sched_trace*() less fat by reducing path size to 20 bytes from 64.
- Fix compilation error when building on UP
The following patches add the bare minimum tracepoints required to perform EAS testing in Lisa[1].
The new tracepoints are bare in a sense that they don't export any info in tracefs, hence shouldn't introduce any ABI. The intended way to use them is by loading a module that will probe the tracepoints and extract the info required for userspace testing.
It is done in this way because adding new TRACE_EVENTS() is no longer accepted AFAIU.
The tracepoints are focused around tracking PELT signals which is what EAS uses to make its decision, hence knowing the value of PELT as it changes allows verifying that EAS is doing the right thing based on synthetic tests that simulate different scenarios.
Beside EAS, the new tracepoints can help investigate CFS load balancer and CFS taskgroup handling as they are both based on PELT signals too.
Patch 1 exports autogroup_path function.
Patch 2 adds helper/accessor functions to extract info from unexported data structures that are passed in the tracepoints. eg: access to sched_avg inside cfs_rq.
Patches 3-5 add the new tracepoints.
Patch 6 exports the tracepoints so that out of tree modules can probe the new tracepoints with least amount of effort - which extends the usefulness of the tracepoints since creating a module to probe them is the only way to access them.
An example module that uses these tracepoints is available in [2].
[1] https://github.com/ARM-software/lisa
[2] https://github.com/qais-yousef/tracepoints-helpers/tree/pelt-tps-v3-create-events/sched_tp
Qais Yousef (6):
sched: autogroup: Make autogroup_path() always available
sched: add a new sched_trace_*() helper functions
sched: Add new tracepoints to track pelt at rq level
sched: Add new tracepoint to track pelt at se level
sched: Add sched_overutilized tracepoint
sched: export the newly added tracepoints
include/linux/sched.h | 16 ++++- include/trace/events/sched.h | 31 ++++++++++ kernel/sched/autogroup.c | 2 - kernel/sched/core.c | 11 ++++ kernel/sched/fair.c | 117 ++++++++++++++++++++++++++++++++++- kernel/sched/pelt.c | 11 +++- 6 files changed, 182 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/6 sched: autogroup: Make autogroup_path() always available
By removing the #ifdef CONFIG_SCHED_DEBUG
Some of the tracepoints to be introduced in later patches need to access this function. Hence make it always available since the tracepoints are not protected by CONFIG_SCHED_DEBUG.
--- kernel/sched/autogroup.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/autogroup.c +0 -2
@@ -259,7 +259,6 @@ void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m) }#endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_SCHED_DEBUG int autogroup_path (struct task_group *tg,char *buf,int buflen) {if (!task_group_is_autogroup (tg))
@@ -267,4 +266,3 @@ int autogroup_path(struct task_group *tg, char *buf, int buflen)return snprintf (buf, buflen,"%s-%ld" ,"/autogroup" , tg->autogroup->id); } -#endif
Signature · 1 line
2.17.1
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/autogroup: Make autogroup_path() always available
sched/autogroup: Make autogroup_path() always available
Commit-ID: 9ba5090aecac08ff3ae54ac3bd94b61db7708ffc Gitweb: https://git.kernel.org/tip/9ba5090aecac08ff3ae54ac3bd94b61db7708ffc Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:54 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:40 +0200
sched/autogroup: Make autogroup_path() always available
Remove the #ifdef CONFIG_SCHED_DEBUG.
Some of the tracepoints to be introduced in later patches need to access this function. Hence make it always available since the tracepoints are not protected by CONFIG_SCHED_DEBUG.
--- kernel/sched/autogroup.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/autogroup.c +0 -2
@@ -259,7 +259,6 @@ out: }#endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_SCHED_DEBUG int autogroup_path (struct task_group *tg,char *buf,int buflen) {if (!task_group_is_autogroup (tg))
@@ -267,4 +266,3 @@ int autogroup_path(struct task_group *tg, char *buf, int buflen)return snprintf (buf, buflen,"%s-%ld" ,"/autogroup" , tg->autogroup->id); } -#endif
PATCH v3 2/6 sched: add a new sched_trace_*() helper functions
In reply to Qais YousefThe new functions allow modules to access internal data structures of unexported struct cfs_rq and struct rq to extract important information from the tracepoints to be introduced in later patches.
While at it fix alphabetical order of struct declarations in sched.h
--- include/linux/sched.h | 16 ++++++- kernel/sched/fair.c | 99 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-)
include/linux/sched.h +15 -1
@@ -35,6 +35,7 @@ struct audit_context;struct backing_dev_info ;struct bio_list ;struct blk_plug ; +struct capture_control ;struct cfs_rq ;struct fs_struct ;struct futex_pi_state ;
@@ -47,8 +48,9 @@ struct pid_namespace;struct pipe_inode_info ;struct rcu_node ;struct reclaim_state ; -struct capture_control ;struct robust_list_head ; +struct root_domain ; +struct rq ;struct sched_attr ;struct sched_param ;struct seq_file ;
@@ -1919,4 +1921,16 @@ static inline void rseq_syscall(struct pt_regs *regs)#endif +const struct sched_avg *sched_trace_cfs_rq_avg (struct cfs_rq *cfs_rq); +char *sched_trace_cfs_rq_path (struct cfs_rq *cfs_rq,char *str,int len); +int sched_trace_cfs_rq_cpu (struct cfs_rq *cfs_rq); + +const struct sched_avg *sched_trace_rq_avg_rt (struct rq *rq); +const struct sched_avg *sched_trace_rq_avg_dl (struct rq *rq); +const struct sched_avg *sched_trace_rq_avg_irq (struct rq *rq); + +int sched_trace_rq_cpu (struct rq *rq); + +const struct cpumask *sched_trace_rd_span (struct root_domain *rd); +#endif
kernel/sched/fair.c +99 -0
114 lines not on this page · raw message
Signature · 1 line
2.17.1
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/debug: Add a new sched_trace_*() helper functions
sched/debug: Add a new sched_trace_*() helper functions
Commit-ID: 3c93a0c04dfdcba199982b53b97488b1b1d90eff Gitweb: https://git.kernel.org/tip/3c93a0c04dfdcba199982b53b97488b1b1d90eff Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:55 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:41 +0200
sched/debug: Add a new sched_trace_*() helper functions
The new functions allow modules to access internal data structures of unexported struct cfs_rq and struct rq to extract important information from the tracepoints to be introduced in later patches.
While at it fix alphabetical order of struct declarations in sched.h
--- include/linux/sched.h | 16 ++++++++- kernel/sched/fair.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-)
include/linux/sched.h +15 -1
@@ -35,6 +35,7 @@ struct audit_context;struct backing_dev_info ;struct bio_list ;struct blk_plug ; +struct capture_control ;struct cfs_rq ;struct fs_struct ;struct futex_pi_state ;
@@ -47,8 +48,9 @@ struct pid_namespace;struct pipe_inode_info ;struct rcu_node ;struct reclaim_state ; -struct capture_control ;struct robust_list_head ; +struct root_domain ; +struct rq ;struct sched_attr ;struct sched_param ;struct seq_file ;
@@ -1920,4 +1922,16 @@ static inline void rseq_syscall(struct pt_regs *regs)#endif +const struct sched_avg *sched_trace_cfs_rq_avg (struct cfs_rq *cfs_rq); +char *sched_trace_cfs_rq_path (struct cfs_rq *cfs_rq,char *str,int len); +int sched_trace_cfs_rq_cpu (struct cfs_rq *cfs_rq); + +const struct sched_avg *sched_trace_rq_avg_rt (struct rq *rq); +const struct sched_avg *sched_trace_rq_avg_dl (struct rq *rq); +const struct sched_avg *sched_trace_rq_avg_irq (struct rq *rq); + +int sched_trace_rq_cpu (struct rq *rq); + +const struct cpumask *sched_trace_rd_span (struct root_domain *rd); +#endif
kernel/sched/fair.c +99 -0
114 lines not on this page · raw message
PATCH v3 3/6 sched: Add new tracepoints to track pelt at rq level
In reply to Qais YousefThe new tracepoints allow tracking PELT signals at rq level for all scheduling classes + irq.
--- include/trace/events/sched.h | 23 +++++++++++++++++++++++ kernel/sched/fair.c | 6 ++++++ kernel/sched/pelt.c | 9 ++++++++- 3 files changed, 37 insertions(+), 1 deletion(-)
include/trace/events/sched.h +23 -0
@@ -594,6 +594,29 @@ TRACE_EVENT(sched_wake_idle_without_ipi,TP_printk ("cpu=%d" , __entry->cpu) ); + +/* +* Following tracepoints are not exported in tracefs and provide hooking +* mechanisms only for testing and debugging purposes. +* +* Postfixed with _tp to make them easily identifiable in the code. +*/ +DECLARE_TRACE (pelt_cfs_tp, + TP_PROTO(struct cfs_rq *cfs_rq), +TP_ARGS (cfs_rq)); + +DECLARE_TRACE (pelt_rt_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); + +DECLARE_TRACE (pelt_dl_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); + +DECLARE_TRACE (pelt_irq_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +6 -0
@@ -3353,6 +3353,8 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)update_tg_cfs_util (cfs_rq, se, gcfs_rq);update_tg_cfs_runnable (cfs_rq, se, gcfs_rq); +trace_pelt_cfs_tp (cfs_rq); +return 1 ; }
@@ -3505,6 +3507,8 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *sadd_tg_cfs_propagate (cfs_rq, se->avg.load_sum);cfs_rq_util_change (cfs_rq, flags); + +trace_pelt_cfs_tp (cfs_rq); }/**
@@ -3524,6 +3528,8 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *sadd_tg_cfs_propagate (cfs_rq, -se->avg.load_sum);cfs_rq_util_change (cfs_rq,0 ); + +trace_pelt_cfs_tp (cfs_rq); }/*
kernel/sched/pelt.c +8 -1
@@ -28,6 +28,8 @@#include "sched.h" #include "pelt.h" +#include <trace/events/sched.h> +/* * Approximate: * val * y^n, where y^32 ~= 0.5 (~1 scheduling period)
@@ -292,6 +294,7 @@ int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq) cfs_rq->curr != NULL)) {___update_load_avg (&cfs_rq->avg,1 ,1 ); +trace_pelt_cfs_tp (cfs_rq);return 1 ; }
@@ -317,6 +320,7 @@ int update_rt_rq_load_avg(u64 now, struct rq *rq, int running) running)) {___update_load_avg (&rq->avg_rt,1 ,1 ); +trace_pelt_rt_tp (rq);return 1 ; }
@@ -340,6 +344,7 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running) running)) {___update_load_avg (&rq->avg_dl,1 ,1 ); +trace_pelt_dl_tp (rq);return 1 ; }
@@ -388,8 +393,10 @@ int update_irq_load_avg(struct rq *rq, u64 running)1 , 1); -if (ret) +if (ret) {___update_load_avg (&rq->avg_irq,1 ,1 ); +trace_pelt_irq_tp (rq); + }return ret; }
Signature · 1 line
2.17.1
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/debug: Add new tracepoints to track PELT at rq level
sched/debug: Add new tracepoints to track PELT at rq level
Commit-ID: ba19f51fcb549c7ee6261da243eea55a47e98d78 Gitweb: https://git.kernel.org/tip/ba19f51fcb549c7ee6261da243eea55a47e98d78 Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:56 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:41 +0200
sched/debug: Add new tracepoints to track PELT at rq level
The new tracepoints allow tracking PELT signals at rq level for all scheduling classes + irq.
--- include/trace/events/sched.h | 23 +++++++++++++++++++++++ kernel/sched/fair.c | 6 ++++++ kernel/sched/pelt.c | 9 ++++++++- 3 files changed, 37 insertions(+), 1 deletion(-)
include/trace/events/sched.h +23 -0
@@ -594,6 +594,29 @@ TRACE_EVENT(sched_wake_idle_without_ipi,TP_printk ("cpu=%d" , __entry->cpu) ); + +/* +* Following tracepoints are not exported in tracefs and provide hooking +* mechanisms only for testing and debugging purposes. +* +* Postfixed with _tp to make them easily identifiable in the code. +*/ +DECLARE_TRACE (pelt_cfs_tp, + TP_PROTO(struct cfs_rq *cfs_rq), +TP_ARGS (cfs_rq)); + +DECLARE_TRACE (pelt_rt_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); + +DECLARE_TRACE (pelt_dl_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); + +DECLARE_TRACE (pelt_irq_tp, + TP_PROTO(struct rq *rq), +TP_ARGS (rq)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +6 -0
@@ -3347,6 +3347,8 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)update_tg_cfs_util (cfs_rq, se, gcfs_rq);update_tg_cfs_runnable (cfs_rq, se, gcfs_rq); +trace_pelt_cfs_tp (cfs_rq); +return 1 ; }
@@ -3499,6 +3501,8 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *sadd_tg_cfs_propagate (cfs_rq, se->avg.load_sum);cfs_rq_util_change (cfs_rq, flags); + +trace_pelt_cfs_tp (cfs_rq); }/**
@@ -3518,6 +3522,8 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *sadd_tg_cfs_propagate (cfs_rq, -se->avg.load_sum);cfs_rq_util_change (cfs_rq,0 ); + +trace_pelt_cfs_tp (cfs_rq); }/*
kernel/sched/pelt.c +8 -1
@@ -28,6 +28,8 @@#include "sched.h" #include "pelt.h" +#include <trace/events/sched.h> +/* * Approximate: * val * y^n, where y^32 ~= 0.5 (~1 scheduling period)
@@ -292,6 +294,7 @@ int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq) cfs_rq->curr != NULL)) {___update_load_avg (&cfs_rq->avg,1 ,1 ); +trace_pelt_cfs_tp (cfs_rq);return 1 ; }
@@ -317,6 +320,7 @@ int update_rt_rq_load_avg(u64 now, struct rq *rq, int running) running)) {___update_load_avg (&rq->avg_rt,1 ,1 ); +trace_pelt_rt_tp (rq);return 1 ; }
@@ -340,6 +344,7 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running) running)) {___update_load_avg (&rq->avg_dl,1 ,1 ); +trace_pelt_dl_tp (rq);return 1 ; }
@@ -388,8 +393,10 @@ int update_irq_load_avg(struct rq *rq, u64 running)1 , 1); -if (ret) +if (ret) {___update_load_avg (&rq->avg_irq,1 ,1 ); +trace_pelt_irq_tp (rq); + }return ret; }
PATCH v3 4/6 sched: Add new tracepoint to track pelt at se level
In reply to Qais YousefThe new tracepoint allows tracking PELT signals at sched_entity level. Which is supported in CFS tasks and taskgroups only.
--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 1 + kernel/sched/pelt.c | 2 ++ 3 files changed, 7 insertions(+)
include/trace/events/sched.h +4 -0
@@ -617,6 +617,10 @@ DECLARE_TRACE(pelt_irq_tp, TP_PROTO(struct rq *rq), TP_ARGS(rq)); +DECLARE_TRACE (pelt_se_tp, + TP_PROTO(struct sched_entity *se), +TP_ARGS (se)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +1 -0
@@ -3354,6 +3354,7 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)update_tg_cfs_runnable (cfs_rq, se, gcfs_rq);trace_pelt_cfs_tp (cfs_rq); +trace_pelt_se_tp (se);return 1 ; }
kernel/sched/pelt.c +2 -0
@@ -267,6 +267,7 @@ int __update_load_avg_blocked_se(u64 now, struct sched_entity *se) {if (___update_load_sum (now, &se->avg,0 ,0 ,0 )) {___update_load_avg (&se->avg,se_weight (se),se_runnable (se)); +trace_pelt_se_tp (se);return 1 ; }
@@ -280,6 +281,7 @@ int __update_load_avg_se(u64 now, struct cfs_rq *cfs_rq, struct sched_entity *se___update_load_avg (&se->avg,se_weight (se),se_runnable (se));cfs_se_util_change (&se->avg); +trace_pelt_se_tp (se);return 1 ; }
Signature · 1 line
2.17.1
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/debug: Add new tracepoint to track PELT at se level
sched/debug: Add new tracepoint to track PELT at se level
Commit-ID: 8de6242cca17d9299e654e29c966d8612d397272 Gitweb: https://git.kernel.org/tip/8de6242cca17d9299e654e29c966d8612d397272 Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:57 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:42 +0200
sched/debug: Add new tracepoint to track PELT at se level
The new tracepoint allows tracking PELT signals at sched_entity level. Which is supported in CFS tasks and taskgroups only.
--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 1 + kernel/sched/pelt.c | 2 ++ 3 files changed, 7 insertions(+)
include/trace/events/sched.h +4 -0
@@ -617,6 +617,10 @@ DECLARE_TRACE(pelt_irq_tp, TP_PROTO(struct rq *rq), TP_ARGS(rq)); +DECLARE_TRACE (pelt_se_tp, + TP_PROTO(struct sched_entity *se), +TP_ARGS (se)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +1 -0
@@ -3348,6 +3348,7 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)update_tg_cfs_runnable (cfs_rq, se, gcfs_rq);trace_pelt_cfs_tp (cfs_rq); +trace_pelt_se_tp (se);return 1 ; }
kernel/sched/pelt.c +2 -0
@@ -267,6 +267,7 @@ int __update_load_avg_blocked_se(u64 now, struct sched_entity *se) {if (___update_load_sum (now, &se->avg,0 ,0 ,0 )) {___update_load_avg (&se->avg,se_weight (se),se_runnable (se)); +trace_pelt_se_tp (se);return 1 ; }
@@ -280,6 +281,7 @@ int __update_load_avg_se(u64 now, struct cfs_rq *cfs_rq, struct sched_entity *se___update_load_avg (&se->avg,se_weight (se),se_runnable (se));cfs_se_util_change (&se->avg); +trace_pelt_se_tp (se);return 1 ; }
PATCH v3 5/6 sched: Add sched_overutilized tracepoint
In reply to Qais YousefThe new tracepoint allows us to track the changes in overutilized status.
Overutilized status is associated with EAS. It indicates that the system is in high performance state. EAS is disabled when the system is in this state since there's not much energy savings while high performance tasks are pushing the system to the limit and it's better to default to the spreading behavior of the scheduler.
This tracepoint helps understanding and debugging the conditions under which this happens.
--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
include/trace/events/sched.h +4 -0
@@ -621,6 +621,10 @@ DECLARE_TRACE(pelt_se_tp, TP_PROTO(struct sched_entity *se), TP_ARGS(se)); +DECLARE_TRACE (sched_overutilized_tp, + TP_PROTO(int overutilized, struct root_domain *rd), +TP_ARGS (overutilized, rd)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +9 -2
@@ -5179,8 +5179,10 @@ static inline bool cpu_overutilized(int cpu)static inline void update_overutilized_status (struct rq *rq) { -if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) +if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) {WRITE_ONCE (rq->rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rq->rd); + } }#else static inline void update_overutilized_status (struct rq *rq) { }
@@ -8542,8 +8544,13 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd/* Update over-utilization (tipping point, U >= 0) indicator */ WRITE_ONCE (rd->overutilized, sg_status &SG_OVERUTILIZED ); + +trace_sched_overutilized_tp (!!(sg_status &SG_OVERUTILIZED ), rd); }else if (sg_status &SG_OVERUTILIZED ) { -WRITE_ONCE (env->dst_rq->rd->overutilized,SG_OVERUTILIZED ); +struct root_domain *rd = env->dst_rq->rd; + +WRITE_ONCE (rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rd); } }
Signature · 1 line
2.17.1
Peter Zijlstra
maintainerRe: [PATCH v3 5/6] sched: Add sched_overutilized tracepoint
Quoted 23 lines · Qais Yousef
The new tracepoint allows us to track the changes in overutilized status.
Overutilized status is associated with EAS. It indicates that the system is in high performance state. EAS is disabled when the system is in this state since there's not much energy savings while high performance tasks are pushing the system to the limit and it's better to default to the spreading behavior of the scheduler.
This tracepoint helps understanding and debugging the conditions under which this happens.
Signed-off-by Qais Yousef <[email protected]>--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)include/trace/events/sched.h +0
-0
include/trace/events/sched.h DECLARE_TRACE(pelt_se_tp, · line 627
Quoted 7 lines
include/trace/events/sched.h +4
-0@@ -621,6 +621,10 @@ DECLARE_TRACE(pelt_se_tp, TP_PROTO(struct sched_entity *se), TP_ARGS(se)); +DECLARE_TRACE (sched_overutilized_tp, + TP_PROTO(int overutilized, struct root_domain *rd), +TP_ARGS (overutilized, rd)); +
strictly speaking you only need @rd :-)
Quoted 23 lines
include/trace/events/sched.h +0
-0#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ kernel/sched/fair.c +3
-1@@ -5179,8 +5179,10 @@ static inline bool cpu_overutilized(int cpu)static inline void update_overutilized_status (struct rq *rq) { -if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) +if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) {WRITE_ONCE (rq->rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rq->rd); + } }#else static inline void update_overutilized_status (struct rq *rq) { }@@ -8542,8 +8544,13 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd/* Update over-utilization (tipping point, U >= 0) indicator */ WRITE_ONCE (rd->overutilized, sg_status &SG_OVERUTILIZED );
kernel/sched/fair.c static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd · line 8555
Quoted 10 lines
kernel/sched/fair.c +6
-1+ +trace_sched_overutilized_tp (!!(sg_status &SG_OVERUTILIZED ), rd); }else if (sg_status &SG_OVERUTILIZED ) { -WRITE_ONCE (env->dst_rq->rd->overutilized,SG_OVERUTILIZED ); +struct root_domain *rd = env->dst_rq->rd; + +WRITE_ONCE (rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rd); } }
But I figure since we need both values anyway, this isn't too much of a bother.
I'm going to flip the argument order though.
Re: [PATCH v3 5/6] sched: Add sched_overutilized tracepoint
Quoted 27 lines · Peter Zijlstra
Quoted 26 lines · Qais Yousef
The new tracepoint allows us to track the changes in overutilized status.
Overutilized status is associated with EAS. It indicates that the system is in high performance state. EAS is disabled when the system is in this state since there's not much energy savings while high performance tasks are pushing the system to the limit and it's better to default to the spreading behavior of the scheduler.
This tracepoint helps understanding and debugging the conditions under which this happens.
Signed-off-by Qais Yousef <[email protected]>--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)include/trace/events/sched.h +0
-0@@ -621,6 +621,10 @@ DECLARE_TRACE(pelt_se_tp, TP_PROTO(struct sched_entity *se), TP_ARGS(se));
Quoted 6 lines
include/trace/events/sched.h DECLARE_TRACE(pelt_se_tp, · line 627
Quoted 4 lines
include/trace/events/sched.h +4
-0+DECLARE_TRACE (sched_overutilized_tp, + TP_PROTO(int overutilized, struct root_domain *rd), +TP_ARGS (overutilized, rd)); +strictly speaking you only need @rd :-)
Yes. Sorry my brain was hardwired this is overutilized event so we need to pass this info :-)
Quoted 38 lines
Quoted 24 lines
include/trace/events/sched.h +0
-0#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ kernel/sched/fair.c +3
-1@@ -5179,8 +5179,10 @@ static inline bool cpu_overutilized(int cpu)static inline void update_overutilized_status (struct rq *rq) { -if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) +if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) {WRITE_ONCE (rq->rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rq->rd); + } }#else static inline void update_overutilized_status (struct rq *rq) { }@@ -8542,8 +8544,13 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd/* Update over-utilization (tipping point, U >= 0) indicator */ WRITE_ONCE (rd->overutilized, sg_status &SG_OVERUTILIZED );kernel/sched/fair.c static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd · line 8555
Quoted 10 lines
kernel/sched/fair.c +6
-1+ +trace_sched_overutilized_tp (!!(sg_status &SG_OVERUTILIZED ), rd); }else if (sg_status &SG_OVERUTILIZED ) { -WRITE_ONCE (env->dst_rq->rd->overutilized,SG_OVERUTILIZED ); +struct root_domain *rd = env->dst_rq->rd; + +WRITE_ONCE (rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (1 , rd); } }But I figure since we need both values anyway, this isn't too much of a bother.
Quoted 1 line
I'm going to flip the argument order though.
Sounds good to me. The good news is that changing the signature should be doable in the future if we felt the need to evolve it :-)
Thanks
--
Qais Yousef
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/debug: Add sched_overutilized tracepoint
In reply to Qais Yousefsched/debug: Add sched_overutilized tracepoint
Commit-ID: f9f240f96efc5bcec62379eac701523e11fbb45b Gitweb: https://git.kernel.org/tip/f9f240f96efc5bcec62379eac701523e11fbb45b Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:58 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:42 +0200
sched/debug: Add sched_overutilized tracepoint
The new tracepoint allows us to track the changes in overutilized status.
Overutilized status is associated with EAS. It indicates that the system is in high performance state. EAS is disabled when the system is in this state since there's not much energy savings while high performance tasks are pushing the system to the limit and it's better to default to the spreading behavior of the scheduler.
This tracepoint helps understanding and debugging the conditions under which this happens.
--- include/trace/events/sched.h | 4 ++++ kernel/sched/fair.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
include/trace/events/sched.h +4 -0
@@ -621,6 +621,10 @@ DECLARE_TRACE(pelt_se_tp, TP_PROTO(struct sched_entity *se), TP_ARGS(se)); +DECLARE_TRACE (sched_overutilized_tp, + TP_PROTO(struct root_domain *rd, bool overutilized), +TP_ARGS (rd, overutilized)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/fair.c +8 -2
@@ -5181,8 +5181,10 @@ static inline bool cpu_overutilized(int cpu)static inline void update_overutilized_status (struct rq *rq) { -if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) +if (!READ_ONCE (rq->rd->overutilized) &&cpu_overutilized (rq->cpu)) {WRITE_ONCE (rq->rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (rq->rd,SG_OVERUTILIZED ); + } }#else static inline void update_overutilized_status (struct rq *rq) { }
@@ -8214,8 +8216,12 @@ next_group:/* Update over-utilization (tipping point, U >= 0) indicator */ WRITE_ONCE (rd->overutilized, sg_status &SG_OVERUTILIZED ); +trace_sched_overutilized_tp (rd, sg_status &SG_OVERUTILIZED ); }else if (sg_status &SG_OVERUTILIZED ) { -WRITE_ONCE (env->dst_rq->rd->overutilized,SG_OVERUTILIZED ); +struct root_domain *rd = env->dst_rq->rd; + +WRITE_ONCE (rd->overutilized,SG_OVERUTILIZED ); +trace_sched_overutilized_tp (rd,SG_OVERUTILIZED ); } }
PATCH v3 6/6 sched: export the newly added tracepoints
In reply to Qais YousefSo that external modules can hook into them and extract the info they need. Since these new tracepoints have no events associated with them exporting these tracepoints make them useful for external modules to perform testing and debugging. There's no other way otherwise to access them.
BPF doesn't have infrastructure to access these bare tracepoints either.
--- kernel/sched/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/sched/core.c +11 -0
@@ -23,6 +23,17 @@#define CREATE_TRACE_POINTS #include <trace/events/sched.h> +/* +* Export tracepoints that act as a bare tracehook (ie: have no trace event +* associated with them) to allow external modules to probe them. +*/ +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_cfs_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_rt_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_dl_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_irq_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_se_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_overutilized_tp); + DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);#if defined(CONFIG_SCHED_DEBUG ) && defined(CONFIG_JUMP_LABEL )
Signature · 1 line
2.17.1
tip-bot for Qais Yousef
merge bot[tip:sched/core] sched/debug: Export the newly added tracepoints
sched/debug: Export the newly added tracepoints
Commit-ID: a056a5bed7fa67706574b00cf1122c38596b2be1 Gitweb: https://git.kernel.org/tip/a056a5bed7fa67706574b00cf1122c38596b2be1 Author: Qais Yousef <[email protected]> AuthorDate: Tue, 4 Jun 2019 12:14:59 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 24 Jun 2019 19:23:43 +0200
sched/debug: Export the newly added tracepoints
So that external modules can hook into them and extract the info they need. Since these new tracepoints have no events associated with them exporting these tracepoints make them useful for external modules to perform testing and debugging. There's no other way otherwise to access them.
BPF doesn't have infrastructure to access these bare tracepoints either.
--- kernel/sched/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/sched/core.c +11 -0
@@ -23,6 +23,17 @@#define CREATE_TRACE_POINTS #include <trace/events/sched.h> +/* +* Export tracepoints that act as a bare tracehook (ie: have no trace event +* associated with them) to allow external modules to probe them. +*/ +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_cfs_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_rt_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_dl_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_irq_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_se_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_overutilized_tp); + DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);#if defined(CONFIG_SCHED_DEBUG ) && defined(CONFIG_JUMP_LABEL )
Quoted 2 lines
The following patches add the bare minimum tracepoints required to perform EAS testing in Lisa[1].
What is EAS? Whhy is "Lisa" not part of the patch submission? submission.
Quoted 2 lines
It is done in this way because adding new
TRACE_EVENTS()is no longer accepted AFAIU.
Huh? We keep adding trace events all the time. And they actually are useful because they are testable.
This series on the other hand adds exports not used in tree, which is a big no-go.
Peter Zijlstra
maintainerQuoted 11 lines · Christoph Hellwig
Quoted 2 lines
The following patches add the bare minimum tracepoints required to perform EAS testing in Lisa[1].
What is EAS? Whhy is "Lisa" not part of the patch submission? submission.
Quoted 2 lines
It is done in this way because adding new
TRACE_EVENTS()is no longer accepted AFAIU.Huh? We keep adding trace events all the time. And they actually are useful because they are testable.
They also form an implicit API/ABI with userspace, and I've been bitten by that crap before. No more tracepoints. IIRC viro is also not having tracepoints in the vfs.
Quoted 2 lines
This series on the other hand adds exports not used in tree, which is a big no-go.
I much prefer a few unused exports that expose data in a controlled fashion than commit to an implicit ABI through tracepoints. By keeping it all in kernel, we're punting to the no-in-kernel-ABI rule.
Basically nobody gives a crap if we break (out-of-tree) modules, but the moment we break something userspace we're fscked.
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines
The following patches add the bare minimum tracepoints required to perform EAS testing in Lisa[1].
What is EAS? Whhy is "Lisa" not part of the patch submission? submission.
EAS is Energy Aware Scheduling. It was merged in 5.0.
Lisa is a python based testing platform that has dependency on other binaries like trace-cmd, rt-app, etc. It is not suitable for kernel submission.
Lisa, or any userspace based testing for that matter, requires to know what's happening inside the scheduler to test its behavior. I don't know know of any other scheduler centric testing framework. I didn't intend to specify Lisa as the sole user and reason for these tracepoints, I know others are interested in these tracepoints in general for anyone who wants to achieve a similar goal of studying scheduler PELT behavior and how it affects some of the decisions it makes.
We had a talk in OSPM a couple of weeks ago to cover this topic if you're interested to learn more
https://www.youtube.com/watch?v=I_MZ9XS3_zc
Quoted 9 lines
Quoted 3 lines
It is done in this way because adding new
TRACE_EVENTS()is no longer accepted AFAIU.Huh? We keep adding trace events all the time. And they actually are useful because they are testable.
This series on the other hand adds exports not used in tree, which is a big no-go.
I see that Peter has already covered this part.
Thanks
--
Qais Yousef
Hi Peter
Quoted 11 lines · Qais Yousef
Changes in v3:
- Splitpelt_rqTP intopelt_cfs,pelt_rq,pelt_dlandpelt_irq
- Replace the fatty preprocessing wrappers with exported helper functions to access data in unexported structures.
- Remove the now unnecessary headers that were introduced in the previous versions.
- Postfix the tracepoints with '_tp' to make them standout more in the code as bare tracepoints with no events associated.
- Updated the example module in [2]
- It demonstrates now how to convert the tracepoints into trace events that extend the sched events subsystem in tracefs.
Does this look okay now? If you have further comments please let me know so I can address them in time in hope it'd make it to the next merge window.
Thanks
--
Qais Yousef
Peter Zijlstra
maintainerQuoted 15 lines · Qais Yousef
Hi Peter
Quoted 11 lines · Qais Yousef
Changes in v3:
- Splitpelt_rqTP intopelt_cfs,pelt_rq,pelt_dlandpelt_irq
- Replace the fatty preprocessing wrappers with exported helper functions to access data in unexported structures.
- Remove the now unnecessary headers that were introduced in the previous versions.
- Postfix the tracepoints with '_tp' to make them standout more in the code as bare tracepoints with no events associated.
- Updated the example module in [2]
- It demonstrates now how to convert the tracepoints into trace events that extend the sched events subsystem in tracefs.
Quoted 2 lines
Does this look okay now? If you have further comments please let me know so I can address them in time in hope it'd make it to the next merge window.
Picked them up (with some minor edits). I feel there is far too much #ifdef in patch #2, but I couldn't quickly come up with anything much saner either.
Quoted 16 lines · Peter Zijlstra
Quoted 15 lines · Qais Yousef
Hi Peter
Quoted 11 lines · Qais Yousef
Changes in v3:
- Splitpelt_rqTP intopelt_cfs,pelt_rq,pelt_dlandpelt_irq
- Replace the fatty preprocessing wrappers with exported helper functions to access data in unexported structures.
- Remove the now unnecessary headers that were introduced in the previous versions.
- Postfix the tracepoints with '_tp' to make them standout more in the code as bare tracepoints with no events associated.
- Updated the example module in [2]
- It demonstrates now how to convert the tracepoints into trace events that extend the sched events subsystem in tracefs.
Quoted 4 lines
Quoted 2 lines
Does this look okay now? If you have further comments please let me know so I can address them in time in hope it'd make it to the next merge window.
Picked them up (with some minor edits). I feel there is far too much
Thanks!
Quoted 2 lines
#ifdef in patch #2, but I couldn't quickly come up with anything much saner either.
We can protect the whole lot with #ifdef CONFIG_SMP? It means the external module will fail to compile for UP configurations - which is fine I think since we're just returning NULL anyway..
--
Qais Yousef