All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] trace: add the ability to parse sizeof()
@ 2017-05-31 21:56 Jeremy Linton
  2017-05-31 21:56 ` [PATCH 01/12] trace: rename kernel enum section to eval Jeremy Linton
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

There are a few cases of sizeof() embedded in TRACE_EVENT()
macros. That is a problem because the sizeof(structure) gets
passed to userspace which doesn't know how to decode the
size of kernel data structures. This is a similar problem
to enums which were being passed in their symbolic form to
userspace.

Rather than recreating much of that infrastructure lets
simply extend it, and append additional symbols into the
enum_map that can translate string sizeof() calls into
values. Of course that means that much of the infrastructure
is now poorly named so we go through and replace instances
describing "enum" with "eval" to indicate a generic C
expression to numerical evaluation routine.

Jeremy Linton (12):
  trace: rename kernel enum section to eval
  trace: rename trace_enum_map to trace_eval_map
  trace: rename struct module entry for trace enums
  trace: rename trace enum data structures in trace.c
  trace: rename trace_enum_mutex to trace_eval_mutex
  trace: rename trace.c enum functions
  trace: rename enum_map functions
  tracing: Rename enum_replace to eval_replace
  tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their
    values
  tracing: Update sample file to describe the new macro
  tracing: Add TRACE_DEFINE_SIZEOF() macros
  tracing: Rename update the enum_map file

 arch/arm64/kvm/trace.h                     |   2 +
 include/asm-generic/vmlinux.lds.h          |   6 +-
 include/linux/module.h                     |   4 +-
 include/linux/tracepoint.h                 |   7 +-
 include/trace/events/xen.h                 |  13 +-
 include/trace/trace_events.h               |  26 +++-
 kernel/module.c                            |   6 +-
 kernel/trace/Kconfig                       |  22 ++--
 kernel/trace/trace.c                       | 194 ++++++++++++++---------------
 kernel/trace/trace.h                       |   4 +-
 kernel/trace/trace_events.c                |  24 ++--
 samples/trace_events/trace-events-sample.h |   7 ++
 12 files changed, 175 insertions(+), 140 deletions(-)

-- 
2.9.4

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

* [PATCH 01/12] trace: rename kernel enum section to eval
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 02/12] trace: rename trace_enum_map to trace_eval_map Jeremy Linton
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

The kernel and its modules have sections containing the enum
string to value conversions. Rename this section because we
intend to store more than enums in it.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 include/asm-generic/vmlinux.lds.h | 6 +++---
 include/trace/trace_events.h      | 2 +-
 kernel/module.c                   | 2 +-
 kernel/trace/trace.c              | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 314a0b9..800f9f9 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -125,9 +125,9 @@
 			VMLINUX_SYMBOL(__start_ftrace_events) = .;	\
 			KEEP(*(_ftrace_events))				\
 			VMLINUX_SYMBOL(__stop_ftrace_events) = .;	\
-			VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .;	\
-			KEEP(*(_ftrace_enum_map))			\
-			VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
+			VMLINUX_SYMBOL(__start_ftrace_eval_maps) = .;	\
+			KEEP(*(_ftrace_eval_map))			\
+			VMLINUX_SYMBOL(__stop_ftrace_eval_maps) = .;
 #else
 #define FTRACE_EVENTS()
 #endif
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 00f6431..4bdd840 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -43,7 +43,7 @@ TRACE_MAKE_SYSTEM_STR();
 		.enum_value = a				\
 	};						\
 	static struct trace_enum_map __used		\
-	__attribute__((section("_ftrace_enum_map")))	\
+	__attribute__((section("_ftrace_eval_map")))	\
 	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
 
 /*
diff --git a/kernel/module.c b/kernel/module.c
index 4a3665f..9ec4713 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3077,7 +3077,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	mod->trace_events = section_objs(info, "_ftrace_events",
 					 sizeof(*mod->trace_events),
 					 &mod->num_trace_events);
-	mod->trace_enums = section_objs(info, "_ftrace_enum_map",
+	mod->trace_enums = section_objs(info, "_ftrace_eval_map",
 					sizeof(*mod->trace_enums),
 					&mod->num_trace_enums);
 #endif
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c4536c4..ce564c2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7704,15 +7704,15 @@ struct dentry *tracing_init_dentry(void)
 	return NULL;
 }
 
-extern struct trace_enum_map *__start_ftrace_enum_maps[];
-extern struct trace_enum_map *__stop_ftrace_enum_maps[];
+extern struct trace_enum_map *__start_ftrace_eval_maps[];
+extern struct trace_enum_map *__stop_ftrace_eval_maps[];
 
 static void __init trace_enum_init(void)
 {
 	int len;
 
-	len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps;
-	trace_insert_enum_map(NULL, __start_ftrace_enum_maps, len);
+	len = __stop_ftrace_eval_maps - __start_ftrace_eval_maps;
+	trace_insert_enum_map(NULL, __start_ftrace_eval_maps, len);
 }
 
 #ifdef CONFIG_MODULES
-- 
2.9.4

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

* [PATCH 02/12] trace: rename trace_enum_map to trace_eval_map
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
  2017-05-31 21:56 ` [PATCH 01/12] trace: rename kernel enum section to eval Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 03/12] trace: rename struct module entry for trace enums Jeremy Linton
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Each enum is loaded into the trace_enum_map, as we
are now using this for more than enums rename it.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 include/linux/module.h       |  2 +-
 include/linux/tracepoint.h   |  6 +++---
 include/trace/trace_events.h |  8 ++++----
 kernel/trace/trace.c         | 24 ++++++++++++------------
 kernel/trace/trace.h         |  4 ++--
 kernel/trace/trace_events.c  | 14 +++++++-------
 6 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 21f5639..46b4804 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -442,7 +442,7 @@ struct module {
 #ifdef CONFIG_EVENT_TRACING
 	struct trace_event_call **trace_events;
 	unsigned int num_trace_events;
-	struct trace_enum_map **trace_enums;
+	struct trace_eval_map **trace_enums;
 	unsigned int num_trace_enums;
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index cc48cb2..f7b0f55 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -25,10 +25,10 @@ struct module;
 struct tracepoint;
 struct notifier_block;
 
-struct trace_enum_map {
+struct trace_eval_map {
 	const char		*system;
-	const char		*enum_string;
-	unsigned long		enum_value;
+	const char		*eval_string;
+	unsigned long		eval_value;
 };
 
 #define TRACEPOINT_DEFAULT_PRIO	10
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 4bdd840..49cce5f 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -35,14 +35,14 @@ TRACE_MAKE_SYSTEM_STR();
 
 #undef TRACE_DEFINE_ENUM
 #define TRACE_DEFINE_ENUM(a)				\
-	static struct trace_enum_map __used __initdata	\
+	static struct trace_eval_map __used __initdata	\
 	__##TRACE_SYSTEM##_##a =			\
 	{						\
 		.system = TRACE_SYSTEM_STRING,		\
-		.enum_string = #a,			\
-		.enum_value = a				\
+		.eval_string = #a,			\
+		.eval_value = a				\
 	};						\
-	static struct trace_enum_map __used		\
+	static struct trace_eval_map __used		\
 	__attribute__((section("_ftrace_eval_map")))	\
 	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
 
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ce564c2..f82764b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -132,7 +132,7 @@ union trace_enum_map_item;
 struct trace_enum_map_tail {
 	/*
 	 * "end" is first and points to NULL as it must be different
-	 * than "mod" or "enum_string"
+	 * than "mod" or "eval_string"
 	 */
 	union trace_enum_map_item	*next;
 	const char			*end;	/* points to NULL */
@@ -148,7 +148,7 @@ static DEFINE_MUTEX(trace_enum_mutex);
  * pointer to the next array of saved enum_map items.
  */
 union trace_enum_map_item {
-	struct trace_enum_map		map;
+	struct trace_eval_map		map;
 	struct trace_enum_map_head	head;
 	struct trace_enum_map_tail	tail;
 };
@@ -4721,7 +4721,7 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
 static union trace_enum_map_item *
 update_enum_map(union trace_enum_map_item *ptr)
 {
-	if (!ptr->map.enum_string) {
+	if (!ptr->map.eval_string) {
 		if (ptr->tail.next) {
 			ptr = ptr->tail.next;
 			/* Set ptr to the next real item (skip head) */
@@ -4781,7 +4781,7 @@ static int enum_map_show(struct seq_file *m, void *v)
 	union trace_enum_map_item *ptr = v;
 
 	seq_printf(m, "%s %ld (%s)\n",
-		   ptr->map.enum_string, ptr->map.enum_value,
+		   ptr->map.eval_string, ptr->map.eval_value,
 		   ptr->map.system);
 
 	return 0;
@@ -4817,11 +4817,11 @@ trace_enum_jmp_to_tail(union trace_enum_map_item *ptr)
 }
 
 static void
-trace_insert_enum_map_file(struct module *mod, struct trace_enum_map **start,
+trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 			   int len)
 {
-	struct trace_enum_map **stop;
-	struct trace_enum_map **map;
+	struct trace_eval_map **stop;
+	struct trace_eval_map **map;
 	union trace_enum_map_item *map_array;
 	union trace_enum_map_item *ptr;
 
@@ -4875,13 +4875,13 @@ static void trace_create_enum_file(struct dentry *d_tracer)
 #else /* CONFIG_TRACE_ENUM_MAP_FILE */
 static inline void trace_create_enum_file(struct dentry *d_tracer) { }
 static inline void trace_insert_enum_map_file(struct module *mod,
-			      struct trace_enum_map **start, int len) { }
+			      struct trace_eval_map **start, int len) { }
 #endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
 
 static void trace_insert_enum_map(struct module *mod,
-				  struct trace_enum_map **start, int len)
+				  struct trace_eval_map **start, int len)
 {
-	struct trace_enum_map **map;
+	struct trace_eval_map **map;
 
 	if (len <= 0)
 		return;
@@ -7704,8 +7704,8 @@ struct dentry *tracing_init_dentry(void)
 	return NULL;
 }
 
-extern struct trace_enum_map *__start_ftrace_eval_maps[];
-extern struct trace_enum_map *__stop_ftrace_eval_maps[];
+extern struct trace_eval_map *__start_ftrace_eval_maps[];
+extern struct trace_eval_map *__stop_ftrace_eval_maps[];
 
 static void __init trace_enum_init(void)
 {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 291a1bc..75d5e27 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1768,10 +1768,10 @@ static inline const char *get_syscall_name(int syscall)
 
 #ifdef CONFIG_EVENT_TRACING
 void trace_event_init(void);
-void trace_event_enum_update(struct trace_enum_map **map, int len);
+void trace_event_enum_update(struct trace_eval_map **map, int len);
 #else
 static inline void __init trace_event_init(void) { }
-static inline void trace_event_enum_update(struct trace_enum_map **map, int len) { }
+static inline void trace_event_enum_update(struct trace_eval_map **map, int len) { }
 #endif
 
 extern struct trace_iterator *tracepoint_print_iter;
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index e7973e1..cf5b9aa 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2067,18 +2067,18 @@ __register_event(struct trace_event_call *call, struct module *mod)
 	return 0;
 }
 
-static char *enum_replace(char *ptr, struct trace_enum_map *map, int len)
+static char *enum_replace(char *ptr, struct trace_eval_map *map, int len)
 {
 	int rlen;
 	int elen;
 
 	/* Find the length of the enum value as a string */
-	elen = snprintf(ptr, 0, "%ld", map->enum_value);
+	elen = snprintf(ptr, 0, "%ld", map->eval_value);
 	/* Make sure there's enough room to replace the string with the value */
 	if (len < elen)
 		return NULL;
 
-	snprintf(ptr, elen + 1, "%ld", map->enum_value);
+	snprintf(ptr, elen + 1, "%ld", map->eval_value);
 
 	/* Get the rest of the string of ptr */
 	rlen = strlen(ptr + len);
@@ -2090,11 +2090,11 @@ static char *enum_replace(char *ptr, struct trace_enum_map *map, int len)
 }
 
 static void update_event_printk(struct trace_event_call *call,
-				struct trace_enum_map *map)
+				struct trace_eval_map *map)
 {
 	char *ptr;
 	int quote = 0;
-	int len = strlen(map->enum_string);
+	int len = strlen(map->eval_string);
 
 	for (ptr = call->print_fmt; *ptr; ptr++) {
 		if (*ptr == '\\') {
@@ -2125,7 +2125,7 @@ static void update_event_printk(struct trace_event_call *call,
 			continue;
 		}
 		if (isalpha(*ptr) || *ptr == '_') {
-			if (strncmp(map->enum_string, ptr, len) == 0 &&
+			if (strncmp(map->eval_string, ptr, len) == 0 &&
 			    !isalnum(ptr[len]) && ptr[len] != '_') {
 				ptr = enum_replace(ptr, map, len);
 				/* Hmm, enum string smaller than value */
@@ -2165,7 +2165,7 @@ static void update_event_printk(struct trace_event_call *call,
 	}
 }
 
-void trace_event_enum_update(struct trace_enum_map **map, int len)
+void trace_event_enum_update(struct trace_eval_map **map, int len)
 {
 	struct trace_event_call *call, *p;
 	const char *last_system = NULL;
-- 
2.9.4

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

* [PATCH 03/12] trace: rename struct module entry for trace enums
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
  2017-05-31 21:56 ` [PATCH 01/12] trace: rename kernel enum section to eval Jeremy Linton
  2017-05-31 21:56 ` [PATCH 02/12] trace: rename trace_enum_map to trace_eval_map Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 04/12] trace: rename trace enum data structures in trace.c Jeremy Linton
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Each module has a list of enum's its contributing to the
enum map, rename that entry to reflect its use by more than
enums.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 include/linux/module.h | 4 ++--
 kernel/module.c        | 6 +++---
 kernel/trace/trace.c   | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 46b4804..8eb9a1e 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -442,8 +442,8 @@ struct module {
 #ifdef CONFIG_EVENT_TRACING
 	struct trace_event_call **trace_events;
 	unsigned int num_trace_events;
-	struct trace_eval_map **trace_enums;
-	unsigned int num_trace_enums;
+	struct trace_eval_map **trace_evals;
+	unsigned int num_trace_evals;
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 	unsigned int num_ftrace_callsites;
diff --git a/kernel/module.c b/kernel/module.c
index 9ec4713..df1c4a9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3077,9 +3077,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	mod->trace_events = section_objs(info, "_ftrace_events",
 					 sizeof(*mod->trace_events),
 					 &mod->num_trace_events);
-	mod->trace_enums = section_objs(info, "_ftrace_eval_map",
-					sizeof(*mod->trace_enums),
-					&mod->num_trace_enums);
+	mod->trace_evals = section_objs(info, "_ftrace_eval_map",
+					sizeof(*mod->trace_evals),
+					&mod->num_trace_evals);
 #endif
 #ifdef CONFIG_TRACING
 	mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f82764b..85f0e3c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7718,7 +7718,7 @@ static void __init trace_enum_init(void)
 #ifdef CONFIG_MODULES
 static void trace_module_add_enums(struct module *mod)
 {
-	if (!mod->num_trace_enums)
+	if (!mod->num_trace_evals)
 		return;
 
 	/*
@@ -7728,7 +7728,7 @@ static void trace_module_add_enums(struct module *mod)
 	if (trace_module_has_bad_taint(mod))
 		return;
 
-	trace_insert_enum_map(mod, mod->trace_enums, mod->num_trace_enums);
+	trace_insert_enum_map(mod, mod->trace_evals, mod->num_trace_evals);
 }
 
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
@@ -7737,7 +7737,7 @@ static void trace_module_remove_enums(struct module *mod)
 	union trace_enum_map_item *map;
 	union trace_enum_map_item **last = &trace_enum_maps;
 
-	if (!mod->num_trace_enums)
+	if (!mod->num_trace_evals)
 		return;
 
 	mutex_lock(&trace_enum_mutex);
-- 
2.9.4

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

* [PATCH 04/12] trace: rename trace enum data structures in trace.c
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (2 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 03/12] trace: rename struct module entry for trace enums Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 05/12] trace: rename trace_enum_mutex to trace_eval_mutex Jeremy Linton
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

The enum map entries can be exported to userspace
via a sys enum_map file. Rename those functions
and structures to reflect the fact that we are using
them for more than enums.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/trace.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 85f0e3c..af6ec07 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -122,38 +122,38 @@ int __disable_trace_on_warning;
 
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
 /* Map of enums to their values, for "enum_map" file */
-struct trace_enum_map_head {
+struct trace_eval_map_head {
 	struct module			*mod;
 	unsigned long			length;
 };
 
-union trace_enum_map_item;
+union trace_eval_map_item;
 
-struct trace_enum_map_tail {
+struct trace_eval_map_tail {
 	/*
 	 * "end" is first and points to NULL as it must be different
 	 * than "mod" or "eval_string"
 	 */
-	union trace_enum_map_item	*next;
+	union trace_eval_map_item	*next;
 	const char			*end;	/* points to NULL */
 };
 
 static DEFINE_MUTEX(trace_enum_mutex);
 
 /*
- * The trace_enum_maps are saved in an array with two extra elements,
+ * The trace_eval_maps are saved in an array with two extra elements,
  * one at the beginning, and one at the end. The beginning item contains
  * the count of the saved maps (head.length), and the module they
  * belong to if not built in (head.mod). The ending item contains a
  * pointer to the next array of saved enum_map items.
  */
-union trace_enum_map_item {
+union trace_eval_map_item {
 	struct trace_eval_map		map;
-	struct trace_enum_map_head	head;
-	struct trace_enum_map_tail	tail;
+	struct trace_eval_map_head	head;
+	struct trace_eval_map_tail	tail;
 };
 
-static union trace_enum_map_item *trace_enum_maps;
+static union trace_eval_map_item *trace_eval_maps;
 #endif /* CONFIG_TRACE_ENUM_MAP_FILE */
 
 static int tracing_set_tracer(struct trace_array *tr, const char *buf);
@@ -4718,8 +4718,8 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
 };
 
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
-static union trace_enum_map_item *
-update_enum_map(union trace_enum_map_item *ptr)
+static union trace_eval_map_item *
+update_enum_map(union trace_eval_map_item *ptr)
 {
 	if (!ptr->map.eval_string) {
 		if (ptr->tail.next) {
@@ -4734,7 +4734,7 @@ update_enum_map(union trace_enum_map_item *ptr)
 
 static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
 {
-	union trace_enum_map_item *ptr = v;
+	union trace_eval_map_item *ptr = v;
 
 	/*
 	 * Paranoid! If ptr points to end, we don't want to increment past it.
@@ -4755,12 +4755,12 @@ static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
 
 static void *enum_map_start(struct seq_file *m, loff_t *pos)
 {
-	union trace_enum_map_item *v;
+	union trace_eval_map_item *v;
 	loff_t l = 0;
 
 	mutex_lock(&trace_enum_mutex);
 
-	v = trace_enum_maps;
+	v = trace_eval_maps;
 	if (v)
 		v++;
 
@@ -4778,7 +4778,7 @@ static void enum_map_stop(struct seq_file *m, void *v)
 
 static int enum_map_show(struct seq_file *m, void *v)
 {
-	union trace_enum_map_item *ptr = v;
+	union trace_eval_map_item *ptr = v;
 
 	seq_printf(m, "%s %ld (%s)\n",
 		   ptr->map.eval_string, ptr->map.eval_value,
@@ -4809,8 +4809,8 @@ static const struct file_operations tracing_enum_map_fops = {
 	.release	= seq_release,
 };
 
-static inline union trace_enum_map_item *
-trace_enum_jmp_to_tail(union trace_enum_map_item *ptr)
+static inline union trace_eval_map_item *
+trace_enum_jmp_to_tail(union trace_eval_map_item *ptr)
 {
 	/* Return tail of array given the head */
 	return ptr + ptr->head.length + 1;
@@ -4822,13 +4822,13 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 {
 	struct trace_eval_map **stop;
 	struct trace_eval_map **map;
-	union trace_enum_map_item *map_array;
-	union trace_enum_map_item *ptr;
+	union trace_eval_map_item *map_array;
+	union trace_eval_map_item *ptr;
 
 	stop = start + len;
 
 	/*
-	 * The trace_enum_maps contains the map plus a head and tail item,
+	 * The trace_eval_maps contains the map plus a head and tail item,
 	 * where the head holds the module and length of array, and the
 	 * tail holds a pointer to the next list.
 	 */
@@ -4840,10 +4840,10 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 
 	mutex_lock(&trace_enum_mutex);
 
-	if (!trace_enum_maps)
-		trace_enum_maps = map_array;
+	if (!trace_eval_maps)
+		trace_eval_maps = map_array;
 	else {
-		ptr = trace_enum_maps;
+		ptr = trace_eval_maps;
 		for (;;) {
 			ptr = trace_enum_jmp_to_tail(ptr);
 			if (!ptr->tail.next)
@@ -7734,15 +7734,15 @@ static void trace_module_add_enums(struct module *mod)
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
 static void trace_module_remove_enums(struct module *mod)
 {
-	union trace_enum_map_item *map;
-	union trace_enum_map_item **last = &trace_enum_maps;
+	union trace_eval_map_item *map;
+	union trace_eval_map_item **last = &trace_eval_maps;
 
 	if (!mod->num_trace_evals)
 		return;
 
 	mutex_lock(&trace_enum_mutex);
 
-	map = trace_enum_maps;
+	map = trace_eval_maps;
 
 	while (map) {
 		if (map->head.mod == mod)
-- 
2.9.4

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

* [PATCH 05/12] trace: rename trace_enum_mutex to trace_eval_mutex
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (3 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 04/12] trace: rename trace enum data structures in trace.c Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 06/12] trace: rename trace.c enum functions Jeremy Linton
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

There is a lock protecting the trace_enum_map, rename
it to reflect the use by more than enums.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/trace.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index af6ec07..e1bc56c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -138,7 +138,7 @@ struct trace_eval_map_tail {
 	const char			*end;	/* points to NULL */
 };
 
-static DEFINE_MUTEX(trace_enum_mutex);
+static DEFINE_MUTEX(trace_eval_mutex);
 
 /*
  * The trace_eval_maps are saved in an array with two extra elements,
@@ -4758,7 +4758,7 @@ static void *enum_map_start(struct seq_file *m, loff_t *pos)
 	union trace_eval_map_item *v;
 	loff_t l = 0;
 
-	mutex_lock(&trace_enum_mutex);
+	mutex_lock(&trace_eval_mutex);
 
 	v = trace_eval_maps;
 	if (v)
@@ -4773,7 +4773,7 @@ static void *enum_map_start(struct seq_file *m, loff_t *pos)
 
 static void enum_map_stop(struct seq_file *m, void *v)
 {
-	mutex_unlock(&trace_enum_mutex);
+	mutex_unlock(&trace_eval_mutex);
 }
 
 static int enum_map_show(struct seq_file *m, void *v)
@@ -4838,7 +4838,7 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 		return;
 	}
 
-	mutex_lock(&trace_enum_mutex);
+	mutex_lock(&trace_eval_mutex);
 
 	if (!trace_eval_maps)
 		trace_eval_maps = map_array;
@@ -4863,7 +4863,7 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 	}
 	memset(map_array, 0, sizeof(*map_array));
 
-	mutex_unlock(&trace_enum_mutex);
+	mutex_unlock(&trace_eval_mutex);
 }
 
 static void trace_create_enum_file(struct dentry *d_tracer)
@@ -7740,7 +7740,7 @@ static void trace_module_remove_enums(struct module *mod)
 	if (!mod->num_trace_evals)
 		return;
 
-	mutex_lock(&trace_enum_mutex);
+	mutex_lock(&trace_eval_mutex);
 
 	map = trace_eval_maps;
 
@@ -7757,7 +7757,7 @@ static void trace_module_remove_enums(struct module *mod)
 	*last = trace_enum_jmp_to_tail(map)->tail.next;
 	kfree(map);
  out:
-	mutex_unlock(&trace_enum_mutex);
+	mutex_unlock(&trace_eval_mutex);
 }
 #else
 static inline void trace_module_remove_enums(struct module *mod) { }
-- 
2.9.4

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

* [PATCH 06/12] trace: rename trace.c enum functions
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (4 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 05/12] trace: rename trace_enum_mutex to trace_eval_mutex Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 07/12] trace: rename enum_map functions Jeremy Linton
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Rename the init and trace_enum_jmp_to_tail() routines
to reflect their use by more than enumerated types.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/trace.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e1bc56c..5eda252 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4810,7 +4810,7 @@ static const struct file_operations tracing_enum_map_fops = {
 };
 
 static inline union trace_eval_map_item *
-trace_enum_jmp_to_tail(union trace_eval_map_item *ptr)
+trace_eval_jmp_to_tail(union trace_eval_map_item *ptr)
 {
 	/* Return tail of array given the head */
 	return ptr + ptr->head.length + 1;
@@ -4845,7 +4845,7 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 	else {
 		ptr = trace_eval_maps;
 		for (;;) {
-			ptr = trace_enum_jmp_to_tail(ptr);
+			ptr = trace_eval_jmp_to_tail(ptr);
 			if (!ptr->tail.next)
 				break;
 			ptr = ptr->tail.next;
@@ -7707,7 +7707,7 @@ struct dentry *tracing_init_dentry(void)
 extern struct trace_eval_map *__start_ftrace_eval_maps[];
 extern struct trace_eval_map *__stop_ftrace_eval_maps[];
 
-static void __init trace_enum_init(void)
+static void __init trace_eval_init(void)
 {
 	int len;
 
@@ -7747,14 +7747,14 @@ static void trace_module_remove_enums(struct module *mod)
 	while (map) {
 		if (map->head.mod == mod)
 			break;
-		map = trace_enum_jmp_to_tail(map);
+		map = trace_eval_jmp_to_tail(map);
 		last = &map->tail.next;
 		map = map->tail.next;
 	}
 	if (!map)
 		goto out;
 
-	*last = trace_enum_jmp_to_tail(map)->tail.next;
+	*last = trace_eval_jmp_to_tail(map)->tail.next;
 	kfree(map);
  out:
 	mutex_unlock(&trace_eval_mutex);
@@ -7811,7 +7811,7 @@ static __init int tracer_init_tracefs(void)
 	trace_create_file("saved_cmdlines_size", 0644, d_tracer,
 			  NULL, &tracing_saved_cmdlines_size_fops);
 
-	trace_enum_init();
+	trace_eval_init();
 
 	trace_create_enum_file(d_tracer);
 
-- 
2.9.4

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

* [PATCH 07/12] trace: rename enum_map functions
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (5 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 06/12] trace: rename trace.c enum functions Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 08/12] tracing: Rename enum_replace to eval_replace Jeremy Linton
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Rename the core trace enum routines to use eval, to
reflect their use by more than just enum to value mapping.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/trace.c        | 74 ++++++++++++++++++++++-----------------------
 kernel/trace/trace.h        |  4 +--
 kernel/trace/trace_events.c |  2 +-
 3 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 5eda252..676c808 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -145,7 +145,7 @@ static DEFINE_MUTEX(trace_eval_mutex);
  * one at the beginning, and one at the end. The beginning item contains
  * the count of the saved maps (head.length), and the module they
  * belong to if not built in (head.mod). The ending item contains a
- * pointer to the next array of saved enum_map items.
+ * pointer to the next array of saved enum_eval/enum_map items.
  */
 union trace_eval_map_item {
 	struct trace_eval_map		map;
@@ -1141,9 +1141,9 @@ unsigned long nsecs_to_usecs(unsigned long nsecs)
 
 /*
  * TRACE_FLAGS is defined as a tuple matching bit masks with strings.
- * It uses C(a, b) where 'a' is the enum name and 'b' is the string that
+ * It uses C(a, b) where 'a' is the eval (enum) name and 'b' is the string that
  * matches it. By defining "C(a, b) b", TRACE_FLAGS becomes a list
- * of strings in the order that the enums were defined.
+ * of strings in the order that the evals (enum) were defined.
  */
 #undef C
 #define C(a, b) b
@@ -4719,7 +4719,7 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
 
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
 static union trace_eval_map_item *
-update_enum_map(union trace_eval_map_item *ptr)
+update_eval_map(union trace_eval_map_item *ptr)
 {
 	if (!ptr->map.eval_string) {
 		if (ptr->tail.next) {
@@ -4732,7 +4732,7 @@ update_enum_map(union trace_eval_map_item *ptr)
 	return ptr;
 }
 
-static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
+static void *eval_map_next(struct seq_file *m, void *v, loff_t *pos)
 {
 	union trace_eval_map_item *ptr = v;
 
@@ -4740,7 +4740,7 @@ static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
 	 * Paranoid! If ptr points to end, we don't want to increment past it.
 	 * This really should never happen.
 	 */
-	ptr = update_enum_map(ptr);
+	ptr = update_eval_map(ptr);
 	if (WARN_ON_ONCE(!ptr))
 		return NULL;
 
@@ -4748,12 +4748,12 @@ static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
 
 	(*pos)++;
 
-	ptr = update_enum_map(ptr);
+	ptr = update_eval_map(ptr);
 
 	return ptr;
 }
 
-static void *enum_map_start(struct seq_file *m, loff_t *pos)
+static void *eval_map_start(struct seq_file *m, loff_t *pos)
 {
 	union trace_eval_map_item *v;
 	loff_t l = 0;
@@ -4765,18 +4765,18 @@ static void *enum_map_start(struct seq_file *m, loff_t *pos)
 		v++;
 
 	while (v && l < *pos) {
-		v = enum_map_next(m, v, &l);
+		v = eval_map_next(m, v, &l);
 	}
 
 	return v;
 }
 
-static void enum_map_stop(struct seq_file *m, void *v)
+static void eval_map_stop(struct seq_file *m, void *v)
 {
 	mutex_unlock(&trace_eval_mutex);
 }
 
-static int enum_map_show(struct seq_file *m, void *v)
+static int eval_map_show(struct seq_file *m, void *v)
 {
 	union trace_eval_map_item *ptr = v;
 
@@ -4787,23 +4787,23 @@ static int enum_map_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static const struct seq_operations tracing_enum_map_seq_ops = {
-	.start		= enum_map_start,
-	.next		= enum_map_next,
-	.stop		= enum_map_stop,
-	.show		= enum_map_show,
+static const struct seq_operations tracing_eval_map_seq_ops = {
+	.start		= eval_map_start,
+	.next		= eval_map_next,
+	.stop		= eval_map_stop,
+	.show		= eval_map_show,
 };
 
-static int tracing_enum_map_open(struct inode *inode, struct file *filp)
+static int tracing_eval_map_open(struct inode *inode, struct file *filp)
 {
 	if (tracing_disabled)
 		return -ENODEV;
 
-	return seq_open(filp, &tracing_enum_map_seq_ops);
+	return seq_open(filp, &tracing_eval_map_seq_ops);
 }
 
-static const struct file_operations tracing_enum_map_fops = {
-	.open		= tracing_enum_map_open,
+static const struct file_operations tracing_eval_map_fops = {
+	.open		= tracing_eval_map_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
@@ -4817,7 +4817,7 @@ trace_eval_jmp_to_tail(union trace_eval_map_item *ptr)
 }
 
 static void
-trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
+trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start,
 			   int len)
 {
 	struct trace_eval_map **stop;
@@ -4834,7 +4834,7 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 	 */
 	map_array = kmalloc(sizeof(*map_array) * (len + 2), GFP_KERNEL);
 	if (!map_array) {
-		pr_warn("Unable to allocate trace enum mapping\n");
+		pr_warn("Unable to allocate trace eval mapping\n");
 		return;
 	}
 
@@ -4866,19 +4866,19 @@ trace_insert_enum_map_file(struct module *mod, struct trace_eval_map **start,
 	mutex_unlock(&trace_eval_mutex);
 }
 
-static void trace_create_enum_file(struct dentry *d_tracer)
+static void trace_create_eval_file(struct dentry *d_tracer)
 {
 	trace_create_file("enum_map", 0444, d_tracer,
-			  NULL, &tracing_enum_map_fops);
+			  NULL, &tracing_eval_map_fops);
 }
 
 #else /* CONFIG_TRACE_ENUM_MAP_FILE */
-static inline void trace_create_enum_file(struct dentry *d_tracer) { }
-static inline void trace_insert_enum_map_file(struct module *mod,
+static inline void trace_create_eval_file(struct dentry *d_tracer) { }
+static inline void trace_insert_eval_map_file(struct module *mod,
 			      struct trace_eval_map **start, int len) { }
 #endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
 
-static void trace_insert_enum_map(struct module *mod,
+static void trace_insert_eval_map(struct module *mod,
 				  struct trace_eval_map **start, int len)
 {
 	struct trace_eval_map **map;
@@ -4888,9 +4888,9 @@ static void trace_insert_enum_map(struct module *mod,
 
 	map = start;
 
-	trace_event_enum_update(map, len);
+	trace_event_eval_update(map, len);
 
-	trace_insert_enum_map_file(mod, start, len);
+	trace_insert_eval_map_file(mod, start, len);
 }
 
 static ssize_t
@@ -7712,11 +7712,11 @@ static void __init trace_eval_init(void)
 	int len;
 
 	len = __stop_ftrace_eval_maps - __start_ftrace_eval_maps;
-	trace_insert_enum_map(NULL, __start_ftrace_eval_maps, len);
+	trace_insert_eval_map(NULL, __start_ftrace_eval_maps, len);
 }
 
 #ifdef CONFIG_MODULES
-static void trace_module_add_enums(struct module *mod)
+static void trace_module_add_evals(struct module *mod)
 {
 	if (!mod->num_trace_evals)
 		return;
@@ -7728,11 +7728,11 @@ static void trace_module_add_enums(struct module *mod)
 	if (trace_module_has_bad_taint(mod))
 		return;
 
-	trace_insert_enum_map(mod, mod->trace_evals, mod->num_trace_evals);
+	trace_insert_eval_map(mod, mod->trace_evals, mod->num_trace_evals);
 }
 
 #ifdef CONFIG_TRACE_ENUM_MAP_FILE
-static void trace_module_remove_enums(struct module *mod)
+static void trace_module_remove_evals(struct module *mod)
 {
 	union trace_eval_map_item *map;
 	union trace_eval_map_item **last = &trace_eval_maps;
@@ -7760,7 +7760,7 @@ static void trace_module_remove_enums(struct module *mod)
 	mutex_unlock(&trace_eval_mutex);
 }
 #else
-static inline void trace_module_remove_enums(struct module *mod) { }
+static inline void trace_module_remove_evals(struct module *mod) { }
 #endif /* CONFIG_TRACE_ENUM_MAP_FILE */
 
 static int trace_module_notify(struct notifier_block *self,
@@ -7770,10 +7770,10 @@ static int trace_module_notify(struct notifier_block *self,
 
 	switch (val) {
 	case MODULE_STATE_COMING:
-		trace_module_add_enums(mod);
+		trace_module_add_evals(mod);
 		break;
 	case MODULE_STATE_GOING:
-		trace_module_remove_enums(mod);
+		trace_module_remove_evals(mod);
 		break;
 	}
 
@@ -7813,7 +7813,7 @@ static __init int tracer_init_tracefs(void)
 
 	trace_eval_init();
 
-	trace_create_enum_file(d_tracer);
+	trace_create_eval_file(d_tracer);
 
 #ifdef CONFIG_MODULES
 	register_module_notifier(&trace_module_nb);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 75d5e27..5f451a6 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1768,10 +1768,10 @@ static inline const char *get_syscall_name(int syscall)
 
 #ifdef CONFIG_EVENT_TRACING
 void trace_event_init(void);
-void trace_event_enum_update(struct trace_eval_map **map, int len);
+void trace_event_eval_update(struct trace_eval_map **map, int len);
 #else
 static inline void __init trace_event_init(void) { }
-static inline void trace_event_enum_update(struct trace_eval_map **map, int len) { }
+static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { }
 #endif
 
 extern struct trace_iterator *tracepoint_print_iter;
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index cf5b9aa..e6897b0 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2165,7 +2165,7 @@ static void update_event_printk(struct trace_event_call *call,
 	}
 }
 
-void trace_event_enum_update(struct trace_eval_map **map, int len)
+void trace_event_eval_update(struct trace_eval_map **map, int len)
 {
 	struct trace_event_call *call, *p;
 	const char *last_system = NULL;
-- 
2.9.4

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

* [PATCH 08/12] tracing: Rename enum_replace to eval_replace
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (6 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 07/12] trace: rename enum_map functions Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 09/12] tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values Jeremy Linton
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

The enum_replace stanza works as is for sizeof()
calls as well as enums. Rename it as well.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/trace_events.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index e6897b0..83dfd0d 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2067,12 +2067,12 @@ __register_event(struct trace_event_call *call, struct module *mod)
 	return 0;
 }
 
-static char *enum_replace(char *ptr, struct trace_eval_map *map, int len)
+static char *eval_replace(char *ptr, struct trace_eval_map *map, int len)
 {
 	int rlen;
 	int elen;
 
-	/* Find the length of the enum value as a string */
+	/* Find the length of the eval value as a string */
 	elen = snprintf(ptr, 0, "%ld", map->eval_value);
 	/* Make sure there's enough room to replace the string with the value */
 	if (len < elen)
@@ -2127,14 +2127,14 @@ static void update_event_printk(struct trace_event_call *call,
 		if (isalpha(*ptr) || *ptr == '_') {
 			if (strncmp(map->eval_string, ptr, len) == 0 &&
 			    !isalnum(ptr[len]) && ptr[len] != '_') {
-				ptr = enum_replace(ptr, map, len);
-				/* Hmm, enum string smaller than value */
+				ptr = eval_replace(ptr, map, len);
+				/* enum/sizeof string smaller than value */
 				if (WARN_ON_ONCE(!ptr))
 					return;
 				/*
-				 * No need to decrement here, as enum_replace()
+				 * No need to decrement here, as eval_replace()
 				 * returns the pointer to the character passed
-				 * the enum, and two enums can not be placed
+				 * the eval, and two evals can not be placed
 				 * back to back without something in between.
 				 * We can skip that something in between.
 				 */
-- 
2.9.4

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

* [PATCH 09/12] tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (7 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 08/12] tracing: Rename enum_replace to eval_replace Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 10/12] tracing: Update sample file to describe the new macro Jeremy Linton
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Perf has a problem that if sizeof() macros are used within TRACE_EVENT()
macro's they end up in userspace as "sizeof(kernel structure)" which
cannot properly be parsed. Add a macro which can forward this data
through the eval_map for userspace utilization.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 include/linux/tracepoint.h   |  1 +
 include/trace/trace_events.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index f7b0f55..a26ffbe 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -88,6 +88,7 @@ extern void syscall_unregfunc(void);
 #define PARAMS(args...) args
 
 #define TRACE_DEFINE_ENUM(x)
+#define TRACE_DEFINE_SIZEOF(x)
 
 #endif /* _LINUX_TRACEPOINT_H */
 
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 49cce5f..3976fa1 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -46,6 +46,19 @@ TRACE_MAKE_SYSTEM_STR();
 	__attribute__((section("_ftrace_eval_map")))	\
 	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
 
+#undef TRACE_DEFINE_SIZEOF
+#define TRACE_DEFINE_SIZEOF(a)				\
+	static struct trace_eval_map __used __initdata	\
+	__##TRACE_SYSTEM##_##a =			\
+	{						\
+		.system = TRACE_SYSTEM_STRING,		\
+		.eval_string = "sizeof(" #a ")",	\
+		.eval_value = sizeof(a)			\
+	};						\
+	static struct trace_eval_map __used		\
+	__attribute__((section("_ftrace_eval_map")))	\
+	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
+
 /*
  * DECLARE_EVENT_CLASS can be used to add a generic function
  * handlers for events. That is, if all events have the same
@@ -158,6 +171,9 @@ TRACE_MAKE_SYSTEM_STR();
 #undef TRACE_DEFINE_ENUM
 #define TRACE_DEFINE_ENUM(a)
 
+#undef TRACE_DEFINE_SIZEOF
+#define TRACE_DEFINE_SIZEOF(a)
+
 #undef __field
 #define __field(type, item)
 
-- 
2.9.4

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

* [PATCH 10/12] tracing: Update sample file to describe the new macro
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (8 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 09/12] tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-06-13 21:07   ` Steven Rostedt
  2017-05-31 21:56 ` [PATCH 11/12] tracing: Add TRACE_DEFINE_SIZEOF() macros Jeremy Linton
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Add a blurb in the trace sample file to describe
the macro used to add sizeof to value conversions.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 samples/trace_events/trace-events-sample.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index 76a75ab..82e1e66 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -225,6 +225,13 @@ TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
 TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
 TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
 
+/*
+ * The same problem as above applies to sizeof(), so there is also
+ * a macro to solve that problem.
+ */
+
+TRACE_DEFINE_SIZEOF(pteval_t);
+
 TRACE_EVENT(foo_bar,
 
 	TP_PROTO(const char *foo, int bar, const int *lst,
-- 
2.9.4

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

* [PATCH 11/12] tracing: Add TRACE_DEFINE_SIZEOF() macros
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (9 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 10/12] tracing: Update sample file to describe the new macro Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-05-31 21:56 ` [PATCH 12/12] tracing: Rename update the enum_map file Jeremy Linton
  2017-06-01  1:11 ` [PATCH 00/12] trace: add the ability to parse sizeof() Steven Rostedt
  12 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

There are a few places in the kernel where sizeof() is already
being used. Update those locations with TRACE_DEFINE_SIZEOF.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 arch/arm64/kvm/trace.h     |  2 ++
 include/trace/events/xen.h | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/trace.h b/arch/arm64/kvm/trace.h
index 7fb0008..5188c70 100644
--- a/arch/arm64/kvm/trace.h
+++ b/arch/arm64/kvm/trace.h
@@ -93,6 +93,8 @@ TRACE_EVENT(kvm_arm_set_dreg32,
 	TP_printk("%s: 0x%08x", __entry->name, __entry->value)
 );
 
+TRACE_DEFINE_SIZEOF(__u64);
+
 TRACE_EVENT(kvm_arm_set_regset,
 	TP_PROTO(const char *type, int len, __u64 *control, __u64 *value),
 	TP_ARGS(type, len, control, value),
diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h
index 31acce9..b70a38b 100644
--- a/include/trace/events/xen.h
+++ b/include/trace/events/xen.h
@@ -30,6 +30,8 @@ DECLARE_EVENT_CLASS(xen_mc__batch,
 DEFINE_XEN_MC_BATCH(xen_mc_batch);
 DEFINE_XEN_MC_BATCH(xen_mc_issue);
 
+TRACE_DEFINE_SIZEOF(ulong);
+
 TRACE_EVENT(xen_mc_entry,
 	    TP_PROTO(struct multicall_entry *mc, unsigned nargs),
 	    TP_ARGS(mc, nargs),
@@ -40,8 +42,8 @@ TRACE_EVENT(xen_mc_entry,
 		    ),
 	    TP_fast_assign(__entry->op = mc->op;
 			   __entry->nargs = nargs;
-			   memcpy(__entry->args, mc->args, sizeof(unsigned long) * nargs);
-			   memset(__entry->args + nargs, 0, sizeof(unsigned long) * (6 - nargs));
+			   memcpy(__entry->args, mc->args, sizeof(ulong) * nargs);
+			   memset(__entry->args + nargs, 0, sizeof(ulong) * (6 - nargs));
 		    ),
 	    TP_printk("op %u%s args [%lx, %lx, %lx, %lx, %lx, %lx]",
 		      __entry->op, xen_hypercall_name(__entry->op),
@@ -122,6 +124,7 @@ TRACE_EVENT(xen_mc_extend_args,
 		      __entry->res == XEN_MC_XE_NO_SPACE ? "NO_SPACE" : "???")
 	);
 
+TRACE_DEFINE_SIZEOF(pteval_t);
 /* mmu */
 DECLARE_EVENT_CLASS(xen_mmu__set_pte,
 	    TP_PROTO(pte_t *ptep, pte_t pteval),
@@ -199,6 +202,8 @@ TRACE_EVENT(xen_mmu_pte_clear,
 		      __entry->mm, __entry->addr, __entry->ptep)
 	);
 
+TRACE_DEFINE_SIZEOF(pmdval_t);
+
 TRACE_EVENT(xen_mmu_set_pmd,
 	    TP_PROTO(pmd_t *pmdp, pmd_t pmdval),
 	    TP_ARGS(pmdp, pmdval),
@@ -226,6 +231,8 @@ TRACE_EVENT(xen_mmu_pmd_clear,
 
 #if CONFIG_PGTABLE_LEVELS >= 4
 
+TRACE_DEFINE_SIZEOF(pudval_t);
+
 TRACE_EVENT(xen_mmu_set_pud,
 	    TP_PROTO(pud_t *pudp, pud_t pudval),
 	    TP_ARGS(pudp, pudval),
@@ -241,6 +248,8 @@ TRACE_EVENT(xen_mmu_set_pud,
 		      (int)sizeof(pudval_t) * 2, (unsigned long long)__entry->pudval)
 	);
 
+TRACE_DEFINE_SIZEOF(p4dval_t);
+
 TRACE_EVENT(xen_mmu_set_p4d,
 	    TP_PROTO(p4d_t *p4dp, p4d_t *user_p4dp, p4d_t p4dval),
 	    TP_ARGS(p4dp, user_p4dp, p4dval),
-- 
2.9.4

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

* [PATCH 12/12] tracing: Rename update the enum_map file
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (10 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 11/12] tracing: Add TRACE_DEFINE_SIZEOF() macros Jeremy Linton
@ 2017-05-31 21:56 ` Jeremy Linton
  2017-06-13 21:12   ` Steven Rostedt
  2017-06-01  1:11 ` [PATCH 00/12] trace: add the ability to parse sizeof() Steven Rostedt
  12 siblings, 1 reply; 19+ messages in thread
From: Jeremy Linton @ 2017-05-31 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, rostedt, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

The enum_map file is used to display a list of symbol
to name conversions. As its now used to resolve sizeof
lets update the name and description.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 kernel/trace/Kconfig | 22 +++++++++++-----------
 kernel/trace/trace.c | 20 ++++++++++----------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 7e06f04..434c840 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -667,30 +667,30 @@ config RING_BUFFER_STARTUP_TEST
 
 	 If unsure, say N
 
-config TRACE_ENUM_MAP_FILE
-       bool "Show enum mappings for trace events"
+config TRACE_EVAL_MAP_FILE
+       bool "Show eval mappings for trace events"
        depends on TRACING
        help
-        The "print fmt" of the trace events will show the enum names instead
-	of their values. This can cause problems for user space tools that
-	use this string to parse the raw data as user space does not know
+	The "print fmt" of the trace events will show the enum/sizeof names
+	instead	of their values. This can cause problems for user space tools
+	that use this string to parse the raw data as user space does not know
 	how to convert the string to its value.
 
 	To fix this, there's a special macro in the kernel that can be used
-	to convert the enum into its value. If this macro is used, then the
-	print fmt strings will have the enums converted to their values.
+	to convert an enum/sizeof into its value. If this macro is used, then
+	the print fmt strings will be converted to their values.
 
 	If something does not get converted properly, this option can be
-	used to show what enums the kernel tried to convert.
+	used to show what enums/sizeof the kernel tried to convert.
 
-	This option is for debugging the enum conversions. A file is created
-	in the tracing directory called "enum_map" that will show the enum
+	This option is for debugging the conversions. A file is created
+	in the tracing directory called "eval_map" that will show the
 	names matched with their values and what trace event system they
 	belong too.
 
 	Normally, the mapping of the strings to values will be freed after
 	boot up or module load. With this option, they will not be freed, as
-	they are needed for the "enum_map" file. Enabling this option will
+	they are needed for the "eval_map" file. Enabling this option will
 	increase the memory footprint of the running kernel.
 
 	If unsure, say N
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 676c808..7297e9d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -120,8 +120,8 @@ enum ftrace_dump_mode ftrace_dump_on_oops;
 /* When set, tracing will stop when a WARN*() is hit */
 int __disable_trace_on_warning;
 
-#ifdef CONFIG_TRACE_ENUM_MAP_FILE
-/* Map of enums to their values, for "enum_map" file */
+#ifdef CONFIG_TRACE_EVAL_MAP_FILE
+/* Map of enums to their values, for "eval_map" file */
 struct trace_eval_map_head {
 	struct module			*mod;
 	unsigned long			length;
@@ -145,7 +145,7 @@ static DEFINE_MUTEX(trace_eval_mutex);
  * one at the beginning, and one at the end. The beginning item contains
  * the count of the saved maps (head.length), and the module they
  * belong to if not built in (head.mod). The ending item contains a
- * pointer to the next array of saved enum_eval/enum_map items.
+ * pointer to the next array of saved eval_map items.
  */
 union trace_eval_map_item {
 	struct trace_eval_map		map;
@@ -154,7 +154,7 @@ union trace_eval_map_item {
 };
 
 static union trace_eval_map_item *trace_eval_maps;
-#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
+#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
 
 static int tracing_set_tracer(struct trace_array *tr, const char *buf);
 
@@ -4717,7 +4717,7 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
 	.write		= tracing_saved_cmdlines_size_write,
 };
 
-#ifdef CONFIG_TRACE_ENUM_MAP_FILE
+#ifdef CONFIG_TRACE_EVAL_MAP_FILE
 static union trace_eval_map_item *
 update_eval_map(union trace_eval_map_item *ptr)
 {
@@ -4868,15 +4868,15 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start,
 
 static void trace_create_eval_file(struct dentry *d_tracer)
 {
-	trace_create_file("enum_map", 0444, d_tracer,
+	trace_create_file("eval_map", 0444, d_tracer,
 			  NULL, &tracing_eval_map_fops);
 }
 
-#else /* CONFIG_TRACE_ENUM_MAP_FILE */
+#else /* CONFIG_TRACE_EVAL_MAP_FILE */
 static inline void trace_create_eval_file(struct dentry *d_tracer) { }
 static inline void trace_insert_eval_map_file(struct module *mod,
 			      struct trace_eval_map **start, int len) { }
-#endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
+#endif /* !CONFIG_TRACE_EVAL_MAP_FILE */
 
 static void trace_insert_eval_map(struct module *mod,
 				  struct trace_eval_map **start, int len)
@@ -7731,7 +7731,7 @@ static void trace_module_add_evals(struct module *mod)
 	trace_insert_eval_map(mod, mod->trace_evals, mod->num_trace_evals);
 }
 
-#ifdef CONFIG_TRACE_ENUM_MAP_FILE
+#ifdef CONFIG_TRACE_EVAL_MAP_FILE
 static void trace_module_remove_evals(struct module *mod)
 {
 	union trace_eval_map_item *map;
@@ -7761,7 +7761,7 @@ static void trace_module_remove_evals(struct module *mod)
 }
 #else
 static inline void trace_module_remove_evals(struct module *mod) { }
-#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
+#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
 
 static int trace_module_notify(struct notifier_block *self,
 			       unsigned long val, void *data)
-- 
2.9.4

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

* Re: [PATCH 00/12] trace: add the ability to parse sizeof()
  2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
                   ` (11 preceding siblings ...)
  2017-05-31 21:56 ` [PATCH 12/12] tracing: Rename update the enum_map file Jeremy Linton
@ 2017-06-01  1:11 ` Steven Rostedt
  12 siblings, 0 replies; 19+ messages in thread
From: Steven Rostedt @ 2017-06-01  1:11 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm


Hi Jeremy,

I'm currently at the Open Source Summit in Tokyo. It may be a while
before I get to look more at this. If I get time during my travels,
I may get to it sooner, otherwise it may be a week or so.

-- Steve

On Wed, 31 May 2017 16:56:41 -0500
Jeremy Linton <jeremy.linton@arm.com> wrote:

> There are a few cases of sizeof() embedded in TRACE_EVENT()
> macros. That is a problem because the sizeof(structure) gets
> passed to userspace which doesn't know how to decode the
> size of kernel data structures. This is a similar problem
> to enums which were being passed in their symbolic form to
> userspace.
> 
> Rather than recreating much of that infrastructure lets
> simply extend it, and append additional symbols into the
> enum_map that can translate string sizeof() calls into
> values. Of course that means that much of the infrastructure
> is now poorly named so we go through and replace instances
> describing "enum" with "eval" to indicate a generic C
> expression to numerical evaluation routine.
> 
> Jeremy Linton (12):
>   trace: rename kernel enum section to eval
>   trace: rename trace_enum_map to trace_eval_map
>   trace: rename struct module entry for trace enums
>   trace: rename trace enum data structures in trace.c
>   trace: rename trace_enum_mutex to trace_eval_mutex
>   trace: rename trace.c enum functions
>   trace: rename enum_map functions
>   tracing: Rename enum_replace to eval_replace
>   tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their
>     values
>   tracing: Update sample file to describe the new macro
>   tracing: Add TRACE_DEFINE_SIZEOF() macros
>   tracing: Rename update the enum_map file
> 
>  arch/arm64/kvm/trace.h                     |   2 +
>  include/asm-generic/vmlinux.lds.h          |   6 +-
>  include/linux/module.h                     |   4 +-
>  include/linux/tracepoint.h                 |   7 +-
>  include/trace/events/xen.h                 |  13 +-
>  include/trace/trace_events.h               |  26 +++-
>  kernel/module.c                            |   6 +-
>  kernel/trace/Kconfig                       |  22 ++--
>  kernel/trace/trace.c                       | 194
> ++++++++++++++---------------
> kernel/trace/trace.h                       |   4 +-
> kernel/trace/trace_events.c                |  24 ++--
> samples/trace_events/trace-events-sample.h |   7 ++ 12 files changed,
> 175 insertions(+), 140 deletions(-)
> 

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

* Re: [PATCH 10/12] tracing: Update sample file to describe the new macro
  2017-05-31 21:56 ` [PATCH 10/12] tracing: Update sample file to describe the new macro Jeremy Linton
@ 2017-06-13 21:07   ` Steven Rostedt
  0 siblings, 0 replies; 19+ messages in thread
From: Steven Rostedt @ 2017-06-13 21:07 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

On Wed, 31 May 2017 16:56:51 -0500
Jeremy Linton <jeremy.linton@arm.com> wrote:

> Add a blurb in the trace sample file to describe
> the macro used to add sizeof to value conversions.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  samples/trace_events/trace-events-sample.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
> index 76a75ab..82e1e66 100644
> --- a/samples/trace_events/trace-events-sample.h
> +++ b/samples/trace_events/trace-events-sample.h
> @@ -225,6 +225,13 @@ TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
>  TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
>  TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
>  
> +/*
> + * The same problem as above applies to sizeof(), so there is also
> + * a macro to solve that problem.
> + */
> +
> +TRACE_DEFINE_SIZEOF(pteval_t);
> +

Could you add this in the example too. That is, a use case. Just
having the define isn't a proper sample. You want to use it in a
TP_printk() too.

-- Steve

>  TRACE_EVENT(foo_bar,
>  
>  	TP_PROTO(const char *foo, int bar, const int *lst,

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

* Re: [PATCH 12/12] tracing: Rename update the enum_map file
  2017-05-31 21:56 ` [PATCH 12/12] tracing: Rename update the enum_map file Jeremy Linton
@ 2017-06-13 21:12   ` Steven Rostedt
  2017-06-13 21:21     ` Jeremy Linton
  0 siblings, 1 reply; 19+ messages in thread
From: Steven Rostedt @ 2017-06-13 21:12 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

On Wed, 31 May 2017 16:56:53 -0500
Jeremy Linton <jeremy.linton@arm.com> wrote:

> The enum_map file is used to display a list of symbol
> to name conversions. As its now used to resolve sizeof
> lets update the name and description.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  kernel/trace/Kconfig | 22 +++++++++++-----------
>  kernel/trace/trace.c | 20 ++++++++++----------
>  2 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
> index 7e06f04..434c840 100644
> --- a/kernel/trace/Kconfig
> +++ b/kernel/trace/Kconfig
> @@ -667,30 +667,30 @@ config RING_BUFFER_STARTUP_TEST
>  
>  	 If unsure, say N
>  
> -config TRACE_ENUM_MAP_FILE
> -       bool "Show enum mappings for trace events"
> +config TRACE_EVAL_MAP_FILE
> +       bool "Show eval mappings for trace events"
>         depends on TRACING
>         help
> -        The "print fmt" of the trace events will show the enum names instead
> -	of their values. This can cause problems for user space tools that
> -	use this string to parse the raw data as user space does not know
> +	The "print fmt" of the trace events will show the enum/sizeof names
> +	instead	of their values. This can cause problems for user space tools
> +	that use this string to parse the raw data as user space does not know
>  	how to convert the string to its value.
>  
>  	To fix this, there's a special macro in the kernel that can be used
> -	to convert the enum into its value. If this macro is used, then the
> -	print fmt strings will have the enums converted to their values.
> +	to convert an enum/sizeof into its value. If this macro is used, then
> +	the print fmt strings will be converted to their values.
>  
>  	If something does not get converted properly, this option can be
> -	used to show what enums the kernel tried to convert.
> +	used to show what enums/sizeof the kernel tried to convert.
>  
> -	This option is for debugging the enum conversions. A file is created
> -	in the tracing directory called "enum_map" that will show the enum
> +	This option is for debugging the conversions. A file is created
> +	in the tracing directory called "eval_map" that will show the
>  	names matched with their values and what trace event system they
>  	belong too.
>  
>  	Normally, the mapping of the strings to values will be freed after
>  	boot up or module load. With this option, they will not be freed, as
> -	they are needed for the "enum_map" file. Enabling this option will
> +	they are needed for the "eval_map" file. Enabling this option will
>  	increase the memory footprint of the running kernel.
>  
>  	If unsure, say N
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 676c808..7297e9d 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -120,8 +120,8 @@ enum ftrace_dump_mode ftrace_dump_on_oops;
>  /* When set, tracing will stop when a WARN*() is hit */
>  int __disable_trace_on_warning;
>  
> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
> -/* Map of enums to their values, for "enum_map" file */
> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
> +/* Map of enums to their values, for "eval_map" file */
>  struct trace_eval_map_head {
>  	struct module			*mod;
>  	unsigned long			length;
> @@ -145,7 +145,7 @@ static DEFINE_MUTEX(trace_eval_mutex);
>   * one at the beginning, and one at the end. The beginning item contains
>   * the count of the saved maps (head.length), and the module they
>   * belong to if not built in (head.mod). The ending item contains a
> - * pointer to the next array of saved enum_eval/enum_map items.
> + * pointer to the next array of saved eval_map items.
>   */
>  union trace_eval_map_item {
>  	struct trace_eval_map		map;
> @@ -154,7 +154,7 @@ union trace_eval_map_item {
>  };
>  
>  static union trace_eval_map_item *trace_eval_maps;
> -#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
> +#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
>  
>  static int tracing_set_tracer(struct trace_array *tr, const char *buf);
>  
> @@ -4717,7 +4717,7 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
>  	.write		= tracing_saved_cmdlines_size_write,
>  };
>  
> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
>  static union trace_eval_map_item *
>  update_eval_map(union trace_eval_map_item *ptr)
>  {
> @@ -4868,15 +4868,15 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start,
>  
>  static void trace_create_eval_file(struct dentry *d_tracer)
>  {
> -	trace_create_file("enum_map", 0444, d_tracer,
> +	trace_create_file("eval_map", 0444, d_tracer,
>  			  NULL, &tracing_eval_map_fops);

Hmm, I have to audit some userspace code to see if this is used. The
enum_map was a debug feature, but it could have been used by some tools.

-- Steve


>  }
>  
> -#else /* CONFIG_TRACE_ENUM_MAP_FILE */
> +#else /* CONFIG_TRACE_EVAL_MAP_FILE */
>  static inline void trace_create_eval_file(struct dentry *d_tracer) { }
>  static inline void trace_insert_eval_map_file(struct module *mod,
>  			      struct trace_eval_map **start, int len) { }
> -#endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
> +#endif /* !CONFIG_TRACE_EVAL_MAP_FILE */
>  
>  static void trace_insert_eval_map(struct module *mod,
>  				  struct trace_eval_map **start, int len)
> @@ -7731,7 +7731,7 @@ static void trace_module_add_evals(struct module *mod)
>  	trace_insert_eval_map(mod, mod->trace_evals, mod->num_trace_evals);
>  }
>  
> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
>  static void trace_module_remove_evals(struct module *mod)
>  {
>  	union trace_eval_map_item *map;
> @@ -7761,7 +7761,7 @@ static void trace_module_remove_evals(struct module *mod)
>  }
>  #else
>  static inline void trace_module_remove_evals(struct module *mod) { }
> -#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
> +#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
>  
>  static int trace_module_notify(struct notifier_block *self,
>  			       unsigned long val, void *data)

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

* Re: [PATCH 12/12] tracing: Rename update the enum_map file
  2017-06-13 21:12   ` Steven Rostedt
@ 2017-06-13 21:21     ` Jeremy Linton
  2017-06-14 17:06       ` Steven Rostedt
  0 siblings, 1 reply; 19+ messages in thread
From: Jeremy Linton @ 2017-06-13 21:21 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

Hi,

On 06/13/2017 04:12 PM, Steven Rostedt wrote:
> On Wed, 31 May 2017 16:56:53 -0500
> Jeremy Linton <jeremy.linton@arm.com> wrote:
> 
>> The enum_map file is used to display a list of symbol
>> to name conversions. As its now used to resolve sizeof
>> lets update the name and description.
>>
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> ---
>>   kernel/trace/Kconfig | 22 +++++++++++-----------
>>   kernel/trace/trace.c | 20 ++++++++++----------
>>   2 files changed, 21 insertions(+), 21 deletions(-)
>>
>> diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
>> index 7e06f04..434c840 100644
>> --- a/kernel/trace/Kconfig
>> +++ b/kernel/trace/Kconfig
>> @@ -667,30 +667,30 @@ config RING_BUFFER_STARTUP_TEST
>>   
>>   	 If unsure, say N
>>   
>> -config TRACE_ENUM_MAP_FILE
>> -       bool "Show enum mappings for trace events"
>> +config TRACE_EVAL_MAP_FILE
>> +       bool "Show eval mappings for trace events"
>>          depends on TRACING
>>          help
>> -        The "print fmt" of the trace events will show the enum names instead
>> -	of their values. This can cause problems for user space tools that
>> -	use this string to parse the raw data as user space does not know
>> +	The "print fmt" of the trace events will show the enum/sizeof names
>> +	instead	of their values. This can cause problems for user space tools
>> +	that use this string to parse the raw data as user space does not know
>>   	how to convert the string to its value.
>>   
>>   	To fix this, there's a special macro in the kernel that can be used
>> -	to convert the enum into its value. If this macro is used, then the
>> -	print fmt strings will have the enums converted to their values.
>> +	to convert an enum/sizeof into its value. If this macro is used, then
>> +	the print fmt strings will be converted to their values.
>>   
>>   	If something does not get converted properly, this option can be
>> -	used to show what enums the kernel tried to convert.
>> +	used to show what enums/sizeof the kernel tried to convert.
>>   
>> -	This option is for debugging the enum conversions. A file is created
>> -	in the tracing directory called "enum_map" that will show the enum
>> +	This option is for debugging the conversions. A file is created
>> +	in the tracing directory called "eval_map" that will show the
>>   	names matched with their values and what trace event system they
>>   	belong too.
>>   
>>   	Normally, the mapping of the strings to values will be freed after
>>   	boot up or module load. With this option, they will not be freed, as
>> -	they are needed for the "enum_map" file. Enabling this option will
>> +	they are needed for the "eval_map" file. Enabling this option will
>>   	increase the memory footprint of the running kernel.
>>   
>>   	If unsure, say N
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 676c808..7297e9d 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -120,8 +120,8 @@ enum ftrace_dump_mode ftrace_dump_on_oops;
>>   /* When set, tracing will stop when a WARN*() is hit */
>>   int __disable_trace_on_warning;
>>   
>> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
>> -/* Map of enums to their values, for "enum_map" file */
>> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
>> +/* Map of enums to their values, for "eval_map" file */
>>   struct trace_eval_map_head {
>>   	struct module			*mod;
>>   	unsigned long			length;
>> @@ -145,7 +145,7 @@ static DEFINE_MUTEX(trace_eval_mutex);
>>    * one at the beginning, and one at the end. The beginning item contains
>>    * the count of the saved maps (head.length), and the module they
>>    * belong to if not built in (head.mod). The ending item contains a
>> - * pointer to the next array of saved enum_eval/enum_map items.
>> + * pointer to the next array of saved eval_map items.
>>    */
>>   union trace_eval_map_item {
>>   	struct trace_eval_map		map;
>> @@ -154,7 +154,7 @@ union trace_eval_map_item {
>>   };
>>   
>>   static union trace_eval_map_item *trace_eval_maps;
>> -#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
>> +#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
>>   
>>   static int tracing_set_tracer(struct trace_array *tr, const char *buf);
>>   
>> @@ -4717,7 +4717,7 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
>>   	.write		= tracing_saved_cmdlines_size_write,
>>   };
>>   
>> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
>> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
>>   static union trace_eval_map_item *
>>   update_eval_map(union trace_eval_map_item *ptr)
>>   {
>> @@ -4868,15 +4868,15 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start,
>>   
>>   static void trace_create_eval_file(struct dentry *d_tracer)
>>   {
>> -	trace_create_file("enum_map", 0444, d_tracer,
>> +	trace_create_file("eval_map", 0444, d_tracer,
>>   			  NULL, &tracing_eval_map_fops);
> 
> Hmm, I have to audit some userspace code to see if this is used. The
> enum_map was a debug feature, but it could have been used by some tools.

I thought perf was using it, but I was mistaken. I didn't find anything 
using it, but to be on the safe side I placed this patch last so it 
could be dropped if a user was found. The CONFIG option seems to be 
disabled in the couple distro's I checked, further indicating that if 
someone is using it, they are seemingly obscure.



>>   }
>>   
>> -#else /* CONFIG_TRACE_ENUM_MAP_FILE */
>> +#else /* CONFIG_TRACE_EVAL_MAP_FILE */
>>   static inline void trace_create_eval_file(struct dentry *d_tracer) { }
>>   static inline void trace_insert_eval_map_file(struct module *mod,
>>   			      struct trace_eval_map **start, int len) { }
>> -#endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
>> +#endif /* !CONFIG_TRACE_EVAL_MAP_FILE */
>>   
>>   static void trace_insert_eval_map(struct module *mod,
>>   				  struct trace_eval_map **start, int len)
>> @@ -7731,7 +7731,7 @@ static void trace_module_add_evals(struct module *mod)
>>   	trace_insert_eval_map(mod, mod->trace_evals, mod->num_trace_evals);
>>   }
>>   
>> -#ifdef CONFIG_TRACE_ENUM_MAP_FILE
>> +#ifdef CONFIG_TRACE_EVAL_MAP_FILE
>>   static void trace_module_remove_evals(struct module *mod)
>>   {
>>   	union trace_eval_map_item *map;
>> @@ -7761,7 +7761,7 @@ static void trace_module_remove_evals(struct module *mod)
>>   }
>>   #else
>>   static inline void trace_module_remove_evals(struct module *mod) { }
>> -#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
>> +#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
>>   
>>   static int trace_module_notify(struct notifier_block *self,
>>   			       unsigned long val, void *data)
> 

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

* Re: [PATCH 12/12] tracing: Rename update the enum_map file
  2017-06-13 21:21     ` Jeremy Linton
@ 2017-06-14 17:06       ` Steven Rostedt
  2017-06-14 18:43         ` Jeremy Linton
  0 siblings, 1 reply; 19+ messages in thread
From: Steven Rostedt @ 2017-06-14 17:06 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

On Tue, 13 Jun 2017 16:21:48 -0500
Jeremy Linton <jeremy.linton@arm.com> wrote:

> > Hmm, I have to audit some userspace code to see if this is used. The
> > enum_map was a debug feature, but it could have been used by some tools.  
> 
> I thought perf was using it, but I was mistaken. I didn't find anything 
> using it, but to be on the safe side I placed this patch last so it 
> could be dropped if a user was found. The CONFIG option seems to be 
> disabled in the couple distro's I checked, further indicating that if 
> someone is using it, they are seemingly obscure.

I pulled in all your patches but the samples one. Could you update that
with a use case as well. You can create some crazy struct that you want
to get the size of, or whatever. Maybe make an array out of it? Or I
can come up with something creative.

I'll start testing your patches and do a push in a few days.

-- Steve

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

* Re: [PATCH 12/12] tracing: Rename update the enum_map file
  2017-06-14 17:06       ` Steven Rostedt
@ 2017-06-14 18:43         ` Jeremy Linton
  0 siblings, 0 replies; 19+ messages in thread
From: Jeremy Linton @ 2017-06-14 18:43 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, mingo, rusty, jeyu, kirill.shutemov,
	christoffer.dall, marc.zyngier, jcm

On 06/14/2017 12:06 PM, Steven Rostedt wrote:
> On Tue, 13 Jun 2017 16:21:48 -0500
> Jeremy Linton <jeremy.linton@arm.com> wrote:
> 
>>> Hmm, I have to audit some userspace code to see if this is used. The
>>> enum_map was a debug feature, but it could have been used by some tools.
>>
>> I thought perf was using it, but I was mistaken. I didn't find anything
>> using it, but to be on the safe side I placed this patch last so it
>> could be dropped if a user was found. The CONFIG option seems to be
>> disabled in the couple distro's I checked, further indicating that if
>> someone is using it, they are seemingly obscure.
> 
> I pulled in all your patches but the samples one. Could you update that
> with a use case as well. You can create some crazy struct that you want
> to get the size of, or whatever. Maybe make an array out of it? Or I
> can come up with something creative.

I was actually working on that, it seems that the existing sample has 
the problem because of the __print_array(...sizeof(int)) case. So I 
think my general plan was just to update it to TRACE_DEFINE_SIZEOF(int).

Do you want a more complex example?

But this lead me to discover a number of other __print_array() cases 
where people have hardcoded the size, so I was running through those and 
converting them to sizeof() since it should work now.

> 
> I'll start testing your patches and do a push in a few days.
> 
> -- Steve
> 

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

end of thread, other threads:[~2017-06-14 18:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 21:56 [PATCH 00/12] trace: add the ability to parse sizeof() Jeremy Linton
2017-05-31 21:56 ` [PATCH 01/12] trace: rename kernel enum section to eval Jeremy Linton
2017-05-31 21:56 ` [PATCH 02/12] trace: rename trace_enum_map to trace_eval_map Jeremy Linton
2017-05-31 21:56 ` [PATCH 03/12] trace: rename struct module entry for trace enums Jeremy Linton
2017-05-31 21:56 ` [PATCH 04/12] trace: rename trace enum data structures in trace.c Jeremy Linton
2017-05-31 21:56 ` [PATCH 05/12] trace: rename trace_enum_mutex to trace_eval_mutex Jeremy Linton
2017-05-31 21:56 ` [PATCH 06/12] trace: rename trace.c enum functions Jeremy Linton
2017-05-31 21:56 ` [PATCH 07/12] trace: rename enum_map functions Jeremy Linton
2017-05-31 21:56 ` [PATCH 08/12] tracing: Rename enum_replace to eval_replace Jeremy Linton
2017-05-31 21:56 ` [PATCH 09/12] tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values Jeremy Linton
2017-05-31 21:56 ` [PATCH 10/12] tracing: Update sample file to describe the new macro Jeremy Linton
2017-06-13 21:07   ` Steven Rostedt
2017-05-31 21:56 ` [PATCH 11/12] tracing: Add TRACE_DEFINE_SIZEOF() macros Jeremy Linton
2017-05-31 21:56 ` [PATCH 12/12] tracing: Rename update the enum_map file Jeremy Linton
2017-06-13 21:12   ` Steven Rostedt
2017-06-13 21:21     ` Jeremy Linton
2017-06-14 17:06       ` Steven Rostedt
2017-06-14 18:43         ` Jeremy Linton
2017-06-01  1:11 ` [PATCH 00/12] trace: add the ability to parse sizeof() 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.