All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints
@ 2013-06-20  4:56 kpark3469
  2013-06-20  4:56 ` [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints kpark3469
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: kpark3469 @ 2013-06-20  4:56 UTC (permalink / raw)
  To: linux-pm; +Cc: keun-o.park, len.brown, rjw, rostedt

From: Sahara <keun-o.park@windriver.com>

This patch adds tracepoints to pm_qos_update_target and
pm_qos_update_flags. It's useful for checking pm qos action,
previous value and current value.

Signed-off-by: Sahara <keun-o.park@windriver.com>
---
 include/trace/events/power.h |   49 ++++++++++++++++++++++++++++++++++++++++++
 kernel/power/qos.c           |    3 ++
 2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 427acab..27a714c 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -5,6 +5,7 @@
 #define _TRACE_POWER_H
 
 #include <linux/ktime.h>
+#include <linux/pm_qos.h>
 #include <linux/tracepoint.h>
 
 DECLARE_EVENT_CLASS(cpu,
@@ -177,6 +178,54 @@ DEFINE_EVENT(power_domain, power_domain_target,
 
 	TP_ARGS(name, state, cpu_id)
 );
+
+/*
+ * The pm qos events are used for pm qos update
+ */
+DECLARE_EVENT_CLASS(pm_qos_update,
+
+	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
+
+	TP_ARGS(action, prev_value, curr_value),
+
+	TP_STRUCT__entry(
+		__field( enum pm_qos_req_action, action         )
+		__field( int,                    prev_value     )
+		__field( int,                    curr_value     )
+	),
+
+	TP_fast_assign(
+		__entry->action = action;
+		__entry->prev_value = prev_value;
+		__entry->curr_value = curr_value;
+	),
+
+	TP_printk("action=%s prev_value=%d curr_value=%d",
+		  (__entry->action == PM_QOS_ADD_REQ) ? "ADD_REQ" :
+		  (__entry->action == PM_QOS_UPDATE_REQ) ? "UPDATE_REQ" :
+		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
+		  __entry->prev_value, __entry->curr_value)
+);
+
+DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
+
+	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
+
+	TP_ARGS(action, prev_value, curr_value)
+);
+
+DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
+
+	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
+
+	TP_ARGS(action, prev_value, curr_value),
+
+	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
+		  (__entry->action == PM_QOS_ADD_REQ) ? "ADD_REQ" :
+		  (__entry->action == PM_QOS_UPDATE_REQ) ? "UPDATE_REQ" :
+		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
+		  __entry->prev_value, __entry->curr_value)
+);
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index f2f5f6e..4fb8d14 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -44,6 +44,7 @@
 
 #include <linux/uaccess.h>
 #include <linux/export.h>
+#include <trace/events/power.h>
 
 /*
  * locking rule: all changes to constraints or notifiers lists
@@ -202,6 +203,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
 
 	spin_unlock_irqrestore(&pm_qos_lock, flags);
 
+	trace_pm_qos_update_target(action, prev_value, curr_value);
 	if (prev_value != curr_value) {
 		blocking_notifier_call_chain(c->notifiers,
 					     (unsigned long)curr_value,
@@ -272,6 +274,7 @@ bool pm_qos_update_flags(struct pm_qos_flags *pqf,
 
 	spin_unlock_irqrestore(&pm_qos_lock, irqflags);
 
+	trace_pm_qos_update_flags(action, prev_value, curr_value);
 	return prev_value != curr_value;
 }
 
-- 
1.7.1


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

* [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints
  2013-06-20  4:56 [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints kpark3469
@ 2013-06-20  4:56 ` kpark3469
  2013-06-20  4:56   ` [PATCH 3/4] PM / tracing: Add dev_pm_qos_request tracepoints kpark3469
  2013-06-20 12:35 ` [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints Steven Rostedt
  2013-06-20 12:36 ` Steven Rostedt
  2 siblings, 1 reply; 7+ messages in thread
From: kpark3469 @ 2013-06-20  4:56 UTC (permalink / raw)
  To: linux-pm; +Cc: keun-o.park, len.brown, rjw, rostedt

From: Sahara <keun-o.park@windriver.com>

Adds tracepoints to pm_qos_add_request, pm_qos_update_request,
pm_qos_remove_request, and pm_qos_update_request_timeout.
It's useful for checking pm_qos_class, value, and timeout_us.

Signed-off-by: Sahara <keun-o.park@windriver.com>
---
 include/trace/events/power.h |   75 ++++++++++++++++++++++++++++++++++++++++++
 kernel/power/qos.c           |    5 +++
 2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 27a714c..28b6645 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -182,6 +182,81 @@ DEFINE_EVENT(power_domain, power_domain_target,
 /*
  * The pm qos events are used for pm qos update
  */
+DECLARE_EVENT_CLASS(pm_qos_request,
+
+	TP_PROTO(int pm_qos_class, s32 value),
+
+	TP_ARGS(pm_qos_class, value),
+
+	TP_STRUCT__entry(
+		__field( int,                    pm_qos_class   )
+		__field( s32,                    value          )
+	),
+
+	TP_fast_assign(
+		__entry->pm_qos_class = pm_qos_class;
+		__entry->value = value;
+	),
+
+	TP_printk("pm_qos_class=%s value=%d",
+		  (__entry->pm_qos_class == PM_QOS_CPU_DMA_LATENCY) ?
+			"CPU_DMA_LATENCY" :
+		  (__entry->pm_qos_class == PM_QOS_NETWORK_LATENCY) ?
+			"NETWORK_LATENCY" :
+		  (__entry->pm_qos_class == PM_QOS_NETWORK_THROUGHPUT) ?
+			"NETWORK_THROUGHPUT" : "??",
+		  __entry->value)
+);
+
+DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
+
+	TP_PROTO(int pm_qos_class, s32 value),
+
+	TP_ARGS(pm_qos_class, value)
+);
+
+DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
+
+	TP_PROTO(int pm_qos_class, s32 value),
+
+	TP_ARGS(pm_qos_class, value)
+);
+
+DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
+
+	TP_PROTO(int pm_qos_class, s32 value),
+
+	TP_ARGS(pm_qos_class, value)
+);
+
+TRACE_EVENT(pm_qos_update_request_timeout,
+
+	TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
+
+	TP_ARGS(pm_qos_class, value, timeout_us),
+
+	TP_STRUCT__entry(
+		__field( int,                    pm_qos_class   )
+		__field( s32,                    value          )
+		__field( unsigned long,          timeout_us     )
+	),
+
+	TP_fast_assign(
+		__entry->pm_qos_class = pm_qos_class;
+		__entry->value = value;
+		__entry->timeout_us = timeout_us;
+	),
+
+	TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
+		  (__entry->pm_qos_class == PM_QOS_CPU_DMA_LATENCY) ?
+			"CPU_DMA_LATENCY" :
+		  (__entry->pm_qos_class == PM_QOS_NETWORK_LATENCY) ?
+			"NETWORK_LATENCY" :
+		  (__entry->pm_qos_class == PM_QOS_NETWORK_THROUGHPUT) ?
+			"NETWORK_THROUGHPUT" : "??",
+		  __entry->value, __entry->timeout_us)
+);
+
 DECLARE_EVENT_CLASS(pm_qos_update,
 
 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 4fb8d14..06fe285 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -336,6 +336,7 @@ void pm_qos_add_request(struct pm_qos_request *req,
 	}
 	req->pm_qos_class = pm_qos_class;
 	INIT_DELAYED_WORK(&req->work, pm_qos_work_fn);
+	trace_pm_qos_add_request(pm_qos_class, value);
 	pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints,
 			     &req->node, PM_QOS_ADD_REQ, value);
 }
@@ -364,6 +365,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
 
 	cancel_delayed_work_sync(&req->work);
 
+	trace_pm_qos_update_request(req->pm_qos_class, new_value);
 	if (new_value != req->node.prio)
 		pm_qos_update_target(
 			pm_qos_array[req->pm_qos_class]->constraints,
@@ -390,6 +392,8 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value,
 
 	cancel_delayed_work_sync(&req->work);
 
+	trace_pm_qos_update_request_timeout(req->pm_qos_class,
+					    new_value, timeout_us);
 	if (new_value != req->node.prio)
 		pm_qos_update_target(
 			pm_qos_array[req->pm_qos_class]->constraints,
@@ -419,6 +423,7 @@ void pm_qos_remove_request(struct pm_qos_request *req)
 
 	cancel_delayed_work_sync(&req->work);
 
+	trace_pm_qos_remove_request(req->pm_qos_class, PM_QOS_DEFAULT_VALUE);
 	pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints,
 			     &req->node, PM_QOS_REMOVE_REQ,
 			     PM_QOS_DEFAULT_VALUE);
-- 
1.7.1


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

* [PATCH 3/4] PM / tracing: Add dev_pm_qos_request tracepoints
  2013-06-20  4:56 ` [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints kpark3469
@ 2013-06-20  4:56   ` kpark3469
  2013-06-20  4:57     ` [PATCH 4/4] Documentation: Add pm_qos and dev_pm_qos to events-power.txt kpark3469
  0 siblings, 1 reply; 7+ messages in thread
From: kpark3469 @ 2013-06-20  4:56 UTC (permalink / raw)
  To: linux-pm; +Cc: keun-o.park, len.brown, rjw, rostedt

From: Sahara <keun-o.park@windriver.com>

Adds tracepoints to dev_pm_qos_add_request, dev_pm_qos_update_request,
and dev_pm_qos_remove_request.  It's useful for checking device name,
dev_pm_qos_request_type, and value.

Signed-off-by: Sahara <keun-o.park@windriver.com>
---
 drivers/base/power/qos.c     |    6 +++++
 include/trace/events/power.h |   52 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 71671c4..5c1361a 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -42,6 +42,7 @@
 #include <linux/export.h>
 #include <linux/pm_runtime.h>
 #include <linux/err.h>
+#include <trace/events/power.h>
 
 #include "power.h"
 
@@ -305,6 +306,7 @@ int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
 	else if (!dev->power.qos)
 		ret = dev_pm_qos_constraints_allocate(dev);
 
+	trace_dev_pm_qos_add_request(dev_name(dev), type, value);
 	if (!ret) {
 		req->dev = dev;
 		req->type = type;
@@ -349,6 +351,8 @@ static int __dev_pm_qos_update_request(struct dev_pm_qos_request *req,
 		return -EINVAL;
 	}
 
+	trace_dev_pm_qos_update_request(dev_name(req->dev), req->type,
+					new_value);
 	if (curr_value != new_value)
 		ret = apply_constraint(req, PM_QOS_UPDATE_REQ, new_value);
 
@@ -398,6 +402,8 @@ static int __dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
 	if (IS_ERR_OR_NULL(req->dev->power.qos))
 		return -ENODEV;
 
+	trace_dev_pm_qos_remove_request(dev_name(req->dev), req->type,
+					PM_QOS_DEFAULT_VALUE);
 	ret = apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
 	memset(req, 0, sizeof(*req));
 	return ret;
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 28b6645..19adcec 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -301,6 +301,58 @@ DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
 		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
 		  __entry->prev_value, __entry->curr_value)
 );
+
+DECLARE_EVENT_CLASS(dev_pm_qos_request,
+
+	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
+		 s32 new_value),
+
+	TP_ARGS(name, type, new_value),
+
+	TP_STRUCT__entry(
+		__string( name,                    name         )
+		__field( enum dev_pm_qos_req_type, type         )
+		__field( s32,                      new_value    )
+	),
+
+	TP_fast_assign(
+		__assign_str(name, name);
+		__entry->type = type;
+		__entry->new_value = new_value;
+	),
+
+	TP_printk("device=%s type=%s new_value=%d",
+		  __get_str(name),
+		  (__entry->type == DEV_PM_QOS_LATENCY) ?
+			"DEV_PM_QOS_LATENCY" :
+		  (__entry->type == DEV_PM_QOS_FLAGS) ?
+			"DEV_PM_QOS_FLAGS" : "??",
+		  __entry->new_value)
+);
+
+DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
+
+	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
+		 s32 new_value),
+
+	TP_ARGS(name, type, new_value)
+);
+
+DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
+
+	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
+		 s32 new_value),
+
+	TP_ARGS(name, type, new_value)
+);
+
+DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
+
+	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
+		 s32 new_value),
+
+	TP_ARGS(name, type, new_value)
+);
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
-- 
1.7.1


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

* [PATCH 4/4] Documentation: Add pm_qos and dev_pm_qos to events-power.txt
  2013-06-20  4:56   ` [PATCH 3/4] PM / tracing: Add dev_pm_qos_request tracepoints kpark3469
@ 2013-06-20  4:57     ` kpark3469
  0 siblings, 0 replies; 7+ messages in thread
From: kpark3469 @ 2013-06-20  4:57 UTC (permalink / raw)
  To: linux-pm; +Cc: keun-o.park, len.brown, rjw, rostedt

From: Sahara <keun-o.park@windriver.com>

Add PM QOS events section and description to events-power.txt.

Signed-off-by: Sahara <keun-o.park@windriver.com>
---
 Documentation/trace/events-power.txt |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/Documentation/trace/events-power.txt b/Documentation/trace/events-power.txt
index e1498ff..90ebab6 100644
--- a/Documentation/trace/events-power.txt
+++ b/Documentation/trace/events-power.txt
@@ -63,3 +63,34 @@ power_domain_target	"%s state=%lu cpu_id=%lu"
 The first parameter gives the power domain name (e.g. "mpu_pwrdm").
 The second parameter is the power domain target state.
 
+4. PM QOS events
+================
+The pm qos events are used for qos add/update/remove request and for
+target/flags update.
+
+pm_qos_add_request                 "pm_qos_class=%s value=%d"
+pm_qos_update_request              "pm_qos_class=%s value=%d"
+pm_qos_remove_request              "pm_qos_class=%s value=%d"
+pm_qos_update_request_timeout      "pm_qos_class=%s value=%d, timeout_us=%ld"
+
+The first parameter gives the qos class name (e.g. "CPU_DMA_LATENCY").
+The second parameter is value to be added/updated/removed.
+The third parameter is timeout value in usec.
+
+pm_qos_update_target               "action=%s prev_value=%d curr_value=%d"
+pm_qos_update_flags                "action=%s prev_value=0x%x curr_value=0x%x"
+
+The first parameter gives the qos action name (e.g. "ADD_REQ").
+The second parameter is the previous qos value.
+The third parameter is the current qos value to update.
+
+And, there are also events used for device pm qos add/update/remove request.
+
+dev_pm_qos_add_request             "device=%s type=%s new_value=%d"
+dev_pm_qos_update_request          "device=%s type=%s new_value=%d"
+dev_pm_qos_remove_request          "device=%s type=%s new_value=%d"
+
+The first parameter gives the device name which tries to add/update/remove
+qos requests.
+The second parameter gives the request type (e.g. "DEV_PM_QOS_LATENCY").
+The third parameter is value to be added/updated/removed.
-- 
1.7.1


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

* Re: [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints
  2013-06-20  4:56 [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints kpark3469
  2013-06-20  4:56 ` [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints kpark3469
@ 2013-06-20 12:35 ` Steven Rostedt
  2013-06-21  2:16   ` Keun-O Park
  2013-06-20 12:36 ` Steven Rostedt
  2 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2013-06-20 12:35 UTC (permalink / raw)
  To: kpark3469; +Cc: linux-pm, keun-o.park, len.brown, rjw

On Thu, 2013-06-20 at 13:56 +0900, kpark3469@gmail.com wrote:

> +DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
> +
> +	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
> +
> +	TP_ARGS(action, prev_value, curr_value),
> +
> +	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
> +		  (__entry->action == PM_QOS_ADD_REQ) ? "ADD_REQ" :
> +		  (__entry->action == PM_QOS_UPDATE_REQ) ? "UPDATE_REQ" :
> +		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
> +		  __entry->prev_value, __entry->curr_value)
> +);
>  #endif /* _TRACE_POWER_H */

Nice! I believe you are the first one to add a new event using a
DEFINE_EVENT_PRINT(). And you did it properly (almost, see below) :-)

The only other use of that was by Li Zefan who converted an existing
event to DEFINE_EVENT_PRINT().

There's a helper function to convert numbers into strings:

	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
		__print_symbolic(__entry->action,
			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
		__entry->prev_value, __entry->curr_value)

The advantage of using __print_symbolic() is that it allows both perf
and trace-cmd to read this event properly. Their parsers are not full C
parsers, and when you open code the the processing, they both will fail
to parse how to read the output, and will just default to printing the
fields via their raw numbers.

Another advantage is if the __entry->action is not one of the defined
fields, instead of outputting "??" it will output the number in hex. Say
if __entry->action is 0x123, the __print_symbolic will return "0x123" as
a string and that will be shown to the user, letting you know the actual
value of the field that was unknown.

-- Steve




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

* Re: [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints
  2013-06-20  4:56 [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints kpark3469
  2013-06-20  4:56 ` [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints kpark3469
  2013-06-20 12:35 ` [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints Steven Rostedt
@ 2013-06-20 12:36 ` Steven Rostedt
  2 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-06-20 12:36 UTC (permalink / raw)
  To: kpark3469; +Cc: linux-pm, keun-o.park, len.brown, rjw

On Thu, 2013-06-20 at 13:56 +0900, kpark3469@gmail.com wrote:
> /*
> + * The pm qos events are used for pm qos update
> + */
> +DECLARE_EVENT_CLASS(pm_qos_update,
> +
> +	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
> +
> +	TP_ARGS(action, prev_value, curr_value),
> +
> +	TP_STRUCT__entry(
> +		__field( enum pm_qos_req_action, action         )
> +		__field( int,                    prev_value     )
> +		__field( int,                    curr_value     )
> +	),
> +
> +	TP_fast_assign(
> +		__entry->action = action;
> +		__entry->prev_value = prev_value;
> +		__entry->curr_value = curr_value;
> +	),
> +
> +	TP_printk("action=%s prev_value=%d curr_value=%d",
> +		  (__entry->action == PM_QOS_ADD_REQ) ? "ADD_REQ" :
> +		  (__entry->action == PM_QOS_UPDATE_REQ) ? "UPDATE_REQ" :
> +		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
> +		  __entry->prev_value, __entry->curr_value)
> +);
> +

This should be converted to use __print_symbolic() as well.

-- Steve



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

* Re: [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints
  2013-06-20 12:35 ` [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints Steven Rostedt
@ 2013-06-21  2:16   ` Keun-O Park
  0 siblings, 0 replies; 7+ messages in thread
From: Keun-O Park @ 2013-06-21  2:16 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: kpark3469, linux-pm, len.brown, rjw

2013년 06월 20일 21:35, Steven Rostedt 쓴 글:
> On Thu, 2013-06-20 at 13:56 +0900, kpark3469@gmail.com wrote:
>
>> +DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
>> +
>> +	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
>> +
>> +	TP_ARGS(action, prev_value, curr_value),
>> +
>> +	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
>> +		  (__entry->action == PM_QOS_ADD_REQ) ? "ADD_REQ" :
>> +		  (__entry->action == PM_QOS_UPDATE_REQ) ? "UPDATE_REQ" :
>> +		  (__entry->action == PM_QOS_REMOVE_REQ) ? "REMOVE_REQ" : "??",
>> +		  __entry->prev_value, __entry->curr_value)
>> +);
>>   #endif /* _TRACE_POWER_H */
> Nice! I believe you are the first one to add a new event using a
> DEFINE_EVENT_PRINT(). And you did it properly (almost, see below) :-)
>
> The only other use of that was by Li Zefan who converted an existing
> event to DEFINE_EVENT_PRINT().
>
> There's a helper function to convert numbers into strings:
>
> 	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
> 		__print_symbolic(__entry->action,
> 			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
> 			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
> 			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
> 		__entry->prev_value, __entry->curr_value)
>
> The advantage of using __print_symbolic() is that it allows both perf
> and trace-cmd to read this event properly. Their parsers are not full C
> parsers, and when you open code the the processing, they both will fail
> to parse how to read the output, and will just default to printing the
> fields via their raw numbers.
>
> Another advantage is if the __entry->action is not one of the defined
> fields, instead of outputting "??" it will output the number in hex. Say
> if __entry->action is 0x123, the __print_symbolic will return "0x123" as
> a string and that will be shown to the user, letting you know the actual
> value of the field that was unknown.
>
> -- Steve
>
>
>

Thanks Steve. I modified codes to use __print_symbolic following your 
recommendation.

-- Sahara

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

end of thread, other threads:[~2013-06-21  2:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-20  4:56 [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints kpark3469
2013-06-20  4:56 ` [PATCH 2/4] PM / tracing: Add pm_qos_request tracepoints kpark3469
2013-06-20  4:56   ` [PATCH 3/4] PM / tracing: Add dev_pm_qos_request tracepoints kpark3469
2013-06-20  4:57     ` [PATCH 4/4] Documentation: Add pm_qos and dev_pm_qos to events-power.txt kpark3469
2013-06-20 12:35 ` [PATCH 1/4] PM / tracing: Add pm_qos_update_target/flags tracepoints Steven Rostedt
2013-06-21  2:16   ` Keun-O Park
2013-06-20 12:36 ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.