Skip to contentSkip to conversation

cpufreq: trace frequency limits change

PATCH Superseded Joel Fernandes 3 participants 4 messages Jul 20, 2018 – Jul 24, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq: trace frequency limits change

From: Ruchi Kandoi <[email protected]>

systrace used for tracing for Android systems has carried a patch for many years in the Android tree that traces when the cpufreq limits change. With the help of this information, systrace can know when the policy limits change and can visually display the data. Lets add upstream support for the same.

---
v1->v2: Minor changes suggested by Viresh

 Documentation/trace/events-power.rst |  1 +
 drivers/cpufreq/cpufreq.c            |  1 +
 include/trace/events/power.h         | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)
Documentation/trace/events-power.rst +1 -0
index a77daca75e30..2ef318962e29 100644
@@ -27,6 +27,7 @@ cpufreq.
 
   cpu_idle		"state=%lu cpu_id=%lu"
   cpu_frequency		"state=%lu cpu_id=%lu"
+  cpu_frequency_limits	"min=%lu max=%lu cpu_id=%lu"
 
 A suspend event is used to indicate the system going in and out of the
 suspend mode:
drivers/cpufreq/cpufreq.c +1 -0
index b0dfd3222013..4fd935df101e 100644
@@ -2236,6 +2236,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
 	policy->min = new_policy->min;
 	policy->max = new_policy->max;
+	trace_cpu_frequency_limits(policy->min, policy->max, policy->cpu);
 
 	policy->cached_target_freq = UINT_MAX;
 
include/trace/events/power.h +25 -0
index 908977d69783..f5bec45108b6 100644
@@ -148,6 +148,31 @@ DEFINE_EVENT(cpu, cpu_frequency,
 	TP_ARGS(frequency, cpu_id)
 );
 
+TRACE_EVENT(cpu_frequency_limits,
+
+	TP_PROTO(unsigned int min_freq, unsigned int max_freq,
+		unsigned int cpu_id),
+
+	TP_ARGS(min_freq, max_freq, cpu_id),
+
+	TP_STRUCT__entry(
+		__field(u32, min_freq)
+		__field(u32, max_freq)
+		__field(u32, cpu_id)
+	),
+
+	TP_fast_assign(
+		__entry->min_freq = min_freq;
+		__entry->max_freq = max_freq;
+		__entry->cpu_id = cpu_id;
+	),
+
+	TP_printk("min=%lu max=%lu cpu_id=%lu",
+		  (unsigned long)__entry->min_freq,
+		  (unsigned long)__entry->max_freq,
+		  (unsigned long)__entry->cpu_id)
+);
+
 TRACE_EVENT(device_pm_callback_start,
 
 	TP_PROTO(struct device *dev, const char *pm_ops, int event),
Signature · 1 line
2.18.0.233.g985f88cf7e-goog
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 68 lines · Joel Fernandes

From: Ruchi Kandoi <[email protected]>

systrace used for tracing for Android systems has carried a patch for many years in the Android tree that traces when the cpufreq limits change. With the help of this information, systrace can know when the policy limits change and can visually display the data. Lets add upstream support for the same.

---
v1->v2: Minor changes suggested by Viresh

 Documentation/trace/events-power.rst |  1 +
 drivers/cpufreq/cpufreq.c            |  1 +
 include/trace/events/power.h         | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)
Documentation/trace/events-power.rst +1 -0
index a77daca75e30..2ef318962e29 100644
@@ -27,6 +27,7 @@ cpufreq.
 
   cpu_idle		"state=%lu cpu_id=%lu"
   cpu_frequency		"state=%lu cpu_id=%lu"
+  cpu_frequency_limits	"min=%lu max=%lu cpu_id=%lu"
 
 A suspend event is used to indicate the system going in and out of the
 suspend mode:
drivers/cpufreq/cpufreq.c +1 -0
index b0dfd3222013..4fd935df101e 100644
@@ -2236,6 +2236,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
 	policy->min = new_policy->min;
 	policy->max = new_policy->max;
+	trace_cpu_frequency_limits(policy->min, policy->max, policy->cpu);
 
 	policy->cached_target_freq = UINT_MAX;
 
include/trace/events/power.h +18 -0
index 908977d69783..f5bec45108b6 100644
@@ -148,6 +148,31 @@ DEFINE_EVENT(cpu, cpu_frequency,
 	TP_ARGS(frequency, cpu_id)
 );
 
+TRACE_EVENT(cpu_frequency_limits,
+
+	TP_PROTO(unsigned int min_freq, unsigned int max_freq,
+		unsigned int cpu_id),
+
+	TP_ARGS(min_freq, max_freq, cpu_id),
+
+	TP_STRUCT__entry(
+		__field(u32, min_freq)
+		__field(u32, max_freq)
+		__field(u32, cpu_id)
+	),
+
+	TP_fast_assign(
+		__entry->min_freq = min_freq;
+		__entry->max_freq = max_freq;
+		__entry->cpu_id = cpu_id;
+	),

include/trace/events/power.h DEFINE_EVENT(cpu, cpu_frequency, · line 178

Quoted 10 lines
include/trace/events/power.h +7 -0
+
+	TP_printk("min=%lu max=%lu cpu_id=%lu",
+		  (unsigned long)__entry->min_freq,
+		  (unsigned long)__entry->max_freq,
+		  (unsigned long)__entry->cpu_id)
+);
+
 TRACE_EVENT(device_pm_callback_start,
 
 	TP_PROTO(struct device *dev, const char *pm_ops, int event),
Signature · 1 line
viresh
maintainer
#2 lore raw
In reply to Joel Fernandes
Quoted 35 lines · On Fri, 20 Jul 2018 15:21:14 -0700 Joel Fernandes <[email protected]>…

From: Ruchi Kandoi <[email protected]>

systrace used for tracing for Android systems has carried a patch for many years in the Android tree that traces when the cpufreq limits change. With the help of this information, systrace can know when the policy limits change and can visually display the data. Lets add upstream support for the same.

---
v1->v2: Minor changes suggested by Viresh

 Documentation/trace/events-power.rst |  1 +
 drivers/cpufreq/cpufreq.c            |  1 +
 include/trace/events/power.h         | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)
Documentation/trace/events-power.rst +1 -0
index a77daca75e30..2ef318962e29 100644
@@ -27,6 +27,7 @@ cpufreq.
 
   cpu_idle		"state=%lu cpu_id=%lu"
   cpu_frequency		"state=%lu cpu_id=%lu"
+  cpu_frequency_limits	"min=%lu max=%lu cpu_id=%lu"
 
 A suspend event is used to indicate the system going in and out of the
 suspend mode:
drivers/cpufreq/cpufreq.c +0 -0
index b0dfd3222013..4fd935df101e 100644

drivers/cpufreq/cpufreq.c static int cpufreq_set_policy(struct cpufreq_policy *policy, · line 2239

Quoted 4 lines
drivers/cpufreq/cpufreq.c +1 -0
@@ -2236,6 +2236,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
 	policy->min = new_policy->min;
 	policy->max = new_policy->max;
+	trace_cpu_frequency_limits(policy->min, policy->max, policy->cpu);

Wouldn't it make more sense just to pass in "policy"?

Quoted 18 lines
drivers/cpufreq/cpufreq.c +0 -0
 	policy->cached_target_freq = UINT_MAX;
 
include/trace/events/power.h +7 -0
index 908977d69783..f5bec45108b6 100644
@@ -148,6 +148,31 @@ DEFINE_EVENT(cpu, cpu_frequency,
 	TP_ARGS(frequency, cpu_id)
 );
 
+TRACE_EVENT(cpu_frequency_limits,
+
+	TP_PROTO(unsigned int min_freq, unsigned int max_freq,
+		unsigned int cpu_id),
+
+	TP_ARGS(min_freq, max_freq, cpu_id),
+

include/trace/events/power.h DEFINE_EVENT(cpu, cpu_frequency, · line 167

Quoted 10 lines
include/trace/events/power.h +10 -0
+	TP_STRUCT__entry(
+		__field(u32, min_freq)
+		__field(u32, max_freq)
+		__field(u32, cpu_id)
+	),
+
+	TP_fast_assign(
+		__entry->min_freq = min_freq;
+		__entry->max_freq = max_freq;
+		__entry->cpu_id = cpu_id;

Then have here:

		__entry->min_freq = policy->min;
		__entry->max_freq = policy->max;
		__entry->puc_id = policy->cpu;

It would also make the footprint of the tracepoint in the code smaller as it would pass fewer parameters to the trace event.

-- Steve

Quoted 11 lines
include/trace/events/power.h +8 -0
+	),
+
+	TP_printk("min=%lu max=%lu cpu_id=%lu",
+		  (unsigned long)__entry->min_freq,
+		  (unsigned long)__entry->max_freq,
+		  (unsigned long)__entry->cpu_id)
+);
+
 TRACE_EVENT(device_pm_callback_start,
 
 	TP_PROTO(struct device *dev, const char *pm_ops, int event),
#3 lore raw
Quoted 39 lines · Steven Rostedt
Quoted 36 lines · On Fri, 20 Jul 2018 15:21:14 -0700 Joel Fernandes <[email protected]>…

From: Ruchi Kandoi <[email protected]>

systrace used for tracing for Android systems has carried a patch for many years in the Android tree that traces when the cpufreq limits change. With the help of this information, systrace can know when the policy limits change and can visually display the data. Lets add upstream support for the same.

---
v1->v2: Minor changes suggested by Viresh

 Documentation/trace/events-power.rst |  1 +
 drivers/cpufreq/cpufreq.c            |  1 +
 include/trace/events/power.h         | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)
Documentation/trace/events-power.rst +1 -0
index a77daca75e30..2ef318962e29 100644
@@ -27,6 +27,7 @@ cpufreq.
 
   cpu_idle		"state=%lu cpu_id=%lu"
   cpu_frequency		"state=%lu cpu_id=%lu"
+  cpu_frequency_limits	"min=%lu max=%lu cpu_id=%lu"
 
 A suspend event is used to indicate the system going in and out of the
 suspend mode:
drivers/cpufreq/cpufreq.c +0 -0
index b0dfd3222013..4fd935df101e 100644
@@ -2236,6 +2236,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
Quoted 5 lines

drivers/cpufreq/cpufreq.c static int cpufreq_set_policy(struct cpufreq_policy *policy, · line 2239

Quoted 3 lines
drivers/cpufreq/cpufreq.c +1 -0
 	policy->min = new_policy->min;
 	policy->max = new_policy->max;
+	trace_cpu_frequency_limits(policy->min, policy->max, policy->cpu);

Wouldn't it make more sense just to pass in "policy"?

Yes I agree, good idea.

Quoted 31 lines
Quoted 18 lines
drivers/cpufreq/cpufreq.c +0 -0
 	policy->cached_target_freq = UINT_MAX;
 
include/trace/events/power.h +7 -0
index 908977d69783..f5bec45108b6 100644
@@ -148,6 +148,31 @@ DEFINE_EVENT(cpu, cpu_frequency,
 	TP_ARGS(frequency, cpu_id)
 );
 
+TRACE_EVENT(cpu_frequency_limits,
+
+	TP_PROTO(unsigned int min_freq, unsigned int max_freq,
+		unsigned int cpu_id),
+
+	TP_ARGS(min_freq, max_freq, cpu_id),
+

include/trace/events/power.h DEFINE_EVENT(cpu, cpu_frequency, · line 167

Quoted 10 lines
include/trace/events/power.h +10 -0
+	TP_STRUCT__entry(
+		__field(u32, min_freq)
+		__field(u32, max_freq)
+		__field(u32, cpu_id)
+	),
+
+	TP_fast_assign(
+		__entry->min_freq = min_freq;
+		__entry->max_freq = max_freq;
+		__entry->cpu_id = cpu_id;

Then have here:

Quoted 6 lines
		__entry->min_freq = policy->min;
		__entry->max_freq = policy->max;
		__entry->puc_id = policy->cpu;

It would also make the footprint of the tracepoint in the code smaller as it would pass fewer parameters to the trace event.

Yes, that's a great idea. I'll make the change and post v3.

-Joel