]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mm: tracing: Export enums in tracepoints to user space
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Fri, 27 Mar 2015 20:48:57 +0000 (16:48 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 8 Apr 2015 13:40:01 +0000 (09:40 -0400)
The enums used in tracepoints with __print_symbolic() have their
names shown in the tracepoint format files and not their values.
This makes it difficult for user space tools to convert the binary
data to the strings as user space does not know what those enums
are about.

By having them use TRACE_DEFINE_ENUM(), the names of the enums will
be mapped to the values and shown to user space.

Link: http://lkml.kernel.org/r/20150403013802.220157513@goodmis.org
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/trace/events/migrate.h

index dd2b5467d905816e72c22026f109e971bbef8724..539b25a76111fc644e1103d744c53ebf78a8fb17 100644 (file)
@@ -7,18 +7,40 @@
 #include <linux/tracepoint.h>
 
 #define MIGRATE_MODE                                           \
-       {MIGRATE_ASYNC,         "MIGRATE_ASYNC"},               \
-       {MIGRATE_SYNC_LIGHT,    "MIGRATE_SYNC_LIGHT"},          \
-       {MIGRATE_SYNC,          "MIGRATE_SYNC"}         
+       EM( MIGRATE_ASYNC,      "MIGRATE_ASYNC")                \
+       EM( MIGRATE_SYNC_LIGHT, "MIGRATE_SYNC_LIGHT")           \
+       EMe(MIGRATE_SYNC,       "MIGRATE_SYNC")
+
 
 #define MIGRATE_REASON                                         \
-       {MR_COMPACTION,         "compaction"},                  \
-       {MR_MEMORY_FAILURE,     "memory_failure"},              \
-       {MR_MEMORY_HOTPLUG,     "memory_hotplug"},              \
-       {MR_SYSCALL,            "syscall_or_cpuset"},           \
-       {MR_MEMPOLICY_MBIND,    "mempolicy_mbind"},             \
-       {MR_NUMA_MISPLACED,     "numa_misplaced"},              \
-       {MR_CMA,                "cma"}
+       EM( MR_COMPACTION,      "compaction")                   \
+       EM( MR_MEMORY_FAILURE,  "memory_failure")               \
+       EM( MR_MEMORY_HOTPLUG,  "memory_hotplug")               \
+       EM( MR_SYSCALL,         "syscall_or_cpuset")            \
+       EM( MR_MEMPOLICY_MBIND, "mempolicy_mbind")              \
+       EM( MR_NUMA_MISPLACED,  "numa_misplaced")               \
+       EMe(MR_CMA,             "cma")
+
+/*
+ * First define the enums in the above macros to be exported to userspace
+ * via TRACE_DEFINE_ENUM().
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)       TRACE_DEFINE_ENUM(a);
+#define EMe(a, b)      TRACE_DEFINE_ENUM(a);
+
+MIGRATE_MODE
+MIGRATE_REASON
+
+/*
+ * Now redefine the EM() and EMe() macros to map the enums to the strings
+ * that will be printed in the output.
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)       {a, b},
+#define EMe(a, b)      {a, b}
 
 TRACE_EVENT(mm_migrate_pages,