Skip to content

RFC Fixes the modules support of dynamic function tracer for MIPS

Wu Zhangjin linux-mips 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2MIPS: tracing/ftrace: Replace in_module() with a generic in_kernel_space()arch/mips/kernel/ftrace.c+36 -303 replies
2/2MIPS: tracing/ftrace: Fixes mcount_regex for modulesscripts/recordmcount.pl+29 -173 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/2] Fixes the modules support of dynamic function tracer for MIPS

From: Wu Zhangjin <[email protected]>

Hi, all

Currently, our in_module() defined in arch/mips/kernel/ftrace.c and scripts/recordmcount.pl for MIPS only considers the module and the core kernel have different address space and long call is assumed to be used.

But as David pointed before, the module may be in the same space as the core kernel, therefore, with the current implementation, dynamic function tracer for MIPS will not work for that situation.

This patchset is created to fix it.

As we know, to jump from an address to _mcount, for _mcount is in kernel space, if the address is also in kernel space, then, no long call is needed(for the "jal" can jump to a place whose offset is smaller than 2^28=256MB and no kernel image is possible to be bigger than 256MB), otherwise, (only consider the address passed by ftrace_make_{nop,call}), to jump from the address to _mcount, long call via "jalr" is needed:

if (in_kernel_space(addr)) {
	jal _mcount;
} else {

load the address of _mcount to a register
jalr <register>
}

Now, after implementing in_kernel_space() in the 1st patch, that situation(module and core kernel are in the same address space) is also covered.

But the 1st patch is not enough to fix the whole problem, we also need to record the right calling site(for long call, not really the calling site, but the position for loading the address to the register) for the module in that situation. Because no long call is needed for that situation, to get the calling site to _mcount, we need to search the R_MIPS_26 like the kernel, the 2nd patch does it.

Regards,
Wu Zhangjin

Wu Zhangjin (2):
MIPS: tracing/ftrace: Replace in_module() with a generic
in_kernel_space()
MIPS: tracing/ftrace: Fixes mcount_regex for modules

 arch/mips/kernel/ftrace.c |   66 ++++++++++++++++++++++++--------------------
 scripts/recordmcount.pl   |   46 +++++++++++++++++++-----------
 2 files changed, 65 insertions(+), 47 deletions(-)