summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-08-10 19:19:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-08-10 19:19:02 -0400
commitd2359a5153ebb16412daedd8f104b886643cbd1a (patch)
treea95d89f52551fdcd1d7309f579628efdf51344e7 /tools
parentdcbb4a153971ff8646af0c963f5698bf21bfbfdc (diff)
parentd7731b8133ad64cd98bf34a33dcf810df4410308 (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf tooling fixes from Thomas Gleixner: "Perf tooling fixes all over the place: - Fix the selection of the main thread COMM in db-export - Fix the disassemmbly display for BPF in annotate - Fix cpumap mask setup in perf ftrace when only one CPU is present - Add the missing 'cpu_clk_unhalted.core' event - Fix CPU 0 bindings in NUMA benchmarks - Fix the module size calculations for s390 - Handle the gap between kernel end and module start on s390 correctly - Build and typo fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf pmu-events: Fix missing "cpu_clk_unhalted.core" event perf annotate: Fix s390 gap between kernel end and module start perf record: Fix module size on s390 perf tools: Fix include paths in ui directory perf tools: Fix a typo in a variable name in the Documentation Makefile perf cpumap: Fix writing to illegal memory in handling cpumap mask perf ftrace: Fix failure to set cpumask when only one cpu is present perf db-export: Fix thread__exec_comm() perf annotate: Fix printing of unaugmented disassembled instructions from BPF perf bench numa: Fix cpu0 binding
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/Makefile2
-rw-r--r--tools/perf/arch/s390/util/machine.c31
-rw-r--r--tools/perf/bench/numa.c6
-rw-r--r--tools/perf/builtin-ftrace.c2
-rw-r--r--tools/perf/pmu-events/jevents.c1
-rw-r--r--tools/perf/ui/browser.c9
-rw-r--r--tools/perf/ui/tui/progress.c2
-rw-r--r--tools/perf/util/annotate.c2
-rw-r--r--tools/perf/util/cpumap.c5
-rw-r--r--tools/perf/util/machine.c3
-rw-r--r--tools/perf/util/machine.h2
-rw-r--r--tools/perf/util/symbol.c7
-rw-r--r--tools/perf/util/symbol.h1
-rw-r--r--tools/perf/util/thread.c12
14 files changed, 69 insertions, 16 deletions
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 6d148a40551c..adc5a7e44b98 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -242,7 +242,7 @@ $(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
242 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ 242 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
243 mv $@+ $@ 243 mv $@+ $@
244 244
245-include $(OUPTUT)doc.dep 245-include $(OUTPUT)doc.dep
246 246
247_cmds_txt = cmds-ancillaryinterrogators.txt \ 247_cmds_txt = cmds-ancillaryinterrogators.txt \
248 cmds-ancillarymanipulators.txt \ 248 cmds-ancillarymanipulators.txt \
diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
index a19690a17291..c8c86a0c9b79 100644
--- a/tools/perf/arch/s390/util/machine.c
+++ b/tools/perf/arch/s390/util/machine.c
@@ -6,8 +6,9 @@
6#include "machine.h" 6#include "machine.h"
7#include "api/fs/fs.h" 7#include "api/fs/fs.h"
8#include "debug.h" 8#include "debug.h"
9#include "symbol.h"
9 10
10int arch__fix_module_text_start(u64 *start, const char *name) 11int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
11{ 12{
12 u64 m_start = *start; 13 u64 m_start = *start;
13 char path[PATH_MAX]; 14 char path[PATH_MAX];
@@ -17,7 +18,35 @@ int arch__fix_module_text_start(u64 *start, const char *name)
17 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) { 18 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
18 pr_debug2("Using module %s start:%#lx\n", path, m_start); 19 pr_debug2("Using module %s start:%#lx\n", path, m_start);
19 *start = m_start; 20 *start = m_start;
21 } else {
22 /* Successful read of the modules segment text start address.
23 * Calculate difference between module start address
24 * in memory and module text segment start address.
25 * For example module load address is 0x3ff8011b000
26 * (from /proc/modules) and module text segment start
27 * address is 0x3ff8011b870 (from file above).
28 *
29 * Adjust the module size and subtract the GOT table
30 * size located at the beginning of the module.
31 */
32 *size -= (*start - m_start);
20 } 33 }
21 34
22 return 0; 35 return 0;
23} 36}
37
38/* On s390 kernel text segment start is located at very low memory addresses,
39 * for example 0x10000. Modules are located at very high memory addresses,
40 * for example 0x3ff xxxx xxxx. The gap between end of kernel text segment
41 * and beginning of first module's text segment is very big.
42 * Therefore do not fill this gap and do not assign it to the kernel dso map.
43 */
44void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
45{
46 if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
47 /* Last kernel symbol mapped to end of page */
48 p->end = roundup(p->end, page_size);
49 else
50 p->end = c->start;
51 pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
52}
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index a640ca7aaada..513cb2f2fa32 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -379,8 +379,10 @@ static u8 *alloc_data(ssize_t bytes0, int map_flags,
379 379
380 /* Allocate and initialize all memory on CPU#0: */ 380 /* Allocate and initialize all memory on CPU#0: */
381 if (init_cpu0) { 381 if (init_cpu0) {
382 orig_mask = bind_to_node(0); 382 int node = numa_node_of_cpu(0);
383 bind_to_memnode(0); 383
384 orig_mask = bind_to_node(node);
385 bind_to_memnode(node);
384 } 386 }
385 387
386 bytes = bytes0 + HPSIZE; 388 bytes = bytes0 + HPSIZE;
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 66d5a6658daf..019312810405 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -173,7 +173,7 @@ static int set_tracing_cpumask(struct cpu_map *cpumap)
173 int last_cpu; 173 int last_cpu;
174 174
175 last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1); 175 last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1);
176 mask_size = (last_cpu + 3) / 4 + 1; 176 mask_size = last_cpu / 4 + 2; /* one more byte for EOS */
177 mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */ 177 mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */
178 178
179 cpumask = malloc(mask_size); 179 cpumask = malloc(mask_size);
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 1a91a197cafb..d413761621b0 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -453,6 +453,7 @@ static struct fixed {
453 { "inst_retired.any_p", "event=0xc0" }, 453 { "inst_retired.any_p", "event=0xc0" },
454 { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" }, 454 { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
455 { "cpu_clk_unhalted.thread", "event=0x3c" }, 455 { "cpu_clk_unhalted.thread", "event=0x3c" },
456 { "cpu_clk_unhalted.core", "event=0x3c" },
456 { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" }, 457 { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
457 { NULL, NULL}, 458 { NULL, NULL},
458}; 459};
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index f80c51d53565..d227d74b28f8 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -1,7 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "../string2.h" 2#include "../util/util.h"
3#include "../config.h" 3#include "../util/string2.h"
4#include "../../perf.h" 4#include "../util/config.h"
5#include "../perf.h"
5#include "libslang.h" 6#include "libslang.h"
6#include "ui.h" 7#include "ui.h"
7#include "util.h" 8#include "util.h"
@@ -14,7 +15,7 @@
14#include "browser.h" 15#include "browser.h"
15#include "helpline.h" 16#include "helpline.h"
16#include "keysyms.h" 17#include "keysyms.h"
17#include "../color.h" 18#include "../util/color.h"
18#include <linux/ctype.h> 19#include <linux/ctype.h>
19#include <linux/zalloc.h> 20#include <linux/zalloc.h>
20 21
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index bc134b82829d..5a24dd3ce4db 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include "../cache.h" 3#include "../../util/cache.h"
4#include "../progress.h" 4#include "../progress.h"
5#include "../libslang.h" 5#include "../libslang.h"
6#include "../ui.h" 6#include "../ui.h"
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ac9ad2330f93..163536720149 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1122,7 +1122,7 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
1122 goto out; 1122 goto out;
1123 1123
1124 (*rawp)[0] = tmp; 1124 (*rawp)[0] = tmp;
1125 *rawp = skip_spaces(*rawp); 1125 *rawp = strim(*rawp);
1126 1126
1127 return 0; 1127 return 0;
1128 1128
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 3acfbe34ebaf..39cce66b4ebc 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -751,7 +751,10 @@ size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
751 unsigned char *bitmap; 751 unsigned char *bitmap;
752 int last_cpu = cpu_map__cpu(map, map->nr - 1); 752 int last_cpu = cpu_map__cpu(map, map->nr - 1);
753 753
754 bitmap = zalloc((last_cpu + 7) / 8); 754 if (buf == NULL)
755 return 0;
756
757 bitmap = zalloc(last_cpu / 8 + 1);
755 if (bitmap == NULL) { 758 if (bitmap == NULL) {
756 buf[0] = '\0'; 759 buf[0] = '\0';
757 return 0; 760 return 0;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index cf826eca3aaf..83b2fbbeeb90 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1378,6 +1378,7 @@ static int machine__set_modules_path(struct machine *machine)
1378 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0); 1378 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
1379} 1379}
1380int __weak arch__fix_module_text_start(u64 *start __maybe_unused, 1380int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
1381 u64 *size __maybe_unused,
1381 const char *name __maybe_unused) 1382 const char *name __maybe_unused)
1382{ 1383{
1383 return 0; 1384 return 0;
@@ -1389,7 +1390,7 @@ static int machine__create_module(void *arg, const char *name, u64 start,
1389 struct machine *machine = arg; 1390 struct machine *machine = arg;
1390 struct map *map; 1391 struct map *map;
1391 1392
1392 if (arch__fix_module_text_start(&start, name) < 0) 1393 if (arch__fix_module_text_start(&start, &size, name) < 0)
1393 return -1; 1394 return -1;
1394 1395
1395 map = machine__findnew_module_map(machine, start, name); 1396 map = machine__findnew_module_map(machine, start, name);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index f70ab98a7bde..7aa38da26427 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -222,7 +222,7 @@ struct symbol *machine__find_kernel_symbol_by_name(struct machine *machine,
222 222
223struct map *machine__findnew_module_map(struct machine *machine, u64 start, 223struct map *machine__findnew_module_map(struct machine *machine, u64 start,
224 const char *filename); 224 const char *filename);
225int arch__fix_module_text_start(u64 *start, const char *name); 225int arch__fix_module_text_start(u64 *start, u64 *size, const char *name);
226 226
227int machine__load_kallsyms(struct machine *machine, const char *filename); 227int machine__load_kallsyms(struct machine *machine, const char *filename);
228 228
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 173f3378aaa0..4efde7879474 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -92,6 +92,11 @@ static int prefix_underscores_count(const char *str)
92 return tail - str; 92 return tail - str;
93} 93}
94 94
95void __weak arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
96{
97 p->end = c->start;
98}
99
95const char * __weak arch__normalize_symbol_name(const char *name) 100const char * __weak arch__normalize_symbol_name(const char *name)
96{ 101{
97 return name; 102 return name;
@@ -218,7 +223,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols)
218 curr = rb_entry(nd, struct symbol, rb_node); 223 curr = rb_entry(nd, struct symbol, rb_node);
219 224
220 if (prev->end == prev->start && prev->end != curr->start) 225 if (prev->end == prev->start && prev->end != curr->start)
221 prev->end = curr->start; 226 arch__symbols__fixup_end(prev, curr);
222 } 227 }
223 228
224 /* Last entry */ 229 /* Last entry */
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 12755b42ea93..183f630cb5f1 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -288,6 +288,7 @@ const char *arch__normalize_symbol_name(const char *name);
288#define SYMBOL_A 0 288#define SYMBOL_A 0
289#define SYMBOL_B 1 289#define SYMBOL_B 1
290 290
291void arch__symbols__fixup_end(struct symbol *p, struct symbol *c);
291int arch__compare_symbol_names(const char *namea, const char *nameb); 292int arch__compare_symbol_names(const char *namea, const char *nameb);
292int arch__compare_symbol_names_n(const char *namea, const char *nameb, 293int arch__compare_symbol_names_n(const char *namea, const char *nameb,
293 unsigned int n); 294 unsigned int n);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 873ab505ca80..590793cc5142 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -214,14 +214,24 @@ struct comm *thread__comm(const struct thread *thread)
214 214
215struct comm *thread__exec_comm(const struct thread *thread) 215struct comm *thread__exec_comm(const struct thread *thread)
216{ 216{
217 struct comm *comm, *last = NULL; 217 struct comm *comm, *last = NULL, *second_last = NULL;
218 218
219 list_for_each_entry(comm, &thread->comm_list, list) { 219 list_for_each_entry(comm, &thread->comm_list, list) {
220 if (comm->exec) 220 if (comm->exec)
221 return comm; 221 return comm;
222 second_last = last;
222 last = comm; 223 last = comm;
223 } 224 }
224 225
226 /*
227 * 'last' with no start time might be the parent's comm of a synthesized
228 * thread (created by processing a synthesized fork event). For a main
229 * thread, that is very probably wrong. Prefer a later comm to avoid
230 * that case.
231 */
232 if (second_last && !last->start && thread->pid_ == thread->tid)
233 return second_last;
234
225 return last; 235 return last;
226} 236}
227 237