Skip to contentSkip to conversation

for tip/tracing/ftrace

GIT PULL New Steven Rostedt 2 participants 6 messages Mar 6, 2009

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Ingo,

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

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

Steven Rostedt (3):
tracing: make all file_operations const
tracing: move print of event format to separate file
tracing: add format files for ftrace default entries

----

 kernel/trace/Makefile               |    1 +
 kernel/trace/ftrace.c               |   10 +-
 kernel/trace/ring_buffer.c          |    2 +-
 kernel/trace/trace.c                |   24 +++---
 kernel/trace/trace_event_types.h    |  165 +++++++++++++++++++++++++++++++++++
 kernel/trace/trace_events.c         |   12 ++-
 kernel/trace/trace_events_stage_2.h |   53 +-----------
 kernel/trace/trace_export.c         |   81 +++++++++++++++++
 kernel/trace/trace_format.h         |   55 ++++++++++++
 kernel/trace/trace_sysprof.c        |    2 +-
 10 files changed, 329 insertions(+), 76 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 tracing: make all file_operations const

From: Steven Rostedt <[email protected]>

Impact: cleanup

All file_operations structures should be constant. No one is going to change them.

---
 kernel/trace/ftrace.c        |   10 +++++-----
 kernel/trace/ring_buffer.c   |    2 +-
 kernel/trace/trace.c         |   24 ++++++++++++------------
 kernel/trace/trace_sysprof.c |    2 +-
 4 files changed, 19 insertions(+), 19 deletions(-)
kernel/trace/ftrace.c +5 -5
index 5a3a06b..d7a06a0 100644
@@ -1869,21 +1869,21 @@ ftrace_notrace_release(struct inode *inode, struct file *file)
 	return ftrace_regex_release(inode, file, 0);
 }
 
-static struct file_operations ftrace_avail_fops = {
+static const struct file_operations ftrace_avail_fops = {
 	.open = ftrace_avail_open,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = ftrace_avail_release,
 };
 
-static struct file_operations ftrace_failures_fops = {
+static const struct file_operations ftrace_failures_fops = {
 	.open = ftrace_failures_open,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = ftrace_avail_release,
 };
 
-static struct file_operations ftrace_filter_fops = {
+static const struct file_operations ftrace_filter_fops = {
 	.open = ftrace_filter_open,
 	.read = ftrace_regex_read,
 	.write = ftrace_filter_write,
@@ -1891,7 +1891,7 @@ static struct file_operations ftrace_filter_fops = {
 	.release = ftrace_filter_release,
 };
 
-static struct file_operations ftrace_notrace_fops = {
+static const struct file_operations ftrace_notrace_fops = {
 	.open = ftrace_notrace_open,
 	.read = ftrace_regex_read,
 	.write = ftrace_notrace_write,
@@ -2423,7 +2423,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
-static struct file_operations ftrace_pid_fops = {
+static const struct file_operations ftrace_pid_fops = {
 	.read = ftrace_pid_read,
 	.write = ftrace_pid_write,
 };
kernel/trace/ring_buffer.c +1 -1
index f747364..1788584 100644
@@ -2606,7 +2606,7 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
-static struct file_operations rb_simple_fops = {
+static const struct file_operations rb_simple_fops = {
 	.open		= tracing_open_generic,
 	.read		= rb_simple_read,
 	.write		= rb_simple_write,
kernel/trace/trace.c +12 -12
index c0e9c12..e6144ac 100644
@@ -1882,14 +1882,14 @@ static int show_traces_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static struct file_operations tracing_fops = {
+static const struct file_operations tracing_fops = {
 	.open		= tracing_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.release	= tracing_release,
 };
 
-static struct file_operations show_traces_fops = {
+static const struct file_operations show_traces_fops = {
 	.open		= show_traces_open,
 	.read		= seq_read,
 	.release	= seq_release,
@@ -1982,7 +1982,7 @@ err_unlock:
 	return err;
 }
 
-static struct file_operations tracing_cpumask_fops = {
+static const struct file_operations tracing_cpumask_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_cpumask_read,
 	.write		= tracing_cpumask_write,
@@ -2134,7 +2134,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
-static struct file_operations tracing_iter_fops = {
+static const struct file_operations tracing_iter_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_trace_options_read,
 	.write		= tracing_trace_options_write,
@@ -2167,7 +2167,7 @@ tracing_readme_read(struct file *filp, char __user *ubuf,
 					readme_msg, strlen(readme_msg));
 }
 
-static struct file_operations tracing_readme_fops = {
+static const struct file_operations tracing_readme_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_readme_read,
 };
@@ -2927,25 +2927,25 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
-static struct file_operations tracing_max_lat_fops = {
+static const struct file_operations tracing_max_lat_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_max_lat_read,
 	.write		= tracing_max_lat_write,
 };
 
-static struct file_operations tracing_ctrl_fops = {
+static const struct file_operations tracing_ctrl_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_ctrl_read,
 	.write		= tracing_ctrl_write,
 };
 
-static struct file_operations set_tracer_fops = {
+static const struct file_operations set_tracer_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_set_trace_read,
 	.write		= tracing_set_trace_write,
 };
 
-static struct file_operations tracing_pipe_fops = {
+static const struct file_operations tracing_pipe_fops = {
 	.open		= tracing_open_pipe,
 	.poll		= tracing_poll_pipe,
 	.read		= tracing_read_pipe,
@@ -2953,13 +2953,13 @@ static struct file_operations tracing_pipe_fops = {
 	.release	= tracing_release_pipe,
 };
 
-static struct file_operations tracing_entries_fops = {
+static const struct file_operations tracing_entries_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_entries_read,
 	.write		= tracing_entries_write,
 };
 
-static struct file_operations tracing_mark_fops = {
+static const struct file_operations tracing_mark_fops = {
 	.open		= tracing_open_generic,
 	.write		= tracing_mark_write,
 };
@@ -3240,7 +3240,7 @@ tracing_read_dyn_info(struct file *filp, char __user *ubuf,
 	return r;
 }
 
-static struct file_operations tracing_dyn_info_fops = {
+static const struct file_operations tracing_dyn_info_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_read_dyn_info,
 };
kernel/trace/trace_sysprof.c +1 -1
index c771af4..91fd19c 100644
@@ -314,7 +314,7 @@ sysprof_sample_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
-static struct file_operations sysprof_sample_fops = {
+static const struct file_operations sysprof_sample_fops = {
 	.read		= sysprof_sample_read,
 	.write		= sysprof_sample_write,
 };
Signature · 3 lines
1.6.1.3

-- 
author maintainer
#2 lore raw

PATCH 2/3 tracing: move print of event format to separate file

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Impact: clean up

Move the macro that creates the event format file to a separate header. This will allow the default ftrace events to use this same macro to create the formats to read those events.

---
 kernel/trace/trace_events_stage_2.h |   53 +---------------------------------
 kernel/trace/trace_format.h         |   55 +++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 52 deletions(-)
 create mode 100644 kernel/trace/trace_format.h
kernel/trace/trace_events_stage_2.h +1 -52
index b1cebba..d24a97e 100644
@@ -75,56 +75,5 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
 
 #include <trace/trace_event_types.h>
 
-/*
- * Setup the showing format of trace point.
- *
- * int
- * ftrace_format_##call(struct trace_seq *s)
- * {
- * 	struct ftrace_raw_##call field;
- * 	int ret;
- *
- * 	ret = trace_seq_printf(s, #type " " #item ";"
- * 			       " size:%d; offset:%d;\n",
- * 			       sizeof(field.type),
- * 			       offsetof(struct ftrace_raw_##call,
- * 					item));
- *
- * }
- */
-
-#undef TRACE_FIELD
-#define TRACE_FIELD(type, item, assign)					\
-	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
-			       "offset:%lu;\tsize:%lu;\n",		\
-			       offsetof(typeof(field), item),		\
-			       sizeof(field.item));			\
-	if (!ret)							\
-		return 0;
-
-
-#undef TRACE_FIELD_SPECIAL
-#define TRACE_FIELD_SPECIAL(type_item, item, cmd)			\
-	ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"	\
-			       "offset:%lu;\tsize:%lu;\n",		\
-			       offsetof(typeof(field), item),		\
-			       sizeof(field.item));			\
-	if (!ret)							\
-		return 0;
-
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
-int									\
-ftrace_format_##call(struct trace_seq *s)				\
-{									\
-	struct ftrace_raw_##call field;					\
-	int ret;							\
-									\
-	tstruct;							\
-									\
-	trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt);		\
-									\
-	return ret;							\
-}
-
+#include "trace_format.h"
 #include <trace/trace_event_types.h>
kernel/trace/trace_format.h new file +55 -0

55 lines not on this page · raw message

Signature · 3 lines
1.6.1.3

-- 
author maintainer
#3 lore raw

PATCH 3/3 tracing: add format files for ftrace default entries

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Impact: allow user apps to read binary format of basic ftrace entries

Currently, only defined raw events export their formats so a binary reader can parse them. There's no reason that the default ftrace entries can't export their formats.

This patch adds a subsystem called "ftrace" in the events directory that includes the ftrace entries for basic ftrace recorded items.

These only have three files in the events directory:

 type             : printf
 available_types  : printf
 format           : format for the event entry

For example:

 # cat /debug/tracing/events/ftrace/wakeup/format
name: wakeup
ID: 3
format:
        field:unsigned char type;       offset:0;       size:1;
        field:unsigned char flags;      offset:1;       size:1;
        field:unsigned char preempt_count;      offset:2;       size:1;
        field:int pid;  offset:4;       size:4;
        field:int tgid; offset:8;       size:4;
        field:unsigned int prev_pid;    offset:12;      size:4;
        field:unsigned char prev_prio;  offset:16;      size:1;
        field:unsigned char prev_state; offset:17;      size:1;
        field:unsigned int next_pid;    offset:20;      size:4;
        field:unsigned char next_prio;  offset:24;      size:1;
        field:unsigned char next_state; offset:25;      size:1;
        field:unsigned int next_cpu;    offset:28;      size:4;

print fmt: "%u:%u:%u ==+ %u:%u:%u [%03u]"

---
 kernel/trace/Makefile            |    1 +
 kernel/trace/trace_event_types.h |  165 ++++++++++++++++++++++++++++++++++++++
 kernel/trace/trace_events.c      |   12 ++-
 kernel/trace/trace_export.c      |   81 +++++++++++++++++++
 kernel/trace/trace_format.h      |    2 +-
 5 files changed, 255 insertions(+), 6 deletions(-)
 create mode 100644 kernel/trace/trace_event_types.h
 create mode 100644 kernel/trace/trace_export.c
kernel/trace/Makefile +1 -0
index c931fe0..f44736c 100644
@@ -41,5 +41,6 @@ obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
 obj-$(CONFIG_BLK_DEV_IO_TRACE)	+= blktrace.o
 obj-$(CONFIG_EVENT_TRACER) += trace_events.o
 obj-$(CONFIG_EVENT_TRACER) += events.o
+obj-$(CONFIG_EVENT_TRACER) += trace_export.o
 
 libftrace-y := ftrace.o
kernel/trace/trace_event_types.h new file +165 -0

165 lines not on this page · raw message

kernel/trace/trace_events.c +7 -5
index 210e71f..4488d90 100644
@@ -656,11 +656,13 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
 		return -1;
 	}
 
-	entry = debugfs_create_file("enable", 0644, call->dir, call,
-				    &ftrace_enable_fops);
-	if (!entry)
-		pr_warning("Could not create debugfs "
-			   "'%s/enable' entry\n", call->name);
+	if (call->regfunc) {
+		entry = debugfs_create_file("enable", 0644, call->dir, call,
+					    &ftrace_enable_fops);
+		if (!entry)
+			pr_warning("Could not create debugfs "
+				   "'%s/enable' entry\n", call->name);
+	}
 
 	/* Only let type be writable, if we can change it */
 	entry = debugfs_create_file("type",
kernel/trace/trace_export.c new file +81 -0

81 lines not on this page · raw message

kernel/trace/trace_format.h +1 -1
index 53a6b13..03f9a4c 100644
@@ -40,7 +40,7 @@
 
 #undef TRACE_EVENT_FORMAT
 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
-int									\
+static int								\
 ftrace_format_##call(struct trace_seq *s)				\
 {									\
 	struct ftrace_raw_##call field;					\
Signature · 3 lines
1.6.1.3

-- 
#4 lore raw
In reply to Steven Rostedt
Quoted 15 lines · Steven Rostedt

Ingo,

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

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

Steven Rostedt (3):
tracing: make all file_operations const
tracing: move print of event format to separate file
tracing: add format files for ftrace default entries

----

Quoted 11 lines
 kernel/trace/Makefile               |    1 +
 kernel/trace/ftrace.c               |   10 +-
 kernel/trace/ring_buffer.c          |    2 +-
 kernel/trace/trace.c                |   24 +++---
 kernel/trace/trace_event_types.h    |  165 +++++++++++++++++++++++++++++++++++
 kernel/trace/trace_events.c         |   12 ++-
 kernel/trace/trace_events_stage_2.h |   53 +-----------
 kernel/trace/trace_export.c         |   81 +++++++++++++++++
 kernel/trace/trace_format.h         |   55 ++++++++++++
 kernel/trace/trace_sysprof.c        |    2 +-
 10 files changed, 329 insertions(+), 76 deletions(-)

Pulled, thanks Steve!

Ingo

#5 lore raw

[tip:tracing/ftrace] tracing, power-trace: make it build even if the power-tracer is turned off

Commit-ID:  af438c0f114b6f731b923b5c07150f6159471502
Gitweb:     http://git.kernel.org/tip/af438c0f114b6f731b923b5c07150f6159471502
Author:     "Ingo Molnar" <[email protected]>
AuthorDate: Fri, 6 Mar 2009 12:47:08 +0100
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 6 Mar 2009 12:47:08 +0100

tracing, power-trace: make it build even if the power-tracer is turned off

Impact: build fix

The 'struct power_trace' definition is needed (for the event tracer) even if the power-tracer plugin is turned off in the .config.

Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>

---
 include/trace/power.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
include/trace/power.h +0 -2
index 2c733e5..38aca53 100644
@@ -11,12 +11,10 @@ enum {
 };
 
 struct power_trace {
-#ifdef CONFIG_POWER_TRACER
 	ktime_t			stamp;
 	ktime_t			end;
 	int			type;
 	int			state;
-#endif
 };
 
 DECLARE_TRACE(power_start,