Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 1 | /* |
| 2 | * builtin-diff.c |
| 3 | * |
| 4 | * Builtin diff command: Analyze two perf.data input files, look up and read |
| 5 | * DSOs and symbol information, sort them and produce a diff. |
| 6 | */ |
| 7 | #include "builtin.h" |
| 8 | |
| 9 | #include "util/debug.h" |
| 10 | #include "util/event.h" |
| 11 | #include "util/hist.h" |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 12 | #include "util/evsel.h" |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 13 | #include "util/evlist.h" |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 14 | #include "util/session.h" |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 15 | #include "util/tool.h" |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 16 | #include "util/sort.h" |
| 17 | #include "util/symbol.h" |
| 18 | #include "util/util.h" |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 22 | static char const *input_old = "perf.data.old", |
| 23 | *input_new = "perf.data"; |
Arnaldo Carvalho de Melo | 604c5c9 | 2009-12-16 14:09:53 -0200 | [diff] [blame] | 24 | static char diff__default_sort_order[] = "dso,symbol"; |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 25 | static bool force; |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 26 | static bool show_displacement; |
Jiri Olsa | 61949b2 | 2012-10-05 16:44:44 +0200 | [diff] [blame] | 27 | static bool show_period; |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 28 | static bool show_formula; |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 29 | static bool show_baseline_only; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 30 | static bool sort_compute; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 31 | |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 32 | static s64 compute_wdiff_w1; |
| 33 | static s64 compute_wdiff_w2; |
| 34 | |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 35 | enum { |
| 36 | COMPUTE_DELTA, |
| 37 | COMPUTE_RATIO, |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 38 | COMPUTE_WEIGHTED_DIFF, |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 39 | COMPUTE_MAX, |
| 40 | }; |
| 41 | |
| 42 | const char *compute_names[COMPUTE_MAX] = { |
| 43 | [COMPUTE_DELTA] = "delta", |
| 44 | [COMPUTE_RATIO] = "ratio", |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 45 | [COMPUTE_WEIGHTED_DIFF] = "wdiff", |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | static int compute; |
| 49 | |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 50 | static int setup_compute_opt_wdiff(char *opt) |
| 51 | { |
| 52 | char *w1_str = opt; |
| 53 | char *w2_str; |
| 54 | |
| 55 | int ret = -EINVAL; |
| 56 | |
| 57 | if (!opt) |
| 58 | goto out; |
| 59 | |
| 60 | w2_str = strchr(opt, ','); |
| 61 | if (!w2_str) |
| 62 | goto out; |
| 63 | |
| 64 | *w2_str++ = 0x0; |
| 65 | if (!*w2_str) |
| 66 | goto out; |
| 67 | |
| 68 | compute_wdiff_w1 = strtol(w1_str, NULL, 10); |
| 69 | compute_wdiff_w2 = strtol(w2_str, NULL, 10); |
| 70 | |
| 71 | if (!compute_wdiff_w1 || !compute_wdiff_w2) |
| 72 | goto out; |
| 73 | |
| 74 | pr_debug("compute wdiff w1(%" PRId64 ") w2(%" PRId64 ")\n", |
| 75 | compute_wdiff_w1, compute_wdiff_w2); |
| 76 | |
| 77 | ret = 0; |
| 78 | |
| 79 | out: |
| 80 | if (ret) |
| 81 | pr_err("Failed: wrong weight data, use 'wdiff:w1,w2'\n"); |
| 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | static int setup_compute_opt(char *opt) |
| 87 | { |
| 88 | if (compute == COMPUTE_WEIGHTED_DIFF) |
| 89 | return setup_compute_opt_wdiff(opt); |
| 90 | |
| 91 | if (opt) { |
| 92 | pr_err("Failed: extra option specified '%s'", opt); |
| 93 | return -EINVAL; |
| 94 | } |
| 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 99 | static int setup_compute(const struct option *opt, const char *str, |
| 100 | int unset __maybe_unused) |
| 101 | { |
| 102 | int *cp = (int *) opt->value; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 103 | char *cstr = (char *) str; |
| 104 | char buf[50]; |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 105 | unsigned i; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 106 | char *option; |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 107 | |
| 108 | if (!str) { |
| 109 | *cp = COMPUTE_DELTA; |
| 110 | return 0; |
| 111 | } |
| 112 | |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 113 | if (*str == '+') { |
| 114 | sort_compute = true; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 115 | cstr = (char *) ++str; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 116 | if (!*str) |
| 117 | return 0; |
| 118 | } |
| 119 | |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 120 | option = strchr(str, ':'); |
| 121 | if (option) { |
| 122 | unsigned len = option++ - str; |
| 123 | |
| 124 | /* |
| 125 | * The str data are not writeable, so we need |
| 126 | * to use another buffer. |
| 127 | */ |
| 128 | |
| 129 | /* No option value is longer. */ |
| 130 | if (len >= sizeof(buf)) |
| 131 | return -EINVAL; |
| 132 | |
| 133 | strncpy(buf, str, len); |
| 134 | buf[len] = 0x0; |
| 135 | cstr = buf; |
| 136 | } |
| 137 | |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 138 | for (i = 0; i < COMPUTE_MAX; i++) |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 139 | if (!strcmp(cstr, compute_names[i])) { |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 140 | *cp = i; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 141 | return setup_compute_opt(option); |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | pr_err("Failed: '%s' is not computation method " |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 145 | "(use 'delta','ratio' or 'wdiff')\n", str); |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 146 | return -EINVAL; |
| 147 | } |
| 148 | |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 149 | double perf_diff__period_percent(struct hist_entry *he, u64 period) |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 150 | { |
| 151 | u64 total = he->hists->stats.total_period; |
| 152 | return (period * 100.0) / total; |
| 153 | } |
| 154 | |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 155 | double perf_diff__compute_delta(struct hist_entry *he, struct hist_entry *pair) |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 156 | { |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 157 | double new_percent = perf_diff__period_percent(he, he->stat.period); |
| 158 | double old_percent = perf_diff__period_percent(pair, pair->stat.period); |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 159 | |
| 160 | he->diff.period_ratio_delta = new_percent - old_percent; |
| 161 | he->diff.computed = true; |
| 162 | return he->diff.period_ratio_delta; |
| 163 | } |
| 164 | |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 165 | double perf_diff__compute_ratio(struct hist_entry *he, struct hist_entry *pair) |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 166 | { |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 167 | double new_period = he->stat.period; |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 168 | double old_period = pair->stat.period; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 169 | |
| 170 | he->diff.computed = true; |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 171 | he->diff.period_ratio = new_period / old_period; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 172 | return he->diff.period_ratio; |
| 173 | } |
| 174 | |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 175 | s64 perf_diff__compute_wdiff(struct hist_entry *he, struct hist_entry *pair) |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 176 | { |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 177 | u64 new_period = he->stat.period; |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 178 | u64 old_period = pair->stat.period; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 179 | |
| 180 | he->diff.computed = true; |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 181 | he->diff.wdiff = new_period * compute_wdiff_w2 - |
| 182 | old_period * compute_wdiff_w1; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 183 | |
| 184 | return he->diff.wdiff; |
| 185 | } |
| 186 | |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 187 | static int formula_delta(struct hist_entry *he, struct hist_entry *pair, |
| 188 | char *buf, size_t size) |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 189 | { |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 190 | return scnprintf(buf, size, |
| 191 | "(%" PRIu64 " * 100 / %" PRIu64 ") - " |
| 192 | "(%" PRIu64 " * 100 / %" PRIu64 ")", |
| 193 | he->stat.period, he->hists->stats.total_period, |
| 194 | pair->stat.period, pair->hists->stats.total_period); |
| 195 | } |
| 196 | |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 197 | static int formula_ratio(struct hist_entry *he, struct hist_entry *pair, |
| 198 | char *buf, size_t size) |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 199 | { |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 200 | double new_period = he->stat.period; |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 201 | double old_period = pair->stat.period; |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 202 | |
| 203 | return scnprintf(buf, size, "%.0F / %.0F", new_period, old_period); |
| 204 | } |
| 205 | |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 206 | static int formula_wdiff(struct hist_entry *he, struct hist_entry *pair, |
| 207 | char *buf, size_t size) |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 208 | { |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 209 | u64 new_period = he->stat.period; |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 210 | u64 old_period = pair->stat.period; |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 211 | |
| 212 | return scnprintf(buf, size, |
| 213 | "(%" PRIu64 " * " "%" PRId64 ") - (%" PRIu64 " * " "%" PRId64 ")", |
| 214 | new_period, compute_wdiff_w2, old_period, compute_wdiff_w1); |
| 215 | } |
| 216 | |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 217 | int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair, |
| 218 | char *buf, size_t size) |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 219 | { |
| 220 | switch (compute) { |
| 221 | case COMPUTE_DELTA: |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 222 | return formula_delta(he, pair, buf, size); |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 223 | case COMPUTE_RATIO: |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 224 | return formula_ratio(he, pair, buf, size); |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 225 | case COMPUTE_WEIGHTED_DIFF: |
Jiri Olsa | f4c8bae | 2012-11-28 14:52:41 +0100 | [diff] [blame^] | 226 | return formula_wdiff(he, pair, buf, size); |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 227 | default: |
| 228 | BUG_ON(1); |
| 229 | } |
| 230 | |
| 231 | return -1; |
| 232 | } |
| 233 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 234 | static int hists__add_entry(struct hists *self, |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 235 | struct addr_location *al, u64 period) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 236 | { |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 237 | if (__hists__add_entry(self, al, NULL, period) != NULL) |
Arnaldo Carvalho de Melo | 28e2a10 | 2010-05-09 13:02:23 -0300 | [diff] [blame] | 238 | return 0; |
| 239 | return -ENOMEM; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 240 | } |
| 241 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 242 | static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 243 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 244 | struct perf_sample *sample, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 245 | struct perf_evsel *evsel, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 246 | struct machine *machine) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 247 | { |
| 248 | struct addr_location al; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 249 | |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 250 | if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 251 | pr_warning("problem processing %d event, skipping it.\n", |
| 252 | event->header.type); |
| 253 | return -1; |
| 254 | } |
| 255 | |
Jiri Olsa | d88c48f | 2012-10-05 16:44:46 +0200 | [diff] [blame] | 256 | if (al.filtered) |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 257 | return 0; |
| 258 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 259 | if (hists__add_entry(&evsel->hists, &al, sample->period)) { |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 260 | pr_warning("problem incrementing symbol period, skipping event\n"); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 261 | return -1; |
| 262 | } |
| 263 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 264 | evsel->hists.stats.total_period += sample->period; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 265 | return 0; |
| 266 | } |
| 267 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 268 | static struct perf_tool tool = { |
| 269 | .sample = diff__process_sample_event, |
| 270 | .mmap = perf_event__process_mmap, |
| 271 | .comm = perf_event__process_comm, |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 272 | .exit = perf_event__process_exit, |
| 273 | .fork = perf_event__process_fork, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 274 | .lost = perf_event__process_lost, |
| 275 | .ordered_samples = true, |
| 276 | .ordering_requires_timestamps = true, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 277 | }; |
| 278 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 279 | static void insert_hist_entry_by_name(struct rb_root *root, |
| 280 | struct hist_entry *he) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 281 | { |
| 282 | struct rb_node **p = &root->rb_node; |
| 283 | struct rb_node *parent = NULL; |
| 284 | struct hist_entry *iter; |
| 285 | |
| 286 | while (*p != NULL) { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 287 | parent = *p; |
| 288 | iter = rb_entry(parent, struct hist_entry, rb_node); |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 289 | if (hist_entry__cmp(he, iter) < 0) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 290 | p = &(*p)->rb_left; |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 291 | else |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 292 | p = &(*p)->rb_right; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | rb_link_node(&he->rb_node, parent, p); |
| 296 | rb_insert_color(&he->rb_node, root); |
| 297 | } |
| 298 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 299 | static void hists__name_resort(struct hists *self, bool sort) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 300 | { |
| 301 | unsigned long position = 1; |
| 302 | struct rb_root tmp = RB_ROOT; |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 303 | struct rb_node *next = rb_first(&self->entries); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 304 | |
| 305 | while (next != NULL) { |
| 306 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); |
| 307 | |
| 308 | next = rb_next(&n->rb_node); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 309 | n->position = position++; |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 310 | |
| 311 | if (sort) { |
| 312 | rb_erase(&n->rb_node, &self->entries); |
| 313 | insert_hist_entry_by_name(&tmp, n); |
| 314 | } |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 315 | } |
| 316 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 317 | if (sort) |
| 318 | self->entries = tmp; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 319 | } |
| 320 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 321 | static struct perf_evsel *evsel_match(struct perf_evsel *evsel, |
| 322 | struct perf_evlist *evlist) |
| 323 | { |
| 324 | struct perf_evsel *e; |
| 325 | |
| 326 | list_for_each_entry(e, &evlist->entries, node) |
| 327 | if (perf_evsel__match2(evsel, e)) |
| 328 | return e; |
| 329 | |
| 330 | return NULL; |
| 331 | } |
| 332 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 333 | static void perf_evlist__resort_hists(struct perf_evlist *evlist, bool name) |
| 334 | { |
| 335 | struct perf_evsel *evsel; |
| 336 | |
| 337 | list_for_each_entry(evsel, &evlist->entries, node) { |
| 338 | struct hists *hists = &evsel->hists; |
| 339 | |
| 340 | hists__output_resort(hists); |
| 341 | |
| 342 | /* |
| 343 | * The hists__name_resort only sets possition |
| 344 | * if name is false. |
| 345 | */ |
| 346 | if (name || ((!name) && show_displacement)) |
| 347 | hists__name_resort(hists, name); |
| 348 | } |
| 349 | } |
| 350 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 351 | static void hists__baseline_only(struct hists *hists) |
| 352 | { |
| 353 | struct rb_node *next = rb_first(&hists->entries); |
| 354 | |
| 355 | while (next != NULL) { |
| 356 | struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); |
| 357 | |
| 358 | next = rb_next(&he->rb_node); |
Arnaldo Carvalho de Melo | b821c73 | 2012-10-25 14:42:45 -0200 | [diff] [blame] | 359 | if (!hist_entry__next_pair(he)) { |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 360 | rb_erase(&he->rb_node, &hists->entries); |
| 361 | hist_entry__free(he); |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 366 | static void hists__precompute(struct hists *hists) |
| 367 | { |
| 368 | struct rb_node *next = rb_first(&hists->entries); |
| 369 | |
| 370 | while (next != NULL) { |
| 371 | struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 372 | struct hist_entry *pair = hist_entry__next_pair(he); |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 373 | |
| 374 | next = rb_next(&he->rb_node); |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 375 | if (!pair) |
| 376 | continue; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 377 | |
| 378 | switch (compute) { |
| 379 | case COMPUTE_DELTA: |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 380 | perf_diff__compute_delta(he, pair); |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 381 | break; |
| 382 | case COMPUTE_RATIO: |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 383 | perf_diff__compute_ratio(he, pair); |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 384 | break; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 385 | case COMPUTE_WEIGHTED_DIFF: |
Jiri Olsa | 05472da | 2012-11-28 14:52:40 +0100 | [diff] [blame] | 386 | perf_diff__compute_wdiff(he, pair); |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 387 | break; |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 388 | default: |
| 389 | BUG_ON(1); |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | static int64_t cmp_doubles(double l, double r) |
| 395 | { |
| 396 | if (l > r) |
| 397 | return -1; |
| 398 | else if (l < r) |
| 399 | return 1; |
| 400 | else |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static int64_t |
| 405 | hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, |
| 406 | int c) |
| 407 | { |
| 408 | switch (c) { |
| 409 | case COMPUTE_DELTA: |
| 410 | { |
| 411 | double l = left->diff.period_ratio_delta; |
| 412 | double r = right->diff.period_ratio_delta; |
| 413 | |
| 414 | return cmp_doubles(l, r); |
| 415 | } |
| 416 | case COMPUTE_RATIO: |
| 417 | { |
| 418 | double l = left->diff.period_ratio; |
| 419 | double r = right->diff.period_ratio; |
| 420 | |
| 421 | return cmp_doubles(l, r); |
| 422 | } |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 423 | case COMPUTE_WEIGHTED_DIFF: |
| 424 | { |
| 425 | s64 l = left->diff.wdiff; |
| 426 | s64 r = right->diff.wdiff; |
| 427 | |
| 428 | return r - l; |
| 429 | } |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 430 | default: |
| 431 | BUG_ON(1); |
| 432 | } |
| 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | static void insert_hist_entry_by_compute(struct rb_root *root, |
| 438 | struct hist_entry *he, |
| 439 | int c) |
| 440 | { |
| 441 | struct rb_node **p = &root->rb_node; |
| 442 | struct rb_node *parent = NULL; |
| 443 | struct hist_entry *iter; |
| 444 | |
| 445 | while (*p != NULL) { |
| 446 | parent = *p; |
| 447 | iter = rb_entry(parent, struct hist_entry, rb_node); |
| 448 | if (hist_entry__cmp_compute(he, iter, c) < 0) |
| 449 | p = &(*p)->rb_left; |
| 450 | else |
| 451 | p = &(*p)->rb_right; |
| 452 | } |
| 453 | |
| 454 | rb_link_node(&he->rb_node, parent, p); |
| 455 | rb_insert_color(&he->rb_node, root); |
| 456 | } |
| 457 | |
| 458 | static void hists__compute_resort(struct hists *hists) |
| 459 | { |
| 460 | struct rb_root tmp = RB_ROOT; |
| 461 | struct rb_node *next = rb_first(&hists->entries); |
| 462 | |
| 463 | while (next != NULL) { |
| 464 | struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); |
| 465 | |
| 466 | next = rb_next(&he->rb_node); |
| 467 | |
| 468 | rb_erase(&he->rb_node, &hists->entries); |
| 469 | insert_hist_entry_by_compute(&tmp, he, compute); |
| 470 | } |
| 471 | |
| 472 | hists->entries = tmp; |
| 473 | } |
| 474 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 475 | static void hists__process(struct hists *old, struct hists *new) |
| 476 | { |
Arnaldo Carvalho de Melo | 95529be | 2012-11-08 17:54:33 -0300 | [diff] [blame] | 477 | hists__match(new, old); |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 478 | |
| 479 | if (show_baseline_only) |
| 480 | hists__baseline_only(new); |
Arnaldo Carvalho de Melo | bfaef4b | 2012-11-08 18:08:26 -0300 | [diff] [blame] | 481 | else |
| 482 | hists__link(new, old); |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 483 | |
Jiri Olsa | 96c47f1 | 2012-10-05 16:44:42 +0200 | [diff] [blame] | 484 | if (sort_compute) { |
| 485 | hists__precompute(new); |
| 486 | hists__compute_resort(new); |
| 487 | } |
| 488 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 489 | hists__fprintf(new, true, 0, 0, stdout); |
| 490 | } |
| 491 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 492 | static int __cmd_diff(void) |
| 493 | { |
| 494 | int ret, i; |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 495 | #define older (session[0]) |
| 496 | #define newer (session[1]) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 497 | struct perf_session *session[2]; |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 498 | struct perf_evlist *evlist_new, *evlist_old; |
| 499 | struct perf_evsel *evsel; |
| 500 | bool first = true; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 501 | |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 502 | older = perf_session__new(input_old, O_RDONLY, force, false, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 503 | &tool); |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 504 | newer = perf_session__new(input_new, O_RDONLY, force, false, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 505 | &tool); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 506 | if (session[0] == NULL || session[1] == NULL) |
| 507 | return -ENOMEM; |
| 508 | |
| 509 | for (i = 0; i < 2; ++i) { |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 510 | ret = perf_session__process_events(session[i], &tool); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 511 | if (ret) |
| 512 | goto out_delete; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 513 | } |
| 514 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 515 | evlist_old = older->evlist; |
| 516 | evlist_new = newer->evlist; |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 517 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 518 | perf_evlist__resort_hists(evlist_old, true); |
| 519 | perf_evlist__resort_hists(evlist_new, false); |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 520 | |
| 521 | list_for_each_entry(evsel, &evlist_new->entries, node) { |
| 522 | struct perf_evsel *evsel_old; |
| 523 | |
| 524 | evsel_old = evsel_match(evsel, evlist_old); |
| 525 | if (!evsel_old) |
| 526 | continue; |
| 527 | |
| 528 | fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n", |
| 529 | perf_evsel__name(evsel)); |
| 530 | |
| 531 | first = false; |
| 532 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 533 | hists__process(&evsel_old->hists, &evsel->hists); |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 534 | } |
| 535 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 536 | out_delete: |
| 537 | for (i = 0; i < 2; ++i) |
| 538 | perf_session__delete(session[i]); |
| 539 | return ret; |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 540 | #undef older |
| 541 | #undef newer |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 542 | } |
| 543 | |
Arnaldo Carvalho de Melo | 0422a4f | 2009-12-18 16:35:58 -0200 | [diff] [blame] | 544 | static const char * const diff_usage[] = { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 545 | "perf diff [<options>] [old_file] [new_file]", |
Arnaldo Carvalho de Melo | 0422a4f | 2009-12-18 16:35:58 -0200 | [diff] [blame] | 546 | NULL, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 547 | }; |
| 548 | |
| 549 | static const struct option options[] = { |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 550 | OPT_INCR('v', "verbose", &verbose, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 551 | "be more verbose (show symbol address, etc)"), |
Shawn Bohrer | 3429555 | 2010-11-30 19:57:11 -0600 | [diff] [blame] | 552 | OPT_BOOLEAN('M', "displacement", &show_displacement, |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 553 | "Show position displacement relative to baseline"), |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame] | 554 | OPT_BOOLEAN('b', "baseline-only", &show_baseline_only, |
| 555 | "Show only items with match in baseline"), |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 556 | OPT_CALLBACK('c', "compute", &compute, |
| 557 | "delta,ratio,wdiff:w1,w2 (default delta)", |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 558 | "Entries differential computation selection", |
| 559 | setup_compute), |
Jiri Olsa | 61949b2 | 2012-10-05 16:44:44 +0200 | [diff] [blame] | 560 | OPT_BOOLEAN('p', "period", &show_period, |
| 561 | "Show period values."), |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 562 | OPT_BOOLEAN('F', "formula", &show_formula, |
| 563 | "Show formula."), |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 564 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
| 565 | "dump raw trace in ASCII"), |
| 566 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
| 567 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
| 568 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 569 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
| 570 | "only consider symbols in these dsos"), |
| 571 | OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
| 572 | "only consider symbols in these comms"), |
| 573 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
| 574 | "only consider these symbols"), |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 575 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
| 576 | "sort by key(s): pid, comm, dso, symbol, parent"), |
| 577 | OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", |
| 578 | "separator for columns, no spaces will be added between " |
| 579 | "columns '.' is reserved."), |
David Ahern | ec5761e | 2010-12-09 13:27:07 -0700 | [diff] [blame] | 580 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
| 581 | "Look for files with symbols relative to this directory"), |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 582 | OPT_END() |
| 583 | }; |
| 584 | |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 585 | static void ui_init(void) |
| 586 | { |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 587 | /* |
| 588 | * Display baseline/delta/ratio/displacement/ |
| 589 | * formula/periods columns. |
| 590 | */ |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 591 | perf_hpp__column_enable(PERF_HPP__BASELINE); |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 592 | |
| 593 | switch (compute) { |
| 594 | case COMPUTE_DELTA: |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 595 | perf_hpp__column_enable(PERF_HPP__DELTA); |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 596 | break; |
| 597 | case COMPUTE_RATIO: |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 598 | perf_hpp__column_enable(PERF_HPP__RATIO); |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 599 | break; |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 600 | case COMPUTE_WEIGHTED_DIFF: |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 601 | perf_hpp__column_enable(PERF_HPP__WEIGHTED_DIFF); |
Jiri Olsa | 81d5f95 | 2012-10-05 16:44:43 +0200 | [diff] [blame] | 602 | break; |
Jiri Olsa | 7aaf6b3 | 2012-10-05 16:44:41 +0200 | [diff] [blame] | 603 | default: |
| 604 | BUG_ON(1); |
| 605 | }; |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 606 | |
| 607 | if (show_displacement) |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 608 | perf_hpp__column_enable(PERF_HPP__DISPL); |
Jiri Olsa | 61949b2 | 2012-10-05 16:44:44 +0200 | [diff] [blame] | 609 | |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 610 | if (show_formula) |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 611 | perf_hpp__column_enable(PERF_HPP__FORMULA); |
Jiri Olsa | ed279da | 2012-10-05 16:44:45 +0200 | [diff] [blame] | 612 | |
Jiri Olsa | 61949b2 | 2012-10-05 16:44:44 +0200 | [diff] [blame] | 613 | if (show_period) { |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 614 | perf_hpp__column_enable(PERF_HPP__PERIOD); |
| 615 | perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE); |
Jiri Olsa | 61949b2 | 2012-10-05 16:44:44 +0200 | [diff] [blame] | 616 | } |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 617 | } |
| 618 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 619 | int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 620 | { |
Arnaldo Carvalho de Melo | 604c5c9 | 2009-12-16 14:09:53 -0200 | [diff] [blame] | 621 | sort_order = diff__default_sort_order; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 622 | argc = parse_options(argc, argv, options, diff_usage, 0); |
| 623 | if (argc) { |
| 624 | if (argc > 2) |
| 625 | usage_with_options(diff_usage, options); |
| 626 | if (argc == 2) { |
| 627 | input_old = argv[0]; |
| 628 | input_new = argv[1]; |
| 629 | } else |
| 630 | input_new = argv[0]; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 631 | } else if (symbol_conf.default_guest_vmlinux_name || |
| 632 | symbol_conf.default_guest_kallsyms) { |
| 633 | input_old = "perf.data.host"; |
| 634 | input_new = "perf.data.guest"; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 635 | } |
| 636 | |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 637 | symbol_conf.exclude_other = false; |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 638 | if (symbol__init() < 0) |
| 639 | return -1; |
| 640 | |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 641 | ui_init(); |
| 642 | |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 643 | setup_sorting(diff_usage, options); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 644 | setup_pager(); |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 645 | |
| 646 | sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL); |
| 647 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL); |
| 648 | sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL); |
| 649 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 650 | return __cmd_diff(); |
| 651 | } |