linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cpufreq: trace frequency limits change
@ 2018-07-20 22:21 Joel Fernandes
  2018-07-23  3:01 ` Viresh Kumar
  2018-07-24 13:49 ` Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Joel Fernandes @ 2018-07-20 22:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-team, Ruchi Kandoi, Joel Fernandes, Ingo Molnar,
	Jonathan Corbet, linux-doc, linux-pm, Rafael J. Wysocki,
	Steven Rostedt, Viresh Kumar

From: Ruchi Kandoi <kandoiruchi@google.com>

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.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
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(+)

diff --git a/Documentation/trace/events-power.rst b/Documentation/trace/events-power.rst
index a77daca75e30..2ef318962e29 100644
--- a/Documentation/trace/events-power.rst
+++ b/Documentation/trace/events-power.rst
@@ -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:
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b0dfd3222013..4fd935df101e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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;
 
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 908977d69783..f5bec45108b6 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -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),
-- 
2.18.0.233.g985f88cf7e-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cpufreq: trace frequency limits change
  2018-07-20 22:21 [PATCH v2] cpufreq: trace frequency limits change Joel Fernandes
@ 2018-07-23  3:01 ` Viresh Kumar
  2018-07-24 13:49 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2018-07-23  3:01 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: linux-kernel, kernel-team, Ruchi Kandoi, Ingo Molnar,
	Jonathan Corbet, linux-doc, linux-pm, Rafael J. Wysocki,
	Steven Rostedt

On 20-07-18, 15:21, Joel Fernandes wrote:
> From: Ruchi Kandoi <kandoiruchi@google.com>
> 
> 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.
> 
> Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
> 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(+)
> 
> diff --git a/Documentation/trace/events-power.rst b/Documentation/trace/events-power.rst
> index a77daca75e30..2ef318962e29 100644
> --- a/Documentation/trace/events-power.rst
> +++ b/Documentation/trace/events-power.rst
> @@ -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:
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index b0dfd3222013..4fd935df101e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -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;
>  
> diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> index 908977d69783..f5bec45108b6 100644
> --- a/include/trace/events/power.h
> +++ b/include/trace/events/power.h
> @@ -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),

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cpufreq: trace frequency limits change
  2018-07-20 22:21 [PATCH v2] cpufreq: trace frequency limits change Joel Fernandes
  2018-07-23  3:01 ` Viresh Kumar
@ 2018-07-24 13:49 ` Steven Rostedt
  2018-07-24 17:24   ` Joel Fernandes
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2018-07-24 13:49 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: linux-kernel, kernel-team, Ruchi Kandoi, Ingo Molnar,
	Jonathan Corbet, linux-doc, linux-pm, Rafael J. Wysocki,
	Viresh Kumar

On Fri, 20 Jul 2018 15:21:14 -0700
Joel Fernandes <joel@joelfernandes.org> wrote:

> From: Ruchi Kandoi <kandoiruchi@google.com>
> 
> 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.
> 
> Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
> 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(+)
> 
> diff --git a/Documentation/trace/events-power.rst b/Documentation/trace/events-power.rst
> index a77daca75e30..2ef318962e29 100644
> --- a/Documentation/trace/events-power.rst
> +++ b/Documentation/trace/events-power.rst
> @@ -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:
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index b0dfd3222013..4fd935df101e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -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"?

>  
>  	policy->cached_target_freq = UINT_MAX;
>  
> diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> index 908977d69783..f5bec45108b6 100644
> --- a/include/trace/events/power.h
> +++ b/include/trace/events/power.h
> @@ -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;

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

> +	),
> +
> +	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),


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cpufreq: trace frequency limits change
  2018-07-24 13:49 ` Steven Rostedt
@ 2018-07-24 17:24   ` Joel Fernandes
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Fernandes @ 2018-07-24 17:24 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, kernel-team, Ruchi Kandoi, Ingo Molnar,
	Jonathan Corbet, linux-doc, linux-pm, Rafael J. Wysocki,
	Viresh Kumar

On Tue, Jul 24, 2018 at 09:49:32AM -0400, Steven Rostedt wrote:
> On Fri, 20 Jul 2018 15:21:14 -0700
> Joel Fernandes <joel@joelfernandes.org> wrote:
> 
> > From: Ruchi Kandoi <kandoiruchi@google.com>
> > 
> > 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.
> > 
> > Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
> > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > ---
> > 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(+)
> > 
> > diff --git a/Documentation/trace/events-power.rst b/Documentation/trace/events-power.rst
> > index a77daca75e30..2ef318962e29 100644
> > --- a/Documentation/trace/events-power.rst
> > +++ b/Documentation/trace/events-power.rst
> > @@ -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:
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index b0dfd3222013..4fd935df101e 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -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"?

Yes I agree, good idea.

> >  
> >  	policy->cached_target_freq = UINT_MAX;
> >  
> > diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> > index 908977d69783..f5bec45108b6 100644
> > --- a/include/trace/events/power.h
> > +++ b/include/trace/events/power.h
> > @@ -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;
> 
> 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.

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

-Joel
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-24 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 22:21 [PATCH v2] cpufreq: trace frequency limits change Joel Fernandes
2018-07-23  3:01 ` Viresh Kumar
2018-07-24 13:49 ` Steven Rostedt
2018-07-24 17:24   ` Joel Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).