From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Theodore Tso <tytso@mit.edu>,
Arjan van de Ven <arjan@infradead.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: [RFC][PATCH 3/5] [PATCH 3/5] tracing/events: Add infrastructure to show stable event formats
Date: Tue, 16 Nov 2010 19:54:00 -0500 [thread overview]
Message-ID: <20101117005940.168079730@goodmis.org> (raw)
In-Reply-To: 20101117005357.024472450@goodmis.org
[-- Attachment #1: 0003-tracing-events-Add-infrastructure-to-show-stable-eve.patch --]
[-- Type: text/plain, Size: 4910 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Add the infrastructure to connect to the eventfs filesystem and
create a event directory. Currently, all events are flat. That is
there is no hierarchy. Each stable event has its own directory
in /sys/kernel/events (after the eventfs is mounted there).
Currently only one file exists in each of the event directories.
This file is the format file. The format shows each item
in the stable event. The name of that item, the item's type,
the size of the item (in bits), the count of entries of the item
(if that item is an array), the alignment needed for that item to
be read (arch specific) and the sign of the item.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/events/Makefile | 2 +-
kernel/events/event_format.c | 74 ++++++++++++++++++++++++++++++++++++++++++
kernel/events/event_format.h | 64 ++++++++++++++++++++++++++++++++++++
3 files changed, 139 insertions(+), 1 deletions(-)
create mode 100644 kernel/events/event_format.c
create mode 100644 kernel/events/event_format.h
diff --git a/kernel/events/Makefile b/kernel/events/Makefile
index 86fd7c1..943bda5 100644
--- a/kernel/events/Makefile
+++ b/kernel/events/Makefile
@@ -1 +1 @@
-obj-y += events.o
+obj-y += events.o event_format.o
diff --git a/kernel/events/event_format.c b/kernel/events/event_format.c
new file mode 100644
index 0000000..705948a
--- /dev/null
+++ b/kernel/events/event_format.c
@@ -0,0 +1,74 @@
+/*
+ * event_format.c - code to show events in eventfs
+ *
+ * Copyright (C) 2010 Steven Rostedt <srostedt@redhat.com> Red Hat Inc
+ */
+#include <linux/eventfs.h>
+#include <linux/seq_file.h>
+
+typedef void (*event_format_func)(struct seq_file *m);
+
+static void *f_next(struct seq_file *m, void *v, loff_t *pos)
+{
+
+ if ((*pos)++ == 0)
+ return m->private;
+
+ return NULL;
+}
+
+static void *f_start(struct seq_file *m, loff_t *pos)
+{
+ /* It's all or nothing */
+ if ((*pos)++)
+ return NULL;
+
+ return m->private;
+}
+
+static int f_show(struct seq_file *m, void *v)
+{
+ event_format_func func = m->private;
+
+ if (!v)
+ return 0;
+
+ func(m);
+ return 0;
+}
+
+static void f_stop(struct seq_file *m, void *p)
+{
+}
+
+static const struct seq_operations event_format_seq_ops = {
+ .start = f_start,
+ .next = f_next,
+ .stop = f_stop,
+ .show = f_show,
+};
+
+static int event_format_open(struct inode *inode, struct file *file)
+{
+ struct seq_file *m;
+ int ret;
+
+ ret = seq_open(file, &event_format_seq_ops);
+ if (ret < 0)
+ return ret;
+
+ m = file->private_data;
+ m->private = inode->i_private;
+
+ return 0;
+}
+
+static const struct file_operations event_format_fops = {
+ .open = event_format_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+#include "event_format.h"
+
diff --git a/kernel/events/event_format.h b/kernel/events/event_format.h
new file mode 100644
index 0000000..aa43fc0
--- /dev/null
+++ b/kernel/events/event_format.h
@@ -0,0 +1,64 @@
+/*
+ * event_format.h - code to show events in eventfs
+ *
+ * Copyright (C) 2010 Steven Rostedt <srostedt@redhat.com> Red Hat Inc
+ *
+ * For every stable event a directory is created in the eventfs.
+ * For now, only one file exists in that directory, which is
+ * the format file. This format shows the format of that event as:
+ *
+ * field:name type:type size:bit-size align:alignment signed:signed;
+ *
+ * Or for arrays:
+ *
+ * array:name type:type size:bit-size count:items algin:alignment signed:signed;
+ *
+ * The size is in bits. For the array, the size is of a single entry,
+ * and the count is the number of those entries.
+ */
+#include <linux/ftrace_event.h>
+
+#define STABLE_HEADER_MULTI_READ
+
+#undef __SEP__
+#define __SEP__
+
+#undef __field
+#define __field(type, item) \
+ seq_printf(m, "\tfield:%s\ttype:%s\tsize:%ld\talign:%ld\tsigned:%d;\n", \
+ #item, #type, sizeof(type) * 8, \
+ __alignof__(type), is_signed_type(type));
+
+#undef __array
+#define __array(type, item, size) \
+ seq_printf(m, "\tarray:%s\ttype:%s\tsize:%ld\tcount:%d\talign:%ld\tsigned:%d;\n", \
+ #item, #type, sizeof(type) * 8, size, \
+ __alignof__(type), is_signed_type(type));
+
+#define EVENT_STRUCT(s) s
+
+#undef STABLE_EVENT
+#define STABLE_EVENT(name, estruct) \
+static void format_##name(struct seq_file *m) \
+{ \
+ estruct; \
+} \
+ \
+static int __init create_stable_##name(void) \
+{ \
+ struct dentry *entry; \
+ struct dentry *dir; \
+ \
+ dir = eventfs_create_dir(#name, NULL); \
+ if (WARN(!dir, "Unable to create directory %s", #name)) \
+ return -1; \
+ \
+ entry = eventfs_create_file("format", 0644, dir, format_##name, \
+ &event_format_fops); \
+ \
+ return 0; \
+} \
+ \
+fs_initcall(create_stable_##name);
+
+#include <trace/stable_list.h>
--
1.7.1
next prev parent reply other threads:[~2010-11-17 1:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 0:53 [RFC][PATCH 0/5] tracing/events: stable tracepoints Steven Rostedt
2010-11-17 0:53 ` [RFC][PATCH 1/5] [PATCH 1/5] events: Add EVENT_FS the event filesystem Steven Rostedt
2010-11-17 3:32 ` Greg KH
2010-11-17 10:39 ` Ingo Molnar
2010-11-17 12:25 ` Steven Rostedt
2010-11-17 15:03 ` Ingo Molnar
2010-11-17 15:16 ` Peter Zijlstra
2010-11-17 15:16 ` Steven Rostedt
2010-11-17 15:35 ` Peter Zijlstra
2010-11-17 18:42 ` Ted Ts'o
2010-11-17 15:16 ` Peter Zijlstra
2010-11-23 21:29 ` Steven Rostedt
2010-11-17 17:46 ` Mathieu Desnoyers
2010-11-17 17:52 ` Steven Rostedt
2010-11-17 18:12 ` Mathieu Desnoyers
2010-11-18 9:42 ` Avi Kivity
2010-11-17 23:48 ` Ted Ts'o
2010-11-18 13:05 ` Mathieu Desnoyers
2010-11-17 12:16 ` Steven Rostedt
2010-11-17 0:53 ` [RFC][PATCH 2/5] [PATCH 2/5] tracing/events: Add code to (un)register stable events Steven Rostedt
2010-11-17 0:54 ` Steven Rostedt [this message]
2010-11-17 0:54 ` [RFC][PATCH 4/5] [PATCH 4/5] tracing/events: Add stable event sched_switch Steven Rostedt
2010-11-17 0:54 ` [RFC][PATCH 5/5] [PATCH 5/5] tracing/events: Add sched_migrate_task stable event Steven Rostedt
2010-11-17 20:14 ` [RFC][PATCH 0/5] tracing/events: stable tracepoints Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101117005940.168079730@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is 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.