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>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#define NUM_VERSION (((LLVM_VERSION_MAJOR) << 16) + (LLVM_VERSION_MINOR << 8) + LLVM_VERSION_PATCH)
|
||||
|
||||
#if NUM_VERSION < 0x030900
|
||||
# error "LLVM version too low"
|
||||
#endif
|
||||
int main()
|
||||
{
|
||||
llvm::errs() << "Hello World!\n";
|
||||
llvm::llvm_shutdown();
|
||||
return 0;
|
||||
}
|
||||
@@ -289,6 +289,15 @@ static int check_attr(void *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
|
||||
{
|
||||
__u8 buf[15];
|
||||
|
||||
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
|
||||
{
|
||||
struct filter_data *d = data;
|
||||
@@ -314,7 +323,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
|
||||
if (early && !d->do_early)
|
||||
return 0;
|
||||
|
||||
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
|
||||
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
|
||||
check_object_code(ctx, sample))
|
||||
return -1;
|
||||
|
||||
if (early)
|
||||
|
||||
@@ -308,6 +308,15 @@ static int check_attr(void *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
|
||||
{
|
||||
__u8 buf[15];
|
||||
|
||||
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
|
||||
{
|
||||
struct filter_data *d = data;
|
||||
@@ -333,7 +342,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
|
||||
if (early && !d->do_early)
|
||||
return 0;
|
||||
|
||||
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
|
||||
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
|
||||
check_object_code(ctx, sample))
|
||||
return -1;
|
||||
|
||||
if (early)
|
||||
|
||||
+16
-18
@@ -284,13 +284,21 @@ static struct perf_event_attr *dlfilter__attr(void *ctx)
|
||||
return &d->evsel->core.attr;
|
||||
}
|
||||
|
||||
static __s32 code_read(__u64 ip, struct map *map, struct machine *machine, void *buf, __u32 len)
|
||||
{
|
||||
u64 offset = map__map_ip(map, ip);
|
||||
|
||||
if (ip + len >= map__end(map))
|
||||
len = map__end(map) - ip;
|
||||
|
||||
return dso__data_read_offset(map__dso(map), machine, offset, buf, len);
|
||||
}
|
||||
|
||||
static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
|
||||
{
|
||||
struct dlfilter *d = (struct dlfilter *)ctx;
|
||||
struct addr_location *al;
|
||||
struct addr_location a;
|
||||
struct map *map;
|
||||
u64 offset;
|
||||
__s32 ret;
|
||||
|
||||
if (!d->ctx_valid)
|
||||
@@ -300,27 +308,17 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
|
||||
if (!al)
|
||||
return -1;
|
||||
|
||||
map = al->map;
|
||||
|
||||
if (map && ip >= map__start(map) && ip < map__end(map) &&
|
||||
if (al->map && ip >= map__start(al->map) && ip < map__end(al->map) &&
|
||||
machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip))
|
||||
goto have_map;
|
||||
return code_read(ip, al->map, d->machine, buf, len);
|
||||
|
||||
addr_location__init(&a);
|
||||
thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a);
|
||||
if (!a.map) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
map = a.map;
|
||||
have_map:
|
||||
offset = map__map_ip(map, ip);
|
||||
if (ip + len >= map__end(map))
|
||||
len = map__end(map) - ip;
|
||||
ret = dso__data_read_offset(map__dso(map), d->machine, offset, buf, len);
|
||||
out:
|
||||
thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a);
|
||||
ret = a.map ? code_read(ip, a.map, d->machine, buf, len) : -1;
|
||||
|
||||
addr_location__exit(&a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ static int perf_pmu__parse_scale(struct perf_pmu *pmu, struct perf_pmu_alias *al
|
||||
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
|
||||
if (!len)
|
||||
return 0;
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/%s.scale", pmu->name, alias->name);
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
@@ -331,7 +331,7 @@ static int perf_pmu__parse_unit(struct perf_pmu *pmu, struct perf_pmu_alias *ali
|
||||
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
|
||||
if (!len)
|
||||
return 0;
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/%s.unit", pmu->name, alias->name);
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pmu->name, alias->name);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
@@ -365,7 +365,7 @@ perf_pmu__parse_per_pkg(struct perf_pmu *pmu, struct perf_pmu_alias *alias)
|
||||
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
|
||||
if (!len)
|
||||
return 0;
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/%s.per-pkg", pmu->name, alias->name);
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg", pmu->name, alias->name);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
@@ -386,7 +386,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu *pmu, struct perf_pmu_alias
|
||||
len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path));
|
||||
if (!len)
|
||||
return 0;
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/%s.snapshot", pmu->name, alias->name);
|
||||
scnprintf(path + len, sizeof(path) - len, "%s/events/%s.snapshot", pmu->name, alias->name);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
||||
Reference in New Issue
Block a user