diff options
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/.gitignore | 1 | ||||
| -rw-r--r-- | tools/perf/Documentation/perf-timechart.txt | 3 | ||||
| -rw-r--r-- | tools/perf/Makefile | 32 | ||||
| -rw-r--r-- | tools/perf/builtin-record.c | 6 | ||||
| -rw-r--r-- | tools/perf/builtin-sched.c | 4 | ||||
| -rw-r--r-- | tools/perf/builtin-stat.c | 26 | ||||
| -rw-r--r-- | tools/perf/builtin-timechart.c | 38 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-trace.c | 6 | ||||
| -rw-r--r-- | tools/perf/design.txt | 3 | ||||
| -rwxr-xr-x | tools/perf/util/PERF-VERSION-GEN | 2 | ||||
| -rw-r--r-- | tools/perf/util/module.c | 96 | ||||
| -rw-r--r-- | tools/perf/util/parse-events.c | 54 | ||||
| -rw-r--r-- | tools/perf/util/svghelper.c | 16 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 26 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 10 | ||||
| -rw-r--r-- | tools/perf/util/trace-event-parse.c | 17 |
17 files changed, 234 insertions, 109 deletions
diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore index d69a759a1046..0854f110bf7f 100644 --- a/tools/perf/.gitignore +++ b/tools/perf/.gitignore | |||
| @@ -10,6 +10,7 @@ perf-stat | |||
| 10 | perf-top | 10 | perf-top |
| 11 | perf*.1 | 11 | perf*.1 |
| 12 | perf*.xml | 12 | perf*.xml |
| 13 | perf*.html | ||
| 13 | common-cmds.h | 14 | common-cmds.h |
| 14 | tags | 15 | tags |
| 15 | TAGS | 16 | TAGS |
diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt index 1c2ed3090cce..a7910099d6fd 100644 --- a/tools/perf/Documentation/perf-timechart.txt +++ b/tools/perf/Documentation/perf-timechart.txt | |||
| @@ -31,6 +31,9 @@ OPTIONS | |||
| 31 | -w:: | 31 | -w:: |
| 32 | --width=:: | 32 | --width=:: |
| 33 | Select the width of the SVG file (default: 1000) | 33 | Select the width of the SVG file (default: 1000) |
| 34 | -p:: | ||
| 35 | --power-only:: | ||
| 36 | Only output the CPU power section of the diagram | ||
| 34 | 37 | ||
| 35 | 38 | ||
| 36 | SEE ALSO | 39 | SEE ALSO |
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index b5f1953b6144..7e190d522cd5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
| @@ -157,11 +157,18 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | |||
| 157 | uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not') | 157 | uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not') |
| 158 | uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not') | 158 | uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not') |
| 159 | 159 | ||
| 160 | # If we're on a 64-bit kernel, use -m64 | 160 | # |
| 161 | ifndef NO_64BIT | 161 | # Add -m32 for cross-builds: |
| 162 | ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M)) | 162 | # |
| 163 | M64 := -m64 | 163 | ifdef NO_64BIT |
| 164 | endif | 164 | MBITS := -m32 |
| 165 | else | ||
| 166 | # | ||
| 167 | # If we're on a 64-bit kernel, use -m64: | ||
| 168 | # | ||
| 169 | ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M)) | ||
| 170 | MBITS := -m64 | ||
| 171 | endif | ||
| 165 | endif | 172 | endif |
| 166 | 173 | ||
| 167 | # CFLAGS and LDFLAGS are for the users to override from the command line. | 174 | # CFLAGS and LDFLAGS are for the users to override from the command line. |
| @@ -170,8 +177,7 @@ endif | |||
| 170 | # Include saner warnings here, which can catch bugs: | 177 | # Include saner warnings here, which can catch bugs: |
| 171 | # | 178 | # |
| 172 | 179 | ||
| 173 | EXTRA_WARNINGS := -Wcast-align | 180 | EXTRA_WARNINGS := -Wformat |
| 174 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat | ||
| 175 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security | 181 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security |
| 176 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k | 182 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k |
| 177 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow | 183 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow |
| @@ -194,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition | |||
| 194 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes | 200 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes |
| 195 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement | 201 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement |
| 196 | 202 | ||
| 197 | CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) | 203 | CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) |
| 198 | LDFLAGS = -lpthread -lrt -lelf -lm | 204 | LDFLAGS = -lpthread -lrt -lelf -lm |
| 199 | ALL_CFLAGS = $(CFLAGS) | 205 | ALL_CFLAGS = $(CFLAGS) |
| 200 | ALL_LDFLAGS = $(LDFLAGS) | 206 | ALL_LDFLAGS = $(LDFLAGS) |
| @@ -415,8 +421,12 @@ ifeq ($(uname_S),Darwin) | |||
| 415 | PTHREAD_LIBS = | 421 | PTHREAD_LIBS = |
| 416 | endif | 422 | endif |
| 417 | 423 | ||
| 418 | ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 424 | ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) |
| 419 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel); | 425 | ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) |
| 426 | BASIC_CFLAGS += -DLIBELF_NO_MMAP | ||
| 427 | endif | ||
| 428 | else | ||
| 429 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); | ||
| 420 | endif | 430 | endif |
| 421 | 431 | ||
| 422 | ifdef NO_DEMANGLE | 432 | ifdef NO_DEMANGLE |
| @@ -728,7 +738,7 @@ $(BUILT_INS): perf$X | |||
| 728 | common-cmds.h: util/generate-cmdlist.sh command-list.txt | 738 | common-cmds.h: util/generate-cmdlist.sh command-list.txt |
| 729 | 739 | ||
| 730 | common-cmds.h: $(wildcard Documentation/perf-*.txt) | 740 | common-cmds.h: $(wildcard Documentation/perf-*.txt) |
| 731 | $(QUIET_GEN)util/generate-cmdlist.sh > $@+ && mv $@+ $@ | 741 | $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@ |
| 732 | 742 | ||
| 733 | $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh | 743 | $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh |
| 734 | $(QUIET_GEN)$(RM) $@ $@+ && \ | 744 | $(QUIET_GEN)$(RM) $@ $@+ && \ |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a5a050af8e7d..3eeef339c787 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -41,6 +41,7 @@ static int raw_samples = 0; | |||
| 41 | static int system_wide = 0; | 41 | static int system_wide = 0; |
| 42 | static int profile_cpu = -1; | 42 | static int profile_cpu = -1; |
| 43 | static pid_t target_pid = -1; | 43 | static pid_t target_pid = -1; |
| 44 | static pid_t child_pid = -1; | ||
| 44 | static int inherit = 1; | 45 | static int inherit = 1; |
| 45 | static int force = 0; | 46 | static int force = 0; |
| 46 | static int append_file = 0; | 47 | static int append_file = 0; |
| @@ -184,6 +185,9 @@ static void sig_handler(int sig) | |||
| 184 | 185 | ||
| 185 | static void sig_atexit(void) | 186 | static void sig_atexit(void) |
| 186 | { | 187 | { |
| 188 | if (child_pid != -1) | ||
| 189 | kill(child_pid, SIGTERM); | ||
| 190 | |||
| 187 | if (signr == -1) | 191 | if (signr == -1) |
| 188 | return; | 192 | return; |
| 189 | 193 | ||
| @@ -610,6 +614,8 @@ static int __cmd_record(int argc, const char **argv) | |||
| 610 | exit(-1); | 614 | exit(-1); |
| 611 | } | 615 | } |
| 612 | } | 616 | } |
| 617 | |||
| 618 | child_pid = pid; | ||
| 613 | } | 619 | } |
| 614 | 620 | ||
| 615 | if (realtime_prio) { | 621 | if (realtime_prio) { |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index ea9c15c0cdfe..ce2d5be4f30e 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
| @@ -1287,7 +1287,7 @@ static struct sort_dimension *available_sorts[] = { | |||
| 1287 | 1287 | ||
| 1288 | static LIST_HEAD(sort_list); | 1288 | static LIST_HEAD(sort_list); |
| 1289 | 1289 | ||
| 1290 | static int sort_dimension__add(char *tok, struct list_head *list) | 1290 | static int sort_dimension__add(const char *tok, struct list_head *list) |
| 1291 | { | 1291 | { |
| 1292 | int i; | 1292 | int i; |
| 1293 | 1293 | ||
| @@ -1917,7 +1917,7 @@ static void setup_sorting(void) | |||
| 1917 | 1917 | ||
| 1918 | free(str); | 1918 | free(str); |
| 1919 | 1919 | ||
| 1920 | sort_dimension__add((char *)"pid", &cmp_pid); | 1920 | sort_dimension__add("pid", &cmp_pid); |
| 1921 | } | 1921 | } |
| 1922 | 1922 | ||
| 1923 | static const char *record_args[] = { | 1923 | static const char *record_args[] = { |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 16af2d82e858..3db31e7bf173 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -69,7 +69,8 @@ static int run_idx = 0; | |||
| 69 | static int run_count = 1; | 69 | static int run_count = 1; |
| 70 | static int inherit = 1; | 70 | static int inherit = 1; |
| 71 | static int scale = 1; | 71 | static int scale = 1; |
| 72 | static int target_pid = -1; | 72 | static pid_t target_pid = -1; |
| 73 | static pid_t child_pid = -1; | ||
| 73 | static int null_run = 0; | 74 | static int null_run = 0; |
| 74 | 75 | ||
| 75 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; | 76 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; |
| @@ -285,6 +286,8 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
| 285 | exit(-1); | 286 | exit(-1); |
| 286 | } | 287 | } |
| 287 | 288 | ||
| 289 | child_pid = pid; | ||
| 290 | |||
| 288 | /* | 291 | /* |
| 289 | * Wait for the child to be ready to exec. | 292 | * Wait for the child to be ready to exec. |
| 290 | */ | 293 | */ |
| @@ -338,14 +341,24 @@ static void nsec_printout(int counter, double avg) | |||
| 338 | 341 | ||
| 339 | static void abs_printout(int counter, double avg) | 342 | static void abs_printout(int counter, double avg) |
| 340 | { | 343 | { |
| 344 | double total, ratio = 0.0; | ||
| 345 | |||
| 341 | fprintf(stderr, " %14.0f %-24s", avg, event_name(counter)); | 346 | fprintf(stderr, " %14.0f %-24s", avg, event_name(counter)); |
| 342 | 347 | ||
| 343 | if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) { | 348 | if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) { |
| 344 | fprintf(stderr, " # %10.3f IPC ", | 349 | total = avg_stats(&runtime_cycles_stats); |
| 345 | avg / avg_stats(&runtime_cycles_stats)); | 350 | |
| 351 | if (total) | ||
| 352 | ratio = avg / total; | ||
| 353 | |||
| 354 | fprintf(stderr, " # %10.3f IPC ", ratio); | ||
| 346 | } else { | 355 | } else { |
| 347 | fprintf(stderr, " # %10.3f M/sec", | 356 | total = avg_stats(&runtime_nsecs_stats); |
| 348 | 1000.0 * avg / avg_stats(&runtime_nsecs_stats)); | 357 | |
| 358 | if (total) | ||
| 359 | ratio = 1000.0 * avg / total; | ||
| 360 | |||
| 361 | fprintf(stderr, " # %10.3f M/sec", ratio); | ||
| 349 | } | 362 | } |
| 350 | } | 363 | } |
| 351 | 364 | ||
| @@ -423,6 +436,9 @@ static void skip_signal(int signo) | |||
| 423 | 436 | ||
| 424 | static void sig_atexit(void) | 437 | static void sig_atexit(void) |
| 425 | { | 438 | { |
| 439 | if (child_pid != -1) | ||
| 440 | kill(child_pid, SIGTERM); | ||
| 441 | |||
| 426 | if (signr == -1) | 442 | if (signr == -1) |
| 427 | return; | 443 | return; |
| 428 | 444 | ||
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 4405681b3134..e8a510d935e5 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
| @@ -46,6 +46,8 @@ static u64 turbo_frequency; | |||
| 46 | 46 | ||
| 47 | static u64 first_time, last_time; | 47 | static u64 first_time, last_time; |
| 48 | 48 | ||
| 49 | static int power_only; | ||
| 50 | |||
| 49 | 51 | ||
| 50 | static struct perf_header *header; | 52 | static struct perf_header *header; |
| 51 | 53 | ||
| @@ -547,7 +549,7 @@ static void end_sample_processing(void) | |||
| 547 | u64 cpu; | 549 | u64 cpu; |
| 548 | struct power_event *pwr; | 550 | struct power_event *pwr; |
| 549 | 551 | ||
| 550 | for (cpu = 0; cpu < numcpus; cpu++) { | 552 | for (cpu = 0; cpu <= numcpus; cpu++) { |
| 551 | pwr = malloc(sizeof(struct power_event)); | 553 | pwr = malloc(sizeof(struct power_event)); |
| 552 | if (!pwr) | 554 | if (!pwr) |
| 553 | return; | 555 | return; |
| @@ -763,19 +765,40 @@ static void draw_wakeups(void) | |||
| 763 | if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { | 765 | if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { |
| 764 | if (p->pid == we->waker) { | 766 | if (p->pid == we->waker) { |
| 765 | from = c->Y; | 767 | from = c->Y; |
| 766 | task_from = c->comm; | 768 | task_from = strdup(c->comm); |
| 767 | } | 769 | } |
| 768 | if (p->pid == we->wakee) { | 770 | if (p->pid == we->wakee) { |
| 769 | to = c->Y; | 771 | to = c->Y; |
| 770 | task_to = c->comm; | 772 | task_to = strdup(c->comm); |
| 771 | } | 773 | } |
| 772 | } | 774 | } |
| 773 | c = c->next; | 775 | c = c->next; |
| 774 | } | 776 | } |
| 777 | c = p->all; | ||
| 778 | while (c) { | ||
| 779 | if (p->pid == we->waker && !from) { | ||
| 780 | from = c->Y; | ||
| 781 | task_from = strdup(c->comm); | ||
| 782 | } | ||
| 783 | if (p->pid == we->wakee && !to) { | ||
| 784 | to = c->Y; | ||
| 785 | task_to = strdup(c->comm); | ||
| 786 | } | ||
| 787 | c = c->next; | ||
| 788 | } | ||
| 775 | } | 789 | } |
| 776 | p = p->next; | 790 | p = p->next; |
| 777 | } | 791 | } |
| 778 | 792 | ||
| 793 | if (!task_from) { | ||
| 794 | task_from = malloc(40); | ||
| 795 | sprintf(task_from, "[%i]", we->waker); | ||
| 796 | } | ||
| 797 | if (!task_to) { | ||
| 798 | task_to = malloc(40); | ||
| 799 | sprintf(task_to, "[%i]", we->wakee); | ||
| 800 | } | ||
| 801 | |||
| 779 | if (we->waker == -1) | 802 | if (we->waker == -1) |
| 780 | svg_interrupt(we->time, to); | 803 | svg_interrupt(we->time, to); |
| 781 | else if (from && to && abs(from - to) == 1) | 804 | else if (from && to && abs(from - to) == 1) |
| @@ -783,6 +806,9 @@ static void draw_wakeups(void) | |||
| 783 | else | 806 | else |
| 784 | svg_partial_wakeline(we->time, from, task_from, to, task_to); | 807 | svg_partial_wakeline(we->time, from, task_from, to, task_to); |
| 785 | we = we->next; | 808 | we = we->next; |
| 809 | |||
| 810 | free(task_from); | ||
| 811 | free(task_to); | ||
| 786 | } | 812 | } |
| 787 | } | 813 | } |
| 788 | 814 | ||
| @@ -871,7 +897,7 @@ static int determine_display_tasks(u64 threshold) | |||
| 871 | /* no exit marker, task kept running to the end */ | 897 | /* no exit marker, task kept running to the end */ |
| 872 | if (p->end_time == 0) | 898 | if (p->end_time == 0) |
| 873 | p->end_time = last_time; | 899 | p->end_time = last_time; |
| 874 | if (p->total_time >= threshold) | 900 | if (p->total_time >= threshold && !power_only) |
| 875 | p->display = 1; | 901 | p->display = 1; |
| 876 | 902 | ||
| 877 | c = p->all; | 903 | c = p->all; |
| @@ -882,7 +908,7 @@ static int determine_display_tasks(u64 threshold) | |||
| 882 | if (c->start_time == 1) | 908 | if (c->start_time == 1) |
| 883 | c->start_time = first_time; | 909 | c->start_time = first_time; |
| 884 | 910 | ||
| 885 | if (c->total_time >= threshold) { | 911 | if (c->total_time >= threshold && !power_only) { |
| 886 | c->display = 1; | 912 | c->display = 1; |
| 887 | count++; | 913 | count++; |
| 888 | } | 914 | } |
| @@ -1134,6 +1160,8 @@ static const struct option options[] = { | |||
| 1134 | "output file name"), | 1160 | "output file name"), |
| 1135 | OPT_INTEGER('w', "width", &svg_page_width, | 1161 | OPT_INTEGER('w', "width", &svg_page_width, |
| 1136 | "page width"), | 1162 | "page width"), |
| 1163 | OPT_BOOLEAN('p', "power-only", &power_only, | ||
| 1164 | "output power data only"), | ||
| 1137 | OPT_END() | 1165 | OPT_END() |
| 1138 | }; | 1166 | }; |
| 1139 | 1167 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 1ca88896eee4..a1b1d10912dc 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -686,6 +686,8 @@ static void handle_keypress(int c) | |||
| 686 | switch (c) { | 686 | switch (c) { |
| 687 | case 'd': | 687 | case 'd': |
| 688 | prompt_integer(&delay_secs, "Enter display delay"); | 688 | prompt_integer(&delay_secs, "Enter display delay"); |
| 689 | if (delay_secs < 1) | ||
| 690 | delay_secs = 1; | ||
| 689 | break; | 691 | break; |
| 690 | case 'e': | 692 | case 'e': |
| 691 | prompt_integer(&print_entries, "Enter display entries (lines)"); | 693 | prompt_integer(&print_entries, "Enter display entries (lines)"); |
| @@ -782,6 +784,7 @@ static const char *skip_symbols[] = { | |||
| 782 | "exit_idle", | 784 | "exit_idle", |
| 783 | "mwait_idle", | 785 | "mwait_idle", |
| 784 | "mwait_idle_with_hints", | 786 | "mwait_idle_with_hints", |
| 787 | "poll_idle", | ||
| 785 | "ppc64_runlatch_off", | 788 | "ppc64_runlatch_off", |
| 786 | "pseries_dedicated_idle_sleep", | 789 | "pseries_dedicated_idle_sleep", |
| 787 | NULL | 790 | NULL |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e9d256e2f47d..0c5e4f72f2ba 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -219,10 +219,6 @@ remap: | |||
| 219 | more: | 219 | more: |
| 220 | event = (event_t *)(buf + head); | 220 | event = (event_t *)(buf + head); |
| 221 | 221 | ||
| 222 | size = event->header.size; | ||
| 223 | if (!size) | ||
| 224 | size = 8; | ||
| 225 | |||
| 226 | if (head + event->header.size >= page_size * mmap_window) { | 222 | if (head + event->header.size >= page_size * mmap_window) { |
| 227 | unsigned long shift = page_size * (head / page_size); | 223 | unsigned long shift = page_size * (head / page_size); |
| 228 | int res; | 224 | int res; |
| @@ -237,7 +233,6 @@ more: | |||
| 237 | 233 | ||
| 238 | size = event->header.size; | 234 | size = event->header.size; |
| 239 | 235 | ||
| 240 | |||
| 241 | if (!size || process_event(event, offset, head) < 0) { | 236 | if (!size || process_event(event, offset, head) < 0) { |
| 242 | 237 | ||
| 243 | /* | 238 | /* |
| @@ -290,7 +285,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
| 290 | usage_with_options(annotate_usage, options); | 285 | usage_with_options(annotate_usage, options); |
| 291 | } | 286 | } |
| 292 | 287 | ||
| 293 | |||
| 294 | setup_pager(); | 288 | setup_pager(); |
| 295 | 289 | ||
| 296 | return __cmd_trace(); | 290 | return __cmd_trace(); |
diff --git a/tools/perf/design.txt b/tools/perf/design.txt index f1946d107b10..fdd42a824c98 100644 --- a/tools/perf/design.txt +++ b/tools/perf/design.txt | |||
| @@ -455,3 +455,6 @@ will need at least this: | |||
| 455 | 455 | ||
| 456 | If your architecture does have hardware capabilities, you can override the | 456 | If your architecture does have hardware capabilities, you can override the |
| 457 | weak stub hw_perf_event_init() to register hardware counters. | 457 | weak stub hw_perf_event_init() to register hardware counters. |
| 458 | |||
| 459 | Architectures that have d-cache aliassing issues, such as Sparc and ARM, | ||
| 460 | should select PERF_USE_VMALLOC in order to avoid these for perf mmap(). | ||
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index c561d1538c03..54552a00a117 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | GVF=PERF-VERSION-FILE | 3 | GVF=PERF-VERSION-FILE |
| 4 | DEF_VER=v0.0.1.PERF | 4 | DEF_VER=v0.0.2.PERF |
| 5 | 5 | ||
| 6 | LF=' | 6 | LF=' |
| 7 | ' | 7 | ' |
diff --git a/tools/perf/util/module.c b/tools/perf/util/module.c index 3d567fe59c79..0d8c85defcd2 100644 --- a/tools/perf/util/module.c +++ b/tools/perf/util/module.c | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "module.h" | 4 | #include "module.h" |
| 5 | 5 | ||
| 6 | #include <libelf.h> | 6 | #include <libelf.h> |
| 7 | #include <libgen.h> | ||
| 7 | #include <gelf.h> | 8 | #include <gelf.h> |
| 8 | #include <elf.h> | 9 | #include <elf.h> |
| 9 | #include <dirent.h> | 10 | #include <dirent.h> |
| @@ -409,35 +410,40 @@ out_failure: | |||
| 409 | static int mod_dso__load_module_paths(struct mod_dso *self) | 410 | static int mod_dso__load_module_paths(struct mod_dso *self) |
| 410 | { | 411 | { |
| 411 | struct utsname uts; | 412 | struct utsname uts; |
| 412 | int count = 0, len; | 413 | int count = 0, len, err = -1; |
| 413 | char *line = NULL; | 414 | char *line = NULL; |
| 414 | FILE *file; | 415 | FILE *file; |
| 415 | char *path; | 416 | char *dpath, *dir; |
| 416 | size_t n; | 417 | size_t n; |
| 417 | 418 | ||
| 418 | if (uname(&uts) < 0) | 419 | if (uname(&uts) < 0) |
| 419 | goto out_failure; | 420 | return err; |
| 420 | 421 | ||
| 421 | len = strlen("/lib/modules/"); | 422 | len = strlen("/lib/modules/"); |
| 422 | len += strlen(uts.release); | 423 | len += strlen(uts.release); |
| 423 | len += strlen("/modules.dep"); | 424 | len += strlen("/modules.dep"); |
| 424 | 425 | ||
| 425 | path = calloc(1, len); | 426 | dpath = calloc(1, len + 1); |
| 426 | if (path == NULL) | 427 | if (dpath == NULL) |
| 427 | goto out_failure; | 428 | return err; |
| 428 | 429 | ||
| 429 | strcat(path, "/lib/modules/"); | 430 | strcat(dpath, "/lib/modules/"); |
| 430 | strcat(path, uts.release); | 431 | strcat(dpath, uts.release); |
| 431 | strcat(path, "/modules.dep"); | 432 | strcat(dpath, "/modules.dep"); |
| 432 | 433 | ||
| 433 | file = fopen(path, "r"); | 434 | file = fopen(dpath, "r"); |
| 434 | free(path); | ||
| 435 | if (file == NULL) | 435 | if (file == NULL) |
| 436 | goto out_failure; | 436 | goto out_failure; |
| 437 | 437 | ||
| 438 | dir = dirname(dpath); | ||
| 439 | if (!dir) | ||
| 440 | goto out_failure; | ||
| 441 | strcat(dir, "/"); | ||
| 442 | |||
| 438 | while (!feof(file)) { | 443 | while (!feof(file)) { |
| 439 | char *name, *tmp; | ||
| 440 | struct module *module; | 444 | struct module *module; |
| 445 | char *name, *path, *tmp; | ||
| 446 | FILE *modfile; | ||
| 441 | int line_len; | 447 | int line_len; |
| 442 | 448 | ||
| 443 | line_len = getline(&line, &n, file); | 449 | line_len = getline(&line, &n, file); |
| @@ -445,17 +451,41 @@ static int mod_dso__load_module_paths(struct mod_dso *self) | |||
| 445 | break; | 451 | break; |
| 446 | 452 | ||
| 447 | if (!line) | 453 | if (!line) |
| 448 | goto out_failure; | 454 | break; |
| 449 | 455 | ||
| 450 | line[--line_len] = '\0'; /* \n */ | 456 | line[--line_len] = '\0'; /* \n */ |
| 451 | 457 | ||
| 452 | path = strtok(line, ":"); | 458 | path = strchr(line, ':'); |
| 459 | if (!path) | ||
| 460 | break; | ||
| 461 | *path = '\0'; | ||
| 462 | |||
| 463 | path = strdup(line); | ||
| 453 | if (!path) | 464 | if (!path) |
| 454 | goto out_failure; | 465 | break; |
| 466 | |||
| 467 | if (!strstr(path, dir)) { | ||
| 468 | if (strncmp(path, "kernel/", 7)) | ||
| 469 | break; | ||
| 470 | |||
| 471 | free(path); | ||
| 472 | path = calloc(1, strlen(dir) + strlen(line) + 1); | ||
| 473 | if (!path) | ||
| 474 | break; | ||
| 475 | strcat(path, dir); | ||
| 476 | strcat(path, line); | ||
| 477 | } | ||
| 478 | |||
| 479 | modfile = fopen(path, "r"); | ||
| 480 | if (modfile == NULL) | ||
| 481 | break; | ||
| 482 | fclose(modfile); | ||
| 455 | 483 | ||
| 456 | name = strdup(path); | 484 | name = strdup(path); |
| 457 | name = strtok(name, "/"); | 485 | if (!name) |
| 486 | break; | ||
| 458 | 487 | ||
| 488 | name = strtok(name, "/"); | ||
| 459 | tmp = name; | 489 | tmp = name; |
| 460 | 490 | ||
| 461 | while (tmp) { | 491 | while (tmp) { |
| @@ -463,26 +493,25 @@ static int mod_dso__load_module_paths(struct mod_dso *self) | |||
| 463 | if (tmp) | 493 | if (tmp) |
| 464 | name = tmp; | 494 | name = tmp; |
| 465 | } | 495 | } |
| 496 | |||
| 466 | name = strsep(&name, "."); | 497 | name = strsep(&name, "."); |
| 498 | if (!name) | ||
| 499 | break; | ||
| 467 | 500 | ||
| 468 | /* Quirk: replace '-' with '_' in sound modules */ | 501 | /* Quirk: replace '-' with '_' in all modules */ |
| 469 | for (len = strlen(name); len; len--) { | 502 | for (len = strlen(name); len; len--) { |
| 470 | if (*(name+len) == '-') | 503 | if (*(name+len) == '-') |
| 471 | *(name+len) = '_'; | 504 | *(name+len) = '_'; |
| 472 | } | 505 | } |
| 473 | 506 | ||
| 474 | module = module__new(name, path); | 507 | module = module__new(name, path); |
| 475 | if (!module) { | 508 | if (!module) |
| 476 | fprintf(stderr, "load_module_paths: allocation error\n"); | 509 | break; |
| 477 | goto out_failure; | ||
| 478 | } | ||
| 479 | mod_dso__insert_module(self, module); | 510 | mod_dso__insert_module(self, module); |
| 480 | 511 | ||
| 481 | module->sections = sec_dso__new_dso("sections"); | 512 | module->sections = sec_dso__new_dso("sections"); |
| 482 | if (!module->sections) { | 513 | if (!module->sections) |
| 483 | fprintf(stderr, "load_module_paths: allocation error\n"); | 514 | break; |
| 484 | goto out_failure; | ||
| 485 | } | ||
| 486 | 515 | ||
| 487 | module->active = mod_dso__load_sections(module); | 516 | module->active = mod_dso__load_sections(module); |
| 488 | 517 | ||
| @@ -490,13 +519,20 @@ static int mod_dso__load_module_paths(struct mod_dso *self) | |||
| 490 | count++; | 519 | count++; |
| 491 | } | 520 | } |
| 492 | 521 | ||
| 493 | free(line); | 522 | if (feof(file)) |
| 494 | fclose(file); | 523 | err = count; |
| 495 | 524 | else | |
| 496 | return count; | 525 | fprintf(stderr, "load_module_paths: modules.dep parsing failure!\n"); |
| 497 | 526 | ||
| 498 | out_failure: | 527 | out_failure: |
| 499 | return -1; | 528 | if (dpath) |
| 529 | free(dpath); | ||
| 530 | if (file) | ||
| 531 | fclose(file); | ||
| 532 | if (line) | ||
| 533 | free(line); | ||
| 534 | |||
| 535 | return err; | ||
| 500 | } | 536 | } |
| 501 | 537 | ||
| 502 | int mod_dso__load_modules(struct mod_dso *dso) | 538 | int mod_dso__load_modules(struct mod_dso *dso) |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 13ab4b842d49..8cfb48cbbea0 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
| @@ -165,33 +165,31 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) | |||
| 165 | DIR *sys_dir, *evt_dir; | 165 | DIR *sys_dir, *evt_dir; |
| 166 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; | 166 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; |
| 167 | char id_buf[4]; | 167 | char id_buf[4]; |
| 168 | int sys_dir_fd, fd; | 168 | int fd; |
| 169 | u64 id; | 169 | u64 id; |
| 170 | char evt_path[MAXPATHLEN]; | 170 | char evt_path[MAXPATHLEN]; |
| 171 | char dir_path[MAXPATHLEN]; | ||
| 171 | 172 | ||
| 172 | if (valid_debugfs_mount(debugfs_path)) | 173 | if (valid_debugfs_mount(debugfs_path)) |
| 173 | return NULL; | 174 | return NULL; |
| 174 | 175 | ||
| 175 | sys_dir = opendir(debugfs_path); | 176 | sys_dir = opendir(debugfs_path); |
| 176 | if (!sys_dir) | 177 | if (!sys_dir) |
| 177 | goto cleanup; | 178 | return NULL; |
| 178 | sys_dir_fd = dirfd(sys_dir); | ||
| 179 | 179 | ||
| 180 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { | 180 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { |
| 181 | int dfd = openat(sys_dir_fd, sys_dirent.d_name, | 181 | |
| 182 | O_RDONLY|O_DIRECTORY), evt_dir_fd; | 182 | snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path, |
| 183 | if (dfd == -1) | 183 | sys_dirent.d_name); |
| 184 | continue; | 184 | evt_dir = opendir(dir_path); |
| 185 | evt_dir = fdopendir(dfd); | 185 | if (!evt_dir) |
| 186 | if (!evt_dir) { | ||
| 187 | close(dfd); | ||
| 188 | continue; | 186 | continue; |
| 189 | } | 187 | |
| 190 | evt_dir_fd = dirfd(evt_dir); | ||
| 191 | for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { | 188 | for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { |
| 192 | snprintf(evt_path, MAXPATHLEN, "%s/id", | 189 | |
| 190 | snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, | ||
| 193 | evt_dirent.d_name); | 191 | evt_dirent.d_name); |
| 194 | fd = openat(evt_dir_fd, evt_path, O_RDONLY); | 192 | fd = open(evt_path, O_RDONLY); |
| 195 | if (fd < 0) | 193 | if (fd < 0) |
| 196 | continue; | 194 | continue; |
| 197 | if (read(fd, id_buf, sizeof(id_buf)) < 0) { | 195 | if (read(fd, id_buf, sizeof(id_buf)) < 0) { |
| @@ -225,7 +223,6 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) | |||
| 225 | closedir(evt_dir); | 223 | closedir(evt_dir); |
| 226 | } | 224 | } |
| 227 | 225 | ||
| 228 | cleanup: | ||
| 229 | closedir(sys_dir); | 226 | closedir(sys_dir); |
| 230 | return NULL; | 227 | return NULL; |
| 231 | } | 228 | } |
| @@ -694,7 +691,10 @@ static void store_event_type(const char *orgname) | |||
| 694 | FILE *file; | 691 | FILE *file; |
| 695 | int id; | 692 | int id; |
| 696 | 693 | ||
| 697 | sprintf(filename, "/sys/kernel/debug/tracing/events/%s/id", orgname); | 694 | sprintf(filename, "%s/", debugfs_path); |
| 695 | strncat(filename, orgname, strlen(orgname)); | ||
| 696 | strcat(filename, "/id"); | ||
| 697 | |||
| 698 | c = strchr(filename, ':'); | 698 | c = strchr(filename, ':'); |
| 699 | if (c) | 699 | if (c) |
| 700 | *c = '/'; | 700 | *c = '/'; |
| @@ -761,28 +761,24 @@ static void print_tracepoint_events(void) | |||
| 761 | { | 761 | { |
| 762 | DIR *sys_dir, *evt_dir; | 762 | DIR *sys_dir, *evt_dir; |
| 763 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; | 763 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; |
| 764 | int sys_dir_fd; | ||
| 765 | char evt_path[MAXPATHLEN]; | 764 | char evt_path[MAXPATHLEN]; |
| 765 | char dir_path[MAXPATHLEN]; | ||
| 766 | 766 | ||
| 767 | if (valid_debugfs_mount(debugfs_path)) | 767 | if (valid_debugfs_mount(debugfs_path)) |
| 768 | return; | 768 | return; |
| 769 | 769 | ||
| 770 | sys_dir = opendir(debugfs_path); | 770 | sys_dir = opendir(debugfs_path); |
| 771 | if (!sys_dir) | 771 | if (!sys_dir) |
| 772 | goto cleanup; | 772 | return; |
| 773 | sys_dir_fd = dirfd(sys_dir); | ||
| 774 | 773 | ||
| 775 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { | 774 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { |
| 776 | int dfd = openat(sys_dir_fd, sys_dirent.d_name, | 775 | |
| 777 | O_RDONLY|O_DIRECTORY), evt_dir_fd; | 776 | snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path, |
| 778 | if (dfd == -1) | 777 | sys_dirent.d_name); |
| 779 | continue; | 778 | evt_dir = opendir(dir_path); |
| 780 | evt_dir = fdopendir(dfd); | 779 | if (!evt_dir) |
| 781 | if (!evt_dir) { | ||
| 782 | close(dfd); | ||
| 783 | continue; | 780 | continue; |
| 784 | } | 781 | |
| 785 | evt_dir_fd = dirfd(evt_dir); | ||
| 786 | for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { | 782 | for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { |
| 787 | snprintf(evt_path, MAXPATHLEN, "%s:%s", | 783 | snprintf(evt_path, MAXPATHLEN, "%s:%s", |
| 788 | sys_dirent.d_name, evt_dirent.d_name); | 784 | sys_dirent.d_name, evt_dirent.d_name); |
| @@ -791,8 +787,6 @@ static void print_tracepoint_events(void) | |||
| 791 | } | 787 | } |
| 792 | closedir(evt_dir); | 788 | closedir(evt_dir); |
| 793 | } | 789 | } |
| 794 | |||
| 795 | cleanup: | ||
| 796 | closedir(sys_dir); | 790 | closedir(sys_dir); |
| 797 | } | 791 | } |
| 798 | 792 | ||
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index a778fd0f4ae4..b3637db025a2 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c | |||
| @@ -28,7 +28,7 @@ static u64 turbo_frequency, max_freq; | |||
| 28 | 28 | ||
| 29 | int svg_page_width = 1000; | 29 | int svg_page_width = 1000; |
| 30 | 30 | ||
| 31 | #define MIN_TEXT_SIZE 0.001 | 31 | #define MIN_TEXT_SIZE 0.01 |
| 32 | 32 | ||
| 33 | static u64 total_height; | 33 | static u64 total_height; |
| 34 | static FILE *svgfile; | 34 | static FILE *svgfile; |
| @@ -103,7 +103,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end) | |||
| 103 | fprintf(svgfile, " rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 103 | fprintf(svgfile, " rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
| 104 | fprintf(svgfile, " rect.sample { fill:rgb( 0, 0,255); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 104 | fprintf(svgfile, " rect.sample { fill:rgb( 0, 0,255); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
| 105 | fprintf(svgfile, " rect.blocked { fill:rgb(255, 0, 0); fill-opacity:0.5; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 105 | fprintf(svgfile, " rect.blocked { fill:rgb(255, 0, 0); fill-opacity:0.5; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
| 106 | fprintf(svgfile, " rect.waiting { fill:rgb(214,214, 0); fill-opacity:0.3; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 106 | fprintf(svgfile, " rect.waiting { fill:rgb(224,214, 0); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
| 107 | fprintf(svgfile, " rect.WAITING { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 107 | fprintf(svgfile, " rect.WAITING { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
| 108 | fprintf(svgfile, " rect.cpu { fill:rgb(192,192,192); fill-opacity:0.2; stroke-width:0.5; stroke:rgb(128,128,128); } \n"); | 108 | fprintf(svgfile, " rect.cpu { fill:rgb(192,192,192); fill-opacity:0.2; stroke-width:0.5; stroke:rgb(128,128,128); } \n"); |
| 109 | fprintf(svgfile, " rect.pstate { fill:rgb(128,128,128); fill-opacity:0.8; stroke-width:0; } \n"); | 109 | fprintf(svgfile, " rect.pstate { fill:rgb(128,128,128); fill-opacity:0.8; stroke-width:0; } \n"); |
| @@ -217,6 +217,18 @@ static char *cpu_model(void) | |||
| 217 | } | 217 | } |
| 218 | fclose(file); | 218 | fclose(file); |
| 219 | } | 219 | } |
| 220 | |||
| 221 | /* CPU type */ | ||
| 222 | file = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", "r"); | ||
| 223 | if (file) { | ||
| 224 | while (fgets(buf, 255, file)) { | ||
| 225 | unsigned int freq; | ||
| 226 | freq = strtoull(buf, NULL, 10); | ||
| 227 | if (freq > max_freq) | ||
| 228 | max_freq = freq; | ||
| 229 | } | ||
| 230 | fclose(file); | ||
| 231 | } | ||
| 220 | return cpu_m; | 232 | return cpu_m; |
| 221 | } | 233 | } |
| 222 | 234 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index fd3d9c8e90fc..226f44a2357d 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -324,8 +324,7 @@ static inline int elf_sym__is_function(const GElf_Sym *sym) | |||
| 324 | { | 324 | { |
| 325 | return elf_sym__type(sym) == STT_FUNC && | 325 | return elf_sym__type(sym) == STT_FUNC && |
| 326 | sym->st_name != 0 && | 326 | sym->st_name != 0 && |
| 327 | sym->st_shndx != SHN_UNDEF && | 327 | sym->st_shndx != SHN_UNDEF; |
| 328 | sym->st_size != 0; | ||
| 329 | } | 328 | } |
| 330 | 329 | ||
| 331 | static inline int elf_sym__is_label(const GElf_Sym *sym) | 330 | static inline int elf_sym__is_label(const GElf_Sym *sym) |
| @@ -414,7 +413,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, int v) | |||
| 414 | if (fd < 0) | 413 | if (fd < 0) |
| 415 | goto out; | 414 | goto out; |
| 416 | 415 | ||
| 417 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 416 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
| 418 | if (elf == NULL) | 417 | if (elf == NULL) |
| 419 | goto out_close; | 418 | goto out_close; |
| 420 | 419 | ||
| @@ -534,7 +533,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name, | |||
| 534 | Elf *elf; | 533 | Elf *elf; |
| 535 | int nr = 0, kernel = !strcmp("[kernel]", self->name); | 534 | int nr = 0, kernel = !strcmp("[kernel]", self->name); |
| 536 | 535 | ||
| 537 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 536 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
| 538 | if (elf == NULL) { | 537 | if (elf == NULL) { |
| 539 | if (v) | 538 | if (v) |
| 540 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | 539 | fprintf(stderr, "%s: cannot read %s ELF file.\n", |
| @@ -676,7 +675,7 @@ static char *dso__read_build_id(struct dso *self, int v) | |||
| 676 | if (fd < 0) | 675 | if (fd < 0) |
| 677 | goto out; | 676 | goto out; |
| 678 | 677 | ||
| 679 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 678 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
| 680 | if (elf == NULL) { | 679 | if (elf == NULL) { |
| 681 | if (v) | 680 | if (v) |
| 682 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | 681 | fprintf(stderr, "%s: cannot read %s ELF file.\n", |
| @@ -833,7 +832,7 @@ int dso__load_modules(struct dso *self, symbol_filter_t filter, int v) | |||
| 833 | struct mod_dso *mods = mod_dso__new_dso("modules"); | 832 | struct mod_dso *mods = mod_dso__new_dso("modules"); |
| 834 | struct module *pos; | 833 | struct module *pos; |
| 835 | struct rb_node *next; | 834 | struct rb_node *next; |
| 836 | int err; | 835 | int err, count = 0; |
| 837 | 836 | ||
| 838 | err = mod_dso__load_modules(mods); | 837 | err = mod_dso__load_modules(mods); |
| 839 | 838 | ||
| @@ -852,14 +851,16 @@ int dso__load_modules(struct dso *self, symbol_filter_t filter, int v) | |||
| 852 | break; | 851 | break; |
| 853 | 852 | ||
| 854 | next = rb_next(&pos->rb_node); | 853 | next = rb_next(&pos->rb_node); |
| 854 | count += err; | ||
| 855 | } | 855 | } |
| 856 | 856 | ||
| 857 | if (err < 0) { | 857 | if (err < 0) { |
| 858 | mod_dso__delete_modules(mods); | 858 | mod_dso__delete_modules(mods); |
| 859 | mod_dso__delete_self(mods); | 859 | mod_dso__delete_self(mods); |
| 860 | return err; | ||
| 860 | } | 861 | } |
| 861 | 862 | ||
| 862 | return err; | 863 | return count; |
| 863 | } | 864 | } |
| 864 | 865 | ||
| 865 | static inline void dso__fill_symbol_holes(struct dso *self) | 866 | static inline void dso__fill_symbol_holes(struct dso *self) |
| @@ -913,8 +914,15 @@ int dso__load_kernel(struct dso *self, const char *vmlinux, | |||
| 913 | 914 | ||
| 914 | if (vmlinux) { | 915 | if (vmlinux) { |
| 915 | err = dso__load_vmlinux(self, vmlinux, filter, v); | 916 | err = dso__load_vmlinux(self, vmlinux, filter, v); |
| 916 | if (err > 0 && use_modules) | 917 | if (err > 0 && use_modules) { |
| 917 | err = dso__load_modules(self, filter, v); | 918 | int syms = dso__load_modules(self, filter, v); |
| 919 | |||
| 920 | if (syms < 0) { | ||
| 921 | fprintf(stderr, "dso__load_modules failed!\n"); | ||
| 922 | return syms; | ||
| 923 | } | ||
| 924 | err += syms; | ||
| 925 | } | ||
| 918 | } | 926 | } |
| 919 | 927 | ||
| 920 | if (err <= 0) | 928 | if (err <= 0) |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6e8490716408..829da9edba64 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -27,6 +27,16 @@ static inline char *bfd_demangle(void __used *v, const char __used *c, | |||
| 27 | #endif | 27 | #endif |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | /* | ||
| 31 | * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; | ||
| 32 | * for newer versions we can use mmap to reduce memory usage: | ||
| 33 | */ | ||
| 34 | #ifdef LIBELF_NO_MMAP | ||
| 35 | # define PERF_ELF_C_READ_MMAP ELF_C_READ | ||
| 36 | #else | ||
| 37 | # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP | ||
| 38 | #endif | ||
| 39 | |||
| 30 | #ifndef DMGL_PARAMS | 40 | #ifndef DMGL_PARAMS |
| 31 | #define DMGL_PARAMS (1 << 0) /* Include function args */ | 41 | #define DMGL_PARAMS (1 << 0) /* Include function args */ |
| 32 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ | 42 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index f6a8437141c8..55c9659a56e2 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
| @@ -618,7 +618,7 @@ static int test_type(enum event_type type, enum event_type expect) | |||
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | static int test_type_token(enum event_type type, char *token, | 620 | static int test_type_token(enum event_type type, char *token, |
| 621 | enum event_type expect, char *expect_tok) | 621 | enum event_type expect, const char *expect_tok) |
| 622 | { | 622 | { |
| 623 | if (type != expect) { | 623 | if (type != expect) { |
| 624 | die("Error: expected type %d but read %d", | 624 | die("Error: expected type %d but read %d", |
| @@ -650,7 +650,7 @@ static int read_expect_type(enum event_type expect, char **tok) | |||
| 650 | return __read_expect_type(expect, tok, 1); | 650 | return __read_expect_type(expect, tok, 1); |
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | static int __read_expected(enum event_type expect, char *str, int newline_ok) | 653 | static int __read_expected(enum event_type expect, const char *str, int newline_ok) |
| 654 | { | 654 | { |
| 655 | enum event_type type; | 655 | enum event_type type; |
| 656 | char *token; | 656 | char *token; |
| @@ -668,12 +668,12 @@ static int __read_expected(enum event_type expect, char *str, int newline_ok) | |||
| 668 | return 0; | 668 | return 0; |
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | static int read_expected(enum event_type expect, char *str) | 671 | static int read_expected(enum event_type expect, const char *str) |
| 672 | { | 672 | { |
| 673 | return __read_expected(expect, str, 1); | 673 | return __read_expected(expect, str, 1); |
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | static int read_expected_item(enum event_type expect, char *str) | 676 | static int read_expected_item(enum event_type expect, const char *str) |
| 677 | { | 677 | { |
| 678 | return __read_expected(expect, str, 0); | 678 | return __read_expected(expect, str, 0); |
| 679 | } | 679 | } |
| @@ -1968,10 +1968,11 @@ static const struct flag flags[] = { | |||
| 1968 | { "NET_TX_SOFTIRQ", 2 }, | 1968 | { "NET_TX_SOFTIRQ", 2 }, |
| 1969 | { "NET_RX_SOFTIRQ", 3 }, | 1969 | { "NET_RX_SOFTIRQ", 3 }, |
| 1970 | { "BLOCK_SOFTIRQ", 4 }, | 1970 | { "BLOCK_SOFTIRQ", 4 }, |
| 1971 | { "TASKLET_SOFTIRQ", 5 }, | 1971 | { "BLOCK_IOPOLL_SOFTIRQ", 5 }, |
| 1972 | { "SCHED_SOFTIRQ", 6 }, | 1972 | { "TASKLET_SOFTIRQ", 6 }, |
| 1973 | { "HRTIMER_SOFTIRQ", 7 }, | 1973 | { "SCHED_SOFTIRQ", 7 }, |
| 1974 | { "RCU_SOFTIRQ", 8 }, | 1974 | { "HRTIMER_SOFTIRQ", 8 }, |
| 1975 | { "RCU_SOFTIRQ", 9 }, | ||
| 1975 | 1976 | ||
| 1976 | { "HRTIMER_NORESTART", 0 }, | 1977 | { "HRTIMER_NORESTART", 0 }, |
| 1977 | { "HRTIMER_RESTART", 1 }, | 1978 | { "HRTIMER_RESTART", 1 }, |
