Skip to contentSkip to conversation

tracing: various fixes

GIT PULL New Steven Rostedt 2 participants 6 messages Oct 23, 2009 – Oct 24, 2009

Subsystems (4)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Ingo,

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

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

Jiri Olsa (4):
tracing: updating *ppos instead of filp->f_pos
tracing: fix trace_seq_printf return value
tracing: comment typo and documentation example fix
tracing: removing cpu arg from rb_time_stamp function

----

 Documentation/trace/ftrace.txt |    2 ++
 include/linux/trace_seq.h      |    2 +-
 kernel/trace/ftrace.c          |    2 +-
 kernel/trace/ring_buffer.c     |   12 ++++++------
 kernel/trace/trace.c           |    8 ++++----
 kernel/trace/trace_output.c    |    5 ++++-
 6 files changed, 18 insertions(+), 13 deletions(-)
author maintainer
#1 lore raw

PATCH 1/4 tracing: updating *ppos instead of filp->f_pos

From: Jiri Olsa <[email protected]>

Instead of direct updating filp->f_pos we should update *ppos argument. The filp->f_pos gets updated within the file_pos_write function called from sys_write.

LKML-Reference: <[email protected]>

---
 kernel/trace/ftrace.c |    2 +-
 kernel/trace/trace.c  |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
kernel/trace/ftrace.c +1 -1
index b10c0d9..1ed514f 100644
@@ -751,7 +751,7 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf,
  out:
 	mutex_unlock(&ftrace_profile_lock);
 
-	filp->f_pos += cnt;
+	*ppos += cnt;
 
 	return cnt;
 }
kernel/trace/trace.c +4 -4
index 026e715..9d3067a 100644
@@ -2440,7 +2440,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 			return ret;
 	}
 
-	filp->f_pos += cnt;
+	*ppos += cnt;
 
 	return cnt;
 }
@@ -2582,7 +2582,7 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
 	}
 	mutex_unlock(&trace_types_lock);
 
-	filp->f_pos += cnt;
+	*ppos += cnt;
 
 	return cnt;
 }
@@ -2764,7 +2764,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
 	if (err)
 		return err;
 
-	filp->f_pos += ret;
+	*ppos += ret;
 
 	return ret;
 }
@@ -3299,7 +3299,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 		}
 	}
 
-	filp->f_pos += cnt;
+	*ppos += cnt;
 
 	/* If check pages failed, return ENOMEM */
 	if (tracing_disabled)
Signature · 1 line
1.6.3.3
author maintainer
#2 lore raw

PATCH 2/4 tracing: fix trace_seq_printf return value

In reply to Steven Rostedt

From: Jiri Olsa <[email protected]>

trace_seq_printf return value is a little ambiguous. It currently returns the length of the space available in the buffer. printf usually returns the amount written. This is not adequate here, because

  trace_seq_printf(s, "");

is perfectly legal, and returning 0 would indicate that it failed.

We can always see the amount written by looking at the before and after values of s->len. This is not quite the same use as printf. We only care if the string was successfully written to the buffer or not.

Making trace_seq_printf return 0 if the trace oversizes the buffer's free space, 1 otherwise.

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_output.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
kernel/trace/trace_output.c +4 -1
index ed17565..b6c12c6 100644
@@ -69,6 +69,9 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
  * @s: trace sequence descriptor
  * @fmt: printf format string
  *
+ * It returns 0 if the trace oversizes the buffer's free
+ * space, 1 otherwise.
+ *
  * The tracer may use either sequence operations or its own
  * copy to user routines. To simplify formating of a trace
  * trace_seq_printf is used to store strings into a special
@@ -95,7 +98,7 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
 
 	s->len += ret;
 
-	return len;
+	return 1;
 }
 EXPORT_SYMBOL_GPL(trace_seq_printf);
 
Signature · 1 line
1.6.3.3
author maintainer
#3 lore raw

PATCH 3/4 tracing: comment typo and documentation example fix

In reply to Steven Rostedt

From: Jiri Olsa <[email protected]>

Trivial patch to fix a documentation example and fixes a comment.

LKML-Reference: <[email protected]>

---
 Documentation/trace/ftrace.txt |    2 ++
 kernel/trace/ring_buffer.c     |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
Documentation/trace/ftrace.txt +2 -0
index 957b22f..8179692 100644
@@ -1231,6 +1231,7 @@ something like this simple program:
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <string.h>
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -1265,6 +1266,7 @@ const char *find_debugfs(void)
                return NULL;
        }
 
+       strcat(debugfs, "/tracing/");
        debugfs_found = 1;
 
        return debugfs;
kernel/trace/ring_buffer.c +1 -1
index d4ff019..217f699 100644
@@ -2681,7 +2681,7 @@ unsigned long ring_buffer_entries(struct ring_buffer *buffer)
 EXPORT_SYMBOL_GPL(ring_buffer_entries);
 
 /**
- * ring_buffer_overrun_cpu - get the number of overruns in buffer
+ * ring_buffer_overruns - get the number of overruns in buffer
  * @buffer: The ring buffer
  *
  * Returns the total number of overruns in the ring buffer
Signature · 1 line
1.6.3.3
author maintainer
#4 lore raw

PATCH 4/4 tracing: removing cpu arg from rb_time_stamp function

In reply to Steven Rostedt

From: Jiri Olsa <[email protected]>

The cpu argument is not used inside rb_time_stamp function. Plus typo fix.

LKML-Reference: <[email protected]>

---
 include/linux/trace_seq.h  |    2 +-
 kernel/trace/ring_buffer.c |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/trace_seq.h +1 -1
index c134dd1..09077f6 100644
@@ -7,7 +7,7 @@
 
 /*
  * Trace sequences are used to allow a function to call several other functions
- * to create a string of data to use (up to a max of PAGE_SIZE.
+ * to create a string of data to use (up to a max of PAGE_SIZE).
  */
 
 struct trace_seq {
kernel/trace/ring_buffer.c +5 -5
index 217f699..3ffa502 100644
@@ -483,7 +483,7 @@ struct ring_buffer_iter {
 /* Up this if you want to test the TIME_EXTENTS and normalization */
 #define DEBUG_SHIFT 0
 
-static inline u64 rb_time_stamp(struct ring_buffer *buffer, int cpu)
+static inline u64 rb_time_stamp(struct ring_buffer *buffer)
 {
 	/* shift to debug/test normalization and TIME_EXTENTS */
 	return buffer->clock() << DEBUG_SHIFT;
@@ -494,7 +494,7 @@ u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu)
 	u64 time;
 
 	preempt_disable_notrace();
-	time = rb_time_stamp(buffer, cpu);
+	time = rb_time_stamp(buffer);
 	preempt_enable_no_resched_notrace();
 
 	return time;
@@ -599,7 +599,7 @@ static struct list_head *rb_list_head(struct list_head *list)
 }
 
 /*
- * rb_is_head_page - test if the give page is the head page
+ * rb_is_head_page - test if the given page is the head page
  *
  * Because the reader may move the head_page pointer, we can
  * not trust what the head page is (it may be pointing to
@@ -1868,7 +1868,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
 		 * Nested commits always have zero deltas, so
 		 * just reread the time stamp
 		 */
-		*ts = rb_time_stamp(buffer, cpu_buffer->cpu);
+		*ts = rb_time_stamp(buffer);
 		next_page->page->time_stamp = *ts;
 	}
 
@@ -2111,7 +2111,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
 	if (RB_WARN_ON(cpu_buffer, ++nr_loops > 1000))
 		goto out_fail;
 
-	ts = rb_time_stamp(cpu_buffer->buffer, cpu_buffer->cpu);
+	ts = rb_time_stamp(cpu_buffer->buffer);
 
 	/*
 	 * Only the first commit can update the timestamp.
Signature · 1 line
1.6.3.3
Applied
#5 lore raw
In reply to Steven Rostedt
Quoted 15 lines · Steven Rostedt

Ingo,

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

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

Jiri Olsa (4):
tracing: updating *ppos instead of filp->f_pos
tracing: fix trace_seq_printf return value
tracing: comment typo and documentation example fix
tracing: removing cpu arg from rb_time_stamp function

Quoted 8 lines

----

 Documentation/trace/ftrace.txt |    2 ++
 include/linux/trace_seq.h      |    2 +-
 kernel/trace/ftrace.c          |    2 +-
 kernel/trace/ring_buffer.c     |   12 ++++++------
 kernel/trace/trace.c           |    8 ++++----
 kernel/trace/trace_output.c    |    5 ++++-
 6 files changed, 18 insertions(+), 13 deletions(-)

Applied, thanks Steve!

Ingo