diff options
34 files changed, 154 insertions, 163 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events index 8b25ffb42562..3c1cc24361bd 100644 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events | |||
@@ -29,7 +29,7 @@ Description: Generic performance monitoring events | |||
29 | 29 | ||
30 | What: /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL | 30 | What: /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL |
31 | /sys/devices/cpu/events/PM_BRU_FIN | 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 | /sys/devices/cpu/events/PM_CMPLU_STALL | 33 | /sys/devices/cpu/events/PM_CMPLU_STALL |
34 | /sys/devices/cpu/events/PM_CMPLU_STALL_BRU | 34 | /sys/devices/cpu/events/PM_CMPLU_STALL_BRU |
35 | /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS | 35 | /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS |
diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c index 13c3f0e547a2..d1821b8bbc4c 100644 --- a/arch/powerpc/perf/power7-pmu.c +++ b/arch/powerpc/perf/power7-pmu.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #define PME_PM_LD_REF_L1 0xc880 | 60 | #define PME_PM_LD_REF_L1 0xc880 |
61 | #define PME_PM_LD_MISS_L1 0x400f0 | 61 | #define PME_PM_LD_MISS_L1 0x400f0 |
62 | #define PME_PM_BRU_FIN 0x10068 | 62 | #define PME_PM_BRU_FIN 0x10068 |
63 | #define PME_PM_BRU_MPRED 0x400f6 | 63 | #define PME_PM_BR_MPRED 0x400f6 |
64 | 64 | ||
65 | #define PME_PM_CMPLU_STALL_FXU 0x20014 | 65 | #define PME_PM_CMPLU_STALL_FXU 0x20014 |
66 | #define PME_PM_CMPLU_STALL_DIV 0x40014 | 66 | #define PME_PM_CMPLU_STALL_DIV 0x40014 |
@@ -349,7 +349,7 @@ static int power7_generic_events[] = { | |||
349 | [PERF_COUNT_HW_CACHE_REFERENCES] = PME_PM_LD_REF_L1, | 349 | [PERF_COUNT_HW_CACHE_REFERENCES] = PME_PM_LD_REF_L1, |
350 | [PERF_COUNT_HW_CACHE_MISSES] = PME_PM_LD_MISS_L1, | 350 | [PERF_COUNT_HW_CACHE_MISSES] = PME_PM_LD_MISS_L1, |
351 | [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = PME_PM_BRU_FIN, | 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 | #define C(x) PERF_COUNT_HW_CACHE_##x | 355 | #define C(x) PERF_COUNT_HW_CACHE_##x |
@@ -405,7 +405,7 @@ GENERIC_EVENT_ATTR(instructions, INST_CMPL); | |||
405 | GENERIC_EVENT_ATTR(cache-references, LD_REF_L1); | 405 | GENERIC_EVENT_ATTR(cache-references, LD_REF_L1); |
406 | GENERIC_EVENT_ATTR(cache-misses, LD_MISS_L1); | 406 | GENERIC_EVENT_ATTR(cache-misses, LD_MISS_L1); |
407 | GENERIC_EVENT_ATTR(branch-instructions, BRU_FIN); | 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 | POWER_EVENT_ATTR(CYC, CYC); | 410 | POWER_EVENT_ATTR(CYC, CYC); |
411 | POWER_EVENT_ATTR(GCT_NOSLOT_CYC, GCT_NOSLOT_CYC); | 411 | POWER_EVENT_ATTR(GCT_NOSLOT_CYC, GCT_NOSLOT_CYC); |
@@ -414,7 +414,7 @@ POWER_EVENT_ATTR(INST_CMPL, INST_CMPL); | |||
414 | POWER_EVENT_ATTR(LD_REF_L1, LD_REF_L1); | 414 | POWER_EVENT_ATTR(LD_REF_L1, LD_REF_L1); |
415 | POWER_EVENT_ATTR(LD_MISS_L1, LD_MISS_L1); | 415 | POWER_EVENT_ATTR(LD_MISS_L1, LD_MISS_L1); |
416 | POWER_EVENT_ATTR(BRU_FIN, BRU_FIN) | 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 | POWER_EVENT_ATTR(CMPLU_STALL_FXU, CMPLU_STALL_FXU); | 419 | POWER_EVENT_ATTR(CMPLU_STALL_FXU, CMPLU_STALL_FXU); |
420 | POWER_EVENT_ATTR(CMPLU_STALL_DIV, CMPLU_STALL_DIV); | 420 | POWER_EVENT_ATTR(CMPLU_STALL_DIV, CMPLU_STALL_DIV); |
@@ -449,7 +449,7 @@ static struct attribute *power7_events_attr[] = { | |||
449 | GENERIC_EVENT_PTR(LD_REF_L1), | 449 | GENERIC_EVENT_PTR(LD_REF_L1), |
450 | GENERIC_EVENT_PTR(LD_MISS_L1), | 450 | GENERIC_EVENT_PTR(LD_MISS_L1), |
451 | GENERIC_EVENT_PTR(BRU_FIN), | 451 | GENERIC_EVENT_PTR(BRU_FIN), |
452 | GENERIC_EVENT_PTR(BRU_MPRED), | 452 | GENERIC_EVENT_PTR(BR_MPRED), |
453 | 453 | ||
454 | POWER_EVENT_PTR(CYC), | 454 | POWER_EVENT_PTR(CYC), |
455 | POWER_EVENT_PTR(GCT_NOSLOT_CYC), | 455 | POWER_EVENT_PTR(GCT_NOSLOT_CYC), |
@@ -458,7 +458,7 @@ static struct attribute *power7_events_attr[] = { | |||
458 | POWER_EVENT_PTR(LD_REF_L1), | 458 | POWER_EVENT_PTR(LD_REF_L1), |
459 | POWER_EVENT_PTR(LD_MISS_L1), | 459 | POWER_EVENT_PTR(LD_MISS_L1), |
460 | POWER_EVENT_PTR(BRU_FIN), | 460 | POWER_EVENT_PTR(BRU_FIN), |
461 | POWER_EVENT_PTR(BRU_MPRED), | 461 | POWER_EVENT_PTR(BR_MPRED), |
462 | 462 | ||
463 | POWER_EVENT_PTR(CMPLU_STALL_FXU), | 463 | POWER_EVENT_PTR(CMPLU_STALL_FXU), |
464 | POWER_EVENT_PTR(CMPLU_STALL_DIV), | 464 | POWER_EVENT_PTR(CMPLU_STALL_DIV), |
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 0920212e6159..ba77ebc2c353 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c | |||
@@ -111,7 +111,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 | |||
111 | */ | 111 | */ |
112 | list_for_each_entry_rcu(a, &desc->head, list) { | 112 | list_for_each_entry_rcu(a, &desc->head, list) { |
113 | u64 before, delta, whole_msecs; | 113 | u64 before, delta, whole_msecs; |
114 | int decimal_msecs, thishandled; | 114 | int remainder_ns, decimal_msecs, thishandled; |
115 | 115 | ||
116 | before = local_clock(); | 116 | before = local_clock(); |
117 | thishandled = a->handler(type, regs); | 117 | thishandled = a->handler(type, regs); |
@@ -123,8 +123,9 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 | |||
123 | continue; | 123 | continue; |
124 | 124 | ||
125 | nmi_longest_ns = delta; | 125 | nmi_longest_ns = delta; |
126 | whole_msecs = do_div(delta, (1000 * 1000)); | 126 | whole_msecs = delta; |
127 | decimal_msecs = do_div(delta, 1000) % 1000; | 127 | remainder_ns = do_div(whole_msecs, (1000 * 1000)); |
128 | decimal_msecs = remainder_ns / 1000; | ||
128 | printk_ratelimited(KERN_INFO | 129 | printk_ratelimited(KERN_INFO |
129 | "INFO: NMI handler (%ps) took too long to run: " | 130 | "INFO: NMI handler (%ps) took too long to run: " |
130 | "%lld.%03d msecs\n", a->handler, whole_msecs, | 131 | "%lld.%03d msecs\n", a->handler, whole_msecs, |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 1833bc5a84a7..eba8fb5834ae 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -947,8 +947,18 @@ perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags) | |||
947 | { | 947 | { |
948 | struct perf_event_context *ctx; | 948 | struct perf_event_context *ctx; |
949 | 949 | ||
950 | rcu_read_lock(); | ||
951 | retry: | 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 | ctx = rcu_dereference(task->perf_event_ctxp[ctxn]); | 962 | ctx = rcu_dereference(task->perf_event_ctxp[ctxn]); |
953 | if (ctx) { | 963 | if (ctx) { |
954 | /* | 964 | /* |
@@ -964,6 +974,8 @@ retry: | |||
964 | raw_spin_lock_irqsave(&ctx->lock, *flags); | 974 | raw_spin_lock_irqsave(&ctx->lock, *flags); |
965 | if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) { | 975 | if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) { |
966 | raw_spin_unlock_irqrestore(&ctx->lock, *flags); | 976 | raw_spin_unlock_irqrestore(&ctx->lock, *flags); |
977 | rcu_read_unlock(); | ||
978 | preempt_enable(); | ||
967 | goto retry; | 979 | goto retry; |
968 | } | 980 | } |
969 | 981 | ||
@@ -973,6 +985,7 @@ retry: | |||
973 | } | 985 | } |
974 | } | 986 | } |
975 | rcu_read_unlock(); | 987 | rcu_read_unlock(); |
988 | preempt_enable(); | ||
976 | return ctx; | 989 | return ctx; |
977 | } | 990 | } |
978 | 991 | ||
@@ -1950,7 +1963,16 @@ static int __perf_event_enable(void *info) | |||
1950 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | 1963 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); |
1951 | int err; | 1964 | int err; |
1952 | 1965 | ||
1953 | if (WARN_ON_ONCE(!ctx->is_active)) | 1966 | /* |
1967 | * There's a time window between 'ctx->is_active' check | ||
1968 | * in perf_event_enable function and this place having: | ||
1969 | * - IRQs on | ||
1970 | * - ctx->lock unlocked | ||
1971 | * | ||
1972 | * where the task could be killed and 'ctx' deactivated | ||
1973 | * by perf_event_exit_task. | ||
1974 | */ | ||
1975 | if (!ctx->is_active) | ||
1954 | return -EINVAL; | 1976 | return -EINVAL; |
1955 | 1977 | ||
1956 | raw_spin_lock(&ctx->lock); | 1978 | raw_spin_lock(&ctx->lock); |
@@ -7465,7 +7487,7 @@ inherit_task_group(struct perf_event *event, struct task_struct *parent, | |||
7465 | * child. | 7487 | * child. |
7466 | */ | 7488 | */ |
7467 | 7489 | ||
7468 | child_ctx = alloc_perf_context(event->pmu, child); | 7490 | child_ctx = alloc_perf_context(parent_ctx->pmu, child); |
7469 | if (!child_ctx) | 7491 | if (!child_ctx) |
7470 | return -ENOMEM; | 7492 | return -ENOMEM; |
7471 | 7493 | ||
diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile index 2c5a19733357..280dd8205430 100644 --- a/tools/lib/lk/Makefile +++ b/tools/lib/lk/Makefile | |||
@@ -3,6 +3,21 @@ include ../../scripts/Makefile.include | |||
3 | CC = $(CROSS_COMPILE)gcc | 3 | CC = $(CROSS_COMPILE)gcc |
4 | AR = $(CROSS_COMPILE)ar | 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 | # guard against environment variables | 21 | # guard against environment variables |
7 | LIB_H= | 22 | LIB_H= |
8 | LIB_OBJS= | 23 | LIB_OBJS= |
@@ -14,7 +29,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o | |||
14 | LIBFILE = liblk.a | 29 | LIBFILE = liblk.a |
15 | 30 | ||
16 | CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC | 31 | CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC |
17 | EXTLIBS = -lpthread -lrt -lelf -lm | 32 | EXTLIBS = -lelf -lpthread -lrt -lm |
18 | ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 | 33 | ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 |
19 | ALL_LDFLAGS = $(LDFLAGS) | 34 | ALL_LDFLAGS = $(LDFLAGS) |
20 | 35 | ||
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile index eb30044a922a..5a37a7c84e69 100644 --- a/tools/perf/Documentation/Makefile +++ b/tools/perf/Documentation/Makefile | |||
@@ -1,12 +1,6 @@ | |||
1 | include ../../scripts/Makefile.include | ||
1 | include ../config/utilities.mak | 2 | include ../config/utilities.mak |
2 | 3 | ||
3 | OUTPUT := ./ | ||
4 | ifeq ("$(origin O)", "command line") | ||
5 | ifneq ($(O),) | ||
6 | OUTPUT := $(O)/ | ||
7 | endif | ||
8 | endif | ||
9 | |||
10 | MAN1_TXT= \ | 4 | MAN1_TXT= \ |
11 | $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ | 5 | $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ |
12 | $(wildcard perf-*.txt)) \ | 6 | $(wildcard perf-*.txt)) \ |
@@ -150,7 +144,7 @@ NO_SUBDIR = : | |||
150 | endif | 144 | endif |
151 | 145 | ||
152 | ifneq ($(findstring $(MAKEFLAGS),s),s) | 146 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
153 | ifndef V | 147 | ifneq ($(V),1) |
154 | QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; | 148 | QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; |
155 | QUIET_XMLTO = @echo ' ' XMLTO $@; | 149 | QUIET_XMLTO = @echo ' ' XMLTO $@; |
156 | QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; | 150 | QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; |
@@ -277,7 +271,7 @@ $(MAN_HTML): $(OUTPUT)%.html : %.txt | |||
277 | 271 | ||
278 | $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml | 272 | $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml |
279 | $(QUIET_XMLTO)$(RM) $@ && \ | 273 | $(QUIET_XMLTO)$(RM) $@ && \ |
280 | $(XMLTO) -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< | 274 | $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< |
281 | 275 | ||
282 | $(OUTPUT)%.xml : %.txt | 276 | $(OUTPUT)%.xml : %.txt |
283 | $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ | 277 | $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ |
diff --git a/tools/perf/Documentation/examples.txt b/tools/perf/Documentation/examples.txt index 77f952762426..a4e392156488 100644 --- a/tools/perf/Documentation/examples.txt +++ b/tools/perf/Documentation/examples.txt | |||
@@ -66,7 +66,7 @@ Furthermore, these tracepoints can be used to sample the workload as | |||
66 | well. For example the page allocations done by a 'git gc' can be | 66 | well. For example the page allocations done by a 'git gc' can be |
67 | captured the following way: | 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 | Counting objects: 1148, done. | 70 | Counting objects: 1148, done. |
71 | Delta compression using up to 2 threads. | 71 | Delta compression using up to 2 threads. |
72 | Compressing objects: 100% (450/450), done. | 72 | Compressing objects: 100% (450/450), done. |
@@ -120,7 +120,7 @@ Furthermore, call-graph sampling can be done too, of page | |||
120 | allocations - to see precisely what kind of page allocations there | 120 | allocations - to see precisely what kind of page allocations there |
121 | are: | 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 | Counting objects: 1148, done. | 124 | Counting objects: 1148, done. |
125 | Delta compression using up to 2 threads. | 125 | Delta compression using up to 2 threads. |
126 | Compressing objects: 100% (450/450), done. | 126 | Compressing objects: 100% (450/450), done. |
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index d4da111ef53d..e297b74471b8 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
@@ -65,16 +65,10 @@ OPTIONS | |||
65 | -r:: | 65 | -r:: |
66 | --realtime=:: | 66 | --realtime=:: |
67 | Collect data with this RT SCHED_FIFO priority. | 67 | Collect data with this RT SCHED_FIFO priority. |
68 | |||
68 | -D:: | 69 | -D:: |
69 | --no-delay:: | 70 | --no-delay:: |
70 | Collect data without buffering. | 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 | -c:: | 73 | -c:: |
80 | --count=:: | 74 | --count=:: |
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 203cb0eecff2..641fccddb249 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -121,17 +121,16 @@ SCRIPT_SH += perf-archive.sh | |||
121 | grep-libs = $(filter -l%,$(1)) | 121 | grep-libs = $(filter -l%,$(1)) |
122 | strip-libs = $(filter-out -l%,$(1)) | 122 | strip-libs = $(filter-out -l%,$(1)) |
123 | 123 | ||
124 | LK_PATH=$(LK_DIR) | ||
125 | |||
126 | ifneq ($(OUTPUT),) | 124 | ifneq ($(OUTPUT),) |
127 | TE_PATH=$(OUTPUT) | 125 | TE_PATH=$(OUTPUT) |
128 | ifneq ($(subdir),) | 126 | ifneq ($(subdir),) |
129 | LK_PATH=$(OUTPUT)$(LK_DIR) | 127 | LK_PATH=$(objtree)/lib/lk/ |
130 | else | 128 | else |
131 | LK_PATH=$(OUTPUT) | 129 | LK_PATH=$(OUTPUT) |
132 | endif | 130 | endif |
133 | else | 131 | else |
134 | TE_PATH=$(TRACE_EVENT_DIR) | 132 | TE_PATH=$(TRACE_EVENT_DIR) |
133 | LK_PATH=$(LK_DIR) | ||
135 | endif | 134 | endif |
136 | 135 | ||
137 | LIBTRACEEVENT = $(TE_PATH)libtraceevent.a | 136 | LIBTRACEEVENT = $(TE_PATH)libtraceevent.a |
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index 93c83e3cb4a7..25fd3f1966f1 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c | |||
@@ -111,11 +111,11 @@ static double timeval2double(struct timeval *ts) | |||
111 | static void alloc_mem(void **dst, void **src, size_t length) | 111 | static void alloc_mem(void **dst, void **src, size_t length) |
112 | { | 112 | { |
113 | *dst = zalloc(length); | 113 | *dst = zalloc(length); |
114 | if (!dst) | 114 | if (!*dst) |
115 | die("memory allocation failed - maybe length is too large?\n"); | 115 | die("memory allocation failed - maybe length is too large?\n"); |
116 | 116 | ||
117 | *src = zalloc(length); | 117 | *src = zalloc(length); |
118 | if (!src) | 118 | if (!*src) |
119 | die("memory allocation failed - maybe length is too large?\n"); | 119 | die("memory allocation failed - maybe length is too large?\n"); |
120 | } | 120 | } |
121 | 121 | ||
diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c index c6e4bc523492..4a2f12081964 100644 --- a/tools/perf/bench/mem-memset.c +++ b/tools/perf/bench/mem-memset.c | |||
@@ -111,7 +111,7 @@ static double timeval2double(struct timeval *ts) | |||
111 | static void alloc_mem(void **dst, size_t length) | 111 | static void alloc_mem(void **dst, size_t length) |
112 | { | 112 | { |
113 | *dst = zalloc(length); | 113 | *dst = zalloc(length); |
114 | if (!dst) | 114 | if (!*dst) |
115 | die("memory allocation failed - maybe length is too large?\n"); | 115 | die("memory allocation failed - maybe length is too large?\n"); |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index da8f8eb383a0..0aac5f3e594d 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -607,7 +607,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) | |||
607 | input_new = "perf.data.guest"; | 607 | input_new = "perf.data.guest"; |
608 | } | 608 | } |
609 | 609 | ||
610 | symbol_conf.exclude_other = false; | ||
611 | if (symbol__init() < 0) | 610 | if (symbol__init() < 0) |
612 | return -1; | 611 | return -1; |
613 | 612 | ||
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 46878daca5cc..0259502638b4 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -708,7 +708,7 @@ static int parse_line_opt(const struct option *opt __maybe_unused, | |||
708 | static int __cmd_record(int argc, const char **argv) | 708 | static int __cmd_record(int argc, const char **argv) |
709 | { | 709 | { |
710 | const char * const record_args[] = { | 710 | const char * const record_args[] = { |
711 | "record", "-a", "-R", "-f", "-c", "1", | 711 | "record", "-a", "-R", "-c", "1", |
712 | "-e", "kmem:kmalloc", | 712 | "-e", "kmem:kmalloc", |
713 | "-e", "kmem:kmalloc_node", | 713 | "-e", "kmem:kmalloc_node", |
714 | "-e", "kmem:kfree", | 714 | "-e", "kmem:kfree", |
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 425830069749..76543a4a7a30 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c | |||
@@ -878,7 +878,7 @@ static int __cmd_report(void) | |||
878 | static int __cmd_record(int argc, const char **argv) | 878 | static int __cmd_record(int argc, const char **argv) |
879 | { | 879 | { |
880 | const char *record_args[] = { | 880 | const char *record_args[] = { |
881 | "record", "-R", "-f", "-m", "1024", "-c", "1", | 881 | "record", "-R", "-m", "1024", "-c", "1", |
882 | }; | 882 | }; |
883 | unsigned int rec_argc, i, j; | 883 | unsigned int rec_argc, i, j; |
884 | const char **rec_argv; | 884 | const char **rec_argv; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index fff985cf3852..ecca62e27b28 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -61,11 +61,6 @@ static void __handle_on_exit_funcs(void) | |||
61 | } | 61 | } |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | enum write_mode_t { | ||
65 | WRITE_FORCE, | ||
66 | WRITE_APPEND | ||
67 | }; | ||
68 | |||
69 | struct perf_record { | 64 | struct perf_record { |
70 | struct perf_tool tool; | 65 | struct perf_tool tool; |
71 | struct perf_record_opts opts; | 66 | struct perf_record_opts opts; |
@@ -77,12 +72,8 @@ struct perf_record { | |||
77 | int output; | 72 | int output; |
78 | unsigned int page_size; | 73 | unsigned int page_size; |
79 | int realtime_prio; | 74 | int realtime_prio; |
80 | enum write_mode_t write_mode; | ||
81 | bool no_buildid; | 75 | bool no_buildid; |
82 | bool no_buildid_cache; | 76 | bool no_buildid_cache; |
83 | bool force; | ||
84 | bool file_new; | ||
85 | bool append_file; | ||
86 | long samples; | 77 | long samples; |
87 | off_t post_processing_offset; | 78 | off_t post_processing_offset; |
88 | }; | 79 | }; |
@@ -200,25 +191,6 @@ static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg) | |||
200 | signal(signr, SIG_DFL); | 191 | signal(signr, SIG_DFL); |
201 | } | 192 | } |
202 | 193 | ||
203 | static bool perf_evlist__equal(struct perf_evlist *evlist, | ||
204 | struct perf_evlist *other) | ||
205 | { | ||
206 | struct perf_evsel *pos, *pair; | ||
207 | |||
208 | if (evlist->nr_entries != other->nr_entries) | ||
209 | return false; | ||
210 | |||
211 | pair = perf_evlist__first(other); | ||
212 | |||
213 | list_for_each_entry(pos, &evlist->entries, node) { | ||
214 | if (memcmp(&pos->attr, &pair->attr, sizeof(pos->attr) != 0)) | ||
215 | return false; | ||
216 | pair = perf_evsel__next(pair); | ||
217 | } | ||
218 | |||
219 | return true; | ||
220 | } | ||
221 | |||
222 | static int perf_record__open(struct perf_record *rec) | 194 | static int perf_record__open(struct perf_record *rec) |
223 | { | 195 | { |
224 | char msg[512]; | 196 | char msg[512]; |
@@ -273,16 +245,7 @@ try_again: | |||
273 | goto out; | 245 | goto out; |
274 | } | 246 | } |
275 | 247 | ||
276 | if (rec->file_new) | 248 | session->evlist = evlist; |
277 | session->evlist = evlist; | ||
278 | else { | ||
279 | if (!perf_evlist__equal(session->evlist, evlist)) { | ||
280 | fprintf(stderr, "incompatible append\n"); | ||
281 | rc = -1; | ||
282 | goto out; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | perf_session__set_id_hdr_size(session); | 249 | perf_session__set_id_hdr_size(session); |
287 | out: | 250 | out: |
288 | return rc; | 251 | return rc; |
@@ -415,23 +378,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
415 | if (!strcmp(output_name, "-")) | 378 | if (!strcmp(output_name, "-")) |
416 | opts->pipe_output = true; | 379 | opts->pipe_output = true; |
417 | else if (!stat(output_name, &st) && st.st_size) { | 380 | else if (!stat(output_name, &st) && st.st_size) { |
418 | if (rec->write_mode == WRITE_FORCE) { | 381 | char oldname[PATH_MAX]; |
419 | char oldname[PATH_MAX]; | 382 | snprintf(oldname, sizeof(oldname), "%s.old", |
420 | snprintf(oldname, sizeof(oldname), "%s.old", | 383 | output_name); |
421 | output_name); | 384 | unlink(oldname); |
422 | unlink(oldname); | 385 | rename(output_name, oldname); |
423 | rename(output_name, oldname); | ||
424 | } | ||
425 | } else if (rec->write_mode == WRITE_APPEND) { | ||
426 | rec->write_mode = WRITE_FORCE; | ||
427 | } | 386 | } |
428 | } | 387 | } |
429 | 388 | ||
430 | flags = O_CREAT|O_RDWR; | 389 | flags = O_CREAT|O_RDWR|O_TRUNC; |
431 | if (rec->write_mode == WRITE_APPEND) | ||
432 | rec->file_new = 0; | ||
433 | else | ||
434 | flags |= O_TRUNC; | ||
435 | 390 | ||
436 | if (opts->pipe_output) | 391 | if (opts->pipe_output) |
437 | output = STDOUT_FILENO; | 392 | output = STDOUT_FILENO; |
@@ -445,7 +400,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
445 | rec->output = output; | 400 | rec->output = output; |
446 | 401 | ||
447 | session = perf_session__new(output_name, O_WRONLY, | 402 | session = perf_session__new(output_name, O_WRONLY, |
448 | rec->write_mode == WRITE_FORCE, false, NULL); | 403 | true, false, NULL); |
449 | if (session == NULL) { | 404 | if (session == NULL) { |
450 | pr_err("Not enough memory for reading perf file header\n"); | 405 | pr_err("Not enough memory for reading perf file header\n"); |
451 | return -1; | 406 | return -1; |
@@ -465,12 +420,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
465 | if (!rec->opts.branch_stack) | 420 | if (!rec->opts.branch_stack) |
466 | perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); | 421 | perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); |
467 | 422 | ||
468 | if (!rec->file_new) { | ||
469 | err = perf_session__read_header(session, output); | ||
470 | if (err < 0) | ||
471 | goto out_delete_session; | ||
472 | } | ||
473 | |||
474 | if (forks) { | 423 | if (forks) { |
475 | err = perf_evlist__prepare_workload(evsel_list, &opts->target, | 424 | err = perf_evlist__prepare_workload(evsel_list, &opts->target, |
476 | argv, opts->pipe_output, | 425 | argv, opts->pipe_output, |
@@ -498,7 +447,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
498 | err = perf_header__write_pipe(output); | 447 | err = perf_header__write_pipe(output); |
499 | if (err < 0) | 448 | if (err < 0) |
500 | goto out_delete_session; | 449 | goto out_delete_session; |
501 | } else if (rec->file_new) { | 450 | } else { |
502 | err = perf_session__write_header(session, evsel_list, | 451 | err = perf_session__write_header(session, evsel_list, |
503 | output, false); | 452 | output, false); |
504 | if (err < 0) | 453 | if (err < 0) |
@@ -869,8 +818,6 @@ static struct perf_record record = { | |||
869 | .uses_mmap = true, | 818 | .uses_mmap = true, |
870 | }, | 819 | }, |
871 | }, | 820 | }, |
872 | .write_mode = WRITE_FORCE, | ||
873 | .file_new = true, | ||
874 | }; | 821 | }; |
875 | 822 | ||
876 | #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " | 823 | #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " |
@@ -906,12 +853,8 @@ const struct option record_options[] = { | |||
906 | "collect raw sample records from all opened counters"), | 853 | "collect raw sample records from all opened counters"), |
907 | OPT_BOOLEAN('a', "all-cpus", &record.opts.target.system_wide, | 854 | OPT_BOOLEAN('a', "all-cpus", &record.opts.target.system_wide, |
908 | "system-wide collection from all CPUs"), | 855 | "system-wide collection from all CPUs"), |
909 | OPT_BOOLEAN('A', "append", &record.append_file, | ||
910 | "append to the output file to do incremental profiling"), | ||
911 | OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", | 856 | OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", |
912 | "list of cpus to monitor"), | 857 | "list of cpus to monitor"), |
913 | OPT_BOOLEAN('f', "force", &record.force, | ||
914 | "overwrite existing data file (deprecated)"), | ||
915 | OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"), | 858 | OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"), |
916 | OPT_STRING('o', "output", &record.output_name, "file", | 859 | OPT_STRING('o', "output", &record.output_name, "file", |
917 | "output file name"), | 860 | "output file name"), |
@@ -977,16 +920,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) | |||
977 | if (!argc && perf_target__none(&rec->opts.target)) | 920 | if (!argc && perf_target__none(&rec->opts.target)) |
978 | usage_with_options(record_usage, record_options); | 921 | usage_with_options(record_usage, record_options); |
979 | 922 | ||
980 | if (rec->force && rec->append_file) { | ||
981 | ui__error("Can't overwrite and append at the same time." | ||
982 | " You need to choose between -f and -A"); | ||
983 | usage_with_options(record_usage, record_options); | ||
984 | } else if (rec->append_file) { | ||
985 | rec->write_mode = WRITE_APPEND; | ||
986 | } else { | ||
987 | rec->write_mode = WRITE_FORCE; | ||
988 | } | ||
989 | |||
990 | if (nr_cgroups && !rec->opts.target.system_wide) { | 923 | if (nr_cgroups && !rec->opts.target.system_wide) { |
991 | ui__error("cgroup monitoring only available in" | 924 | ui__error("cgroup monitoring only available in" |
992 | " system-wide mode\n"); | 925 | " system-wide mode\n"); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ca98d34cd58b..3662047cc6b1 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -939,8 +939,7 @@ repeat: | |||
939 | */ | 939 | */ |
940 | if (!strstr(sort_order, "parent")) | 940 | if (!strstr(sort_order, "parent")) |
941 | sort_parent.elide = 1; | 941 | sort_parent.elide = 1; |
942 | } else | 942 | } |
943 | symbol_conf.exclude_other = false; | ||
944 | 943 | ||
945 | if (argc) { | 944 | if (argc) { |
946 | /* | 945 | /* |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2da2a6ca22bf..fed9ae432c16 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1632,7 +1632,6 @@ static int __cmd_record(int argc, const char **argv) | |||
1632 | "record", | 1632 | "record", |
1633 | "-a", | 1633 | "-a", |
1634 | "-R", | 1634 | "-R", |
1635 | "-f", | ||
1636 | "-m", "1024", | 1635 | "-m", "1024", |
1637 | "-c", "1", | 1636 | "-c", "1", |
1638 | "-e", "sched:sched_switch", | 1637 | "-e", "sched:sched_switch", |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7e910bab1097..352fbd7ff4a1 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -87,7 +87,7 @@ static int run_count = 1; | |||
87 | static bool no_inherit = false; | 87 | static bool no_inherit = false; |
88 | static bool scale = true; | 88 | static bool scale = true; |
89 | static enum aggr_mode aggr_mode = AGGR_GLOBAL; | 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 | static bool null_run = false; | 91 | static bool null_run = false; |
92 | static int detailed_run = 0; | 92 | static int detailed_run = 0; |
93 | static bool big_num = true; | 93 | static bool big_num = true; |
@@ -924,7 +924,7 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) | |||
924 | static void print_aggr(char *prefix) | 924 | static void print_aggr(char *prefix) |
925 | { | 925 | { |
926 | struct perf_evsel *counter; | 926 | struct perf_evsel *counter; |
927 | int cpu, s, s2, id, nr; | 927 | int cpu, cpu2, s, s2, id, nr; |
928 | u64 ena, run, val; | 928 | u64 ena, run, val; |
929 | 929 | ||
930 | if (!(aggr_map || aggr_get_id)) | 930 | if (!(aggr_map || aggr_get_id)) |
@@ -936,7 +936,8 @@ static void print_aggr(char *prefix) | |||
936 | val = ena = run = 0; | 936 | val = ena = run = 0; |
937 | nr = 0; | 937 | nr = 0; |
938 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | 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 | if (s2 != id) | 941 | if (s2 != id) |
941 | continue; | 942 | continue; |
942 | val += counter->counts->cpu[cpu].val; | 943 | val += counter->counts->cpu[cpu].val; |
@@ -948,7 +949,7 @@ static void print_aggr(char *prefix) | |||
948 | fprintf(output, "%s", prefix); | 949 | fprintf(output, "%s", prefix); |
949 | 950 | ||
950 | if (run == 0 || ena == 0) { | 951 | if (run == 0 || ena == 0) { |
951 | aggr_printout(counter, cpu, nr); | 952 | aggr_printout(counter, id, nr); |
952 | 953 | ||
953 | fprintf(output, "%*s%s%*s", | 954 | fprintf(output, "%*s%s%*s", |
954 | csv_output ? 0 : 18, | 955 | csv_output ? 0 : 18, |
@@ -1148,13 +1149,34 @@ static void skip_signal(int signo) | |||
1148 | done = 1; | 1149 | done = 1; |
1149 | 1150 | ||
1150 | signr = signo; | 1151 | signr = signo; |
1152 | /* | ||
1153 | * render child_pid harmless | ||
1154 | * won't send SIGTERM to a random | ||
1155 | * process in case of race condition | ||
1156 | * and fast PID recycling | ||
1157 | */ | ||
1158 | child_pid = -1; | ||
1151 | } | 1159 | } |
1152 | 1160 | ||
1153 | static void sig_atexit(void) | 1161 | static void sig_atexit(void) |
1154 | { | 1162 | { |
1163 | sigset_t set, oset; | ||
1164 | |||
1165 | /* | ||
1166 | * avoid race condition with SIGCHLD handler | ||
1167 | * in skip_signal() which is modifying child_pid | ||
1168 | * goal is to avoid send SIGTERM to a random | ||
1169 | * process | ||
1170 | */ | ||
1171 | sigemptyset(&set); | ||
1172 | sigaddset(&set, SIGCHLD); | ||
1173 | sigprocmask(SIG_BLOCK, &set, &oset); | ||
1174 | |||
1155 | if (child_pid != -1) | 1175 | if (child_pid != -1) |
1156 | kill(child_pid, SIGTERM); | 1176 | kill(child_pid, SIGTERM); |
1157 | 1177 | ||
1178 | sigprocmask(SIG_SETMASK, &oset, NULL); | ||
1179 | |||
1158 | if (signr == -1) | 1180 | if (signr == -1) |
1159 | return; | 1181 | return; |
1160 | 1182 | ||
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index ab4cf232b852..4536a92b18f3 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -1005,7 +1005,7 @@ static int __cmd_record(int argc, const char **argv) | |||
1005 | { | 1005 | { |
1006 | #ifdef SUPPORT_OLD_POWER_EVENTS | 1006 | #ifdef SUPPORT_OLD_POWER_EVENTS |
1007 | const char * const record_old_args[] = { | 1007 | const char * const record_old_args[] = { |
1008 | "record", "-a", "-R", "-f", "-c", "1", | 1008 | "record", "-a", "-R", "-c", "1", |
1009 | "-e", "power:power_start", | 1009 | "-e", "power:power_start", |
1010 | "-e", "power:power_end", | 1010 | "-e", "power:power_end", |
1011 | "-e", "power:power_frequency", | 1011 | "-e", "power:power_frequency", |
@@ -1014,7 +1014,7 @@ static int __cmd_record(int argc, const char **argv) | |||
1014 | }; | 1014 | }; |
1015 | #endif | 1015 | #endif |
1016 | const char * const record_new_args[] = { | 1016 | const char * const record_new_args[] = { |
1017 | "record", "-a", "-R", "-f", "-c", "1", | 1017 | "record", "-a", "-R", "-c", "1", |
1018 | "-e", "power:cpu_frequency", | 1018 | "-e", "power:cpu_frequency", |
1019 | "-e", "power:cpu_idle", | 1019 | "-e", "power:cpu_idle", |
1020 | "-e", "sched:sched_wakeup", | 1020 | "-e", "sched:sched_wakeup", |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f036af9b6f09..e06c4f869330 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1130,8 +1130,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1130 | if (top.evlist == NULL) | 1130 | if (top.evlist == NULL) |
1131 | return -ENOMEM; | 1131 | return -ENOMEM; |
1132 | 1132 | ||
1133 | symbol_conf.exclude_other = false; | ||
1134 | |||
1135 | argc = parse_options(argc, argv, options, top_usage, 0); | 1133 | argc = parse_options(argc, argv, options, top_usage, 0); |
1136 | if (argc) | 1134 | if (argc) |
1137 | usage_with_options(top_usage, options); | 1135 | usage_with_options(top_usage, options); |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f139dcd2796e..b5d9238cb181 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -39,7 +39,7 @@ src-perf := $(srctree)/tools/perf | |||
39 | endif | 39 | endif |
40 | 40 | ||
41 | ifeq ($(obj-perf),) | 41 | ifeq ($(obj-perf),) |
42 | obj-perf := $(objtree) | 42 | obj-perf := $(OUTPUT) |
43 | endif | 43 | endif |
44 | 44 | ||
45 | ifneq ($(obj-perf),) | 45 | ifneq ($(obj-perf),) |
@@ -85,7 +85,7 @@ CFLAGS += -Wall | |||
85 | CFLAGS += -Wextra | 85 | CFLAGS += -Wextra |
86 | CFLAGS += -std=gnu99 | 86 | CFLAGS += -std=gnu99 |
87 | 87 | ||
88 | EXTLIBS = -lpthread -lrt -lelf -lm | 88 | EXTLIBS = -lelf -lpthread -lrt -lm |
89 | 89 | ||
90 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) | 90 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) |
91 | CFLAGS += -fstack-protector-all | 91 | CFLAGS += -fstack-protector-all |
@@ -165,7 +165,7 @@ else | |||
165 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib | 165 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib |
166 | endif | 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 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) | 169 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) |
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); | 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 | NO_DWARF := 1 | 171 | NO_DWARF := 1 |
diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak index 8ef3bd30a549..94d2d4f9c35d 100644 --- a/tools/perf/config/utilities.mak +++ b/tools/perf/config/utilities.mak | |||
@@ -173,7 +173,7 @@ _ge-abspath = $(if $(is-executable),$(1)) | |||
173 | # Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default) | 173 | # Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default) |
174 | # | 174 | # |
175 | define get-executable-or-default | 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 | endef | 177 | endef |
178 | _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) | 178 | _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) |
179 | _gea_warn = $(warning The path '$(1)' is not executable.) | 179 | _gea_warn = $(warning The path '$(1)' is not executable.) |
@@ -181,7 +181,7 @@ _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) | |||
181 | 181 | ||
182 | # try-cc | 182 | # try-cc |
183 | # Usage: option = $(call try-cc, source-to-build, cc-options, msg) | 183 | # Usage: option = $(call try-cc, source-to-build, cc-options, msg) |
184 | ifndef V | 184 | ifneq ($(V),1) |
185 | TRY_CC_OUTPUT= > /dev/null 2>&1 | 185 | TRY_CC_OUTPUT= > /dev/null 2>&1 |
186 | endif | 186 | endif |
187 | TRY_CC_MSG=echo " CHK $(3)" 1>&2; | 187 | TRY_CC_MSG=echo " CHK $(3)" 1>&2; |
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs index c1e2ed1ed34e..8c7ea42444d1 100644 --- a/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "perl.h" | 23 | #include "perl.h" |
24 | #include "XSUB.h" | 24 | #include "XSUB.h" |
25 | #include "../../../perf.h" | 25 | #include "../../../perf.h" |
26 | #include "../../../util/script-event.h" | 26 | #include "../../../util/trace-event.h" |
27 | 27 | ||
28 | MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context | 28 | MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context |
29 | PROTOTYPES: ENABLE | 29 | PROTOTYPES: ENABLE |
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 055fef34b6f6..15a77b7c0e36 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN | |||
@@ -13,13 +13,22 @@ LF=' | |||
13 | # First check if there is a .git to get the version from git describe | 13 | # First check if there is a .git to get the version from git describe |
14 | # otherwise try to get the version from the kernel Makefile | 14 | # otherwise try to get the version from the kernel Makefile |
15 | # | 15 | # |
16 | if test -d ../../.git -o -f ../../.git && | 16 | CID= |
17 | VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") | 17 | TAG= |
18 | if test -d ../../.git -o -f ../../.git | ||
18 | then | 19 | then |
19 | VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) | 20 | TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) |
20 | VN=$(echo "$VN" | sed -e 's/-/./g'); | 21 | CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" |
21 | else | 22 | fi |
22 | VN=$(MAKEFLAGS= make -sC ../.. kernelversion) | 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 | fi | 32 | fi |
24 | 33 | ||
25 | VN=$(expr "$VN" : v*'\(.*\)') | 34 | VN=$(expr "$VN" : v*'\(.*\)') |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 6f7d5a9d6b05..c4374f07603c 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -513,10 +513,16 @@ void dsos__add(struct list_head *head, struct dso *dso) | |||
513 | list_add_tail(&dso->node, head); | 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 | struct dso *pos; | 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 | list_for_each_entry(pos, head, node) | 526 | list_for_each_entry(pos, head, node) |
521 | if (strcmp(pos->long_name, name) == 0) | 527 | if (strcmp(pos->long_name, name) == 0) |
522 | return pos; | 528 | return pos; |
@@ -525,7 +531,7 @@ struct dso *dsos__find(struct list_head *head, const char *name) | |||
525 | 531 | ||
526 | struct dso *__dsos__findnew(struct list_head *head, const char *name) | 532 | struct dso *__dsos__findnew(struct list_head *head, const char *name) |
527 | { | 533 | { |
528 | struct dso *dso = dsos__find(head, name); | 534 | struct dso *dso = dsos__find(head, name, false); |
529 | 535 | ||
530 | if (!dso) { | 536 | if (!dso) { |
531 | dso = dso__new(name); | 537 | dso = dso__new(name); |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 450199ab51b5..d51aaf272c68 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -133,7 +133,8 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name, | |||
133 | const char *short_name, int dso_type); | 133 | const char *short_name, int dso_type); |
134 | 134 | ||
135 | void dsos__add(struct list_head *head, struct dso *dso); | 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 | struct dso *__dsos__findnew(struct list_head *head, const char *name); | 138 | struct dso *__dsos__findnew(struct list_head *head, const char *name); |
138 | bool __dsos__read_build_ids(struct list_head *head, bool with_hits); | 139 | bool __dsos__read_build_ids(struct list_head *head, bool with_hits); |
139 | 140 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 99b43dd18c57..8065ce8fa9a5 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -821,6 +821,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, | |||
821 | goto out_close_pipes; | 821 | goto out_close_pipes; |
822 | } | 822 | } |
823 | 823 | ||
824 | fcntl(go_pipe[1], F_SETFD, FD_CLOEXEC); | ||
824 | evlist->workload.cork_fd = go_pipe[1]; | 825 | evlist->workload.cork_fd = go_pipe[1]; |
825 | close(child_ready_pipe[0]); | 826 | close(child_ready_pipe[0]); |
826 | return 0; | 827 | return 0; |
@@ -837,10 +838,17 @@ out_close_ready_pipe: | |||
837 | int perf_evlist__start_workload(struct perf_evlist *evlist) | 838 | int perf_evlist__start_workload(struct perf_evlist *evlist) |
838 | { | 839 | { |
839 | if (evlist->workload.cork_fd > 0) { | 840 | if (evlist->workload.cork_fd > 0) { |
841 | char bf; | ||
842 | int ret; | ||
840 | /* | 843 | /* |
841 | * Remove the cork, let it rip! | 844 | * Remove the cork, let it rip! |
842 | */ | 845 | */ |
843 | return close(evlist->workload.cork_fd); | 846 | ret = write(evlist->workload.cork_fd, &bf, 1); |
847 | if (ret < 0) | ||
848 | perror("enable to write to pipe"); | ||
849 | |||
850 | close(evlist->workload.cork_fd); | ||
851 | return ret; | ||
844 | } | 852 | } |
845 | 853 | ||
846 | return 0; | 854 | return 0; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 63b6f8c8edf2..c9c7494506a1 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -124,7 +124,7 @@ struct event_format *event_format__new(const char *sys, const char *name) | |||
124 | bf = nbf; | 124 | bf = nbf; |
125 | } | 125 | } |
126 | 126 | ||
127 | n = read(fd, bf + size, BUFSIZ); | 127 | n = read(fd, bf + size, alloc_size - size); |
128 | if (n < 0) | 128 | if (n < 0) |
129 | goto out_free_bf; | 129 | goto out_free_bf; |
130 | size += n; | 130 | size += n; |
@@ -1170,7 +1170,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | |||
1170 | } else { | 1170 | } else { |
1171 | data->user_stack.data = (char *)array; | 1171 | data->user_stack.data = (char *)array; |
1172 | array += size / sizeof(*array); | 1172 | array += size / sizeof(*array); |
1173 | data->user_stack.size = *array; | 1173 | data->user_stack.size = *array++; |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | 1176 | ||
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 738d3b8d9745..a4dafbee2511 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2303,29 +2303,18 @@ int perf_session__write_header(struct perf_session *session, | |||
2303 | struct perf_file_header f_header; | 2303 | struct perf_file_header f_header; |
2304 | struct perf_file_attr f_attr; | 2304 | struct perf_file_attr f_attr; |
2305 | struct perf_header *header = &session->header; | 2305 | struct perf_header *header = &session->header; |
2306 | struct perf_evsel *evsel, *pair = NULL; | 2306 | struct perf_evsel *evsel; |
2307 | int err; | 2307 | int err; |
2308 | 2308 | ||
2309 | lseek(fd, sizeof(f_header), SEEK_SET); | 2309 | lseek(fd, sizeof(f_header), SEEK_SET); |
2310 | 2310 | ||
2311 | if (session->evlist != evlist) | ||
2312 | pair = perf_evlist__first(session->evlist); | ||
2313 | |||
2314 | list_for_each_entry(evsel, &evlist->entries, node) { | 2311 | list_for_each_entry(evsel, &evlist->entries, node) { |
2315 | evsel->id_offset = lseek(fd, 0, SEEK_CUR); | 2312 | evsel->id_offset = lseek(fd, 0, SEEK_CUR); |
2316 | err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); | 2313 | err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); |
2317 | if (err < 0) { | 2314 | if (err < 0) { |
2318 | out_err_write: | ||
2319 | pr_debug("failed to write perf header\n"); | 2315 | pr_debug("failed to write perf header\n"); |
2320 | return err; | 2316 | return err; |
2321 | } | 2317 | } |
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 | } | ||
2329 | } | 2318 | } |
2330 | 2319 | ||
2331 | header->attr_offset = lseek(fd, 0, SEEK_CUR); | 2320 | header->attr_offset = lseek(fd, 0, SEEK_CUR); |
@@ -2967,6 +2956,8 @@ int perf_event__process_attr(union perf_event *event, | |||
2967 | perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]); | 2956 | perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]); |
2968 | } | 2957 | } |
2969 | 2958 | ||
2959 | symbol_conf.nr_events = evlist->nr_entries; | ||
2960 | |||
2970 | return 0; | 2961 | return 0; |
2971 | } | 2962 | } |
2972 | 2963 | ||
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 6c8bb0fb189b..995fc25db8c6 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -860,7 +860,8 @@ int parse_events_terms(struct list_head *terms, const char *str) | |||
860 | return 0; | 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 | return ret; | 865 | return ret; |
865 | } | 866 | } |
866 | 867 | ||
@@ -1183,6 +1184,7 @@ static int new_term(struct parse_events_term **_term, int type_val, | |||
1183 | term->val.str = str; | 1184 | term->val.str = str; |
1184 | break; | 1185 | break; |
1185 | default: | 1186 | default: |
1187 | free(term); | ||
1186 | return -EINVAL; | 1188 | return -EINVAL; |
1187 | } | 1189 | } |
1188 | 1190 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 8cf3b5426a9a..d5528e1cc03a 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -32,7 +32,6 @@ int vmlinux_path__nr_entries; | |||
32 | char **vmlinux_path; | 32 | char **vmlinux_path; |
33 | 33 | ||
34 | struct symbol_conf symbol_conf = { | 34 | struct symbol_conf symbol_conf = { |
35 | .exclude_other = true, | ||
36 | .use_modules = true, | 35 | .use_modules = true, |
37 | .try_vmlinux_path = true, | 36 | .try_vmlinux_path = true, |
38 | .annotate_src = true, | 37 | .annotate_src = true, |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 7a484c97e500..2732fad03908 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -72,6 +72,7 @@ | |||
72 | #include "types.h" | 72 | #include "types.h" |
73 | #include <sys/ttydefaults.h> | 73 | #include <sys/ttydefaults.h> |
74 | #include <lk/debugfs.h> | 74 | #include <lk/debugfs.h> |
75 | #include <termios.h> | ||
75 | 76 | ||
76 | extern const char *graph_line; | 77 | extern const char *graph_line; |
77 | extern const char *graph_dotted_line; | 78 | extern const char *graph_dotted_line; |
@@ -274,6 +275,5 @@ void dump_stack(void); | |||
274 | 275 | ||
275 | extern unsigned int page_size; | 276 | extern unsigned int page_size; |
276 | 277 | ||
277 | struct winsize; | ||
278 | void get_term_dimensions(struct winsize *ws); | 278 | void get_term_dimensions(struct winsize *ws); |
279 | #endif /* GIT_COMPAT_UTIL_H */ | 279 | #endif /* GIT_COMPAT_UTIL_H */ |
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index e60951fcdb12..39159822d58f 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
@@ -91,7 +91,7 @@ void vdso__exit(void) | |||
91 | 91 | ||
92 | struct dso *vdso__dso_findnew(struct list_head *head) | 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 | if (!dso) { | 96 | if (!dso) { |
97 | char *file; | 97 | char *file; |
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index f03e681f8891..0d0506d55c71 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include | |||
@@ -59,7 +59,7 @@ QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir | |||
59 | QUIET_SUBDIR1 = | 59 | QUIET_SUBDIR1 = |
60 | 60 | ||
61 | ifneq ($(findstring $(MAKEFLAGS),s),s) | 61 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
62 | ifndef V | 62 | ifneq ($(V),1) |
63 | QUIET_CC = @echo ' ' CC $@; | 63 | QUIET_CC = @echo ' ' CC $@; |
64 | QUIET_AR = @echo ' ' AR $@; | 64 | QUIET_AR = @echo ' ' AR $@; |
65 | QUIET_LINK = @echo ' ' LINK $@; | 65 | QUIET_LINK = @echo ' ' LINK $@; |