Commit d0b45880 authored by Michele Di Giorgio's avatar Michele Di Giorgio Committed by Zhang Rui

thermal: trace: migrating thermal traces to use TRACE_DEFINE_ENUM() macros

Userspace tools are not aware of how to convert the enums provided by
the tracepoints to their corresponding strings.

Adding TRACE_DEFINE_ENUM() macros allows to make the enums available
to userspace to let the tools know what those enum values represent.

In particular, for thermal zone trip types what we obtained before was
something like:

kworker/1:1-460   [001]   320.372732: thermal_zone_trip:    thermal_zone=soc
				id=0 trip=1 trip_type=1

Unfortunately, userspace tools do not know how to convert enum values to
strings and as a consequence they can only forward the enum value to the
output. By using TRACE_DEFINE_ENUM() macros for thermal traces we get the
following trace line:

kworker/1:1-460   [001]   320.372732: thermal_zone_trip:    thermal_zone=soc
				id=0 trip=1 trip_type=PASSIVE

Userspace tools are now able to better understand the meaning of the trip_type
and provide the user with more readable information.

CC: Steven Rostedt <rostedt@goodmis.org>
CC: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: default avatarMichele Di Giorgio <michele.digiorgio@arm.com>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Acked-by: default avatarJavi Merino <javi.merino@arm.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
parent fc77dbd3
......@@ -8,6 +8,18 @@
#include <linux/thermal.h>
#include <linux/tracepoint.h>
TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
#define show_tzt_type(type) \
__print_symbolic(type, \
{ THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
{ THERMAL_TRIP_HOT, "HOT"}, \
{ THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
{ THERMAL_TRIP_ACTIVE, "ACTIVE"})
TRACE_EVENT(thermal_temperature,
TP_PROTO(struct thermal_zone_device *tz),
......@@ -73,9 +85,9 @@ TRACE_EVENT(thermal_zone_trip,
__entry->trip_type = trip_type;
),
TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%d",
TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%s",
__get_str(thermal_zone), __entry->id, __entry->trip,
__entry->trip_type)
show_tzt_type(__entry->trip_type))
);
TRACE_EVENT(thermal_power_cpu_get_power,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment