perf: Do not export power_frequency, but power_start event
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 perf: Do not export power_frequency, but power_start event
power_frequency moved to drivers/cpufreq/cpufreq.c which has to be compiled in, no need to export it.
intel_idle can a be module though...
LKML-Reference: <[email protected]>
--- drivers/idle/intel_idle.c | 2 -- kernel/trace/power-traces.c | 2 +- 2 files changed, 1 insertions(+), 3 deletions(-)
drivers/idle/intel_idle.c +0 -2
@@ -220,9 +220,7 @@ static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state) kt_before =ktime_get_real ();stop_critical_timings (); -#ifndef MODULE trace_power_start (POWER_CSTATE , (eax >>4 ) +1 , cpu); -#endif if (!need_resched ()) {__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );
kernel/trace/power-traces.c +1 -1
@@ -13,5 +13,5 @@#define CREATE_TRACE_POINTS #include <trace/events/power.h> -EXPORT_TRACEPOINT_SYMBOL_GPL (power_frequency); +EXPORT_TRACEPOINT_SYMBOL_GPL (power_start);
Signature · 1 line
1.6.0.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/3 PERF(userspace): Adjust perf timechart to the new power events
Recent changes:
- Adjust state/cpuid to u32 as done in the kernel
The transition was rather smooth, only part I had to fiddle some time was the check whether a tracepoint/event is supported by the running kernel.
builtin-timechart must only pass -e power:xy events which are supported by the running kernel.
For this I added the tiny helper function:
int is_valid_tracepoint(const char *event_string)
to parse-events.[hc]
which could be more generic as an interface and support hardware/software/... events, not only tracepoints, but someone else could extend that if needed...
--- tools/perf/builtin-timechart.c | 92 +++++++++++++++++++++++++++++++++------- tools/perf/util/parse-events.c | 41 ++++++++++++++++++ tools/perf/util/parse-events.h | 1 + 3 files changed, 118 insertions(+), 16 deletions(-)
tools/perf/builtin-timechart.c +76 -16
@@ -32,6 +32,10 @@#include "util/session.h" #include "util/svghelper.h" +#define SUPPORT_OLD_POWER_EVENTS 1 +#define PWR_EVENT_EXIT -1 + +static char const *input_name ="perf.data" ;static char const *output_name ="output.svg" ;
@@ -298,12 +302,21 @@ struct trace_entry {int lock_depth; }; -struct power_entry { +#if defined(SUPPORT_OLD_POWER_EVENTS ) +static int use_old_power_events; +struct power_entry_old {struct trace_entry te;u64 type;u64 value;u64 cpu_id; }; +#endif + +struct power_processor_entry { +struct trace_entry te; +u32 state; +u32 cpu_id; +};#define TASK_COMM_LEN 16struct wakeup_entry {
@@ -489,29 +502,51 @@ static int process_sample_event(event_t *event, struct perf_session *session) te = (void *)data.raw_data;if (session->sample_type &PERF_SAMPLE_RAW && data.raw_size >0 ) {char *event_str; -struct power_entry *pe; - - pe = (void *)te; +#if defined(SUPPORT_OLD_POWER_EVENTS ) +struct power_entry_old *peo; + peo = (void *)te; +#endif event_str =perf_header__find_event (te->type);if (!event_str)return 0 ; -if (strcmp (event_str,"power:power_start" ) ==0 ) -c_state_start (pe->cpu_id, data.time, pe->value); - -if (strcmp (event_str,"power:power_end" ) ==0 ) -c_state_end (pe->cpu_id, data.time); +if (strcmp (event_str,"power:cpu_idle" ) ==0 ) { +struct power_processor_entry *ppe = (void *)te; +if (ppe->state == (u32 )PWR_EVENT_EXIT ) +c_state_end (ppe->cpu_id, data.time); +else +c_state_start (ppe->cpu_id, data.time, + ppe->state); + } -if (strcmp (event_str,"power:power_frequency" ) ==0 ) -p_state_change (pe->cpu_id, data.time, pe->value); +else if (strcmp (event_str,"power:cpu_frequency" ) ==0 ) { +struct power_processor_entry *ppe = (void *)te; +p_state_change (ppe->cpu_id, data.time, ppe->state); + } -if (strcmp (event_str,"sched:sched_wakeup" ) ==0 ) +else if (strcmp (event_str,"sched:sched_wakeup" ) ==0 )sched_wakeup (data.cpu, data.time, data.pid, te); -if (strcmp (event_str,"sched:sched_switch" ) ==0 ) +else if (strcmp (event_str,"sched:sched_switch" ) ==0 )sched_switch (data.cpu, data.time, te); + +#if defined(SUPPORT_OLD_POWER_EVENTS ) +if (use_old_power_events) { +if (strcmp (event_str,"power:power_start" ) ==0 ) +c_state_start (peo->cpu_id, data.time, + peo->value); + +else if (strcmp (event_str,"power:power_end" ) ==0 ) +c_state_end (data.cpu, data.time); + +else if (strcmp (event_str, +"power:power_frequency" ) ==0 ) +p_state_change (peo->cpu_id, data.time, + peo->value); + } +#endif }return 0 ; }
@@ -968,7 +1003,8 @@ static const char * const timechart_usage[] = {NULL }; -static const char *record_args[] = { +#if defined(SUPPORT_OLD_POWER_EVENTS ) +static const char *const record_old_args[] = {"record" ,"-a" , "-R",
@@ -980,16 +1016,40 @@ static const char *record_args[] = {"-e" ,"sched:sched_wakeup" , "-e", "sched:sched_switch", }; +#endif + +static const char *const record_new_args[] = { +"record" , +"-a" , +"-R" , +"-f" , +"-c" ,"1" , +"-e" ,"power:cpu_frequency" , +"-e" ,"power:cpu_idle" , +"-e" ,"sched:sched_wakeup" , +"-e" ,"sched:sched_switch" , +};static int __cmd_record (int argc,const char **argv) {unsigned int rec_argc, i, j;const char **rec_argv; +const char *const *record_args = record_new_args; +unsigned int record_elems =ARRAY_SIZE (record_new_args); + +#if defined(SUPPORT_OLD_POWER_EVENTS ) +if (!is_valid_tracepoint ("power:cpu_idle" ) && +is_valid_tracepoint ("power:power_start" )) { + use_old_power_events =1 ; + record_args = record_old_args; + record_elems =ARRAY_SIZE (record_old_args); + } +#endif - rec_argc =ARRAY_SIZE (record_args) + argc -1 ; + rec_argc = record_elems + argc -1 ; rec_argv =calloc (rec_argc +1 ,sizeof (char *)); -for (i =0 ; i <ARRAY_SIZE (record_args); i++) +for (i =0 ; i < record_elems; i++) rec_argv[i] =strdup (record_args[i]);for (j =1 ; j < (unsigned int )argc; j++, i++)
tools/perf/util/parse-events.c +41 -0
47 lines not on this page · raw message
tools/perf/util/parse-events.h +1 -0
@@ -29,6 +29,7 @@ extern int parse_filter(const struct option *opt, const char *str, int unset);#define EVENTS_HELP_MAX (128*1024)extern void print_events (void ); +extern int is_valid_tracepoint (const char *event_string);extern char debugfs_path[];extern int valid_debugfs_mount (const char *debugfs);
Signature · 1 line
1.6.0.2