mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL] updates for tip/tracing/ftrace
@ 2009-03-26 15:49 Steven Rostedt
  2009-03-26 15:49 ` [PATCH 1/2] tracing: increase size of number of possible events Steven Rostedt
  2009-03-26 15:49 ` [PATCH 2/2] tracing: add size checks for exported ftrace internal structures Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2009-03-26 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Thomas Gleixner,
	Frederic Weisbecker


Ingo,

Please pull the latest tip/tracing/ftrace-1 tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace-1


Steven Rostedt (2):
      tracing: increase size of number of possible events
      tracing: add size checks for exported ftrace internal structures

----
 kernel/trace/trace.h        |    5 ++++-
 kernel/trace/trace_events.c |    5 ++++-
 kernel/trace/trace_export.c |    4 ++++
 kernel/trace/trace_output.c |    2 ++
 4 files changed, 14 insertions(+), 2 deletions(-)
-- 

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

* [PATCH 1/2] tracing: increase size of number of possible events
  2009-03-26 15:49 [PATCH 0/2] [GIT PULL] updates for tip/tracing/ftrace Steven Rostedt
@ 2009-03-26 15:49 ` Steven Rostedt
  2009-03-26 15:49 ` [PATCH 2/2] tracing: add size checks for exported ftrace internal structures Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2009-03-26 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Thomas Gleixner,
	Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0001-tracing-increase-size-of-number-of-possible-events.patch --]
[-- Type: text/plain, Size: 2220 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

With the new event tracing registration, we must increase the number
of events that can be registered. Currently the type field is only
one byte, which leaves us only 256 possible events.

Since we do not save the CPU number in the tracer anymore (it is determined
by the per cpu ring buffer that is used) we have an extra byte to use.

This patch increases the size of type from 1 byte (256 events) to
2 bytes (65,536 events).

It also adds a WARN_ON_ONCE if we exceed that limit.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.h        |    5 ++++-
 kernel/trace/trace_events.c |    2 +-
 kernel/trace/trace_output.c |    2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index d7410bb..1c7cb30 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -48,13 +48,16 @@ enum trace_type {
  *     bash-15816 [01]   235.197585: idle_cpu <- irq_enter
  */
 struct trace_entry {
-	unsigned char		type;
+	unsigned short		type;
 	unsigned char		flags;
 	unsigned char		preempt_count;
 	int			pid;
 	int			tgid;
 };
 
+#define FTRACE_MAX_EVENT						\
+	((1 << (sizeof(((struct trace_entry *)0)->type) * 8)) - 1)
+
 /*
  * Function trace entry - function address and parent function addres:
  */
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 3047b56..d0f9968 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -357,7 +357,7 @@ static int trace_write_header(struct trace_seq *s)
 				"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
 				"\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
 				"\n",
-				FIELD(unsigned char, type),
+				FIELD(unsigned short, type),
 				FIELD(unsigned char, flags),
 				FIELD(unsigned char, preempt_count),
 				FIELD(int, pid),
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 19261fd..b2599b0 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -513,6 +513,8 @@ int register_ftrace_event(struct trace_event *event)
  out:
 	mutex_unlock(&trace_event_mutex);
 
+	WARN_ON_ONCE(next_event_type > FTRACE_MAX_EVENT);
+
 	return ret;
 }
 
-- 
1.6.2

-- 

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

* [PATCH 2/2] tracing: add size checks for exported ftrace internal structures
  2009-03-26 15:49 [PATCH 0/2] [GIT PULL] updates for tip/tracing/ftrace Steven Rostedt
  2009-03-26 15:49 ` [PATCH 1/2] tracing: increase size of number of possible events Steven Rostedt
@ 2009-03-26 15:49 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2009-03-26 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Thomas Gleixner,
	Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0002-tracing-add-size-checks-for-exported-ftrace-interna.patch --]
[-- Type: text/plain, Size: 1928 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

The events exported by TRACE_EVENT are automated and are guaranteed
to be correct when used.

The internal ftrace sturctures on the other hand are more manually
exported. These require the ftrace maintainer to make sure they
are up to date.

This patch adds a size check to help flag when a type changes in
an internal ftrace data structure, and the update needs to be reflected
in the export.

If a export is incorrect, then the only harm is that the user space
tools will not know how to correctly read the internal structures of
ftrace.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace_events.c |    3 +++
 kernel/trace/trace_export.c |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index d0f9968..4a1c1bc 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -341,8 +341,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	return cnt;
 }
 
+extern char *__bad_type_size(void);
+
 #undef FIELD
 #define FIELD(type, name)						\
+	sizeof(type) != sizeof(field.name) ? __bad_type_size() :	\
 	#type, #name, offsetof(typeof(field), name), sizeof(field.name)
 
 static int trace_write_header(struct trace_seq *s)
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 4d9952d..4ae01bc 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -19,8 +19,12 @@
 #undef TRACE_STRUCT
 #define TRACE_STRUCT(args...) args
 
+extern void __bad_type_size(void);
+
 #undef TRACE_FIELD
 #define TRACE_FIELD(type, item, assign)					\
+	if (sizeof(type) != sizeof(field.item))				\
+		__bad_type_size();					\
 	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
 			       "offset:%u;\tsize:%u;\n",		\
 			       (unsigned int)offsetof(typeof(field), item), \
-- 
1.6.2

-- 

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

end of thread, other threads:[~2009-03-26 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-26 15:49 [PATCH 0/2] [GIT PULL] updates for tip/tracing/ftrace Steven Rostedt
2009-03-26 15:49 ` [PATCH 1/2] tracing: increase size of number of possible events Steven Rostedt
2009-03-26 15:49 ` [PATCH 2/2] tracing: add size checks for exported ftrace internal structures Steven Rostedt

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®