]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tracing: Have seq_buf use full buffer
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Wed, 29 Oct 2014 19:26:09 +0000 (15:26 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 20 Nov 2014 03:01:17 +0000 (22:01 -0500)
Currently seq_buf is full when all but one byte of the buffer is
filled. Change it so that the seq_buf is full when all of the
buffer is filled.

Some of the functions would fill the buffer completely and report
everything was fine. This was inconsistent with the max of size - 1.
Changing this to be max of size makes all functions consistent.

Link: http://lkml.kernel.org/r/20141104160222.502133196@goodmis.org
Link: http://lkml.kernel.org/r/20141114011412.811957882@goodmis.org
Tested-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/seq_buf.h
kernel/trace/seq_buf.c

index 93718e570d4c50e094e2d81fb308587e3726aa5c..0800a24b4348150392739328fc823e50814fa249 100644 (file)
@@ -43,13 +43,13 @@ seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size)
 static inline bool
 seq_buf_has_overflowed(struct seq_buf *s)
 {
-       return s->len == s->size;
+       return s->len > s->size;
 }
 
 static inline void
 seq_buf_set_overflow(struct seq_buf *s)
 {
-       s->len = s->size;
+       s->len = s->size + 1;
 }
 
 /*
@@ -61,7 +61,7 @@ seq_buf_buffer_left(struct seq_buf *s)
        if (seq_buf_has_overflowed(s))
                return 0;
 
-       return (s->size - 1) - s->len;
+       return s->size - s->len;
 }
 
 /* How much buffer was written? */
index 6fc9d021cbef15ebd8bc9ebdf552a3871843079e..c53f1d5088e8d3de886bdfbe35ec03bb85f18edc 100644 (file)
@@ -26,7 +26,7 @@
  */
 static bool seq_buf_can_fit(struct seq_buf *s, size_t len)
 {
-       return s->len + len < s->size;
+       return s->len + len <= s->size;
 }
 
 /**
@@ -110,8 +110,11 @@ int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
        WARN_ON(s->size == 0);
 
        /*
-        * The last byte of the buffer is used to determine if we
-        * overflowed or not.
+        * Note, because bitmap_scnprintf() only returns the number of bytes
+        * written and not the number that would be written, we use the last
+        * byte of the buffer to let us know if we overflowed. There's a small
+        * chance that the bitmap could have fit exactly inside the buffer, but
+        * it's not that critical if that does happen.
         */
        if (len > 1) {
                ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits);