mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Slava Pestov <slavapestov@google.com>
To: linux-kernel@vger.kernel.org
Cc: mrubin@google.com, dhsharp@google.com, rostedt@goodmis.org,
	Slava Pestov <slavapestov@google.com>
Subject: [PATCH] ftrace: add 'version' special file for ring buffer format
Date: Mon, 14 Mar 2011 15:42:08 -0700	[thread overview]
Message-ID: <1300142528-4918-1-git-send-email-slavapestov@google.com> (raw)

The intention here is that if the ftrace ring buffer format changes
in the future like it did in the past with ktrace, we can increment
the version number and update clients appropriately.

Tested: Verified that special file contains correct content

This patch is against 2.6.38-rc8 but should apply to any version
from at least 2.6.34 onwards.

Signed-Off-By: Slava Pestov <slavapestov@google.com>
---
 kernel/trace/trace.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index dc53ecb..e56868a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -44,6 +44,12 @@
 #define TRACE_BUFFER_FLAGS	(RB_FL_OVERWRITE)
 
 /*
+ * The version number should be incremented if the ring buffer
+ * format changes in an incompatible way.
+ */
+static const char ftrace_version[] = "1.0.0\n";
+
+/*
  * On boot up, the ring buffer is set to the minimum size, so that
  * we do not waste memory on systems that are not using tracing.
  */
@@ -2624,6 +2630,20 @@ static const struct file_operations tracing_readme_fops = {
 };
 
 static ssize_t
+tracing_version_read(struct file *filp, char __user *ubuf,
+		     size_t cnt, loff_t *ppos)
+{
+	return simple_read_from_buffer(ubuf, cnt, ppos,
+				       ftrace_version, strlen(ftrace_version));
+}
+
+static const struct file_operations tracing_version_fops = {
+	.open		= tracing_open_generic,
+	.read		= tracing_version_read,
+	.llseek		= generic_file_llseek,
+};
+
+static ssize_t
 tracing_saved_cmdlines_read(struct file *file, char __user *ubuf,
 				size_t cnt, loff_t *ppos)
 {
@@ -4336,6 +4356,9 @@ static __init int tracer_init_debugfs(void)
 	trace_create_file("README", 0444, d_tracer,
 			NULL, &tracing_readme_fops);
 
+	trace_create_file("version", 0444, d_tracer,
+			NULL, &tracing_version_fops);
+
 	trace_create_file("trace_pipe", 0444, d_tracer,
 			(void *) TRACE_PIPE_ALL_CPU, &tracing_pipe_fops);
 
-- 
1.7.3.1


             reply	other threads:[~2011-03-14 22:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 22:42 Slava Pestov [this message]
2011-03-15  2:31 ` Steven Rostedt
2011-03-16  0:33   ` David Sharp
2011-03-16  0:56     ` 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=1300142528-4918-1-git-send-email-slavapestov@google.com \
    --to=slavapestov@google.com \
    --cc=dhsharp@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrubin@google.com \
    --cc=rostedt@goodmis.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 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®