Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-tools-fixes-for-v6.6-2-2023-10-20' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools

Pull perf tools fixes from Arnaldo Carvalho de Melo:

- Fix regression in reading scale and unit files from sysfs for PMU
events, so that we can use that info to pretty print instead of
printing raw numbers:

# perf stat -e power/energy-ram/,power/energy-gpu/ sleep 2

Performance counter stats for 'system wide':

1.64 Joules power/energy-ram/
0.20 Joules power/energy-gpu/

2.001228914 seconds time elapsed
#
# grep -m1 "model name" /proc/cpuinfo
model name : Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
#

- The small llvm.cpp file used to check if the llvm devel files are
present was incorrectly deleted when removing the BPF event in 'perf
trace', put it back as it is also used by tools/bpf/bpftool, that
uses llvm routines to do disassembly of BPF object files.

- Fix use of addr_location__exit() in dlfilter__object_code(), making
sure that it is only used to pair a previous addr_location__init()
call.

* tag 'perf-tools-fixes-for-v6.6-2-2023-10-20' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools:
tools build: Fix llvm feature detection, still used by bpftool
perf dlfilter: Add a test for object_code()
perf dlfilter: Fix use of addr_location__exit() in dlfilter__object_code()
perf pmu: Fix perf stat output with correct scale and unit

+56 -24
+14
tools/build/feature/test-llvm.cpp
··· 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 + }
+11 -1
tools/perf/dlfilters/dlfilter-test-api-v0.c
··· 289 289 return 0; 290 290 } 291 291 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 + 292 301 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early) 293 302 { 294 303 struct filter_data *d = data; ··· 323 314 if (early && !d->do_early) 324 315 return 0; 325 316 326 - if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample)) 317 + if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) || 318 + check_object_code(ctx, sample)) 327 319 return -1; 328 320 329 321 if (early)
+11 -1
tools/perf/dlfilters/dlfilter-test-api-v2.c
··· 308 308 return 0; 309 309 } 310 310 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 + 311 320 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early) 312 321 { 313 322 struct filter_data *d = data; ··· 342 333 if (early && !d->do_early) 343 334 return 0; 344 335 345 - if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample)) 336 + if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) || 337 + check_object_code(ctx, sample)) 346 338 return -1; 347 339 348 340 if (early)
+16 -18
tools/perf/util/dlfilter.c
··· 282 282 return &d->evsel->core.attr; 283 283 } 284 284 285 + static __s32 code_read(__u64 ip, struct map *map, struct machine *machine, void *buf, __u32 len) 286 + { 287 + u64 offset = map__map_ip(map, ip); 288 + 289 + if (ip + len >= map__end(map)) 290 + len = map__end(map) - ip; 291 + 292 + return dso__data_read_offset(map__dso(map), machine, offset, buf, len); 293 + } 294 + 285 295 static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len) 286 296 { 287 297 struct dlfilter *d = (struct dlfilter *)ctx; 288 298 struct addr_location *al; 289 299 struct addr_location a; 290 - struct map *map; 291 - u64 offset; 292 300 __s32 ret; 293 301 294 302 if (!d->ctx_valid) ··· 306 298 if (!al) 307 299 return -1; 308 300 309 - map = al->map; 310 - 311 - if (map && ip >= map__start(map) && ip < map__end(map) && 301 + if (al->map && ip >= map__start(al->map) && ip < map__end(al->map) && 312 302 machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip)) 313 - goto have_map; 303 + return code_read(ip, al->map, d->machine, buf, len); 314 304 315 305 addr_location__init(&a); 316 - thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a); 317 - if (!a.map) { 318 - ret = -1; 319 - goto out; 320 - } 321 306 322 - map = a.map; 323 - have_map: 324 - offset = map__map_ip(map, ip); 325 - if (ip + len >= map__end(map)) 326 - len = map__end(map) - ip; 327 - ret = dso__data_read_offset(map__dso(map), d->machine, offset, buf, len); 328 - out: 307 + thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a); 308 + ret = a.map ? code_read(ip, a.map, d->machine, buf, len) : -1; 309 + 329 310 addr_location__exit(&a); 311 + 330 312 return ret; 331 313 } 332 314
+4 -4
tools/perf/util/pmu.c
··· 295 295 len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 296 296 if (!len) 297 297 return 0; 298 - scnprintf(path + len, sizeof(path) - len, "%s/%s.scale", pmu->name, alias->name); 298 + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name); 299 299 300 300 fd = open(path, O_RDONLY); 301 301 if (fd == -1) ··· 330 330 len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 331 331 if (!len) 332 332 return 0; 333 - scnprintf(path + len, sizeof(path) - len, "%s/%s.unit", pmu->name, alias->name); 333 + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pmu->name, alias->name); 334 334 335 335 fd = open(path, O_RDONLY); 336 336 if (fd == -1) ··· 364 364 len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 365 365 if (!len) 366 366 return 0; 367 - scnprintf(path + len, sizeof(path) - len, "%s/%s.per-pkg", pmu->name, alias->name); 367 + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg", pmu->name, alias->name); 368 368 369 369 fd = open(path, O_RDONLY); 370 370 if (fd == -1) ··· 385 385 len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 386 386 if (!len) 387 387 return 0; 388 - scnprintf(path + len, sizeof(path) - len, "%s/%s.snapshot", pmu->name, alias->name); 388 + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.snapshot", pmu->name, alias->name); 389 389 390 390 fd = open(path, O_RDONLY); 391 391 if (fd == -1)