Skip to content

Commit 727cde6

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf tool fixes from Thomas Gleixner: "A couple of fixes for perf tools: - Build system updates - Plug a memory leak in an error path of perf probe - Tear down probes correctly when adding fails - Fixes to the perf symbol handling - Fix ordering of event processing in buildid-list - Fix per DSO filtering in the histogram browser" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf probe: Clear probe_trace_event when add_probe_trace_event() fails perf probe: Fix memory leaking on failure by clearing all probe_trace_events perf inject: Also re-pipe lost_samples event perf buildid-list: Requires ordered events perf symbols: Fix dso lookup by long name and missing buildids perf symbols: Allow forcing reading of non-root owned files by root perf hists browser: The dso can be obtained from popup_action->ms.map->dso perf hists browser: Fix 'd' hotkey action to filter by DSO perf symbols: Rebuild rbtree when adjusting symbols for kcore tools: Add a "make all" rule tools: Actually install tmon in the install rule
2 parents 069ec22 + e15bf88 commit 727cde6

File tree

11 files changed

+69
-35
lines changed

11 files changed

+69
-35
lines changed

tools/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ help:
3232
@echo ' from the kernel command line to build and install one of'
3333
@echo ' the tools above'
3434
@echo ''
35+
@echo ' $$ make tools/all'
36+
@echo ''
37+
@echo ' builds all tools.'
38+
@echo ''
3539
@echo ' $$ make tools/install'
3640
@echo ''
3741
@echo ' installs all tools.'
@@ -77,6 +81,11 @@ tmon: FORCE
7781
freefall: FORCE
7882
$(call descend,laptop/$@)
7983

84+
all: acpi cgroup cpupower hv firewire lguest \
85+
perf selftests turbostat usb \
86+
virtio vm net x86_energy_perf_policy \
87+
tmon freefall
88+
8089
acpi_install:
8190
$(call descend,power/$(@:_install=),install)
8291

@@ -101,7 +110,7 @@ freefall_install:
101110
install: acpi_install cgroup_install cpupower_install hv_install firewire_install lguest_install \
102111
perf_install selftests_install turbostat_install usb_install \
103112
virtio_install vm_install net_install x86_energy_perf_policy_install \
104-
tmon freefall_install
113+
tmon_install freefall_install
105114

106115
acpi_clean:
107116
$(call descend,power/acpi,clean)

tools/perf/builtin-inject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
675675
.fork = perf_event__repipe,
676676
.exit = perf_event__repipe,
677677
.lost = perf_event__repipe,
678+
.lost_samples = perf_event__repipe,
678679
.aux = perf_event__repipe,
679680
.itrace_start = perf_event__repipe,
680681
.context_switch = perf_event__repipe,

tools/perf/builtin-report.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
struct report {
4545
struct perf_tool tool;
4646
struct perf_session *session;
47-
bool force, use_tui, use_gtk, use_stdio;
47+
bool use_tui, use_gtk, use_stdio;
4848
bool hide_unresolved;
4949
bool dont_use_callchains;
5050
bool show_full_info;
@@ -678,7 +678,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
678678
"file", "vmlinux pathname"),
679679
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
680680
"file", "kallsyms pathname"),
681-
OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"),
681+
OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
682682
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
683683
"load module symbols - WARNING: use only with -k and LIVE kernel"),
684684
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
@@ -832,7 +832,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
832832
}
833833

834834
file.path = input_name;
835-
file.force = report.force;
835+
file.force = symbol_conf.force;
836836

837837
repeat:
838838
session = perf_session__new(&file, false, &report.tool);

tools/perf/ui/browsers/hists.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,6 @@ static int switch_data_file(void)
14301430

14311431
struct popup_action {
14321432
struct thread *thread;
1433-
struct dso *dso;
14341433
struct map_symbol ms;
14351434
int socket;
14361435

@@ -1565,7 +1564,6 @@ add_dso_opt(struct hist_browser *browser, struct popup_action *act,
15651564
return 0;
15661565

15671566
act->ms.map = map;
1568-
act->dso = map->dso;
15691567
act->fn = do_zoom_dso;
15701568
return 1;
15711569
}
@@ -1827,7 +1825,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
18271825

18281826
while (1) {
18291827
struct thread *thread = NULL;
1830-
struct dso *dso = NULL;
18311828
struct map *map = NULL;
18321829
int choice = 0;
18331830
int socked_id = -1;
@@ -1839,8 +1836,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
18391836
if (browser->he_selection != NULL) {
18401837
thread = hist_browser__selected_thread(browser);
18411838
map = browser->selection->map;
1842-
if (map)
1843-
dso = map->dso;
18441839
socked_id = browser->he_selection->socket;
18451840
}
18461841
switch (key) {
@@ -1874,7 +1869,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
18741869
hist_browser__dump(browser);
18751870
continue;
18761871
case 'd':
1877-
actions->dso = dso;
1872+
actions->ms.map = map;
18781873
do_zoom_dso(browser, actions);
18791874
continue;
18801875
case 'V':

tools/perf/util/build-id.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct perf_tool build_id__mark_dso_hit_ops = {
7676
.exit = perf_event__exit_del_thread,
7777
.attr = perf_event__process_attr,
7878
.build_id = perf_event__process_build_id,
79+
.ordered_events = true,
7980
};
8081

8182
int build_id__sprintf(const u8 *build_id, int len, char *bf)

tools/perf/util/dso.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ static struct dso *__dso__findlink_by_longname(struct rb_root *root,
933933
/* Add new node and rebalance tree */
934934
rb_link_node(&dso->rb_node, parent, p);
935935
rb_insert_color(&dso->rb_node, root);
936+
dso->root = root;
936937
}
937938
return NULL;
938939
}
@@ -945,15 +946,30 @@ static inline struct dso *__dso__find_by_longname(struct rb_root *root,
945946

946947
void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated)
947948
{
949+
struct rb_root *root = dso->root;
950+
948951
if (name == NULL)
949952
return;
950953

951954
if (dso->long_name_allocated)
952955
free((char *)dso->long_name);
953956

957+
if (root) {
958+
rb_erase(&dso->rb_node, root);
959+
/*
960+
* __dso__findlink_by_longname() isn't guaranteed to add it
961+
* back, so a clean removal is required here.
962+
*/
963+
RB_CLEAR_NODE(&dso->rb_node);
964+
dso->root = NULL;
965+
}
966+
954967
dso->long_name = name;
955968
dso->long_name_len = strlen(name);
956969
dso->long_name_allocated = name_allocated;
970+
971+
if (root)
972+
__dso__findlink_by_longname(root, dso, NULL);
957973
}
958974

959975
void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
@@ -1046,6 +1062,7 @@ struct dso *dso__new(const char *name)
10461062
dso->kernel = DSO_TYPE_USER;
10471063
dso->needs_swap = DSO_SWAP__UNSET;
10481064
RB_CLEAR_NODE(&dso->rb_node);
1065+
dso->root = NULL;
10491066
INIT_LIST_HEAD(&dso->node);
10501067
INIT_LIST_HEAD(&dso->data.open_entry);
10511068
pthread_mutex_init(&dso->lock, NULL);

tools/perf/util/dso.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct dso {
135135
pthread_mutex_t lock;
136136
struct list_head node;
137137
struct rb_node rb_node; /* rbtree node sorted by long name */
138+
struct rb_root *root; /* root of rbtree that rb_node is in */
138139
struct rb_root symbols[MAP__NR_TYPES];
139140
struct rb_root symbol_names[MAP__NR_TYPES];
140141
struct {

tools/perf/util/machine.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static void dsos__purge(struct dsos *dsos)
9191

9292
list_for_each_entry_safe(pos, n, &dsos->head, node) {
9393
RB_CLEAR_NODE(&pos->rb_node);
94+
pos->root = NULL;
9495
list_del_init(&pos->node);
9596
dso__put(pos);
9697
}

tools/perf/util/probe-finder.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
11831183
container_of(pf, struct trace_event_finder, pf);
11841184
struct perf_probe_point *pp = &pf->pev->point;
11851185
struct probe_trace_event *tev;
1186-
struct perf_probe_arg *args;
1186+
struct perf_probe_arg *args = NULL;
11871187
int ret, i;
11881188

11891189
/* Check number of tevs */
@@ -1198,19 +1198,23 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
11981198
ret = convert_to_trace_point(&pf->sp_die, tf->mod, pf->addr,
11991199
pp->retprobe, pp->function, &tev->point);
12001200
if (ret < 0)
1201-
return ret;
1201+
goto end;
12021202

12031203
tev->point.realname = strdup(dwarf_diename(sc_die));
1204-
if (!tev->point.realname)
1205-
return -ENOMEM;
1204+
if (!tev->point.realname) {
1205+
ret = -ENOMEM;
1206+
goto end;
1207+
}
12061208

12071209
pr_debug("Probe point found: %s+%lu\n", tev->point.symbol,
12081210
tev->point.offset);
12091211

12101212
/* Expand special probe argument if exist */
12111213
args = zalloc(sizeof(struct perf_probe_arg) * MAX_PROBE_ARGS);
1212-
if (args == NULL)
1213-
return -ENOMEM;
1214+
if (args == NULL) {
1215+
ret = -ENOMEM;
1216+
goto end;
1217+
}
12141218

12151219
ret = expand_probe_args(sc_die, pf, args);
12161220
if (ret < 0)
@@ -1234,6 +1238,10 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
12341238
}
12351239

12361240
end:
1241+
if (ret) {
1242+
clear_probe_trace_event(tev);
1243+
tf->ntevs--;
1244+
}
12371245
free(args);
12381246
return ret;
12391247
}
@@ -1246,7 +1254,7 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
12461254
struct trace_event_finder tf = {
12471255
.pf = {.pev = pev, .callback = add_probe_trace_event},
12481256
.max_tevs = probe_conf.max_probes, .mod = dbg->mod};
1249-
int ret;
1257+
int ret, i;
12501258

12511259
/* Allocate result tevs array */
12521260
*tevs = zalloc(sizeof(struct probe_trace_event) * tf.max_tevs);
@@ -1258,6 +1266,8 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
12581266

12591267
ret = debuginfo__find_probes(dbg, &tf.pf);
12601268
if (ret < 0) {
1269+
for (i = 0; i < tf.ntevs; i++)
1270+
clear_probe_trace_event(&tf.tevs[i]);
12611271
zfree(tevs);
12621272
return ret;
12631273
}

tools/perf/util/symbol.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -654,48 +654,46 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
654654
struct map_groups *kmaps = map__kmaps(map);
655655
struct map *curr_map;
656656
struct symbol *pos;
657-
int count = 0, moved = 0;
657+
int count = 0;
658+
struct rb_root old_root = dso->symbols[map->type];
658659
struct rb_root *root = &dso->symbols[map->type];
659660
struct rb_node *next = rb_first(root);
660661

661662
if (!kmaps)
662663
return -1;
663664

665+
*root = RB_ROOT;
666+
664667
while (next) {
665668
char *module;
666669

667670
pos = rb_entry(next, struct symbol, rb_node);
668671
next = rb_next(&pos->rb_node);
669672

673+
rb_erase_init(&pos->rb_node, &old_root);
674+
670675
module = strchr(pos->name, '\t');
671676
if (module)
672677
*module = '\0';
673678

674679
curr_map = map_groups__find(kmaps, map->type, pos->start);
675680

676681
if (!curr_map || (filter && filter(curr_map, pos))) {
677-
rb_erase_init(&pos->rb_node, root);
678682
symbol__delete(pos);
679-
} else {
680-
pos->start -= curr_map->start - curr_map->pgoff;
681-
if (pos->end)
682-
pos->end -= curr_map->start - curr_map->pgoff;
683-
if (curr_map->dso != map->dso) {
684-
rb_erase_init(&pos->rb_node, root);
685-
symbols__insert(
686-
&curr_map->dso->symbols[curr_map->type],
687-
pos);
688-
++moved;
689-
} else {
690-
++count;
691-
}
683+
continue;
692684
}
685+
686+
pos->start -= curr_map->start - curr_map->pgoff;
687+
if (pos->end)
688+
pos->end -= curr_map->start - curr_map->pgoff;
689+
symbols__insert(&curr_map->dso->symbols[curr_map->type], pos);
690+
++count;
693691
}
694692

695693
/* Symbols have been adjusted */
696694
dso->adjust_symbols = 1;
697695

698-
return count + moved;
696+
return count;
699697
}
700698

701699
/*
@@ -1438,9 +1436,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
14381436
if (lstat(dso->name, &st) < 0)
14391437
goto out;
14401438

1441-
if (st.st_uid && (st.st_uid != geteuid())) {
1439+
if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
14421440
pr_warning("File %s not owned by current user or root, "
1443-
"ignoring it.\n", dso->name);
1441+
"ignoring it (use -f to override).\n", dso->name);
14441442
goto out;
14451443
}
14461444

tools/perf/util/symbol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct symbol_conf {
8484
unsigned short priv_size;
8585
unsigned short nr_events;
8686
bool try_vmlinux_path,
87+
force,
8788
ignore_vmlinux,
8889
ignore_vmlinux_buildid,
8990
show_kernel_path,

0 commit comments

Comments
 (0)