Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / tools / perf / builtin-diff.c
index 6ef80f22c1e2fefe5cc2d6c68864b72b1a730a30..8bff543acaab7a093ed3579b42b24bc15e8d14ab 100644 (file)
@@ -60,7 +60,6 @@ static int data__files_cnt;
 #define data__for_each_file(i, d) data__for_each_file_start(i, d, 0)
 #define data__for_each_file_new(i, d) data__for_each_file_start(i, d, 1)
 
-static char diff__default_sort_order[] = "dso,symbol";
 static bool force;
 static bool show_period;
 static bool show_formula;
@@ -341,11 +340,16 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
                return -1;
        }
 
-       if (al.filtered == 0) {
-               evsel->hists.stats.total_non_filtered_period += sample->period;
-               evsel->hists.nr_non_filtered_entries++;
-       }
+       /*
+        * The total_period is updated here before going to the output
+        * tree since normally only the baseline hists will call
+        * hists__output_resort() and precompute needs the total
+        * period in order to sort entries by percentage delta.
+        */
        evsel->hists.stats.total_period += sample->period;
+       if (!al.filtered)
+               evsel->hists.stats.total_non_filtered_period += sample->period;
+
        return 0;
 }
 
@@ -573,10 +577,7 @@ static void hists__compute_resort(struct hists *hists)
        hists->entries = RB_ROOT;
        next = rb_first(root);
 
-       hists->nr_entries = 0;
-       hists->nr_non_filtered_entries = 0;
-       hists->stats.total_period = 0;
-       hists->stats.total_non_filtered_period = 0;
+       hists__reset_stats(hists);
        hists__reset_col_len(hists);
 
        while (next != NULL) {
@@ -586,7 +587,10 @@ static void hists__compute_resort(struct hists *hists)
                next = rb_next(&he->rb_node_in);
 
                insert_hist_entry_by_compute(&hists->entries, he, compute);
-               hists__inc_nr_entries(hists, he);
+               hists__inc_stats(hists, he);
+
+               if (!he->filtered)
+                       hists__calc_col_len(hists, he);
        }
 }
 
@@ -736,7 +740,8 @@ static const struct option options[] = {
        OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
                   "only consider these symbols"),
        OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
-                  "sort by key(s): pid, comm, dso, symbol, parent"),
+                  "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
+                  " Please refer the man page for the complete list."),
        OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
                   "separator for columns, no spaces will be added between "
                   "columns '.' is reserved."),
@@ -1136,7 +1141,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        perf_config(perf_default_config, NULL);
 
-       sort_order = diff__default_sort_order;
        argc = parse_options(argc, argv, options, diff_usage, 0);
 
        if (symbol__init() < 0)
@@ -1147,6 +1151,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
        ui_init();
 
+       sort__mode = SORT_MODE__DIFF;
+
        if (setup_sorting() < 0)
                usage_with_options(diff_usage, options);