Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel

From: Jiri Kosina
Date: Wed Feb 03 2016 - 03:55:21 EST


On Wed, 3 Feb 2016, AKASHI Takahiro wrote:

> > The gcc switch -mprofile-kernel, available for ppc64 on gcc > 4.8.5,
> > allows to call _mcount very early in the function, which low-level
> > ASM code and code patching functions need to consider.
> > Especially the link register and the parameter registers are still
> > alive and not yet saved into a new stack frame.
>
> I'm thinking of implementing live patch support *for arm64*, and as part of
> those efforts, we are proposing[1] a new *generic* gcc option, -fprolog-add=N.
> This option will insert N nop instructions at the beginning of each function.
> So we have to initialize those codes at the boot time to later utilize
> them for FTRACE_WITH_REGS. Other than that, it will work similarly
> with -mfentry on x86 (and -mprofile-kernel?).
>
> I'm totally unfamiliar with ppc architecture, but just wondering
> whether this option will also be useful for other architectures.

The interesting part of the story with ppc64 is that you indeed want to
create the callsite before the *most* of the prologue, but not really :)
The part of the prologue where TOC pointer is saved needs to happen before
the fentry/profiling call.

I don't think this will be an issue on ARM64, but it definitely is
something that should be taken into account in case the gcc option is
meant to be really generic.

Thanks,

--
Jiri Kosina
SUSE Labs