Merge branch 'for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[safe/jmp/linux-2.6] / kernel / trace / trace_stat.c
index 07c60b0..96cffb2 100644 (file)
@@ -10,6 +10,7 @@
 
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/rbtree.h>
 #include <linux/debugfs.h>
 #include "trace_stat.h"
@@ -203,17 +204,21 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos)
 {
        struct stat_session *session = s->private;
        struct rb_node *node;
+       int n = *pos;
        int i;
 
        /* Prevent from tracer switch or rbtree modification */
        mutex_lock(&session->stat_mutex);
 
        /* If we are in the beginning of the file, print the headers */
-       if (!*pos && session->ts->stat_headers)
-               return SEQ_START_TOKEN;
+       if (session->ts->stat_headers) {
+               if (n == 0)
+                       return SEQ_START_TOKEN;
+               n--;
+       }
 
        node = rb_first(&session->stat_root);
-       for (i = 0; node && i < *pos; i++)
+       for (i = 0; node && i < n; i++)
                node = rb_next(node);
 
        return node;