[PATCH v1] PM / Domains: Add tracepoints

From: Matthias Kaehlcke
Date: Thu Sep 26 2019 - 18:04:57 EST


Define genpd_power_on/off and genpd_set_performance_state
tracepoints and use them.

Signed-off-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx>
---

drivers/base/power/domain.c | 27 +++++++++++++++++---
include/trace/events/power.h | 49 ++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index cc85e87eaf05..aee988c112e5 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -21,6 +21,7 @@
#include <linux/suspend.h>
#include <linux/export.h>
#include <linux/cpu.h>
+#include <trace/events/power.h>

#include "power.h"

@@ -329,6 +330,9 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd,
goto err;

genpd->performance_state = state;
+
+ trace_genpd_set_performance_state(genpd);
+
return 0;

err:
@@ -418,14 +422,21 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
if (!genpd->power_on)
return 0;

- if (!timed)
- return genpd->power_on(genpd);
+ if (!timed) {
+ ret = genpd->power_on(genpd);
+ if (!ret)
+ trace_genpd_power_on(genpd);
+
+ return ret;
+ }

time_start = ktime_get();
ret = genpd->power_on(genpd);
if (ret)
return ret;

+ trace_genpd_power_on(genpd);
+
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
if (elapsed_ns <= genpd->states[state_idx].power_on_latency_ns)
return ret;
@@ -448,14 +459,22 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
if (!genpd->power_off)
return 0;

- if (!timed)
- return genpd->power_off(genpd);
+ if (!timed) {
+ ret = genpd->power_off(genpd);
+ if (!ret)
+ trace_genpd_power_off(genpd);
+
+ return ret;
+ }

time_start = ktime_get();
ret = genpd->power_off(genpd);
if (ret)
return ret;

+ if (!ret)
+ trace_genpd_power_off(genpd);
+
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
if (elapsed_ns <= genpd->states[state_idx].power_off_latency_ns)
return 0;
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 7457e238e1b7..de56cd1e8d0d 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -7,6 +7,7 @@

#include <linux/cpufreq.h>
#include <linux/ktime.h>
+#include <linux/pm_domain.h>
#include <linux/pm_qos.h>
#include <linux/tracepoint.h>
#include <linux/trace_events.h>
@@ -525,6 +526,54 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,

TP_ARGS(name, type, new_value)
);
+
+#ifdef CONFIG_PM_GENERIC_DOMAINS
+DECLARE_EVENT_CLASS(genpd_power_on_off,
+ TP_PROTO(struct generic_pm_domain *genpd),
+
+ TP_ARGS(genpd),
+
+ TP_STRUCT__entry(
+ __string(name, genpd->name)
+ ),
+
+ TP_fast_assign(
+ __assign_str(name, genpd->name);
+ ),
+
+ TP_printk("name=%s", __get_str(name))
+);
+
+DEFINE_EVENT(genpd_power_on_off, genpd_power_on,
+ TP_PROTO(struct generic_pm_domain *genpd),
+
+ TP_ARGS(genpd)
+);
+
+DEFINE_EVENT(genpd_power_on_off, genpd_power_off,
+ TP_PROTO(struct generic_pm_domain *genpd),
+
+ TP_ARGS(genpd)
+);
+
+TRACE_EVENT(genpd_set_performance_state,
+ TP_PROTO(struct generic_pm_domain *genpd),
+
+ TP_ARGS(genpd),
+
+ TP_STRUCT__entry(
+ __string(name, genpd->name)
+ __field(unsigned int, state)
+ ),
+
+ TP_fast_assign(
+ __assign_str(name, genpd->name);
+ __entry->state = genpd->performance_state;
+ ),
+
+ TP_printk("name=%s state=%u", __get_str(name), __entry->state)
+);
+#endif /* CONFIG_PM_GENERIC_DOMAINS */
#endif /* _TRACE_POWER_H */

/* This part must be outside protection */
--
2.23.0.444.g18eeb5a265-goog