Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Thomas Gleixner:
- fix for do_div() abuse on x86
- locking fix in perf core
- a pile of (build) fixes and cleanups in perf tools

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits)
perf/x86: Fix incorrect use of do_div() in NMI warning
perf: Fix perf_lock_task_context() vs RCU
perf: Remove WARN_ON_ONCE() check in __perf_event_enable() for valid scenario
perf: Clone child context from parent context pmu
perf script: Fix broken include in Context.xs
perf tools: Fix -ldw/-lelf link test when static linking
perf tools: Revert regression in configuration of Python support
perf tools: Fix perf version generation
perf stat: Fix per-socket output bug for uncore events
perf symbols: Fix vdso list searching
perf evsel: Fix missing increment in sample parsing
perf tools: Update symbol_conf.nr_events when processing attribute events
perf tools: Fix new_term() missing free on error path
perf tools: Fix parse_events_terms() segfault on error path
perf evsel: Fix count parameter to read call in event_format__new
perf tools: fix a typo of a Power7 event name
perf tools: Fix -x/--exclude-other option for report command
perf evlist: Enhance perf_evlist__start_workload()
perf record: Remove -f/--force option
perf record: Remove -A/--append option
...

+154 -163
+1 -1
Documentation/ABI/testing/sysfs-bus-event_source-devices-events
··· 29 29 30 30 What: /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL 31 31 /sys/devices/cpu/events/PM_BRU_FIN 32 - /sys/devices/cpu/events/PM_BRU_MPRED 32 + /sys/devices/cpu/events/PM_BR_MPRED 33 33 /sys/devices/cpu/events/PM_CMPLU_STALL 34 34 /sys/devices/cpu/events/PM_CMPLU_STALL_BRU 35 35 /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
+6 -6
arch/powerpc/perf/power7-pmu.c
··· 60 60 #define PME_PM_LD_REF_L1 0xc880 61 61 #define PME_PM_LD_MISS_L1 0x400f0 62 62 #define PME_PM_BRU_FIN 0x10068 63 - #define PME_PM_BRU_MPRED 0x400f6 63 + #define PME_PM_BR_MPRED 0x400f6 64 64 65 65 #define PME_PM_CMPLU_STALL_FXU 0x20014 66 66 #define PME_PM_CMPLU_STALL_DIV 0x40014 ··· 349 349 [PERF_COUNT_HW_CACHE_REFERENCES] = PME_PM_LD_REF_L1, 350 350 [PERF_COUNT_HW_CACHE_MISSES] = PME_PM_LD_MISS_L1, 351 351 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = PME_PM_BRU_FIN, 352 - [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BRU_MPRED, 352 + [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BR_MPRED, 353 353 }; 354 354 355 355 #define C(x) PERF_COUNT_HW_CACHE_##x ··· 405 405 GENERIC_EVENT_ATTR(cache-references, LD_REF_L1); 406 406 GENERIC_EVENT_ATTR(cache-misses, LD_MISS_L1); 407 407 GENERIC_EVENT_ATTR(branch-instructions, BRU_FIN); 408 - GENERIC_EVENT_ATTR(branch-misses, BRU_MPRED); 408 + GENERIC_EVENT_ATTR(branch-misses, BR_MPRED); 409 409 410 410 POWER_EVENT_ATTR(CYC, CYC); 411 411 POWER_EVENT_ATTR(GCT_NOSLOT_CYC, GCT_NOSLOT_CYC); ··· 414 414 POWER_EVENT_ATTR(LD_REF_L1, LD_REF_L1); 415 415 POWER_EVENT_ATTR(LD_MISS_L1, LD_MISS_L1); 416 416 POWER_EVENT_ATTR(BRU_FIN, BRU_FIN) 417 - POWER_EVENT_ATTR(BRU_MPRED, BRU_MPRED); 417 + POWER_EVENT_ATTR(BR_MPRED, BR_MPRED); 418 418 419 419 POWER_EVENT_ATTR(CMPLU_STALL_FXU, CMPLU_STALL_FXU); 420 420 POWER_EVENT_ATTR(CMPLU_STALL_DIV, CMPLU_STALL_DIV); ··· 449 449 GENERIC_EVENT_PTR(LD_REF_L1), 450 450 GENERIC_EVENT_PTR(LD_MISS_L1), 451 451 GENERIC_EVENT_PTR(BRU_FIN), 452 - GENERIC_EVENT_PTR(BRU_MPRED), 452 + GENERIC_EVENT_PTR(BR_MPRED), 453 453 454 454 POWER_EVENT_PTR(CYC), 455 455 POWER_EVENT_PTR(GCT_NOSLOT_CYC), ··· 458 458 POWER_EVENT_PTR(LD_REF_L1), 459 459 POWER_EVENT_PTR(LD_MISS_L1), 460 460 POWER_EVENT_PTR(BRU_FIN), 461 - POWER_EVENT_PTR(BRU_MPRED), 461 + POWER_EVENT_PTR(BR_MPRED), 462 462 463 463 POWER_EVENT_PTR(CMPLU_STALL_FXU), 464 464 POWER_EVENT_PTR(CMPLU_STALL_DIV),
+4 -3
arch/x86/kernel/nmi.c
··· 111 111 */ 112 112 list_for_each_entry_rcu(a, &desc->head, list) { 113 113 u64 before, delta, whole_msecs; 114 - int decimal_msecs, thishandled; 114 + int remainder_ns, decimal_msecs, thishandled; 115 115 116 116 before = local_clock(); 117 117 thishandled = a->handler(type, regs); ··· 123 123 continue; 124 124 125 125 nmi_longest_ns = delta; 126 - whole_msecs = do_div(delta, (1000 * 1000)); 127 - decimal_msecs = do_div(delta, 1000) % 1000; 126 + whole_msecs = delta; 127 + remainder_ns = do_div(whole_msecs, (1000 * 1000)); 128 + decimal_msecs = remainder_ns / 1000; 128 129 printk_ratelimited(KERN_INFO 129 130 "INFO: NMI handler (%ps) took too long to run: " 130 131 "%lld.%03d msecs\n", a->handler, whole_msecs,
+25 -3
kernel/events/core.c
··· 947 947 { 948 948 struct perf_event_context *ctx; 949 949 950 - rcu_read_lock(); 951 950 retry: 951 + /* 952 + * One of the few rules of preemptible RCU is that one cannot do 953 + * rcu_read_unlock() while holding a scheduler (or nested) lock when 954 + * part of the read side critical section was preemptible -- see 955 + * rcu_read_unlock_special(). 956 + * 957 + * Since ctx->lock nests under rq->lock we must ensure the entire read 958 + * side critical section is non-preemptible. 959 + */ 960 + preempt_disable(); 961 + rcu_read_lock(); 952 962 ctx = rcu_dereference(task->perf_event_ctxp[ctxn]); 953 963 if (ctx) { 954 964 /* ··· 974 964 raw_spin_lock_irqsave(&ctx->lock, *flags); 975 965 if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) { 976 966 raw_spin_unlock_irqrestore(&ctx->lock, *flags); 967 + rcu_read_unlock(); 968 + preempt_enable(); 977 969 goto retry; 978 970 } 979 971 ··· 985 973 } 986 974 } 987 975 rcu_read_unlock(); 976 + preempt_enable(); 988 977 return ctx; 989 978 } 990 979 ··· 1963 1950 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); 1964 1951 int err; 1965 1952 1966 - if (WARN_ON_ONCE(!ctx->is_active)) 1953 + /* 1954 + * There's a time window between 'ctx->is_active' check 1955 + * in perf_event_enable function and this place having: 1956 + * - IRQs on 1957 + * - ctx->lock unlocked 1958 + * 1959 + * where the task could be killed and 'ctx' deactivated 1960 + * by perf_event_exit_task. 1961 + */ 1962 + if (!ctx->is_active) 1967 1963 return -EINVAL; 1968 1964 1969 1965 raw_spin_lock(&ctx->lock); ··· 7487 7465 * child. 7488 7466 */ 7489 7467 7490 - child_ctx = alloc_perf_context(event->pmu, child); 7468 + child_ctx = alloc_perf_context(parent_ctx->pmu, child); 7491 7469 if (!child_ctx) 7492 7470 return -ENOMEM; 7493 7471
+16 -1
tools/lib/lk/Makefile
··· 3 3 CC = $(CROSS_COMPILE)gcc 4 4 AR = $(CROSS_COMPILE)ar 5 5 6 + # Makefiles suck: This macro sets a default value of $(2) for the 7 + # variable named by $(1), unless the variable has been set by 8 + # environment or command line. This is necessary for CC and AR 9 + # because make sets default values, so the simpler ?= approach 10 + # won't work as expected. 11 + define allow-override 12 + $(if $(or $(findstring environment,$(origin $(1))),\ 13 + $(findstring command line,$(origin $(1)))),,\ 14 + $(eval $(1) = $(2))) 15 + endef 16 + 17 + # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. 18 + $(call allow-override,CC,$(CROSS_COMPILE)gcc) 19 + $(call allow-override,AR,$(CROSS_COMPILE)ar) 20 + 6 21 # guard against environment variables 7 22 LIB_H= 8 23 LIB_OBJS= ··· 29 14 LIBFILE = liblk.a 30 15 31 16 CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC 32 - EXTLIBS = -lpthread -lrt -lelf -lm 17 + EXTLIBS = -lelf -lpthread -lrt -lm 33 18 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 34 19 ALL_LDFLAGS = $(LDFLAGS) 35 20
+3 -9
tools/perf/Documentation/Makefile
··· 1 + include ../../scripts/Makefile.include 1 2 include ../config/utilities.mak 2 - 3 - OUTPUT := ./ 4 - ifeq ("$(origin O)", "command line") 5 - ifneq ($(O),) 6 - OUTPUT := $(O)/ 7 - endif 8 - endif 9 3 10 4 MAN1_TXT= \ 11 5 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ ··· 144 150 endif 145 151 146 152 ifneq ($(findstring $(MAKEFLAGS),s),s) 147 - ifndef V 153 + ifneq ($(V),1) 148 154 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; 149 155 QUIET_XMLTO = @echo ' ' XMLTO $@; 150 156 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; ··· 271 277 272 278 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml 273 279 $(QUIET_XMLTO)$(RM) $@ && \ 274 - $(XMLTO) -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< 280 + $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< 275 281 276 282 $(OUTPUT)%.xml : %.txt 277 283 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
+2 -2
tools/perf/Documentation/examples.txt
··· 66 66 well. For example the page allocations done by a 'git gc' can be 67 67 captured the following way: 68 68 69 - titan:~/git> perf record -f -e kmem:mm_page_alloc -c 1 ./git gc 69 + titan:~/git> perf record -e kmem:mm_page_alloc -c 1 ./git gc 70 70 Counting objects: 1148, done. 71 71 Delta compression using up to 2 threads. 72 72 Compressing objects: 100% (450/450), done. ··· 120 120 allocations - to see precisely what kind of page allocations there 121 121 are: 122 122 123 - titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc 123 + titan:~/git> perf record -g -e kmem:mm_page_alloc -c 1 ./git gc 124 124 Counting objects: 1148, done. 125 125 Delta compression using up to 2 threads. 126 126 Compressing objects: 100% (450/450), done.
+1 -7
tools/perf/Documentation/perf-record.txt
··· 65 65 -r:: 66 66 --realtime=:: 67 67 Collect data with this RT SCHED_FIFO priority. 68 + 68 69 -D:: 69 70 --no-delay:: 70 71 Collect data without buffering. 71 - -A:: 72 - --append:: 73 - Append to the output file to do incremental profiling. 74 - 75 - -f:: 76 - --force:: 77 - Overwrite existing data file. (deprecated) 78 72 79 73 -c:: 80 74 --count=::
+2 -3
tools/perf/Makefile
··· 121 121 grep-libs = $(filter -l%,$(1)) 122 122 strip-libs = $(filter-out -l%,$(1)) 123 123 124 - LK_PATH=$(LK_DIR) 125 - 126 124 ifneq ($(OUTPUT),) 127 125 TE_PATH=$(OUTPUT) 128 126 ifneq ($(subdir),) 129 - LK_PATH=$(OUTPUT)$(LK_DIR) 127 + LK_PATH=$(objtree)/lib/lk/ 130 128 else 131 129 LK_PATH=$(OUTPUT) 132 130 endif 133 131 else 134 132 TE_PATH=$(TRACE_EVENT_DIR) 133 + LK_PATH=$(LK_DIR) 135 134 endif 136 135 137 136 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
+2 -2
tools/perf/bench/mem-memcpy.c
··· 111 111 static void alloc_mem(void **dst, void **src, size_t length) 112 112 { 113 113 *dst = zalloc(length); 114 - if (!dst) 114 + if (!*dst) 115 115 die("memory allocation failed - maybe length is too large?\n"); 116 116 117 117 *src = zalloc(length); 118 - if (!src) 118 + if (!*src) 119 119 die("memory allocation failed - maybe length is too large?\n"); 120 120 } 121 121
+1 -1
tools/perf/bench/mem-memset.c
··· 111 111 static void alloc_mem(void **dst, size_t length) 112 112 { 113 113 *dst = zalloc(length); 114 - if (!dst) 114 + if (!*dst) 115 115 die("memory allocation failed - maybe length is too large?\n"); 116 116 } 117 117
-1
tools/perf/builtin-diff.c
··· 607 607 input_new = "perf.data.guest"; 608 608 } 609 609 610 - symbol_conf.exclude_other = false; 611 610 if (symbol__init() < 0) 612 611 return -1; 613 612
+1 -1
tools/perf/builtin-kmem.c
··· 708 708 static int __cmd_record(int argc, const char **argv) 709 709 { 710 710 const char * const record_args[] = { 711 - "record", "-a", "-R", "-f", "-c", "1", 711 + "record", "-a", "-R", "-c", "1", 712 712 "-e", "kmem:kmalloc", 713 713 "-e", "kmem:kmalloc_node", 714 714 "-e", "kmem:kfree",
+1 -1
tools/perf/builtin-lock.c
··· 878 878 static int __cmd_record(int argc, const char **argv) 879 879 { 880 880 const char *record_args[] = { 881 - "record", "-R", "-f", "-m", "1024", "-c", "1", 881 + "record", "-R", "-m", "1024", "-c", "1", 882 882 }; 883 883 unsigned int rec_argc, i, j; 884 884 const char **rec_argv;
+9 -76
tools/perf/builtin-record.c
··· 61 61 } 62 62 #endif 63 63 64 - enum write_mode_t { 65 - WRITE_FORCE, 66 - WRITE_APPEND 67 - }; 68 - 69 64 struct perf_record { 70 65 struct perf_tool tool; 71 66 struct perf_record_opts opts; ··· 72 77 int output; 73 78 unsigned int page_size; 74 79 int realtime_prio; 75 - enum write_mode_t write_mode; 76 80 bool no_buildid; 77 81 bool no_buildid_cache; 78 - bool force; 79 - bool file_new; 80 - bool append_file; 81 82 long samples; 82 83 off_t post_processing_offset; 83 84 }; ··· 191 200 signal(signr, SIG_DFL); 192 201 } 193 202 194 - static bool perf_evlist__equal(struct perf_evlist *evlist, 195 - struct perf_evlist *other) 196 - { 197 - struct perf_evsel *pos, *pair; 198 - 199 - if (evlist->nr_entries != other->nr_entries) 200 - return false; 201 - 202 - pair = perf_evlist__first(other); 203 - 204 - list_for_each_entry(pos, &evlist->entries, node) { 205 - if (memcmp(&pos->attr, &pair->attr, sizeof(pos->attr) != 0)) 206 - return false; 207 - pair = perf_evsel__next(pair); 208 - } 209 - 210 - return true; 211 - } 212 - 213 203 static int perf_record__open(struct perf_record *rec) 214 204 { 215 205 char msg[512]; ··· 245 273 goto out; 246 274 } 247 275 248 - if (rec->file_new) 249 - session->evlist = evlist; 250 - else { 251 - if (!perf_evlist__equal(session->evlist, evlist)) { 252 - fprintf(stderr, "incompatible append\n"); 253 - rc = -1; 254 - goto out; 255 - } 256 - } 257 - 276 + session->evlist = evlist; 258 277 perf_session__set_id_hdr_size(session); 259 278 out: 260 279 return rc; ··· 378 415 if (!strcmp(output_name, "-")) 379 416 opts->pipe_output = true; 380 417 else if (!stat(output_name, &st) && st.st_size) { 381 - if (rec->write_mode == WRITE_FORCE) { 382 - char oldname[PATH_MAX]; 383 - snprintf(oldname, sizeof(oldname), "%s.old", 384 - output_name); 385 - unlink(oldname); 386 - rename(output_name, oldname); 387 - } 388 - } else if (rec->write_mode == WRITE_APPEND) { 389 - rec->write_mode = WRITE_FORCE; 418 + char oldname[PATH_MAX]; 419 + snprintf(oldname, sizeof(oldname), "%s.old", 420 + output_name); 421 + unlink(oldname); 422 + rename(output_name, oldname); 390 423 } 391 424 } 392 425 393 - flags = O_CREAT|O_RDWR; 394 - if (rec->write_mode == WRITE_APPEND) 395 - rec->file_new = 0; 396 - else 397 - flags |= O_TRUNC; 426 + flags = O_CREAT|O_RDWR|O_TRUNC; 398 427 399 428 if (opts->pipe_output) 400 429 output = STDOUT_FILENO; ··· 400 445 rec->output = output; 401 446 402 447 session = perf_session__new(output_name, O_WRONLY, 403 - rec->write_mode == WRITE_FORCE, false, NULL); 448 + true, false, NULL); 404 449 if (session == NULL) { 405 450 pr_err("Not enough memory for reading perf file header\n"); 406 451 return -1; ··· 419 464 420 465 if (!rec->opts.branch_stack) 421 466 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); 422 - 423 - if (!rec->file_new) { 424 - err = perf_session__read_header(session, output); 425 - if (err < 0) 426 - goto out_delete_session; 427 - } 428 467 429 468 if (forks) { 430 469 err = perf_evlist__prepare_workload(evsel_list, &opts->target, ··· 447 498 err = perf_header__write_pipe(output); 448 499 if (err < 0) 449 500 goto out_delete_session; 450 - } else if (rec->file_new) { 501 + } else { 451 502 err = perf_session__write_header(session, evsel_list, 452 503 output, false); 453 504 if (err < 0) ··· 818 869 .uses_mmap = true, 819 870 }, 820 871 }, 821 - .write_mode = WRITE_FORCE, 822 - .file_new = true, 823 872 }; 824 873 825 874 #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " ··· 853 906 "collect raw sample records from all opened counters"), 854 907 OPT_BOOLEAN('a', "all-cpus", &record.opts.target.system_wide, 855 908 "system-wide collection from all CPUs"), 856 - OPT_BOOLEAN('A', "append", &record.append_file, 857 - "append to the output file to do incremental profiling"), 858 909 OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", 859 910 "list of cpus to monitor"), 860 - OPT_BOOLEAN('f', "force", &record.force, 861 - "overwrite existing data file (deprecated)"), 862 911 OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"), 863 912 OPT_STRING('o', "output", &record.output_name, "file", 864 913 "output file name"), ··· 919 976 PARSE_OPT_STOP_AT_NON_OPTION); 920 977 if (!argc && perf_target__none(&rec->opts.target)) 921 978 usage_with_options(record_usage, record_options); 922 - 923 - if (rec->force && rec->append_file) { 924 - ui__error("Can't overwrite and append at the same time." 925 - " You need to choose between -f and -A"); 926 - usage_with_options(record_usage, record_options); 927 - } else if (rec->append_file) { 928 - rec->write_mode = WRITE_APPEND; 929 - } else { 930 - rec->write_mode = WRITE_FORCE; 931 - } 932 979 933 980 if (nr_cgroups && !rec->opts.target.system_wide) { 934 981 ui__error("cgroup monitoring only available in"
+1 -2
tools/perf/builtin-report.c
··· 939 939 */ 940 940 if (!strstr(sort_order, "parent")) 941 941 sort_parent.elide = 1; 942 - } else 943 - symbol_conf.exclude_other = false; 942 + } 944 943 945 944 if (argc) { 946 945 /*
-1
tools/perf/builtin-sched.c
··· 1632 1632 "record", 1633 1633 "-a", 1634 1634 "-R", 1635 - "-f", 1636 1635 "-m", "1024", 1637 1636 "-c", "1", 1638 1637 "-e", "sched:sched_switch",
+26 -4
tools/perf/builtin-stat.c
··· 87 87 static bool no_inherit = false; 88 88 static bool scale = true; 89 89 static enum aggr_mode aggr_mode = AGGR_GLOBAL; 90 - static pid_t child_pid = -1; 90 + static volatile pid_t child_pid = -1; 91 91 static bool null_run = false; 92 92 static int detailed_run = 0; 93 93 static bool big_num = true; ··· 924 924 static void print_aggr(char *prefix) 925 925 { 926 926 struct perf_evsel *counter; 927 - int cpu, s, s2, id, nr; 927 + int cpu, cpu2, s, s2, id, nr; 928 928 u64 ena, run, val; 929 929 930 930 if (!(aggr_map || aggr_get_id)) ··· 936 936 val = ena = run = 0; 937 937 nr = 0; 938 938 for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { 939 - s2 = aggr_get_id(evsel_list->cpus, cpu); 939 + cpu2 = perf_evsel__cpus(counter)->map[cpu]; 940 + s2 = aggr_get_id(evsel_list->cpus, cpu2); 940 941 if (s2 != id) 941 942 continue; 942 943 val += counter->counts->cpu[cpu].val; ··· 949 948 fprintf(output, "%s", prefix); 950 949 951 950 if (run == 0 || ena == 0) { 952 - aggr_printout(counter, cpu, nr); 951 + aggr_printout(counter, id, nr); 953 952 954 953 fprintf(output, "%*s%s%*s", 955 954 csv_output ? 0 : 18, ··· 1149 1148 done = 1; 1150 1149 1151 1150 signr = signo; 1151 + /* 1152 + * render child_pid harmless 1153 + * won't send SIGTERM to a random 1154 + * process in case of race condition 1155 + * and fast PID recycling 1156 + */ 1157 + child_pid = -1; 1152 1158 } 1153 1159 1154 1160 static void sig_atexit(void) 1155 1161 { 1162 + sigset_t set, oset; 1163 + 1164 + /* 1165 + * avoid race condition with SIGCHLD handler 1166 + * in skip_signal() which is modifying child_pid 1167 + * goal is to avoid send SIGTERM to a random 1168 + * process 1169 + */ 1170 + sigemptyset(&set); 1171 + sigaddset(&set, SIGCHLD); 1172 + sigprocmask(SIG_BLOCK, &set, &oset); 1173 + 1156 1174 if (child_pid != -1) 1157 1175 kill(child_pid, SIGTERM); 1176 + 1177 + sigprocmask(SIG_SETMASK, &oset, NULL); 1158 1178 1159 1179 if (signr == -1) 1160 1180 return;
+2 -2
tools/perf/builtin-timechart.c
··· 1005 1005 { 1006 1006 #ifdef SUPPORT_OLD_POWER_EVENTS 1007 1007 const char * const record_old_args[] = { 1008 - "record", "-a", "-R", "-f", "-c", "1", 1008 + "record", "-a", "-R", "-c", "1", 1009 1009 "-e", "power:power_start", 1010 1010 "-e", "power:power_end", 1011 1011 "-e", "power:power_frequency", ··· 1014 1014 }; 1015 1015 #endif 1016 1016 const char * const record_new_args[] = { 1017 - "record", "-a", "-R", "-f", "-c", "1", 1017 + "record", "-a", "-R", "-c", "1", 1018 1018 "-e", "power:cpu_frequency", 1019 1019 "-e", "power:cpu_idle", 1020 1020 "-e", "sched:sched_wakeup",
-2
tools/perf/builtin-top.c
··· 1130 1130 if (top.evlist == NULL) 1131 1131 return -ENOMEM; 1132 1132 1133 - symbol_conf.exclude_other = false; 1134 - 1135 1133 argc = parse_options(argc, argv, options, top_usage, 0); 1136 1134 if (argc) 1137 1135 usage_with_options(top_usage, options);
+3 -3
tools/perf/config/Makefile
··· 39 39 endif 40 40 41 41 ifeq ($(obj-perf),) 42 - obj-perf := $(objtree) 42 + obj-perf := $(OUTPUT) 43 43 endif 44 44 45 45 ifneq ($(obj-perf),) ··· 85 85 CFLAGS += -Wextra 86 86 CFLAGS += -std=gnu99 87 87 88 - EXTLIBS = -lpthread -lrt -lelf -lm 88 + EXTLIBS = -lelf -lpthread -lrt -lm 89 89 90 90 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) 91 91 CFLAGS += -fstack-protector-all ··· 165 165 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 166 166 endif 167 167 168 - FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) 168 + FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) 169 169 ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) 170 170 msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); 171 171 NO_DWARF := 1
+2 -2
tools/perf/config/utilities.mak
··· 173 173 # Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default) 174 174 # 175 175 define get-executable-or-default 176 - $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2),$(1))) 176 + $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2))) 177 177 endef 178 178 _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) 179 179 _gea_warn = $(warning The path '$(1)' is not executable.) ··· 181 181 182 182 # try-cc 183 183 # Usage: option = $(call try-cc, source-to-build, cc-options, msg) 184 - ifndef V 184 + ifneq ($(V),1) 185 185 TRY_CC_OUTPUT= > /dev/null 2>&1 186 186 endif 187 187 TRY_CC_MSG=echo " CHK $(3)" 1>&2;
+1 -1
tools/perf/scripts/perl/Perf-Trace-Util/Context.xs
··· 23 23 #include "perl.h" 24 24 #include "XSUB.h" 25 25 #include "../../../perf.h" 26 - #include "../../../util/script-event.h" 26 + #include "../../../util/trace-event.h" 27 27 28 28 MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context 29 29 PROTOTYPES: ENABLE
+15 -6
tools/perf/util/PERF-VERSION-GEN
··· 13 13 # First check if there is a .git to get the version from git describe 14 14 # otherwise try to get the version from the kernel Makefile 15 15 # 16 - if test -d ../../.git -o -f ../../.git && 17 - VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") 16 + CID= 17 + TAG= 18 + if test -d ../../.git -o -f ../../.git 18 19 then 19 - VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) 20 - VN=$(echo "$VN" | sed -e 's/-/./g'); 21 - else 22 - VN=$(MAKEFLAGS= make -sC ../.. kernelversion) 20 + TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) 21 + CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" 22 + fi 23 + if test -z "$TAG" 24 + then 25 + TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) 26 + fi 27 + VN="$TAG$CID" 28 + if test -n "$CID" 29 + then 30 + # format version string, strip trailing zero of sublevel: 31 + VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/') 23 32 fi 24 33 25 34 VN=$(expr "$VN" : v*'\(.*\)')
+8 -2
tools/perf/util/dso.c
··· 513 513 list_add_tail(&dso->node, head); 514 514 } 515 515 516 - struct dso *dsos__find(struct list_head *head, const char *name) 516 + struct dso *dsos__find(struct list_head *head, const char *name, bool cmp_short) 517 517 { 518 518 struct dso *pos; 519 519 520 + if (cmp_short) { 521 + list_for_each_entry(pos, head, node) 522 + if (strcmp(pos->short_name, name) == 0) 523 + return pos; 524 + return NULL; 525 + } 520 526 list_for_each_entry(pos, head, node) 521 527 if (strcmp(pos->long_name, name) == 0) 522 528 return pos; ··· 531 525 532 526 struct dso *__dsos__findnew(struct list_head *head, const char *name) 533 527 { 534 - struct dso *dso = dsos__find(head, name); 528 + struct dso *dso = dsos__find(head, name, false); 535 529 536 530 if (!dso) { 537 531 dso = dso__new(name);
+2 -1
tools/perf/util/dso.h
··· 133 133 const char *short_name, int dso_type); 134 134 135 135 void dsos__add(struct list_head *head, struct dso *dso); 136 - struct dso *dsos__find(struct list_head *head, const char *name); 136 + struct dso *dsos__find(struct list_head *head, const char *name, 137 + bool cmp_short); 137 138 struct dso *__dsos__findnew(struct list_head *head, const char *name); 138 139 bool __dsos__read_build_ids(struct list_head *head, bool with_hits); 139 140
+9 -1
tools/perf/util/evlist.c
··· 821 821 goto out_close_pipes; 822 822 } 823 823 824 + fcntl(go_pipe[1], F_SETFD, FD_CLOEXEC); 824 825 evlist->workload.cork_fd = go_pipe[1]; 825 826 close(child_ready_pipe[0]); 826 827 return 0; ··· 838 837 int perf_evlist__start_workload(struct perf_evlist *evlist) 839 838 { 840 839 if (evlist->workload.cork_fd > 0) { 840 + char bf; 841 + int ret; 841 842 /* 842 843 * Remove the cork, let it rip! 843 844 */ 844 - return close(evlist->workload.cork_fd); 845 + ret = write(evlist->workload.cork_fd, &bf, 1); 846 + if (ret < 0) 847 + perror("enable to write to pipe"); 848 + 849 + close(evlist->workload.cork_fd); 850 + return ret; 845 851 } 846 852 847 853 return 0;
+2 -2
tools/perf/util/evsel.c
··· 124 124 bf = nbf; 125 125 } 126 126 127 - n = read(fd, bf + size, BUFSIZ); 127 + n = read(fd, bf + size, alloc_size - size); 128 128 if (n < 0) 129 129 goto out_free_bf; 130 130 size += n; ··· 1170 1170 } else { 1171 1171 data->user_stack.data = (char *)array; 1172 1172 array += size / sizeof(*array); 1173 - data->user_stack.size = *array; 1173 + data->user_stack.size = *array++; 1174 1174 } 1175 1175 } 1176 1176
+3 -12
tools/perf/util/header.c
··· 2303 2303 struct perf_file_header f_header; 2304 2304 struct perf_file_attr f_attr; 2305 2305 struct perf_header *header = &session->header; 2306 - struct perf_evsel *evsel, *pair = NULL; 2306 + struct perf_evsel *evsel; 2307 2307 int err; 2308 2308 2309 2309 lseek(fd, sizeof(f_header), SEEK_SET); 2310 - 2311 - if (session->evlist != evlist) 2312 - pair = perf_evlist__first(session->evlist); 2313 2310 2314 2311 list_for_each_entry(evsel, &evlist->entries, node) { 2315 2312 evsel->id_offset = lseek(fd, 0, SEEK_CUR); 2316 2313 err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); 2317 2314 if (err < 0) { 2318 - out_err_write: 2319 2315 pr_debug("failed to write perf header\n"); 2320 2316 return err; 2321 - } 2322 - if (session->evlist != evlist) { 2323 - err = do_write(fd, pair->id, pair->ids * sizeof(u64)); 2324 - if (err < 0) 2325 - goto out_err_write; 2326 - evsel->ids += pair->ids; 2327 - pair = perf_evsel__next(pair); 2328 2317 } 2329 2318 } 2330 2319 ··· 2955 2966 for (i = 0; i < n_ids; i++) { 2956 2967 perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]); 2957 2968 } 2969 + 2970 + symbol_conf.nr_events = evlist->nr_entries; 2958 2971 2959 2972 return 0; 2960 2973 }
+3 -1
tools/perf/util/parse-events.c
··· 860 860 return 0; 861 861 } 862 862 863 - parse_events__free_terms(data.terms); 863 + if (data.terms) 864 + parse_events__free_terms(data.terms); 864 865 return ret; 865 866 } 866 867 ··· 1184 1183 term->val.str = str; 1185 1184 break; 1186 1185 default: 1186 + free(term); 1187 1187 return -EINVAL; 1188 1188 } 1189 1189
-1
tools/perf/util/symbol.c
··· 32 32 char **vmlinux_path; 33 33 34 34 struct symbol_conf symbol_conf = { 35 - .exclude_other = true, 36 35 .use_modules = true, 37 36 .try_vmlinux_path = true, 38 37 .annotate_src = true,
+1 -1
tools/perf/util/util.h
··· 72 72 #include "types.h" 73 73 #include <sys/ttydefaults.h> 74 74 #include <lk/debugfs.h> 75 + #include <termios.h> 75 76 76 77 extern const char *graph_line; 77 78 extern const char *graph_dotted_line; ··· 275 274 276 275 extern unsigned int page_size; 277 276 278 - struct winsize; 279 277 void get_term_dimensions(struct winsize *ws); 280 278 #endif /* GIT_COMPAT_UTIL_H */
+1 -1
tools/perf/util/vdso.c
··· 91 91 92 92 struct dso *vdso__dso_findnew(struct list_head *head) 93 93 { 94 - struct dso *dso = dsos__find(head, VDSO__MAP_NAME); 94 + struct dso *dso = dsos__find(head, VDSO__MAP_NAME, true); 95 95 96 96 if (!dso) { 97 97 char *file;
+1 -1
tools/scripts/Makefile.include
··· 59 59 QUIET_SUBDIR1 = 60 60 61 61 ifneq ($(findstring $(MAKEFLAGS),s),s) 62 - ifndef V 62 + ifneq ($(V),1) 63 63 QUIET_CC = @echo ' ' CC $@; 64 64 QUIET_AR = @echo ' ' AR $@; 65 65 QUIET_LINK = @echo ' ' LINK $@;