devfreq: Add tracepoint for frequency changes
Subsystems (2)
PATCH v2 1/1 devfreq: Add tracepoint for frequency changes
Add a tracepoint for frequency changes of devfreq devices and use it.
---
(sending v2 without much delay wrt v1, since the change in devfreq
probably isn't controversial, and I'll be offline a few days)
Changes in v2:
- included trace_devfreq_frequency_enabled() in the condition to avoid unnecessary evaluation when the trace point is disabled
--- 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 (trace_devfreq_frequency_enabled () && 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
Quoted 4 lines · On Thu, 19 Sep 2019 10:44:23 -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]>
From the tracing point of view:
-- Steve
Chanwoo Choi
maintainerHi,
Quoted 22 lines · Matthias Kaehlcke
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>---
(sending v2 without much delay wrt v1, since the change in devfreq
probably isn't controversial, and I'll be offline a few days)Changes in v2:
- includedtrace_devfreq_frequency_enabled()in the condition to avoid unnecessary evaluation when the trace point is disabled--- 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 321
Quoted 5 lines
drivers/devfreq/devfreq.c +2
-0@@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, devfreq->previous_freq = new_freq; +if (trace_devfreq_frequency_enabled () && new_freq != cur_freq) +trace_devfreq_frequency (devfreq, new_freq);
You can change as following without 'new_freq' variable because devfreq->previous_freq is the new frequency.
trace_devfreq_frequency(devfreq);
Quoted 9 lines
drivers/devfreq/devfreq.c +1
-0+if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;include/trace/events/devfreq.h +0
-0
include/trace/events/devfreq.h line 12
Quoted 5 lines
include/trace/events/devfreq.h +2
-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),
'unsigned long freq' parameter is not necessary.
include/trace/events/devfreq.h line 23
Quoted 11 lines
include/trace/events/devfreq.h +11
-0+ +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;
Initialize the new frequency with 'devfreq->previous_freq' as following:
__entry->freq = devfreq->previous_freq;
Quoted 9 lines
include/trace/events/devfreq.h +5
-0+ ), + +TP_printk ("dev_name=%s freq=%lu" ,__get_str (dev_name), __entry->freq) +); + TRACE_EVENT(devfreq_monitor, TP_PROTO(struct devfreq *devfreq),
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Quoted 1 line · Chanwoo Choi
Hi,
sorry for the delayed response, you message got buried in my mailbox.
Quoted 24 lines · Matthias Kaehlcke
Quoted 23 lines
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>---
(sending v2 without much delay wrt v1, since the change in devfreq
probably isn't controversial, and I'll be offline a few days)Changes in v2:
- includedtrace_devfreq_frequency_enabled()in the condition to avoid unnecessary evaluation when the trace point is disabled--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)drivers/devfreq/devfreq.c +0
-0@@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
Quoted 8 lines
drivers/devfreq/devfreq.c static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, · line 321
Quoted 4 lines
drivers/devfreq/devfreq.c +2
-0devfreq->previous_freq = new_freq; +if (trace_devfreq_frequency_enabled () && new_freq != cur_freq) +trace_devfreq_frequency (devfreq, new_freq);You can change as following without '
new_freq' variable becausedevfreq->previous_freqis the new frequency.trace_devfreq_frequency(devfreq);
In general that sounds good.
devfreq essentially uses df->previous_freq as df->cur_freq, I think most code using it would be clearer if we renamed it accordingly. I'll send a separate patch for this.
Quoted 48 lines
Quoted 9 lines
drivers/devfreq/devfreq.c +1
-0+if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;include/trace/events/devfreq.h +0
-0include/trace/events/devfreq.h line 12
Quoted 5 lines
include/trace/events/devfreq.h +2
-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),'unsigned long freq' parameter is not necessary.
include/trace/events/devfreq.h line 23
Quoted 11 lines
include/trace/events/devfreq.h +11
-0+ +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;Initialize the new frequency with '
devfreq->previous_freq' as following:__entry->freq = devfreq->previous_freq;Quoted 9 lines
include/trace/events/devfreq.h +5
-0+ ), + +TP_printk ("dev_name=%s freq=%lu" ,__get_str (dev_name), __entry->freq) +); + TRACE_EVENT(devfreq_monitor, TP_PROTO(struct devfreq *devfreq),Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Chanwoo Choi
maintainerQuoted 39 lines · Matthias Kaehlcke
Quoted 1 line · Chanwoo Choi
Hi,
sorry for the delayed response, you message got buried in my mailbox.
Quoted 24 lines · Matthias Kaehlcke
Quoted 23 lines
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>---
(sending v2 without much delay wrt v1, since the change in devfreq
probably isn't controversial, and I'll be offline a few days)Changes in v2:
- includedtrace_devfreq_frequency_enabled()in the condition to avoid unnecessary evaluation when the trace point is disabled--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)drivers/devfreq/devfreq.c +0
-0@@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,Quoted 8 lines
drivers/devfreq/devfreq.c static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, · line 321
Quoted 4 lines
drivers/devfreq/devfreq.c +2
-0devfreq->previous_freq = new_freq; +if (trace_devfreq_frequency_enabled () && new_freq != cur_freq) +trace_devfreq_frequency (devfreq, new_freq);You can change as following without '
new_freq' variable becausedevfreq->previous_freqis the new frequency.trace_devfreq_frequency(devfreq);
Quoted 5 lines
In general that sounds good.
devfreq essentially uses
df->previous_freqasdf->cur_freq, I think most code using it would be clearer if we renamed it accordingly. I'll send a separate patch for this.
Actually, according to reference time of the 'df->previous_freq', 'previous_freq' is proper or 'cur_freq is proper.
But, In the comment of 'struct devfreq',
it means the configured time as following:
* @previous_freq: previously configured frequency value.
I think that it it not big problem to keep the name.
Quoted 51 lines
Quoted 49 lines
Quoted 10 lines
drivers/devfreq/devfreq.c +1
-0+if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;include/trace/events/devfreq.h +0
-0include/trace/events/devfreq.h line 12
Quoted 5 lines
include/trace/events/devfreq.h +2
-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),'unsigned long freq' parameter is not necessary.
include/trace/events/devfreq.h line 23
Quoted 11 lines
include/trace/events/devfreq.h +11
-0+ +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;Initialize the new frequency with '
devfreq->previous_freq' as following:__entry->freq = devfreq->previous_freq;Quoted 9 lines
include/trace/events/devfreq.h +5
-0+ ), + +TP_printk ("dev_name=%s freq=%lu" ,__get_str (dev_name), __entry->freq) +); + TRACE_EVENT(devfreq_monitor, TP_PROTO(struct devfreq *devfreq),Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Quoted 46 lines · Chanwoo Choi
Quoted 39 lines · Matthias Kaehlcke
Quoted 1 line · Chanwoo Choi
Hi,
sorry for the delayed response, you message got buried in my mailbox.
Quoted 24 lines · Matthias Kaehlcke
Quoted 23 lines
Add a tracepoint for frequency changes of devfreq devices and use it.
Signed-off-by Matthias Kaehlcke <[email protected]>---
(sending v2 without much delay wrt v1, since the change in devfreq
probably isn't controversial, and I'll be offline a few days)Changes in v2:
- includedtrace_devfreq_frequency_enabled()in the condition to avoid unnecessary evaluation when the trace point is disabled--- drivers/devfreq/devfreq.c | 3 +++ include/trace/events/devfreq.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)drivers/devfreq/devfreq.c +0
-0@@ -317,6 +317,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,Quoted 8 lines
drivers/devfreq/devfreq.c static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, · line 321
Quoted 4 lines
drivers/devfreq/devfreq.c +2
-0devfreq->previous_freq = new_freq; +if (trace_devfreq_frequency_enabled () && new_freq != cur_freq) +trace_devfreq_frequency (devfreq, new_freq);You can change as following without '
new_freq' variable becausedevfreq->previous_freqis the new frequency.trace_devfreq_frequency(devfreq);Quoted 5 lines
In general that sounds good.
devfreq essentially uses
df->previous_freqasdf->cur_freq, I think most code using it would be clearer if we renamed it accordingly. I'll send a separate patch for this.
Quoted 5 lines
Actually, according to reference time of the '
df->previous_freq', 'previous_freq' is proper or 'cur_freqis proper.
But, In the comment of 'struct devfreq',
it means the configured time as following:
* @previous_freq: previously configured frequency value.
sure, I wouldn't expect the comment of a variable/field called 'previous_freq' say that it's the current frequency.
Quoted 1 line
I think that it it not big problem to keep the name.
It's indeed not a big problem, because the code works either way, something like 'cur_freq' would just be less confusing.
These are the functions that use 'previous_freq' and how they use it:
devfreq_set_targetdevfreq_monitor_suspendcur_freq_showtarget_freq_showtrans_stat_showdevfreq_passive_notifier_calldevfreq_userspace_func
cur freq
devfreq_update_status
prev freq
More than 85% use the variable as current frequency, which seems like a good argument to give it the proper name, instead of having folks wonder why the previous frequency is used.