All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Zanussi <tzanussi@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4] zedtrace: use workqueue tracepoints
Date: Fri, 27 Feb 2009 03:01:09 -0600	[thread overview]
Message-ID: <1235725269.8512.90.camel@charm-linux> (raw)

Add support for the workqueue tracepoints.

Signed-off-by: Tom Zanussi <tzanussi@gmail.com>

---
 kernel/trace/trace_binary/Makefile        |    3 +-
 kernel/trace/trace_binary/zed.c           |    7 ++
 kernel/trace/trace_binary/zed.h           |    5 ++
 kernel/trace/trace_binary/zed_workqueue.c |   97 +++++++++++++++++++++++++++++
 kernel/trace/trace_binary/zed_workqueue.h |   43 +++++++++++++
 5 files changed, 154 insertions(+), 1 deletions(-)
 create mode 100644 kernel/trace/trace_binary/zed_workqueue.c
 create mode 100644 kernel/trace/trace_binary/zed_workqueue.h

diff --git a/kernel/trace/trace_binary/Makefile b/kernel/trace/trace_binary/Makefile
index 89fceba..146528e 100644
--- a/kernel/trace/trace_binary/Makefile
+++ b/kernel/trace/trace_binary/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_ZEDTRACE) += zedtrace.o
 
-zedtrace-objs := zed.o zed_filter.o zed_sched.o zed_block.o
+zedtrace-objs := zed.o zed_filter.o zed_sched.o zed_block.o zed_workqueue.o
+
diff --git a/kernel/trace/trace_binary/zed.c b/kernel/trace/trace_binary/zed.c
index 5fb61dc..54a3d70 100644
--- a/kernel/trace/trace_binary/zed.c
+++ b/kernel/trace/trace_binary/zed.c
@@ -25,6 +25,7 @@
 #include <linux/debugfs.h>
 #include <trace/sched.h>
 #include <trace/block.h>
+#include <trace/workqueue.h>
 #include "zed.h"
 #include "zed_filter.h"
 
@@ -992,6 +993,10 @@ static int zed_enable_tracepoints(void)
 		printk(KERN_ERR "Couldn't register block tracepoints.\n");
 		goto fail;
 	}
+	if (zed_enable_workqueue_tracepoints()) {
+		printk(KERN_ERR "Couldn't register workqueue tracepoints.\n");
+		goto fail;
+	}
 	return 0;
 fail:
 	return -1;
@@ -1001,12 +1006,14 @@ static void zed_disable_tracepoints(void)
 {
 	zed_disable_sched_tracepoints();
 	zed_disable_block_tracepoints();
+	zed_disable_workqueue_tracepoints();
 }
 
 static void zed_init_subsystems(void)
 {
 	zed_sched_init();
 	zed_block_init();
+	zed_workqueue_init();
 }
 
 /**
diff --git a/kernel/trace/trace_binary/zed.h b/kernel/trace/trace_binary/zed.h
index 7f86f3b..d6d9746 100644
--- a/kernel/trace/trace_binary/zed.h
+++ b/kernel/trace/trace_binary/zed.h
@@ -73,9 +73,14 @@
 	EVENT(block, unplug_timer_trace) sep \
 	EVENT(block, split_trace) sep \
 	EVENT(block, remap_trace) sep \
+	EVENT(workqueue, insertion_trace) sep \
+	EVENT(workqueue, execution_trace) sep \
+	EVENT(workqueue, creation_trace) sep \
+	EVENT(workqueue, destruction_trace) sep \
 
 #include "zed_sched.h"
 #include "zed_block.h"
+#include "zed_workqueue.h"
 
 /* magic or'ed with version, last byte of magic should be 00 */
 #define ZED_TRACE_MAGIC		0x26F82100
diff --git a/kernel/trace/trace_binary/zed_workqueue.c b/kernel/trace/trace_binary/zed_workqueue.c
new file mode 100644
index 0000000..b1bdb43
--- /dev/null
+++ b/kernel/trace/trace_binary/zed_workqueue.c
@@ -0,0 +1,97 @@
+/*
+ * zedtrace "workqueue" subsys event definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2008-2009 Tom Zanussi <tzanussi@gmail.com>
+ */
+
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/jhash.h>
+#include <linux/vmalloc.h>
+#include <linux/debugfs.h>
+#include <trace/workqueue.h>
+#include "zed.h"
+
+EVENTS(EXTERN_TRACE_FLAG, SEMICOLON);
+
+ZED_TRACEPOINT_ENTER(workqueue_insertion,
+		     TPPROTO(struct task_struct *wq_thread,
+			     struct work_struct *work))
+{
+	zed_event->pid = wq_thread->pid;
+}
+ZED_TRACEPOINT_EXIT(workqueue_insertion)
+
+ZED_TRACEPOINT_ENTER(workqueue_execution,
+		     TPPROTO(struct task_struct *wq_thread,
+			     struct work_struct *work))
+{
+	zed_event->pid = wq_thread->pid;
+}
+ZED_TRACEPOINT_EXIT(workqueue_execution)
+
+ZED_TRACEPOINT_ENTER(workqueue_creation,
+		     TPPROTO(struct task_struct *wq_thread, int cpu))
+{
+	zed_event->pid = wq_thread->pid;
+	zed_event->wq_cpu = cpu;
+}
+ZED_TRACEPOINT_EXIT(workqueue_creation)
+
+ZED_TRACEPOINT_ENTER(workqueue_destruction,
+		     TPPROTO(struct task_struct *wq_thread))
+{
+	zed_event->pid = wq_thread->pid;
+}
+ZED_TRACEPOINT_EXIT(workqueue_destruction)
+
+int zed_enable_workqueue_tracepoints(void)
+{
+	if (register_trace_workqueue_insertion(workqueue_insertion_tracepoint)) {
+		printk(KERN_ERR "Couldn't register workqueue_insertion tracepoint.\n");
+		goto fail;
+	}
+	if (register_trace_workqueue_execution(workqueue_execution_tracepoint)) {
+		printk(KERN_ERR "Couldn't register workqueue_execution tracepoint.\n");
+		goto fail;
+	}
+	if (register_trace_workqueue_creation(workqueue_creation_tracepoint)) {
+		printk(KERN_ERR "Couldn't register workqueue_creation tracepoint.\n");
+		goto fail;
+	}
+	if (register_trace_workqueue_destruction(workqueue_destruction_tracepoint)) {
+		printk(KERN_ERR "Couldn't register workqueue_destruction tracepoint.\n");
+		goto fail;
+	}
+
+	return 0;
+fail:
+	return -1;
+}
+
+void zed_disable_workqueue_tracepoints(void)
+{
+	unregister_trace_workqueue_insertion(workqueue_insertion_tracepoint);
+	unregister_trace_workqueue_execution(workqueue_execution_tracepoint);
+	unregister_trace_workqueue_creation(workqueue_creation_tracepoint);
+	unregister_trace_workqueue_destruction(workqueue_destruction_tracepoint);
+}
+
+void zed_workqueue_init(void)
+{
+}
+
diff --git a/kernel/trace/trace_binary/zed_workqueue.h b/kernel/trace/trace_binary/zed_workqueue.h
new file mode 100644
index 0000000..ea0dabf
--- /dev/null
+++ b/kernel/trace/trace_binary/zed_workqueue.h
@@ -0,0 +1,43 @@
+/*
+ * zedtrace "workqueue" subsys event declarations
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2008-2009 Tom Zanussi <tzanussi@gmail.com>
+ */
+
+/* convention: name[0] of u8 = var data, name[0] of char = string */
+
+#ifndef _ZED_WORKQUEUE_H
+#define _ZED_WORKQUEUE_H
+
+#define workqueue_insertion_trace_fields(subsys, event_name, FIELD) \
+	FIELD(subsys, event_name, pid, pid_t)			\
+
+#define workqueue_execution_trace_fields(subsys, event_name, FIELD) \
+	FIELD(subsys, event_name, pid, pid_t)			\
+
+#define workqueue_creation_trace_fields(subsys, event_name, FIELD) \
+	FIELD(subsys, event_name, pid, pid_t)			\
+	FIELD(subsys, event_name, wq_cpu, int)			\
+
+#define workqueue_destruction_trace_fields(subsys, event_name, FIELD) \
+	FIELD(subsys, event_name, pid, pid_t)			\
+
+extern void zed_workqueue_init(void);
+extern int zed_enable_workqueue_tracepoints(void);
+extern void zed_disable_workqueue_tracepoints(void);
+
+#endif /* _ZED_WORKQUEUE_H */
-- 
1.5.6.3




                 reply	other threads:[~2009-02-27  9:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1235725269.8512.90.camel@charm-linux \
    --to=tzanussi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.