Commit ad275981 authored by He Sheng's avatar He Sheng Committed by guzitao
Browse files

sw64: fix recordmcount and dynamic ftrace

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I645P4



--------------------------------

SW64 mcount call site has 5 instructions as follows:

 0:       00 00 bb ff     ldih    $r29,0($r27)
                  0: GPDISP       .text+0x4
 4:       00 00 bd fb     ldi     $r29,0($r29)
 8:       00 00 9d ff     ldih    $r28,0($r29)
                  8: ELF_LITERAL_GOT      *ABS*
 c:       00 00 9d 8f     ldl     $r28,0($r29)
                  c: ELF_LITERAL  _mcount
10:       00 00 9c 07     call    $r28,($r28)
		  10: HINT        _mcount

It shows that there are 2 _mcount symbols, so recordmcount has to
set the second one as fake and filter it, then do the necessary
offset adjustment.

The first two instructions are aimed at loading global pointer(ldgp),
because _mcount is global symbol and global symbols must be accessed
through gp due to the design of GCC on sw64.

For functions that access global symbols, the ldgp instructions are
necessary for both _mcount call and other symbols. However, there is
no way to tell whether a function access global symbols, so it has to
always reserve the ldgp instructions for dynamic function tracer even
when tracing is disabled. This has a negative impact on performance.

With it, to disable tracing(ftrace_make_nop), the last 3 instructions
in position are replaced with 3 NOP instructions at once. To enable
tracing(ftrace_make_call), they are replaced with:

nop
ldl	$28, TI_FTRACE_ADDR($8)
call	$28, ($28), 1

Signed-off-by: default avatarHe Sheng <hesheng@wxiat.com>
Reviewed-by: default avatarCui Wei <cuiwei@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 1379061f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment