public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	akpm@osdl.org, Peter Zijlstra <peterz@infradead.org>,
	Soeren Sandmann Pedersen <sandmann@redhat.com>,
	Pekka Paalanen <pq@iki.fi>, Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/3] TEST PATCH - ftrace example patch for use of trace pipe headers
Date: Mon, 21 Apr 2008 17:09:38 -0400	[thread overview]
Message-ID: <20080421212128.516224560@goodmis.org> (raw)
In-Reply-To: 20080421210935.460817943@goodmis.org

[-- Attachment #1: ftrace-test-pipe-open.patch --]
[-- Type: text/plain, Size: 1706 bytes --]

DO NOT APPLY THIS PATCH!!!!!

This is an example of implementing a plugin for header for the trace_pipe
file.

DO NOT APPLY THIS PATCH!!!!! 

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace_functions.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Index: linux-sched-devel.git/kernel/trace/trace_functions.c
===================================================================
--- linux-sched-devel.git.orig/kernel/trace/trace_functions.c	2008-04-21 16:50:49.000000000 -0400
+++ linux-sched-devel.git/kernel/trace/trace_functions.c	2008-04-21 16:54:55.000000000 -0400
@@ -16,6 +16,45 @@
 
 #include "trace.h"
 
+static void function_pipe_open(struct trace_iterator *iter)
+{
+	int *traceme;
+
+	traceme = kzalloc(sizeof(int), GFP_KERNEL);
+	if (!traceme)
+		return;
+
+	iter->private = traceme;
+}
+
+static ssize_t function_read(struct trace_iterator *iter,
+			     struct file *filp, char __user *ubuf,
+			     size_t cnt, loff_t *ppos)
+{
+	unsigned char head[] = "Test header\n";
+	int *traced;
+	int ret;
+
+	if (!iter->private)
+		return 0;
+
+	traced = iter->private;
+	if (*traced >= sizeof(head)-1)
+		return 0;
+
+	if (cnt > sizeof(head)-1)
+		cnt = sizeof(head)-1;
+
+	ret = copy_to_user(ubuf, head + *traced, cnt);
+
+	*traced += cnt;
+
+	if (ret)
+		cnt = -EFAULT;
+
+	return cnt;
+}
+
 static void function_reset(struct trace_array *tr)
 {
 	int cpu;
@@ -68,6 +107,8 @@ static struct tracer function_trace __re
 #ifdef CONFIG_FTRACE_SELFTEST
 	.selftest    = trace_selftest_startup_function,
 #endif
+	.pipe_open   = function_pipe_open,
+	.read        = function_read,
 };
 
 static __init int init_function_trace(void)

-- 

  parent reply	other threads:[~2008-04-21 21:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21 21:09 [PATCH 0/3] ftrace: overrun accounting and trace_pipe headers Steven Rostedt
2008-04-21 21:09 ` [PATCH 1/3] ftrace: add logic to record overruns Steven Rostedt
2008-04-26 20:47   ` Pekka Paalanen
2008-04-28 13:13     ` Steven Rostedt
2008-04-21 21:09 ` [PATCH 2/3] ftrace: add trace pipe header pluggin Steven Rostedt
2008-04-26 17:33   ` Pekka Paalanen
2008-04-28 13:05     ` Steven Rostedt
2008-04-21 21:09 ` Steven Rostedt [this message]
2008-04-22 13:33 ` [PATCH 0/3] ftrace: overrun accounting and trace_pipe headers Ingo Molnar
2008-04-22 17:36 ` Pekka Paalanen
2008-04-23  0:58   ` Steven Rostedt

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=20080421212128.516224560@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=pq@iki.fi \
    --cc=sandmann@redhat.com \
    --cc=srostedt@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox