Conversation

Richard Weinberger

Today I finally carved out some time to implement return value capture for the Linux kernel function tracer. As of 6.17-rc1, this is done via the HAVE_FUNCTION_GRAPH_FREGS architecture feature. On ARM32, that basically means stashing function call specific registers in pt_regs inside the ftrace arch code.

Once I wrapped my head around the intended semantics, it came together surprisingly smoothly.

Then I enabled the ftrace self-test… and hit this splat:

[    3.299111] ------------[ cut here ]------------
[    3.299173] WARNING: CPU: 0 PID: 1 at kernel/trace/trace.c:2215 run_tracer_selftest+0x110/0x148
[    3.299441] Modules linked in:
[    3.299725] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.17.0-rc1-gd7ee5bdce789 #141 NONE 
[    3.299806] Hardware name: Generic DT based system
[    3.299887] Call trace: 
[    3.299932]  unwind_backtrace from show_stack+0x18/0x1c
[    3.299987]  show_stack from dump_stack_lvl+0x54/0x68
[    3.299999]  dump_stack_lvl from __warn+0x88/0x12c
[    3.300013]  __warn from warn_slowpath_fmt+0x194/0x19c
[    3.300026]  warn_slowpath_fmt from run_tracer_selftest+0x110/0x148
[    3.300039]  run_tracer_selftest from register_tracer+0x11c/0x1cc
[    3.300054]  register_tracer from do_one_initcall+0x60/0x210
[    3.300066]  do_one_initcall from kernel_init_freeable+0x1d4/0x240
[    3.300079]  kernel_init_freeable from kernel_init+0x20/0x140
[    3.300091]  kernel_init from ret_from_fork+0x14/0x28
[    3.300131] Exception stack(0xe080dfb0 to 0xe080dff8)
[    3.300204] dfa0:                                     00000000 00000000 00000000 00000000
[    3.300217] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    3.300224] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    3.300282] ---[ end trace 0000000000000000 ]---

I double- and triple-checked my changes, still no clue. Then it dawned on me: the test fails even without any of my patches. đŸ« 

1
1
3

@rw I struggle about whether to report bugs in such cases sometimes. At least your code is all GPL (presumably). When proprietary userspace code triggered schedule_timeout recently, I thought about trying to write a minimum reproducer to post. Naturally $JOB has no time in the schedule to perform such tasks. I couldn't write the code at home on the weekend without using the work HW . . . ugh.

1
0
0
@alison Huh? Do you fear that the splat contains confidential information?
0
0
0