]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT
authorChen Pei <cp0613@linux.alibaba.com>
Sun, 7 Jun 2026 02:17:53 +0000 (20:17 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 7 Jun 2026 05:48:14 +0000 (23:48 -0600)
RISC-V already satisfies all prerequisites for build-time mcount sorting:
the sorttable host tool handles EM_RISCV in its machine-type dispatch, and
the __mcount_loc section entries are stored as direct virtual addresses in
the final vmlinux binary, so no relocation processing is required during
the sort step.

Select HAVE_BUILDTIME_MCOUNT_SORT so that BUILDTIME_MCOUNT_SORT is
automatically enabled when DYNAMIC_FTRACE is configured.  This allows
sorttable to sort the __mcount_loc section at link time, making the
run-time ftrace initialisation path skip the software sort and reducing
kernel startup overhead.

Verified with CONFIG_FTRACE_SORT_STARTUP_TEST=y, which confirms that
the section produced by the build is already in ascending order:

  [    0.000000] ftrace section at ffffffff81015a60 sorted properly

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Tested-by: Guo Ren <guoren@kernel.org>
Link: https://patch.msgid.link/20260409114736.907-1-cp0613@linux.alibaba.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/Kconfig

index bf4bc39c76b87f290a6c8f91206b7c421b072221..ce5f4342e2f25b938d30167fa8ac399ee68e181c 100644 (file)
@@ -152,6 +152,7 @@ config RISCV
        select HAVE_ARCH_USERFAULTFD_WP if 64BIT && MMU && USERFAULTFD && RISCV_ISA_SVRSW60T59B
        select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
        select HAVE_ASM_MODVERSIONS
+       select HAVE_BUILDTIME_MCOUNT_SORT
        select HAVE_CONTEXT_TRACKING_USER
        select HAVE_DEBUG_KMEMLEAK
        select HAVE_DMA_CONTIGUOUS if MMU