sched: Eliminate the ts->idle_lastupdate field
[safe/jmp/linux-2.6] / kernel / trace / trace_branch.c
index e6e3291..b9bc4d4 100644 (file)
@@ -30,9 +30,11 @@ static struct trace_array *branch_tracer;
 static void
 probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
 {
+       struct ftrace_event_call *call = &event_branch;
        struct trace_array *tr = branch_tracer;
        struct ring_buffer_event *event;
        struct trace_branch *entry;
+       struct ring_buffer *buffer;
        unsigned long flags;
        int cpu, pc;
        const char *p;
@@ -53,7 +55,8 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
                goto out;
 
        pc = preempt_count();
-       event = trace_buffer_lock_reserve(tr, TRACE_BRANCH,
+       buffer = tr->buffer;
+       event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
                                          sizeof(*entry), flags, pc);
        if (!event)
                goto out;
@@ -73,7 +76,8 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
        entry->line = f->line;
        entry->correct = val == expect;
 
-       ring_buffer_unlock_commit(tr->buffer, event);
+       if (!filter_check_discard(call, entry, buffer, event))
+               ring_buffer_unlock_commit(buffer, event);
 
  out:
        atomic_dec(&tr->data[cpu]->disabled);
@@ -155,6 +159,13 @@ static enum print_line_t trace_branch_print(struct trace_iterator *iter,
        return TRACE_TYPE_HANDLED;
 }
 
+static void branch_print_header(struct seq_file *s)
+{
+       seq_puts(s, "#           TASK-PID    CPU#    TIMESTAMP  CORRECT"
+               "  FUNC:FILE:LINE\n");
+       seq_puts(s, "#              | |       |          |         |   "
+               "    |\n");
+}
 
 static struct trace_event trace_branch_event = {
        .type           = TRACE_BRANCH,
@@ -169,6 +180,7 @@ static struct tracer branch_trace __read_mostly =
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest       = trace_selftest_startup_branch,
 #endif /* CONFIG_FTRACE_SELFTEST */
+       .print_header   = branch_print_header,
 };
 
 __init static int init_branch_tracer(void)
@@ -295,8 +307,23 @@ static int annotated_branch_stat_cmp(void *p1, void *p2)
                return -1;
        if (percent_a > percent_b)
                return 1;
-       else
-               return 0;
+
+       if (a->incorrect < b->incorrect)
+               return -1;
+       if (a->incorrect > b->incorrect)
+               return 1;
+
+       /*
+        * Since the above shows worse (incorrect) cases
+        * first, we continue that by showing best (correct)
+        * cases last.
+        */
+       if (a->correct > b->correct)
+               return -1;
+       if (a->correct < b->correct)
+               return 1;
+
+       return 0;
 }
 
 static struct tracer_stat annotated_branch_stats = {