Skip to content

Commit 5aca796

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.17-2025-09-16' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Namhyung Kim: "A small set of fixes for crashes in different commands and conditions" * tag 'perf-tools-fixes-for-v6.17-2025-09-16' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: perf maps: Ensure kmap is set up for all inserts perf lock: Provide a host_env for session new perf subcmd: avoid crash in exclude_cmds when excludes is empty
2 parents 46a51f4 + 20c9ccf commit 5aca796

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

tools/lib/subcmd/help.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
7575
size_t ci, cj, ei;
7676
int cmp;
7777

78+
if (!excludes->cnt)
79+
return;
80+
7881
ci = cj = ei = 0;
7982
while (ci < cmds->cnt && ei < excludes->cnt) {
8083
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);

tools/perf/builtin-lock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ static int __cmd_contention(int argc, const char **argv)
20092009
.owner = show_lock_owner,
20102010
.cgroups = RB_ROOT,
20112011
};
2012+
struct perf_env host_env;
20122013

20132014
lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table));
20142015
if (!lockhash_table)
@@ -2024,7 +2025,10 @@ static int __cmd_contention(int argc, const char **argv)
20242025
eops.mmap = perf_event__process_mmap;
20252026
eops.tracing_data = perf_event__process_tracing_data;
20262027

2027-
session = perf_session__new(use_bpf ? NULL : &data, &eops);
2028+
perf_env__init(&host_env);
2029+
session = __perf_session__new(use_bpf ? NULL : &data, &eops,
2030+
/*trace_event_repipe=*/false, &host_env);
2031+
20282032
if (IS_ERR(session)) {
20292033
pr_err("Initializing perf session failed\n");
20302034
err = PTR_ERR(session);
@@ -2142,6 +2146,7 @@ static int __cmd_contention(int argc, const char **argv)
21422146
evlist__delete(con.evlist);
21432147
lock_contention_finish(&con);
21442148
perf_session__delete(session);
2149+
perf_env__exit(&host_env);
21452150
zfree(&lockhash_table);
21462151
return err;
21472152
}

tools/perf/util/maps.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ static int __maps__insert(struct maps *maps, struct map *new)
477477
}
478478
/* Insert the value at the end. */
479479
maps_by_address[nr_maps] = map__get(new);
480+
map__set_kmap_maps(new, maps);
480481
if (maps_by_name)
481482
maps_by_name[nr_maps] = map__get(new);
482483

@@ -502,8 +503,6 @@ static int __maps__insert(struct maps *maps, struct map *new)
502503
if (map__end(new) < map__start(new))
503504
RC_CHK_ACCESS(maps)->ends_broken = true;
504505

505-
map__set_kmap_maps(new, maps);
506-
507506
return 0;
508507
}
509508

@@ -891,6 +890,7 @@ static int __maps__fixup_overlap_and_insert(struct maps *maps, struct map *new)
891890
if (before) {
892891
map__put(maps_by_address[i]);
893892
maps_by_address[i] = before;
893+
map__set_kmap_maps(before, maps);
894894

895895
if (maps_by_name) {
896896
map__put(maps_by_name[ni]);
@@ -918,6 +918,7 @@ static int __maps__fixup_overlap_and_insert(struct maps *maps, struct map *new)
918918
*/
919919
map__put(maps_by_address[i]);
920920
maps_by_address[i] = map__get(new);
921+
map__set_kmap_maps(new, maps);
921922

922923
if (maps_by_name) {
923924
map__put(maps_by_name[ni]);
@@ -942,14 +943,13 @@ static int __maps__fixup_overlap_and_insert(struct maps *maps, struct map *new)
942943
*/
943944
map__put(maps_by_address[i]);
944945
maps_by_address[i] = map__get(new);
946+
map__set_kmap_maps(new, maps);
945947

946948
if (maps_by_name) {
947949
map__put(maps_by_name[ni]);
948950
maps_by_name[ni] = map__get(new);
949951
}
950952

951-
map__set_kmap_maps(new, maps);
952-
953953
check_invariants(maps);
954954
return err;
955955
}
@@ -1019,6 +1019,7 @@ int maps__copy_from(struct maps *dest, struct maps *parent)
10191019
err = unwind__prepare_access(dest, new, NULL);
10201020
if (!err) {
10211021
dest_maps_by_address[i] = new;
1022+
map__set_kmap_maps(new, dest);
10221023
if (dest_maps_by_name)
10231024
dest_maps_by_name[i] = map__get(new);
10241025
RC_CHK_ACCESS(dest)->nr_maps = i + 1;

0 commit comments

Comments
 (0)