Merge branch 'tracing/urgent' into tracing/core
authorIngo Molnar <mingo@elte.hu>
Fri, 10 Apr 2009 10:46:28 +0000 (12:46 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 10 Apr 2009 10:46:51 +0000 (12:46 +0200)
Merge reason: pick up both v2.6.30-rc1 [which includes tracing/urgent fixes]
              and pick up the current lineup of tracing/urgent fixes as well

Signed-off-by: Ingo Molnar <mingo@elte.hu>
1  2 
include/linux/ftrace.h
kernel/trace/trace.c

diff --combined include/linux/ftrace.h
index 6aea54d2dd3e7f27224f3333f8a01dd6117b2430,8a0c2f221e6b95b448991b1e291610c9e52ea91e..53869bef610210bfe0720c056d7499d496a20507
@@@ -357,7 -357,7 +357,7 @@@ struct ftrace_graph_ret 
  #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  
  /* for init task */
- #define INIT_FTRACE_GRAPH             .ret_stack = NULL
+ #define INIT_FTRACE_GRAPH             .ret_stack = NULL,
  
  /*
   * Stack of return addresses for functions
@@@ -368,7 -368,6 +368,7 @@@ struct ftrace_ret_stack 
        unsigned long ret;
        unsigned long func;
        unsigned long long calltime;
 +      unsigned long long subtime;
  };
  
  /*
@@@ -380,6 -379,8 +380,6 @@@ extern void return_to_handler(void)
  
  extern int
  ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth);
 -extern void
 -ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret);
  
  /*
   * Sometimes we don't want to trace a function with the function
@@@ -510,33 -511,4 +510,4 @@@ static inline void trace_hw_branch_oops
  
  #endif /* CONFIG_HW_BRANCH_TRACER */
  
- /*
-  * A syscall entry in the ftrace syscalls array.
-  *
-  * @name: name of the syscall
-  * @nb_args: number of parameters it takes
-  * @types: list of types as strings
-  * @args: list of args as strings (args[i] matches types[i])
-  */
- struct syscall_metadata {
-       const char      *name;
-       int             nb_args;
-       const char      **types;
-       const char      **args;
- };
- #ifdef CONFIG_FTRACE_SYSCALLS
- extern void arch_init_ftrace_syscalls(void);
- extern struct syscall_metadata *syscall_nr_to_meta(int nr);
- extern void start_ftrace_syscalls(void);
- extern void stop_ftrace_syscalls(void);
- extern void ftrace_syscall_enter(struct pt_regs *regs);
- extern void ftrace_syscall_exit(struct pt_regs *regs);
- #else
- static inline void start_ftrace_syscalls(void) { }
- static inline void stop_ftrace_syscalls(void) { }
- static inline void ftrace_syscall_enter(struct pt_regs *regs) { }
- static inline void ftrace_syscall_exit(struct pt_regs *regs) { }
- #endif
  #endif /* _LINUX_FTRACE_H */
diff --combined kernel/trace/trace.c
index 0615751a3ed7a43f24c7e324562296070e12b54c,1ce5dc6372b8fcc617bcb37722f22fdf95620e0a..4865459f609f94c8cc42601d6f1e8c245582594c
@@@ -255,8 -255,7 +255,8 @@@ static DECLARE_WAIT_QUEUE_HEAD(trace_wa
  
  /* trace_flags holds trace_options default values */
  unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
 -      TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME;
 +      TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME |
 +      TRACE_ITER_GRAPH_TIME;
  
  /**
   * trace_wake_up - wake up tasks waiting for trace input
@@@ -318,7 -317,6 +318,7 @@@ static const char *trace_options[] = 
        "latency-format",
        "global-clock",
        "sleep-time",
 +      "graph-time",
        NULL
  };
  
@@@ -404,6 -402,17 +404,6 @@@ static ssize_t trace_seq_to_buffer(stru
        return cnt;
  }
  
 -static void
 -trace_print_seq(struct seq_file *m, struct trace_seq *s)
 -{
 -      int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len;
 -
 -      s->buffer[len] = 0;
 -      seq_puts(m, s->buffer);
 -
 -      trace_seq_init(s);
 -}
 -
  /**
   * update_max_tr - snapshot all trace buffers from global_trace to max_tr
   * @tr: tracer
@@@ -3268,19 -3277,13 +3268,13 @@@ static int tracing_buffers_open(struct 
  
        info->tr        = &global_trace;
        info->cpu       = cpu;
-       info->spare     = ring_buffer_alloc_read_page(info->tr->buffer);
+       info->spare     = NULL;
        /* Force reading ring buffer for first read */
        info->read      = (unsigned int)-1;
-       if (!info->spare)
-               goto out;
  
        filp->private_data = info;
  
-       return 0;
-  out:
-       kfree(info);
-       return -ENOMEM;
+       return nonseekable_open(inode, filp);
  }
  
  static ssize_t
@@@ -3295,6 -3298,11 +3289,11 @@@ tracing_buffers_read(struct file *filp
        if (!count)
                return 0;
  
+       if (!info->spare)
+               info->spare = ring_buffer_alloc_read_page(info->tr->buffer);
+       if (!info->spare)
+               return -ENOMEM;
        /* Do we have previous read data to read? */
        if (info->read < PAGE_SIZE)
                goto read;
@@@ -3333,7 -3341,8 +3332,8 @@@ static int tracing_buffers_release(stru
  {
        struct ftrace_buffer_info *info = file->private_data;
  
-       ring_buffer_free_read_page(info->tr->buffer, info->spare);
+       if (info->spare)
+               ring_buffer_free_read_page(info->tr->buffer, info->spare);
        kfree(info);
  
        return 0;
@@@ -3419,14 -3428,19 +3419,19 @@@ tracing_buffers_splice_read(struct fil
        int size, i;
        size_t ret;
  
-       /*
-        * We can't seek on a buffer input
-        */
-       if (unlikely(*ppos))
-               return -ESPIPE;
+       if (*ppos & (PAGE_SIZE - 1)) {
+               WARN_ONCE(1, "Ftrace: previous read must page-align\n");
+               return -EINVAL;
+       }
  
+       if (len & (PAGE_SIZE - 1)) {
+               WARN_ONCE(1, "Ftrace: splice_read should page-align\n");
+               if (len < PAGE_SIZE)
+                       return -EINVAL;
+               len &= PAGE_MASK;
+       }
  
-       for (i = 0; i < PIPE_BUFFERS && len; i++, len -= size) {
+       for (i = 0; i < PIPE_BUFFERS && len; i++, len -= PAGE_SIZE) {
                struct page *page;
                int r;
  
                spd.partial[i].offset = 0;
                spd.partial[i].private = (unsigned long)ref;
                spd.nr_pages++;
+               *ppos += PAGE_SIZE;
        }
  
        spd.nr_pages = i;
@@@ -3581,7 -3596,7 +3587,7 @@@ struct dentry *tracing_dentry_percpu(vo
  static void tracing_init_debugfs_percpu(long cpu)
  {
        struct dentry *d_percpu = tracing_dentry_percpu();
 -      struct dentry *entry, *d_cpu;
 +      struct dentry *d_cpu;
        /* strlen(cpu) + MAX(log10(cpu)) + '\0' */
        char cpu_dir[7];
  
        }
  
        /* per cpu trace_pipe */
 -      entry = debugfs_create_file("trace_pipe", 0444, d_cpu,
 -                              (void *) cpu, &tracing_pipe_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'trace_pipe' entry\n");
 +      trace_create_file("trace_pipe", 0444, d_cpu,
 +                      (void *) cpu, &tracing_pipe_fops);
  
        /* per cpu trace */
 -      entry = debugfs_create_file("trace", 0644, d_cpu,
 -                              (void *) cpu, &tracing_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'trace' entry\n");
 +      trace_create_file("trace", 0644, d_cpu,
 +                      (void *) cpu, &tracing_fops);
  
 -      entry = debugfs_create_file("trace_pipe_raw", 0444, d_cpu,
 -                                  (void *) cpu, &tracing_buffers_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'trace_pipe_raw' entry\n");
 +      trace_create_file("trace_pipe_raw", 0444, d_cpu,
 +                      (void *) cpu, &tracing_buffers_fops);
  }
  
  #ifdef CONFIG_FTRACE_SELFTEST
@@@ -3760,22 -3781,6 +3766,22 @@@ static const struct file_operations tra
        .write = trace_options_core_write,
  };
  
 +struct dentry *trace_create_file(const char *name,
 +                               mode_t mode,
 +                               struct dentry *parent,
 +                               void *data,
 +                               const struct file_operations *fops)
 +{
 +      struct dentry *ret;
 +
 +      ret = debugfs_create_file(name, mode, parent, data, fops);
 +      if (!ret)
 +              pr_warning("Could not create debugfs '%s' entry\n", name);
 +
 +      return ret;
 +}
 +
 +
  static struct dentry *trace_options_init_dentry(void)
  {
        struct dentry *d_tracer;
@@@ -3803,6 -3808,7 +3809,6 @@@ create_trace_option_file(struct trace_o
                         struct tracer_opt *opt)
  {
        struct dentry *t_options;
 -      struct dentry *entry;
  
        t_options = trace_options_init_dentry();
        if (!t_options)
        topt->flags = flags;
        topt->opt = opt;
  
 -      entry = debugfs_create_file(opt->name, 0644, t_options, topt,
 +      topt->entry = trace_create_file(opt->name, 0644, t_options, topt,
                                    &trace_options_fops);
  
 -      topt->entry = entry;
 -
  }
  
  static struct trace_option_dentry *
@@@ -3868,81 -3876,123 +3874,81 @@@ static struct dentry 
  create_trace_option_core_file(const char *option, long index)
  {
        struct dentry *t_options;
 -      struct dentry *entry;
  
        t_options = trace_options_init_dentry();
        if (!t_options)
                return NULL;
  
 -      entry = debugfs_create_file(option, 0644, t_options, (void *)index,
 +      return trace_create_file(option, 0644, t_options, (void *)index,
                                    &trace_options_core_fops);
 -
 -      return entry;
  }
  
  static __init void create_trace_options_dir(void)
  {
        struct dentry *t_options;
 -      struct dentry *entry;
        int i;
  
        t_options = trace_options_init_dentry();
        if (!t_options)
                return;
  
 -      for (i = 0; trace_options[i]; i++) {
 -              entry = create_trace_option_core_file(trace_options[i], i);
 -              if (!entry)
 -                      pr_warning("Could not create debugfs %s entry\n",
 -                                 trace_options[i]);
 -      }
 +      for (i = 0; trace_options[i]; i++)
 +              create_trace_option_core_file(trace_options[i], i);
  }
  
  static __init int tracer_init_debugfs(void)
  {
        struct dentry *d_tracer;
 -      struct dentry *entry;
        int cpu;
  
        d_tracer = tracing_init_dentry();
  
 -      entry = debugfs_create_file("tracing_enabled", 0644, d_tracer,
 -                                  &global_trace, &tracing_ctrl_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'tracing_enabled' entry\n");
 +      trace_create_file("tracing_enabled", 0644, d_tracer,
 +                      &global_trace, &tracing_ctrl_fops);
  
 -      entry = debugfs_create_file("trace_options", 0644, d_tracer,
 -                                  NULL, &tracing_iter_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'trace_options' entry\n");
 +      trace_create_file("trace_options", 0644, d_tracer,
 +                      NULL, &tracing_iter_fops);
  
 -      create_trace_options_dir();
 +      trace_create_file("tracing_cpumask", 0644, d_tracer,
 +                      NULL, &tracing_cpumask_fops);
 +
 +      trace_create_file("trace", 0644, d_tracer,
 +                      (void *) TRACE_PIPE_ALL_CPU, &tracing_fops);
 +
 +      trace_create_file("available_tracers", 0444, d_tracer,
 +                      &global_trace, &show_traces_fops);
 +
 +      trace_create_file("current_tracer", 0444, d_tracer,
 +                      &global_trace, &set_tracer_fops);
  
 -      entry = debugfs_create_file("tracing_cpumask", 0644, d_tracer,
 -                                  NULL, &tracing_cpumask_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'tracing_cpumask' entry\n");
 -
 -      entry = debugfs_create_file("trace", 0644, d_tracer,
 -                               (void *) TRACE_PIPE_ALL_CPU, &tracing_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'trace' entry\n");
 -
 -      entry = debugfs_create_file("available_tracers", 0444, d_tracer,
 -                                  &global_trace, &show_traces_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'available_tracers' entry\n");
 -
 -      entry = debugfs_create_file("current_tracer", 0444, d_tracer,
 -                                  &global_trace, &set_tracer_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'current_tracer' entry\n");
 -
 -      entry = debugfs_create_file("tracing_max_latency", 0644, d_tracer,
 -                                  &tracing_max_latency,
 -                                  &tracing_max_lat_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'tracing_max_latency' entry\n");
 -
 -      entry = debugfs_create_file("tracing_thresh", 0644, d_tracer,
 -                                  &tracing_thresh, &tracing_max_lat_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'tracing_thresh' entry\n");
 -      entry = debugfs_create_file("README", 0644, d_tracer,
 -                                  NULL, &tracing_readme_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs 'README' entry\n");
 -
 -      entry = debugfs_create_file("trace_pipe", 0444, d_tracer,
 +      trace_create_file("tracing_max_latency", 0644, d_tracer,
 +                      &tracing_max_latency, &tracing_max_lat_fops);
 +
 +      trace_create_file("tracing_thresh", 0644, d_tracer,
 +                      &tracing_thresh, &tracing_max_lat_fops);
 +
 +      trace_create_file("README", 0644, d_tracer,
 +                      NULL, &tracing_readme_fops);
 +
 +      trace_create_file("trace_pipe", 0444, d_tracer,
                        (void *) TRACE_PIPE_ALL_CPU, &tracing_pipe_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'trace_pipe' entry\n");
 -
 -      entry = debugfs_create_file("buffer_size_kb", 0644, d_tracer,
 -                                  &global_trace, &tracing_entries_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'buffer_size_kb' entry\n");
 -
 -      entry = debugfs_create_file("trace_marker", 0220, d_tracer,
 -                                  NULL, &tracing_mark_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'trace_marker' entry\n");
 +
 +      trace_create_file("buffer_size_kb", 0644, d_tracer,
 +                      &global_trace, &tracing_entries_fops);
 +
 +      trace_create_file("trace_marker", 0220, d_tracer,
 +                      NULL, &tracing_mark_fops);
  
  #ifdef CONFIG_DYNAMIC_FTRACE
 -      entry = debugfs_create_file("dyn_ftrace_total_info", 0444, d_tracer,
 -                                  &ftrace_update_tot_cnt,
 -                                  &tracing_dyn_info_fops);
 -      if (!entry)
 -              pr_warning("Could not create debugfs "
 -                         "'dyn_ftrace_total_info' entry\n");
 +      trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
 +                      &ftrace_update_tot_cnt, &tracing_dyn_info_fops);
  #endif
  #ifdef CONFIG_SYSPROF_TRACER
        init_tracer_sysprof_debugfs(d_tracer);
  #endif
  
 +      create_trace_options_dir();
 +
        for_each_tracing_cpu(cpu)
                tracing_init_debugfs_percpu(cpu);