Re: [PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-19 Thread Steven Rostedt
On Wed, 19 Nov 2014 15:51:38 +0100
Petr Mladek  wrote:

> On Fri 2014-11-14 23:59:01, Steven Rostedt wrote:
> > From: "Steven Rostedt (Red Hat)" 
> > 
> > Create a seq_buf layer that trace_seq sits on. The seq_buf will not
> > be limited to page size. This will allow other usages of seq_buf
> > instead of a hard set PAGE_SIZE one that trace_seq has.
> > 
> > Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
> > Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org
> > 
> > Tested-by: Jiri Kosina 
> > Acked-by: Jiri Kosina 
> > Reviewed-by: Petr Mladek 
> > Signed-off-by: Steven Rostedt 
> > ---
> >  include/linux/seq_buf.h  |  81 +
> >  include/linux/trace_seq.h|  12 +-
> >  kernel/trace/Makefile|   1 +
> >  kernel/trace/seq_buf.c   | 341 
> > +++
> >  kernel/trace/trace.c |  39 ++--
> >  kernel/trace/trace_events.c  |   6 +-
> >  kernel/trace/trace_functions_graph.c |   6 +-
> >  kernel/trace/trace_seq.c | 177 +-
> >  8 files changed, 538 insertions(+), 125 deletions(-)
> >  create mode 100644 include/linux/seq_buf.h
> >  create mode 100644 kernel/trace/seq_buf.c
> 
> [...]
>  
> > diff --git a/kernel/trace/trace_functions_graph.c 
> > b/kernel/trace/trace_functions_graph.c
> > index 100288d10e1f..6d1342ae7a44 100644
> > --- a/kernel/trace/trace_functions_graph.c
> > +++ b/kernel/trace/trace_functions_graph.c
> 
> [...]
> 
> > @@ -163,21 +176,22 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf);
> >   */
> >  void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 
> > *binary)
> >  {
> > -   unsigned int len = TRACE_SEQ_BUF_LEFT(s);
> > +   unsigned int save_len = s->seq.len;
> > int ret;
> 
> Last but one small thing. The "ret" is assigned but not longer used.
> 
> JFYI, I have skipped this patch yesterday because it was long and already
> marked as reviewed. I could not help myself and double checked it today.
> 

OK, I'll fix that up.

> > -   if (s->full || !len)
> > +   if (s->full)
> > return;
> >  
> > -   ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
> > +   __trace_seq_init(s);
> > +
> > +   ret = seq_buf_bprintf(>seq, fmt, binary);
> >  
> > /* If we can't write it all, don't bother writing anything */
> > -   if (ret >= len) {
> > +   if (unlikely(seq_buf_has_overflowed(>seq))) {
> > +   s->seq.len = save_len;
> > s->full = 1;
> > return;
> > }
> > -
> > -   s->len += ret;
> >  }
> >  EXPORT_SYMBOL_GPL(trace_seq_bprintf);
> 
> The last small thing is the same unused "ret" in trace_seq_path(). But
> this one should get fixed in "[PATCH 15/26 v5] tracing: Convert
> seq_buf_path() to be like seq_path()".

OK, I'll try to remember that :-)

> 
> Both these changes are rather cosmetic. Feel free to leave them for
> some later clean up.
> 
> 
> Eureka, I have finished review of the patchset and am happy with it \o/
> I am looking forward to see it in the main tree.

Well now it comes down to Linus or Andrew giving me the OK. I've pulled
all the trace_seq updates into my ftrace/core branch (which will be
going into my for-next branch shortly). I stopped just before this
patch. I didn't want to create the seq_buf until I knew it was going to
be used by something other than trace_seq.

> 
> Thanks a lot for the hard work.
> 

Yeah, let's hope that it was worth it.

Thanks for the in depth reviews.

-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-19 Thread Petr Mladek
On Fri 2014-11-14 23:59:01, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" 
> 
> Create a seq_buf layer that trace_seq sits on. The seq_buf will not
> be limited to page size. This will allow other usages of seq_buf
> instead of a hard set PAGE_SIZE one that trace_seq has.
> 
> Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
> Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org
> 
> Tested-by: Jiri Kosina 
> Acked-by: Jiri Kosina 
> Reviewed-by: Petr Mladek 
> Signed-off-by: Steven Rostedt 
> ---
>  include/linux/seq_buf.h  |  81 +
>  include/linux/trace_seq.h|  12 +-
>  kernel/trace/Makefile|   1 +
>  kernel/trace/seq_buf.c   | 341 
> +++
>  kernel/trace/trace.c |  39 ++--
>  kernel/trace/trace_events.c  |   6 +-
>  kernel/trace/trace_functions_graph.c |   6 +-
>  kernel/trace/trace_seq.c | 177 +-
>  8 files changed, 538 insertions(+), 125 deletions(-)
>  create mode 100644 include/linux/seq_buf.h
>  create mode 100644 kernel/trace/seq_buf.c

[...]
 
> diff --git a/kernel/trace/trace_functions_graph.c 
> b/kernel/trace/trace_functions_graph.c
> index 100288d10e1f..6d1342ae7a44 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c

[...]

> @@ -163,21 +176,22 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf);
>   */
>  void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 
> *binary)
>  {
> - unsigned int len = TRACE_SEQ_BUF_LEFT(s);
> + unsigned int save_len = s->seq.len;
>   int ret;

Last but one small thing. The "ret" is assigned but not longer used.

JFYI, I have skipped this patch yesterday because it was long and already
marked as reviewed. I could not help myself and double checked it today.

> - if (s->full || !len)
> + if (s->full)
>   return;
>  
> - ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
> + __trace_seq_init(s);
> +
> + ret = seq_buf_bprintf(>seq, fmt, binary);
>  
>   /* If we can't write it all, don't bother writing anything */
> - if (ret >= len) {
> + if (unlikely(seq_buf_has_overflowed(>seq))) {
> + s->seq.len = save_len;
>   s->full = 1;
>   return;
>   }
> -
> - s->len += ret;
>  }
>  EXPORT_SYMBOL_GPL(trace_seq_bprintf);

The last small thing is the same unused "ret" in trace_seq_path(). But
this one should get fixed in "[PATCH 15/26 v5] tracing: Convert
seq_buf_path() to be like seq_path()".

Both these changes are rather cosmetic. Feel free to leave them for
some later clean up.


Eureka, I have finished review of the patchset and am happy with it \o/
I am looking forward to see it in the main tree.

Thanks a lot for the hard work.

Best Regards,
Petr
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-19 Thread Petr Mladek
On Fri 2014-11-14 23:59:01, Steven Rostedt wrote:
 From: Steven Rostedt (Red Hat) rost...@goodmis.org
 
 Create a seq_buf layer that trace_seq sits on. The seq_buf will not
 be limited to page size. This will allow other usages of seq_buf
 instead of a hard set PAGE_SIZE one that trace_seq has.
 
 Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
 Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org
 
 Tested-by: Jiri Kosina jkos...@suse.cz
 Acked-by: Jiri Kosina jkos...@suse.cz
 Reviewed-by: Petr Mladek pmla...@suse.cz
 Signed-off-by: Steven Rostedt rost...@goodmis.org
 ---
  include/linux/seq_buf.h  |  81 +
  include/linux/trace_seq.h|  12 +-
  kernel/trace/Makefile|   1 +
  kernel/trace/seq_buf.c   | 341 
 +++
  kernel/trace/trace.c |  39 ++--
  kernel/trace/trace_events.c  |   6 +-
  kernel/trace/trace_functions_graph.c |   6 +-
  kernel/trace/trace_seq.c | 177 +-
  8 files changed, 538 insertions(+), 125 deletions(-)
  create mode 100644 include/linux/seq_buf.h
  create mode 100644 kernel/trace/seq_buf.c

[...]
 
 diff --git a/kernel/trace/trace_functions_graph.c 
 b/kernel/trace/trace_functions_graph.c
 index 100288d10e1f..6d1342ae7a44 100644
 --- a/kernel/trace/trace_functions_graph.c
 +++ b/kernel/trace/trace_functions_graph.c

[...]

 @@ -163,21 +176,22 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf);
   */
  void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 
 *binary)
  {
 - unsigned int len = TRACE_SEQ_BUF_LEFT(s);
 + unsigned int save_len = s-seq.len;
   int ret;

Last but one small thing. The ret is assigned but not longer used.

JFYI, I have skipped this patch yesterday because it was long and already
marked as reviewed. I could not help myself and double checked it today.

 - if (s-full || !len)
 + if (s-full)
   return;
  
 - ret = bstr_printf(s-buffer + s-len, len, fmt, binary);
 + __trace_seq_init(s);
 +
 + ret = seq_buf_bprintf(s-seq, fmt, binary);
  
   /* If we can't write it all, don't bother writing anything */
 - if (ret = len) {
 + if (unlikely(seq_buf_has_overflowed(s-seq))) {
 + s-seq.len = save_len;
   s-full = 1;
   return;
   }
 -
 - s-len += ret;
  }
  EXPORT_SYMBOL_GPL(trace_seq_bprintf);

The last small thing is the same unused ret in trace_seq_path(). But
this one should get fixed in [PATCH 15/26 v5] tracing: Convert
seq_buf_path() to be like seq_path().

Both these changes are rather cosmetic. Feel free to leave them for
some later clean up.


Eureka, I have finished review of the patchset and am happy with it \o/
I am looking forward to see it in the main tree.

Thanks a lot for the hard work.

Best Regards,
Petr
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-19 Thread Steven Rostedt
On Wed, 19 Nov 2014 15:51:38 +0100
Petr Mladek pmla...@suse.cz wrote:

 On Fri 2014-11-14 23:59:01, Steven Rostedt wrote:
  From: Steven Rostedt (Red Hat) rost...@goodmis.org
  
  Create a seq_buf layer that trace_seq sits on. The seq_buf will not
  be limited to page size. This will allow other usages of seq_buf
  instead of a hard set PAGE_SIZE one that trace_seq has.
  
  Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
  Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org
  
  Tested-by: Jiri Kosina jkos...@suse.cz
  Acked-by: Jiri Kosina jkos...@suse.cz
  Reviewed-by: Petr Mladek pmla...@suse.cz
  Signed-off-by: Steven Rostedt rost...@goodmis.org
  ---
   include/linux/seq_buf.h  |  81 +
   include/linux/trace_seq.h|  12 +-
   kernel/trace/Makefile|   1 +
   kernel/trace/seq_buf.c   | 341 
  +++
   kernel/trace/trace.c |  39 ++--
   kernel/trace/trace_events.c  |   6 +-
   kernel/trace/trace_functions_graph.c |   6 +-
   kernel/trace/trace_seq.c | 177 +-
   8 files changed, 538 insertions(+), 125 deletions(-)
   create mode 100644 include/linux/seq_buf.h
   create mode 100644 kernel/trace/seq_buf.c
 
 [...]
  
  diff --git a/kernel/trace/trace_functions_graph.c 
  b/kernel/trace/trace_functions_graph.c
  index 100288d10e1f..6d1342ae7a44 100644
  --- a/kernel/trace/trace_functions_graph.c
  +++ b/kernel/trace/trace_functions_graph.c
 
 [...]
 
  @@ -163,21 +176,22 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf);
*/
   void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 
  *binary)
   {
  -   unsigned int len = TRACE_SEQ_BUF_LEFT(s);
  +   unsigned int save_len = s-seq.len;
  int ret;
 
 Last but one small thing. The ret is assigned but not longer used.
 
 JFYI, I have skipped this patch yesterday because it was long and already
 marked as reviewed. I could not help myself and double checked it today.
 

OK, I'll fix that up.

  -   if (s-full || !len)
  +   if (s-full)
  return;
   
  -   ret = bstr_printf(s-buffer + s-len, len, fmt, binary);
  +   __trace_seq_init(s);
  +
  +   ret = seq_buf_bprintf(s-seq, fmt, binary);
   
  /* If we can't write it all, don't bother writing anything */
  -   if (ret = len) {
  +   if (unlikely(seq_buf_has_overflowed(s-seq))) {
  +   s-seq.len = save_len;
  s-full = 1;
  return;
  }
  -
  -   s-len += ret;
   }
   EXPORT_SYMBOL_GPL(trace_seq_bprintf);
 
 The last small thing is the same unused ret in trace_seq_path(). But
 this one should get fixed in [PATCH 15/26 v5] tracing: Convert
 seq_buf_path() to be like seq_path().

OK, I'll try to remember that :-)

 
 Both these changes are rather cosmetic. Feel free to leave them for
 some later clean up.
 
 
 Eureka, I have finished review of the patchset and am happy with it \o/
 I am looking forward to see it in the main tree.

Well now it comes down to Linus or Andrew giving me the OK. I've pulled
all the trace_seq updates into my ftrace/core branch (which will be
going into my for-next branch shortly). I stopped just before this
patch. I didn't want to create the seq_buf until I knew it was going to
be used by something other than trace_seq.

 
 Thanks a lot for the hard work.
 

Yeah, let's hope that it was worth it.

Thanks for the in depth reviews.

-- Steve
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-14 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Create a seq_buf layer that trace_seq sits on. The seq_buf will not
be limited to page size. This will allow other usages of seq_buf
instead of a hard set PAGE_SIZE one that trace_seq has.

Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org

Tested-by: Jiri Kosina 
Acked-by: Jiri Kosina 
Reviewed-by: Petr Mladek 
Signed-off-by: Steven Rostedt 
---
 include/linux/seq_buf.h  |  81 +
 include/linux/trace_seq.h|  12 +-
 kernel/trace/Makefile|   1 +
 kernel/trace/seq_buf.c   | 341 +++
 kernel/trace/trace.c |  39 ++--
 kernel/trace/trace_events.c  |   6 +-
 kernel/trace/trace_functions_graph.c |   6 +-
 kernel/trace/trace_seq.c | 177 +-
 8 files changed, 538 insertions(+), 125 deletions(-)
 create mode 100644 include/linux/seq_buf.h
 create mode 100644 kernel/trace/seq_buf.c

diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
new file mode 100644
index ..4f7a96a9d71a
--- /dev/null
+++ b/include/linux/seq_buf.h
@@ -0,0 +1,81 @@
+#ifndef _LINUX_SEQ_BUF_H
+#define _LINUX_SEQ_BUF_H
+
+#include 
+
+/*
+ * Trace sequences are used to allow a function to call several other functions
+ * to create a string of data to use.
+ */
+
+/**
+ * seq_buf - seq buffer structure
+ * @buffer:pointer to the buffer
+ * @size:  size of the buffer
+ * @len:   the amount of data inside the buffer
+ * @readpos:   The next position to read in the buffer.
+ */
+struct seq_buf {
+   unsigned char   *buffer;
+   unsigned intsize;
+   unsigned intlen;
+   unsigned intreadpos;
+};
+
+static inline void
+seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size)
+{
+   s->buffer = buf;
+   s->size = size;
+   s->len = 0;
+   s->readpos = 0;
+}
+
+/*
+ * seq_buf have a buffer that might overflow. When this happens
+ * the len and size are set to be equal.
+ */
+static inline bool
+seq_buf_has_overflowed(struct seq_buf *s)
+{
+   return s->len == s->size;
+}
+
+static inline void
+seq_buf_set_overflow(struct seq_buf *s)
+{
+   s->len = s->size;
+}
+
+/*
+ * How much buffer is left on the seq_buf?
+ */
+static inline unsigned int
+seq_buf_buffer_left(struct seq_buf *s)
+{
+   if (seq_buf_has_overflowed(s))
+   return 0;
+
+   return (s->size - 1) - s->len;
+}
+
+extern __printf(2, 3)
+int seq_buf_printf(struct seq_buf *s, const char *fmt, ...);
+extern __printf(2, 0)
+int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args);
+extern int
+seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
+extern int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s);
+extern int seq_buf_to_user(struct seq_buf *s, char __user *ubuf,
+  int cnt);
+extern int seq_buf_puts(struct seq_buf *s, const char *str);
+extern int seq_buf_putc(struct seq_buf *s, unsigned char c);
+extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int 
len);
+extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
+ unsigned int len);
+extern int seq_buf_path(struct seq_buf *s, const struct path *path);
+
+extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
+  int nmaskbits);
+
+#endif /* _LINUX_SEQ_BUF_H */
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h
index db8a73224f1a..85d37106be3d 100644
--- a/include/linux/trace_seq.h
+++ b/include/linux/trace_seq.h
@@ -1,7 +1,7 @@
 #ifndef _LINUX_TRACE_SEQ_H
 #define _LINUX_TRACE_SEQ_H
 
-#include 
+#include 
 
 #include 
 
@@ -12,16 +12,14 @@
 
 struct trace_seq {
unsigned char   buffer[PAGE_SIZE];
-   unsigned intlen;
-   unsigned intreadpos;
+   struct seq_buf  seq;
int full;
 };
 
 static inline void
 trace_seq_init(struct trace_seq *s)
 {
-   s->len = 0;
-   s->readpos = 0;
+   seq_buf_init(>seq, s->buffer, PAGE_SIZE);
s->full = 0;
 }
 
@@ -37,7 +35,7 @@ trace_seq_init(struct trace_seq *s)
 static inline unsigned char *
 trace_seq_buffer_ptr(struct trace_seq *s)
 {
-   return s->buffer + s->len;
+   return s->buffer + s->seq.len;
 }
 
 /**
@@ -49,7 +47,7 @@ trace_seq_buffer_ptr(struct trace_seq *s)
  */
 static inline bool trace_seq_has_overflowed(struct trace_seq *s)
 {
-   return s->full || s->len > PAGE_SIZE - 1;
+   return s->full || seq_buf_has_overflowed(>seq);
 }
 
 /*
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 67d6369ddf83..edc98c72a634 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o
 obj-$(CONFIG_TRACING) += 

[PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq

2014-11-14 Thread Steven Rostedt
From: Steven Rostedt (Red Hat) rost...@goodmis.org

Create a seq_buf layer that trace_seq sits on. The seq_buf will not
be limited to page size. This will allow other usages of seq_buf
instead of a hard set PAGE_SIZE one that trace_seq has.

Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org
Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org

Tested-by: Jiri Kosina jkos...@suse.cz
Acked-by: Jiri Kosina jkos...@suse.cz
Reviewed-by: Petr Mladek pmla...@suse.cz
Signed-off-by: Steven Rostedt rost...@goodmis.org
---
 include/linux/seq_buf.h  |  81 +
 include/linux/trace_seq.h|  12 +-
 kernel/trace/Makefile|   1 +
 kernel/trace/seq_buf.c   | 341 +++
 kernel/trace/trace.c |  39 ++--
 kernel/trace/trace_events.c  |   6 +-
 kernel/trace/trace_functions_graph.c |   6 +-
 kernel/trace/trace_seq.c | 177 +-
 8 files changed, 538 insertions(+), 125 deletions(-)
 create mode 100644 include/linux/seq_buf.h
 create mode 100644 kernel/trace/seq_buf.c

diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
new file mode 100644
index ..4f7a96a9d71a
--- /dev/null
+++ b/include/linux/seq_buf.h
@@ -0,0 +1,81 @@
+#ifndef _LINUX_SEQ_BUF_H
+#define _LINUX_SEQ_BUF_H
+
+#include linux/fs.h
+
+/*
+ * Trace sequences are used to allow a function to call several other functions
+ * to create a string of data to use.
+ */
+
+/**
+ * seq_buf - seq buffer structure
+ * @buffer:pointer to the buffer
+ * @size:  size of the buffer
+ * @len:   the amount of data inside the buffer
+ * @readpos:   The next position to read in the buffer.
+ */
+struct seq_buf {
+   unsigned char   *buffer;
+   unsigned intsize;
+   unsigned intlen;
+   unsigned intreadpos;
+};
+
+static inline void
+seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size)
+{
+   s-buffer = buf;
+   s-size = size;
+   s-len = 0;
+   s-readpos = 0;
+}
+
+/*
+ * seq_buf have a buffer that might overflow. When this happens
+ * the len and size are set to be equal.
+ */
+static inline bool
+seq_buf_has_overflowed(struct seq_buf *s)
+{
+   return s-len == s-size;
+}
+
+static inline void
+seq_buf_set_overflow(struct seq_buf *s)
+{
+   s-len = s-size;
+}
+
+/*
+ * How much buffer is left on the seq_buf?
+ */
+static inline unsigned int
+seq_buf_buffer_left(struct seq_buf *s)
+{
+   if (seq_buf_has_overflowed(s))
+   return 0;
+
+   return (s-size - 1) - s-len;
+}
+
+extern __printf(2, 3)
+int seq_buf_printf(struct seq_buf *s, const char *fmt, ...);
+extern __printf(2, 0)
+int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args);
+extern int
+seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
+extern int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s);
+extern int seq_buf_to_user(struct seq_buf *s, char __user *ubuf,
+  int cnt);
+extern int seq_buf_puts(struct seq_buf *s, const char *str);
+extern int seq_buf_putc(struct seq_buf *s, unsigned char c);
+extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int 
len);
+extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
+ unsigned int len);
+extern int seq_buf_path(struct seq_buf *s, const struct path *path);
+
+extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
+  int nmaskbits);
+
+#endif /* _LINUX_SEQ_BUF_H */
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h
index db8a73224f1a..85d37106be3d 100644
--- a/include/linux/trace_seq.h
+++ b/include/linux/trace_seq.h
@@ -1,7 +1,7 @@
 #ifndef _LINUX_TRACE_SEQ_H
 #define _LINUX_TRACE_SEQ_H
 
-#include linux/fs.h
+#include linux/seq_buf.h
 
 #include asm/page.h
 
@@ -12,16 +12,14 @@
 
 struct trace_seq {
unsigned char   buffer[PAGE_SIZE];
-   unsigned intlen;
-   unsigned intreadpos;
+   struct seq_buf  seq;
int full;
 };
 
 static inline void
 trace_seq_init(struct trace_seq *s)
 {
-   s-len = 0;
-   s-readpos = 0;
+   seq_buf_init(s-seq, s-buffer, PAGE_SIZE);
s-full = 0;
 }
 
@@ -37,7 +35,7 @@ trace_seq_init(struct trace_seq *s)
 static inline unsigned char *
 trace_seq_buffer_ptr(struct trace_seq *s)
 {
-   return s-buffer + s-len;
+   return s-buffer + s-seq.len;
 }
 
 /**
@@ -49,7 +47,7 @@ trace_seq_buffer_ptr(struct trace_seq *s)
  */
 static inline bool trace_seq_has_overflowed(struct trace_seq *s)
 {
-   return s-full || s-len  PAGE_SIZE - 1;
+   return s-full || seq_buf_has_overflowed(s-seq);
 }
 
 /*
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 67d6369ddf83..edc98c72a634 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile