Skip to content

Commit fed3a1b

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.6-2-2023-10-20' into perf-tools-next
To get the latest fixes in the perf tools including perf stat output, dlfilter and LLVM feature detection. Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2 parents c43c64f + 4fa008a commit fed3a1b

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

tools/build/feature/test-llvm.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include "llvm/Support/ManagedStatic.h"
3+
#include "llvm/Support/raw_ostream.h"
4+
#define NUM_VERSION (((LLVM_VERSION_MAJOR) << 16) + (LLVM_VERSION_MINOR << 8) + LLVM_VERSION_PATCH)
5+
6+
#if NUM_VERSION < 0x030900
7+
# error "LLVM version too low"
8+
#endif
9+
int main()
10+
{
11+
llvm::errs() << "Hello World!\n";
12+
llvm::llvm_shutdown();
13+
return 0;
14+
}

tools/perf/dlfilters/dlfilter-test-api-v0.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,15 @@ static int check_attr(void *ctx)
289289
return 0;
290290
}
291291

292+
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
293+
{
294+
__u8 buf[15];
295+
296+
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
297+
298+
return 0;
299+
}
300+
292301
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
293302
{
294303
struct filter_data *d = data;
@@ -314,7 +323,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
314323
if (early && !d->do_early)
315324
return 0;
316325

317-
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
326+
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
327+
check_object_code(ctx, sample))
318328
return -1;
319329

320330
if (early)

tools/perf/dlfilters/dlfilter-test-api-v2.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ static int check_attr(void *ctx)
308308
return 0;
309309
}
310310

311+
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
312+
{
313+
__u8 buf[15];
314+
315+
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
316+
317+
return 0;
318+
}
319+
311320
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
312321
{
313322
struct filter_data *d = data;
@@ -333,7 +342,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
333342
if (early && !d->do_early)
334343
return 0;
335344

336-
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
345+
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
346+
check_object_code(ctx, sample))
337347
return -1;
338348

339349
if (early)

tools/perf/util/dlfilter.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,21 @@ static struct perf_event_attr *dlfilter__attr(void *ctx)
284284
return &d->evsel->core.attr;
285285
}
286286

287+
static __s32 code_read(__u64 ip, struct map *map, struct machine *machine, void *buf, __u32 len)
288+
{
289+
u64 offset = map__map_ip(map, ip);
290+
291+
if (ip + len >= map__end(map))
292+
len = map__end(map) - ip;
293+
294+
return dso__data_read_offset(map__dso(map), machine, offset, buf, len);
295+
}
296+
287297
static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
288298
{
289299
struct dlfilter *d = (struct dlfilter *)ctx;
290300
struct addr_location *al;
291301
struct addr_location a;
292-
struct map *map;
293-
u64 offset;
294302
__s32 ret;
295303

296304
if (!d->ctx_valid)
@@ -300,27 +308,17 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
300308
if (!al)
301309
return -1;
302310

303-
map = al->map;
304-
305-
if (map && ip >= map__start(map) && ip < map__end(map) &&
311+
if (al->map && ip >= map__start(al->map) && ip < map__end(al->map) &&
306312
machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip))
307-
goto have_map;
313+
return code_read(ip, al->map, d->machine, buf, len);
308314

309315
addr_location__init(&a);
316+
310317
thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a);
311-
if (!a.map) {
312-
ret = -1;
313-
goto out;
314-
}
318+
ret = a.map ? code_read(ip, a.map, d->machine, buf, len) : -1;
315319

316-
map = a.map;
317-
have_map:
318-
offset = map__map_ip(map, ip);
319-
if (ip + len >= map__end(map))
320-
len = map__end(map) - ip;
321-
ret = dso__data_read_offset(map__dso(map), d->machine, offset, buf, len);
322-
out:
323320
addr_location__exit(&a);
321+
324322
return ret;
325323
}
326324

tools/perf/util/pmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int perf_pmu__parse_scale(struct perf_pmu *pmu, struct perf_pmu_alias *al
296296
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
297297
if (!len)
298298
return 0;
299-
scnprintf(path + len, sizeof(path) - len, "%s/%s.scale", pmu->name, alias->name);
299+
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name);
300300

301301
fd = open(path, O_RDONLY);
302302
if (fd == -1)
@@ -331,7 +331,7 @@ static int perf_pmu__parse_unit(struct perf_pmu *pmu, struct perf_pmu_alias *ali
331331
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
332332
if (!len)
333333
return 0;
334-
scnprintf(path + len, sizeof(path) - len, "%s/%s.unit", pmu->name, alias->name);
334+
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pmu->name, alias->name);
335335

336336
fd = open(path, O_RDONLY);
337337
if (fd == -1)
@@ -365,7 +365,7 @@ perf_pmu__parse_per_pkg(struct perf_pmu *pmu, struct perf_pmu_alias *alias)
365365
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
366366
if (!len)
367367
return 0;
368-
scnprintf(path + len, sizeof(path) - len, "%s/%s.per-pkg", pmu->name, alias->name);
368+
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg", pmu->name, alias->name);
369369

370370
fd = open(path, O_RDONLY);
371371
if (fd == -1)
@@ -386,7 +386,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu *pmu, struct perf_pmu_alias
386386
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
387387
if (!len)
388388
return 0;
389-
scnprintf(path + len, sizeof(path) - len, "%s/%s.snapshot", pmu->name, alias->name);
389+
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.snapshot", pmu->name, alias->name);
390390

391391
fd = open(path, O_RDONLY);
392392
if (fd == -1)

0 commit comments

Comments
 (0)