diff options
Diffstat (limited to 'tools')
29 files changed, 470 insertions, 115 deletions
diff --git a/tools/perf/Documentation/perf-inject.txt b/tools/perf/Documentation/perf-inject.txt index a00a34276c54..dc7442cf3d7f 100644 --- a/tools/perf/Documentation/perf-inject.txt +++ b/tools/perf/Documentation/perf-inject.txt | |||
| @@ -41,6 +41,9 @@ OPTIONS | |||
| 41 | tasks slept. sched_switch contains a callchain where a task slept and | 41 | tasks slept. sched_switch contains a callchain where a task slept and |
| 42 | sched_stat contains a timeslice how long a task slept. | 42 | sched_stat contains a timeslice how long a task slept. |
| 43 | 43 | ||
| 44 | --kallsyms=<file>:: | ||
| 45 | kallsyms pathname | ||
| 46 | |||
| 44 | SEE ALSO | 47 | SEE ALSO |
| 45 | -------- | 48 | -------- |
| 46 | linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-archive[1] | 49 | linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-archive[1] |
diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c index 2f7073d107fd..6c1b8a75db09 100644 --- a/tools/perf/arch/powerpc/util/header.c +++ b/tools/perf/arch/powerpc/util/header.c | |||
| @@ -5,9 +5,7 @@ | |||
| 5 | #include <string.h> | 5 | #include <string.h> |
| 6 | 6 | ||
| 7 | #include "../../util/header.h" | 7 | #include "../../util/header.h" |
| 8 | 8 | #include "../../util/util.h" | |
| 9 | #define __stringify_1(x) #x | ||
| 10 | #define __stringify(x) __stringify_1(x) | ||
| 11 | 9 | ||
| 12 | #define mfspr(rn) ({unsigned long rval; \ | 10 | #define mfspr(rn) ({unsigned long rval; \ |
| 13 | asm volatile("mfspr %0," __stringify(rn) \ | 11 | asm volatile("mfspr %0," __stringify(rn) \ |
diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index 3655f24c3170..fd2868490d00 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c | |||
| @@ -37,3 +37,12 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, | |||
| 37 | 37 | ||
| 38 | return 0; | 38 | return 0; |
| 39 | } | 39 | } |
| 40 | |||
| 41 | u64 rdtsc(void) | ||
| 42 | { | ||
| 43 | unsigned int low, high; | ||
| 44 | |||
| 45 | asm volatile("rdtsc" : "=a" (low), "=d" (high)); | ||
| 46 | |||
| 47 | return low | ((u64)high) << 32; | ||
| 48 | } | ||
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index cf6a605a13e8..9a02807387d6 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
| @@ -439,6 +439,8 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | |||
| 439 | "where and how long tasks slept"), | 439 | "where and how long tasks slept"), |
| 440 | OPT_INCR('v', "verbose", &verbose, | 440 | OPT_INCR('v', "verbose", &verbose, |
| 441 | "be more verbose (show build ids, etc)"), | 441 | "be more verbose (show build ids, etc)"), |
| 442 | OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file", | ||
| 443 | "kallsyms pathname"), | ||
| 442 | OPT_END() | 444 | OPT_END() |
| 443 | }; | 445 | }; |
| 444 | const char * const inject_usage[] = { | 446 | const char * const inject_usage[] = { |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 378b85b731a7..4869050e7194 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -238,6 +238,7 @@ static struct perf_event_header finished_round_event = { | |||
| 238 | 238 | ||
| 239 | static int record__mmap_read_all(struct record *rec) | 239 | static int record__mmap_read_all(struct record *rec) |
| 240 | { | 240 | { |
| 241 | u64 bytes_written = rec->bytes_written; | ||
| 241 | int i; | 242 | int i; |
| 242 | int rc = 0; | 243 | int rc = 0; |
| 243 | 244 | ||
| @@ -250,7 +251,11 @@ static int record__mmap_read_all(struct record *rec) | |||
| 250 | } | 251 | } |
| 251 | } | 252 | } |
| 252 | 253 | ||
| 253 | if (perf_header__has_feat(&rec->session->header, HEADER_TRACING_DATA)) | 254 | /* |
| 255 | * Mark the round finished in case we wrote | ||
| 256 | * at least one event. | ||
| 257 | */ | ||
| 258 | if (bytes_written != rec->bytes_written) | ||
| 254 | rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); | 259 | rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); |
| 255 | 260 | ||
| 256 | out: | 261 | out: |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9e9c91f5b7fa..f57035b89c15 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -358,27 +358,6 @@ static void print_sample_start(struct perf_sample *sample, | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | static bool is_bts_event(struct perf_event_attr *attr) | ||
| 362 | { | ||
| 363 | return ((attr->type == PERF_TYPE_HARDWARE) && | ||
| 364 | (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) && | ||
| 365 | (attr->sample_period == 1)); | ||
| 366 | } | ||
| 367 | |||
| 368 | static bool sample_addr_correlates_sym(struct perf_event_attr *attr) | ||
| 369 | { | ||
| 370 | if ((attr->type == PERF_TYPE_SOFTWARE) && | ||
| 371 | ((attr->config == PERF_COUNT_SW_PAGE_FAULTS) || | ||
| 372 | (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MIN) || | ||
| 373 | (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ))) | ||
| 374 | return true; | ||
| 375 | |||
| 376 | if (is_bts_event(attr)) | ||
| 377 | return true; | ||
| 378 | |||
| 379 | return false; | ||
| 380 | } | ||
| 381 | |||
| 382 | static void print_sample_addr(union perf_event *event, | 361 | static void print_sample_addr(union perf_event *event, |
| 383 | struct perf_sample *sample, | 362 | struct perf_sample *sample, |
| 384 | struct machine *machine, | 363 | struct machine *machine, |
| @@ -386,24 +365,13 @@ static void print_sample_addr(union perf_event *event, | |||
| 386 | struct perf_event_attr *attr) | 365 | struct perf_event_attr *attr) |
| 387 | { | 366 | { |
| 388 | struct addr_location al; | 367 | struct addr_location al; |
| 389 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | ||
| 390 | 368 | ||
| 391 | printf("%16" PRIx64, sample->addr); | 369 | printf("%16" PRIx64, sample->addr); |
| 392 | 370 | ||
| 393 | if (!sample_addr_correlates_sym(attr)) | 371 | if (!sample_addr_correlates_sym(attr)) |
| 394 | return; | 372 | return; |
| 395 | 373 | ||
| 396 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, | 374 | perf_event__preprocess_sample_addr(event, sample, machine, thread, &al); |
| 397 | sample->addr, &al); | ||
| 398 | if (!al.map) | ||
| 399 | thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE, | ||
| 400 | sample->addr, &al); | ||
| 401 | |||
| 402 | al.cpu = sample->cpu; | ||
| 403 | al.sym = NULL; | ||
| 404 | |||
| 405 | if (al.map) | ||
| 406 | al.sym = map__find_symbol(al.map, al.addr, NULL); | ||
| 407 | 375 | ||
| 408 | if (PRINT_FIELD(SYM)) { | 376 | if (PRINT_FIELD(SYM)) { |
| 409 | printf(" "); | 377 | printf(" "); |
| @@ -427,25 +395,35 @@ static void print_sample_bts(union perf_event *event, | |||
| 427 | struct addr_location *al) | 395 | struct addr_location *al) |
| 428 | { | ||
