devfreq: Add tracepoint for frequency changes
Subsystems (2)
PATCH 1/1 devfreq: Add tracepoint for frequency changes
Add a tracepoint for frequency changes of devfreq devices and use it.
--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)
drivers/devfreq/devfreq.c +3 -0
@@ -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;
include/trace/events/devfreq.h +18 -0
@@ -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),
Signature · 1 line
2.23.0.237.gc6a4ce50a0-goog
Steven Rostedt
maintainerQuoted 14 lines · On Wed, 18 Sep 2019 12:15:37 -0700 Matthias Kaehlcke <[email protected]> wrote:
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)drivers/devfreq/devfreq.c +0
-0
drivers/devfreq/devfreq.c static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, · line 320
Quoted 4 lines
drivers/devfreq/devfreq.c +1
-0@@ -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
Quoted 34 lines
drivers/devfreq/devfreq.c +2
-0+trace_devfreq_frequency (devfreq, new_freq); +if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;include/trace/events/devfreq.h +18
-0@@ -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),
Quoted 24 lines · Steven Rostedt
Quoted 14 lines · On Wed, 18 Sep 2019 12:15:37 -0700 Matthias Kaehlcke <[email protected]> wrote:
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)drivers/devfreq/devfreq.c +0
-0drivers/devfreq/devfreq.c static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, · line 320
Quoted 4 lines
drivers/devfreq/devfreq.c +1
-0@@ -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:
Quoted 6 lines
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_frequencytrace point is not enabled. Slight micro optimization, but still enough to add it.
Sounds good to me, thanks for the review!