Re: [PATCH v2 5/8] ftrace: Add swap_func to ftrace_process_locs()
Steven Rostedt <[email protected]>
| Newsgroups | gmane.linux.ports.alpha,gmane.linux.kernel.bpf,gmane.linux.kernel.cross-arch,gmane.linux.ports.arm.kernel,gmane.linux.ports.hexagon,gmane.linux.kernel,gmane.linux.ports.mips,gmane.linux.kernel.mm,gmane.linux.kernel.modules,gmane.linux.ports.parisc,gmane.linux.ports.riscv,gmane.linux.ports.sh.devel,gmane.linux.kernel.arc,gmane.linux.uml.devel,gmane.linux.ports.ppc64.devel,gmane.linux.ports.sparc |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 26 Aug 2024 09:55:29 +0300 Mike Rapoport <[email protected]> wrote: > From: Song Liu <[email protected]> > > ftrace_process_locs sorts module mcount, which is inside RO memory. Add a > ftrace_swap_func so that archs can use RO-memory-poke function to do the > sorting. Can you add the above as a comment above the ftrace_swap_func() function? Thanks, -- Steve > > Signed-off-by: Song Liu <[email protected]> > Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> > --- > include/linux/ftrace.h | 2 ++ > kernel/trace/ftrace.c | 13 ++++++++++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h > index fd5e84d0ec47..b794dcb7cae8 100644 > --- a/include/linux/ftrace.h > +++ b/include/linux/ftrace.h > @@ -1188,4 +1188,6 @@ unsigned long arch_syscall_addr(int nr); > > #endif /* CONFIG_FTRACE_SYSCALLS */ > > +void ftrace_swap_func(void *a, void *b, int n); > + > #endif /* _LINUX_FTRACE_H */ > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 4c28dd177ca6..9829979f3a46 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -6989,6 +6989,17 @@ static void test_is_sorted(unsigned long *start, > unsigned long count) } > #endif > > +void __weak ftrace_swap_func(void *a, void *b, int n) > +{ > + unsigned long t; > + > + WARN_ON_ONCE(n != sizeof(t)); > + > + t = *((unsigned long *)a); > + *(unsigned long *)a = *(unsigned long *)b; > + *(unsigned long *)b = t; > +} > + > static int ftrace_process_locs(struct module *mod, > unsigned long *start, > unsigned long *end) > @@ -7016,7 +7027,7 @@ static int ftrace_process_locs(struct module *mod, > */ > if (!IS_ENABLED(CONFIG_BUILDTIME_MCOUNT_SORT) || mod) { > sort(start, count, sizeof(*start), > - ftrace_cmp_ips, NULL); > + ftrace_cmp_ips, ftrace_swap_func); > } else { > test_is_sorted(start, count); > }