From 0de032ca952bbc8358b1dce3c178dd9388d4b858 Mon Sep 17 00:00:00 2001 From: Dietmar Eggemann Date: Tue, 15 Nov 2022 15:26:58 +0100 Subject: [PATCH 1/3] lisa._assets.kmodules.sched_tp: Add sched_pelt_thermal trace event The corresponding trace point is already supported in Linux kernel mainline: Commit 77cf151b7bbdf ("sched/core: Export pelt_thermal_tp") Commit 765047932f153 ("sched/pelt: Add support to track thermal pressure") Signed-off-by: Dietmar Eggemann --- lisa/_assets/kmodules/sched_tp/ftrace_events.h | 4 ++++ lisa/_assets/kmodules/sched_tp/sched_helpers.h | 9 +++++++++ lisa/_assets/kmodules/sched_tp/tp.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/lisa/_assets/kmodules/sched_tp/ftrace_events.h b/lisa/_assets/kmodules/sched_tp/ftrace_events.h index 2dccabf9d..1360cd8a7 100644 --- a/lisa/_assets/kmodules/sched_tp/ftrace_events.h +++ b/lisa/_assets/kmodules/sched_tp/ftrace_events.h @@ -95,6 +95,10 @@ DEFINE_EVENT(sched_pelt_rq_template, sched_pelt_irq, TP_PROTO(int cpu, const struct sched_avg *avg), TP_ARGS(cpu, avg)); +DEFINE_EVENT(sched_pelt_rq_template, sched_pelt_thermal, + TP_PROTO(int cpu, const struct sched_avg *avg), + TP_ARGS(cpu, avg)); + TRACE_EVENT(sched_pelt_se, TP_PROTO(int cpu, char *path, char *comm, int pid, const struct sched_avg *avg), diff --git a/lisa/_assets/kmodules/sched_tp/sched_helpers.h b/lisa/_assets/kmodules/sched_tp/sched_helpers.h index 6305cefcd..800a603d9 100644 --- a/lisa/_assets/kmodules/sched_tp/sched_helpers.h +++ b/lisa/_assets/kmodules/sched_tp/sched_helpers.h @@ -165,6 +165,15 @@ static inline const struct sched_avg *sched_tp_rq_avg_irq(struct rq *rq) #endif } +static inline const struct sched_avg *sched_tp_rq_avg_thermal(struct rq *rq) +{ +#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_THERMAL_PRESSURE) + return rq ? (struct sched_avg *)&rq->avg_thermal : NULL; +#else + return NULL; +#endif +} + static inline int sched_tp_rq_cpu(struct rq *rq) { return rq ? cpu_of(rq) : -1; diff --git a/lisa/_assets/kmodules/sched_tp/tp.c b/lisa/_assets/kmodules/sched_tp/tp.c index 097cf1730..503a3f1b7 100644 --- a/lisa/_assets/kmodules/sched_tp/tp.c +++ b/lisa/_assets/kmodules/sched_tp/tp.c @@ -95,6 +95,18 @@ static void sched_pelt_irq_probe(struct feature *feature, struct rq *rq) } DEFINE_TP_EVENT_FEATURE(sched_pelt_irq, pelt_irq_tp, sched_pelt_irq_probe); +static void sched_pelt_thermal_probe(struct feature *feature, struct rq *rq) +{ + const struct sched_avg *avg = sched_tp_rq_avg_thermal(rq); + int cpu = sched_tp_rq_cpu(rq); + + if (!avg) + return; + + trace_sched_pelt_thermal(cpu, avg); +} +DEFINE_TP_EVENT_FEATURE(sched_pelt_thermal, pelt_thermal_tp, sched_pelt_thermal_probe); + static void sched_pelt_se_probe(struct feature *feature, struct sched_entity *se) { _trace_se(se, trace_sched_pelt_se); -- GitLab From b09752299089ca2b70cbf62503d8b61a1afb5936 Mon Sep 17 00:00:00 2001 From: Dietmar Eggemann Date: Thu, 15 Dec 2022 21:19:25 +0100 Subject: [PATCH 2/3] lisa.trace: Add sched_pelt_thermal event description This is necessary for a speedier trace parsing. Signed-off-by: Dietmar Eggemann --- lisa/trace.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisa/trace.py b/lisa/trace.py index 80f183c78..e565c0694 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -1486,6 +1486,14 @@ class TxtTraceParser(TxtTraceParserBase): 'util': _KERNEL_DTYPE['util'], }, ), + 'sched_pelt_thermal': dict( + fields={ + 'cpu': _KERNEL_DTYPE['cpu'], + 'load': _KERNEL_DTYPE['util'], + 'rbl_load': _KERNEL_DTYPE['util'], + 'util': _KERNEL_DTYPE['util'], + }, + ), 'sched_process_wait': dict( fields={ 'comm': _KERNEL_DTYPE['comm'], -- GitLab From edf032605ff8148ec1f2f91115c15b8d82eae932 Mon Sep 17 00:00:00 2001 From: Dietmar Eggemann Date: Mon, 19 Dec 2022 17:12:44 +0100 Subject: [PATCH 3/3] lisa.datautils: Add SignalDesc for sched_pelt_thermal event This is necessary to have a correct windowing behavior, i.e. to have an event at the beginning of any window if the information exists. Otherwise analysis like taking an average value or plotting a signal will be somehow broken when using trace windows. Signed-off-by: Dietmar Eggemann --- lisa/datautils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lisa/datautils.py b/lisa/datautils.py index 399555d6c..75081c6d1 100644 --- a/lisa/datautils.py +++ b/lisa/datautils.py @@ -2062,6 +2062,7 @@ _SIGNALS = [ SignalDesc('sched_pelt_irq', ['cpu']), SignalDesc('sched_pelt_rt', ['cpu']), SignalDesc('sched_pelt_dl', ['cpu']), + SignalDesc('sched_pelt_thermal', ['cpu']), SignalDesc('uclamp_util_se', ['pid', 'comm']), SignalDesc('uclamp_util_cfs', ['cpu']), -- GitLab