Commit 9edaafa
selftests/bpf: Fix kprobe_multi_bench_attach test failure with LTO kernel
In my locally build clang LTO kernel (enabling CONFIG_LTO and
CONFIG_LTO_CLANG_THIN), kprobe_multi_bench_attach/kernel subtest
failed like:
test_kprobe_multi_bench_attach:PASS:get_syms 0 nsec
test_kprobe_multi_bench_attach:PASS:kprobe_multi_empty__open_and_load 0 nsec
libbpf: prog 'test_kprobe_empty': failed to attach: No such process
test_kprobe_multi_bench_attach:FAIL:bpf_program__attach_kprobe_multi_opts unexpected error: -3
#117/1 kprobe_multi_bench_attach/kernel:FAIL
There are multiple symbols in /sys/kernel/debug/tracing/available_filter_functions
are renamed in /proc/kallsyms due to cross file inlining. One example is for
static function __access_remote_vm in mm/memory.c.
In a non-LTO kernel, we have the following call stack:
ptrace_access_vm (global, kernel/ptrace.c)
access_remote_vm (global, mm/memory.c)
__access_remote_vm (static, mm/memory.c)
With LTO kernel, it is possible that access_remote_vm() is inlined by
ptrace_access_vm(). So we end up with the following call stack:
ptrace_access_vm (global, kernel/ptrace.c)
__access_remote_vm (static, mm/memory.c)
The compiler renames __access_remote_vm to __access_remote_vm.llvm.<hash>
to prevent potential name collision.
The kernel bpf_kprobe_multi_link_attach() and ftrace_lookup_symbols() try
to find addresses based on /proc/kallsyms, hence the current test failed
with LTO kenrel.
This patch consulted /proc/kallsyms to find the corresponding entries
for the ksym and this solved the issue.
Signed-off-by: Yonghong Song <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 parent d1f0258 commit 9edaafa
1 file changed
+48
-14
lines changedLines changed: 48 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
370 | 398 | | |
371 | 399 | | |
372 | | - | |
373 | | - | |
| 400 | + | |
| 401 | + | |
374 | 402 | | |
| 403 | + | |
| 404 | + | |
375 | 405 | | |
376 | 406 | | |
377 | 407 | | |
378 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
379 | 413 | | |
380 | 414 | | |
381 | 415 | | |
| |||
408 | 442 | | |
409 | 443 | | |
410 | 444 | | |
411 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
412 | 453 | | |
413 | 454 | | |
414 | 455 | | |
| |||
421 | 462 | | |
422 | 463 | | |
423 | 464 | | |
424 | | - | |
425 | | - | |
| 465 | + | |
426 | 466 | | |
427 | 467 | | |
428 | 468 | | |
| |||
432 | 472 | | |
433 | 473 | | |
434 | 474 | | |
435 | | - | |
436 | | - | |
437 | | - | |
| 475 | + | |
438 | 476 | | |
439 | | - | |
440 | 477 | | |
441 | 478 | | |
442 | 479 | | |
| |||
472 | 509 | | |
473 | 510 | | |
474 | 511 | | |
475 | | - | |
| 512 | + | |
476 | 513 | | |
477 | 514 | | |
478 | 515 | | |
| |||
488 | 525 | | |
489 | 526 | | |
490 | 527 | | |
491 | | - | |
492 | | - | |
493 | | - | |
| 528 | + | |
494 | 529 | | |
495 | | - | |
496 | 530 | | |
497 | 531 | | |
498 | 532 | | |
| |||
0 commit comments