mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT
@ 2026-04-09 11:47 cp0613
  2026-04-10  9:17 ` Guo Ren
  2026-05-23  0:00 ` Paul Walmsley
  0 siblings, 2 replies; 3+ messages in thread
From: cp0613 @ 2026-04-09 11:47 UTC (permalink / raw)
  To: pjw, alex, andybnac, guoren; +Cc: linux-riscv, linux-kernel, Chen Pei

From: Chen Pei <cp0613@linux.alibaba.com>

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>
---
 arch/riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 90c531e6abf5..6fe90591a274 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -151,6 +151,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
-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT
  2026-04-09 11:47 [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT cp0613
@ 2026-04-10  9:17 ` Guo Ren
  2026-05-23  0:00 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Guo Ren @ 2026-04-10  9:17 UTC (permalink / raw)
  To: cp0613; +Cc: pjw, alex, andybnac, linux-riscv, linux-kernel

Hi Chen,

Cool, we missed that. Good catch!

Tested-by: Guo Ren <guoren@kernel.org>

On Thu, Apr 9, 2026 at 7:48 PM <cp0613@linux.alibaba.com> wrote:
>
> From: Chen Pei <cp0613@linux.alibaba.com>
>
> 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>
> ---
>  arch/riscv/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 90c531e6abf5..6fe90591a274 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -151,6 +151,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
> --
> 2.50.1
>

-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT
  2026-04-09 11:47 [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT cp0613
  2026-04-10  9:17 ` Guo Ren
@ 2026-05-23  0:00 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Walmsley @ 2026-05-23  0:00 UTC (permalink / raw)
  To: Chen Pei; +Cc: pjw, alex, andybnac, guoren, linux-riscv, linux-kernel

On Thu, 9 Apr 2026, cp0613@linux.alibaba.com wrote:

> From: Chen Pei <cp0613@linux.alibaba.com>
> 
> 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>

Thanks, queued for v7.2.


- Paul


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-23  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-09 11:47 [PATCH] riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT cp0613
2026-04-10  9:17 ` Guo Ren
2026-05-23  0:00 ` Paul Walmsley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®