linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] devfreq: Add tracepoint for frequency changes
@ 2019-09-18 19:15 Matthias Kaehlcke
  2019-09-19 16:35 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Kaehlcke @ 2019-09-18 19:15 UTC (permalink / raw)
  To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Steven Rostedt, Ingo Molnar
  Cc: linux-pm, linux-kernel, Douglas Anderson, Matthias Kaehlcke

Add a tracepoint for frequency changes of devfreq devices and
use it.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 drivers/devfreq/devfreq.c      |  3 +++
 include/trace/events/devfreq.h | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ab22bf8a12d6..32de1f6ac776 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 
 	devfreq->previous_freq = new_freq;
 
+	if (new_freq != cur_freq)
+		trace_devfreq_frequency(devfreq, new_freq);
+
 	if (devfreq->suspend_freq)
 		devfreq->resume_freq = cur_freq;
 
diff --git a/include/trace/events/devfreq.h b/include/trace/events/devfreq.h
index cf5b8772175d..a62d32fe3c33 100644
--- a/include/trace/events/devfreq.h
+++ b/include/trace/events/devfreq.h
@@ -8,6 +8,24 @@
 #include <linux/devfreq.h>
 #include <linux/tracepoint.h>
 
+TRACE_EVENT(devfreq_frequency,
+	TP_PROTO(struct devfreq *devfreq, unsigned long freq),
+
+	TP_ARGS(devfreq, freq),
+
+	TP_STRUCT__entry(
+		__string(dev_name, dev_name(&devfreq->dev))
+		__field(unsigned long, freq)
+	),
+
+	TP_fast_assign(
+		__assign_str(dev_name, dev_name(&devfreq->dev));
+		__entry->freq = freq;
+	),
+
+	TP_printk("dev_name=%s freq=%lu", __get_str(dev_name), __entry->freq)
+);
+
 TRACE_EVENT(devfreq_monitor,
 	TP_PROTO(struct devfreq *devfreq),
 
-- 
2.23.0.237.gc6a4ce50a0-goog


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

* Re: [PATCH] devfreq: Add tracepoint for frequency changes
  2019-09-18 19:15 [PATCH] devfreq: Add tracepoint for frequency changes Matthias Kaehlcke
@ 2019-09-19 16:35 ` Steven Rostedt
  2019-09-19 17:25   ` Matthias Kaehlcke
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2019-09-19 16:35 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Ingo Molnar, linux-pm,
	linux-kernel, Douglas Anderson

On Wed, 18 Sep 2019 12:15:37 -0700
Matthias Kaehlcke <mka@chromium.org> wrote:

> Add a tracepoint for frequency changes of devfreq devices and
> use it.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  drivers/devfreq/devfreq.c      |  3 +++
>  include/trace/events/devfreq.h | 18 ++++++++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index ab22bf8a12d6..32de1f6ac776 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>  
>  	devfreq->previous_freq = new_freq;
>  
> +	if (new_freq != cur_freq)

I would make this:

	if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)

Because this would place the second check into the "nop" portion of the
code, keeping the test from being performed if the devfreq_frequency
trace point is not enabled. Slight micro optimization, but still enough
to add it.

-- Steve


> +		trace_devfreq_frequency(devfreq, new_freq);
> +
>  	if (devfreq->suspend_freq)
>  		devfreq->resume_freq = cur_freq;
>  
> diff --git a/include/trace/events/devfreq.h b/include/trace/events/devfreq.h
> index cf5b8772175d..a62d32fe3c33 100644
> --- a/include/trace/events/devfreq.h
> +++ b/include/trace/events/devfreq.h
> @@ -8,6 +8,24 @@
>  #include <linux/devfreq.h>
>  #include <linux/tracepoint.h>
>  
> +TRACE_EVENT(devfreq_frequency,
> +	TP_PROTO(struct devfreq *devfreq, unsigned long freq),
> +
> +	TP_ARGS(devfreq, freq),
> +
> +	TP_STRUCT__entry(
> +		__string(dev_name, dev_name(&devfreq->dev))
> +		__field(unsigned long, freq)
> +	),
> +
> +	TP_fast_assign(
> +		__assign_str(dev_name, dev_name(&devfreq->dev));
> +		__entry->freq = freq;
> +	),
> +
> +	TP_printk("dev_name=%s freq=%lu", __get_str(dev_name), __entry->freq)
> +);
> +
>  TRACE_EVENT(devfreq_monitor,
>  	TP_PROTO(struct devfreq *devfreq),
>  


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

* Re: [PATCH] devfreq: Add tracepoint for frequency changes
  2019-09-19 16:35 ` Steven Rostedt
@ 2019-09-19 17:25   ` Matthias Kaehlcke
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Kaehlcke @ 2019-09-19 17:25 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Ingo Molnar, linux-pm,
	linux-kernel, Douglas Anderson


On Thu, Sep 19, 2019 at 12:35:59PM -0400, Steven Rostedt wrote:
> On Wed, 18 Sep 2019 12:15:37 -0700
> Matthias Kaehlcke <mka@chromium.org> wrote:
> 
> > Add a tracepoint for frequency changes of devfreq devices and
> > use it.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> >  drivers/devfreq/devfreq.c      |  3 +++
> >  include/trace/events/devfreq.h | 18 ++++++++++++++++++
> >  2 files changed, 21 insertions(+)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index ab22bf8a12d6..32de1f6ac776 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> >  
> >  	devfreq->previous_freq = new_freq;
> >  
> > +	if (new_freq != cur_freq)
> 
> I would make this:
> 
> 	if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)
> 
> Because this would place the second check into the "nop" portion of the
> code, keeping the test from being performed if the devfreq_frequency
> trace point is not enabled. Slight micro optimization, but still enough
> to add it.

Sounds good to me, thanks for the review!

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

end of thread, other threads:[~2019-09-19 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 19:15 [PATCH] devfreq: Add tracepoint for frequency changes Matthias Kaehlcke
2019-09-19 16:35 ` Steven Rostedt
2019-09-19 17:25   ` Matthias Kaehlcke

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).