mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kpark3469@gmail.com
To: rostedt@goodmis.org
Cc: keun-o.park@windriver.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] xen/trace: replace old code with __print_symbolic
Date: Tue,  6 Aug 2013 13:51:21 +0900	[thread overview]
Message-ID: <1375764681-4618-2-git-send-email-kpark3469@gmail.com> (raw)
In-Reply-To: <1375764681-4618-1-git-send-email-kpark3469@gmail.com>

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

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.

Signed-off-by: Sahara <keun-o.park@windriver.com>
---
 include/trace/events/xen.h |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h
index d06b6da..8c6f945 100644
--- a/include/trace/events/xen.h
+++ b/include/trace/events/xen.h
@@ -10,6 +10,25 @@
 
 struct multicall_entry;
 
+#define show_paravirt_lazy_mode(val)				\
+	__print_symbolic(val,					\
+		{ PARAVIRT_LAZY_NONE,	"LAZY_NONE" },		\
+		{ PARAVIRT_LAZY_MMU,	"LAZY_MMU" },		\
+		{ PARAVIRT_LAZY_CPU,	"LAZY_CPU" })
+
+#define show_xen_mc_flush_reason(val)				\
+	__print_symbolic(val,					\
+		{ XEN_MC_FL_NONE,	"NONE" },		\
+		{ XEN_MC_FL_BATCH,	"BATCH" },		\
+		{ XEN_MC_FL_ARGS,	"ARGS" },		\
+		{ XEN_MC_FL_CALLBACK,	"CALLBACK" })
+
+#define show_xen_mc_extend_args(val)				\
+	__print_symbolic(val,					\
+		{ XEN_MC_XE_OK,	"OK" },				\
+		{ XEN_MC_XE_BAD_OP,	"BAD_OP" },		\
+		{ XEN_MC_XE_NO_SPACE,	"NO_SPACE" })
+
 /* Multicalls */
 DECLARE_EVENT_CLASS(xen_mc__batch,
 	    TP_PROTO(enum paravirt_lazy_mode mode),
@@ -18,9 +37,8 @@ DECLARE_EVENT_CLASS(xen_mc__batch,
 		    __field(enum paravirt_lazy_mode, mode)
 		    ),
 	    TP_fast_assign(__entry->mode = mode),
-	    TP_printk("start batch LAZY_%s",
-		      (__entry->mode == PARAVIRT_LAZY_MMU) ? "MMU" :
-		      (__entry->mode == PARAVIRT_LAZY_CPU) ? "CPU" : "NONE")
+	    TP_printk("start batch %s",
+		      show_paravirt_lazy_mode(__entry->mode)
 	);
 #define DEFINE_XEN_MC_BATCH(name)			\
 	DEFINE_EVENT(xen_mc__batch, name,		\
@@ -82,10 +100,7 @@ TRACE_EVENT(xen_mc_flush_reason,
 		    ),
 	    TP_fast_assign(__entry->reason = reason),
 	    TP_printk("flush reason %s",
-		      (__entry->reason == XEN_MC_FL_NONE) ? "NONE" :
-		      (__entry->reason == XEN_MC_FL_BATCH) ? "BATCH" :
-		      (__entry->reason == XEN_MC_FL_ARGS) ? "ARGS" :
-		      (__entry->reason == XEN_MC_FL_CALLBACK) ? "CALLBACK" : "??")
+		      show_xen_mc_flush_reason(__entry->reason)
 	);
 
 TRACE_EVENT(xen_mc_flush,
@@ -117,9 +132,7 @@ TRACE_EVENT(xen_mc_extend_args,
 	    TP_printk("extending op %u%s by %zu bytes res %s",
 		      __entry->op, xen_hypercall_name(__entry->op),
 		      __entry->args,
-		      __entry->res == XEN_MC_XE_OK ? "OK" :
-		      __entry->res == XEN_MC_XE_BAD_OP ? "BAD_OP" :
-		      __entry->res == XEN_MC_XE_NO_SPACE ? "NO_SPACE" : "???")
+		      show_xen_mc_extend_args(__entry->res)
 	);
 
 /* mmu */
-- 
1.7.1


      reply	other threads:[~2013-08-06  4:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06  4:51 [PATCH 1/2] PM / QoS: use __print_symbolic with more convenient way kpark3469
2013-08-06  4:51 ` kpark3469 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375764681-4618-2-git-send-email-kpark3469@gmail.com \
    --to=kpark3469@gmail.com \
    --cc=keun-o.park@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®