On Wed, Feb 12, 2025 at 12:11 AM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote: > > On Mon, Feb 10, 2025 at 08:12:32PM -0800, Eduard Zingerman wrote: > > I'm probably out of context for this discussion, sorry if I'm raising > > points already discussed. > > > > The DW_AT_noreturn attribute is defined for DWARF. A simple script > > like [1] could be used to find all functions with this attribute known > > to DWARF. Using this script I see several functions present in my > > kernel but not present in the NORETURN list from this patch: > > - abort > > - devtmpfs_work_loop > > - play_dead > > - rcu_gp_kthread > > - rcu_tasks_kthread > > > > All these are marked as FUNC symbols when doing 'readelf --symbols vmlinux'. > > > > 'pahole' could be modified to look for DW_AT_noreturn attributes and > > add this information in BTF. E.g. by adding special btf_decl_tag to > > corresponding FUNC definitions. This won't work if kernel is compiled > > w/o BTF, of-course. > > > > [1] https://gist.github.com/eddyz87/d8513a731dfe7e2be52b346aef1de353 > > I also suggested this, I agree this is a much better way to go. > noreturns.h is manually maintained based on objtool warnings and > I'm not surprised it has missing entries. > > Alexei mentioned 30k+ noreturns, but when I eliminate dups and > __compiletime_assert_* it's a much smaller list: > > $ ./noreturn_printer vmlinux |sort |uniq |grep -v compiletime_assert > arch_cpu_idle_dead external idle.c > arch_cpu_idle_dead external process.c > cpu_startup_entry external cpu.h > cpu_startup_entry external idle.c > do_exit external exit.c > do_exit external kernel.h > do_group_exit external exit.c > do_group_exit external task.h > do_task_dead external core.c > do_task_dead external task.h > doublefault_shim external doublefault_32.c > ex_handler_msr_mce external core.c > ex_handler_msr_mce external extable.h > __fortify_panic external fortify-string.h > __fortify_panic external string_helpers.c > i386_start_kernel external head32.c > __ia32_sys_exit external syscalls_32.h > __ia32_sys_exit_group external syscalls_32.h > kthread_complete_and_exit external kthread.c > kthread_exit external kthread.c > kthread_exit external kthread.h > machine_real_restart external reboot.c > make_task_dead external exit.c > __module_put_and_kthread_exit external main.c > __module_put_and_kthread_exit external module.h > nmi_panic_self_stop external panic.c > panic external panic.c > panic external panic.h > panic_smp_self_stop external panic.c > play_dead process.c > rcu_gp_kthread tree.c > rcu_tasks_kthread tasks.h > rest_init main.c > rewind_stack_and_make_dead external dumpstack.c > start_kernel external main.c > start_kernel external start_kernel.h > stop_this_cpu external process.c > stop_this_cpu external processor.h > > Also, for objtool we could use something based on your program to > autogenerate noreturns.h. Automatically generating noreturns.h is a great idea, as it would make the file accessible for use by others as well. > Only problem is, objtool doesn't currently > have a dependency on CONFIG_DEBUG_INFO. Is there any reason we can't make it dependent on CONFIG_DEBUG_INFO?" > Another option we've considered > is compiler annotations (or compiler plugins). -- Regards Yafang