Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1324987 > unrolled thread
| Started by | AKASHI Takahiro <takahiro.akashi@linaro.org> |
|---|---|
| First post | 2016-02-03 08:30 +0100 |
| Last post | 2016-02-04 22:50 +0100 |
| Articles | 8 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel AKASHI Takahiro <takahiro.akashi@linaro.org> - 2016-02-03 08:30 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Jiri Kosina <jikos@kernel.org> - 2016-02-03 10:00 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Torsten Duwe <duwe@lst.de> - 2016-02-03 12:30 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel AKASHI Takahiro <takahiro.akashi@linaro.org> - 2016-02-04 10:40 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Petr Mladek <pmladek@suse.com> - 2016-02-04 12:10 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Balbir Singh <bsingharora@gmail.com> - 2016-02-05 05:50 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Petr Mladek <pmladek@suse.com> - 2016-02-05 11:30 +0100
Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel Jiri Kosina <jikos@kernel.org> - 2016-02-04 22:50 +0100
| From | AKASHI Takahiro <takahiro.akashi@linaro.org> |
|---|---|
| Date | 2016-02-03 08:30 +0100 |
| Subject | Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel |
| Message-ID | <qY030-7gg-15@gated-at.bofh.it> |
Hi,
On 01/26/2016 12:26 AM, Torsten Duwe 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.
I will really appreciate you if you share your thoughts with me, please?
[1] https://gcc.gnu.org/ml/gcc/2015-05/msg00267.html, and
https://gcc.gnu.org/ml/gcc/2015-10/msg00090.html
Thanks,
-Takahiro AKASHI
> Signed-off-by: Torsten Duwe <duwe@suse.de>
> ---
> arch/powerpc/kernel/entry_64.S | 45 +++++++++++++++++++++++++++++++++++++++--
> arch/powerpc/kernel/ftrace.c | 12 +++++++++--
> arch/powerpc/kernel/module_64.c | 14 +++++++++++++
> 3 files changed, 67 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index a94f155..e7cd043 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -1206,7 +1206,12 @@ _GLOBAL(enter_prom)
> #ifdef CONFIG_DYNAMIC_FTRACE
> _GLOBAL(mcount)
> _GLOBAL(_mcount)
> - blr
> + std r0,LRSAVE(r1) /* gcc6 does this _after_ this call _only_ */
> + mflr r0
> + mtctr r0
> + ld r0,LRSAVE(r1)
> + mtlr r0
> + bctr
>
> _GLOBAL_TOC(ftrace_caller)
> /* Taken from output of objdump from lib64/glibc */
> @@ -1262,13 +1267,28 @@ _GLOBAL(ftrace_stub)
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> _GLOBAL(ftrace_graph_caller)
> +#ifdef CC_USING_MPROFILE_KERNEL
> + /* with -mprofile-kernel, parameter regs are still alive at _mcount */
> + std r10, 104(r1)
> + std r9, 96(r1)
> + std r8, 88(r1)
> + std r7, 80(r1)
> + std r6, 72(r1)
> + std r5, 64(r1)
> + std r4, 56(r1)
> + std r3, 48(r1)
> + mfctr r4 /* ftrace_caller has moved local addr here */
> + std r4, 40(r1)
> + mflr r3 /* ftrace_caller has restored LR from stack */
> +#else
> /* load r4 with local address */
> ld r4, 128(r1)
> - subi r4, r4, MCOUNT_INSN_SIZE
>
> /* Grab the LR out of the caller stack frame */
> ld r11, 112(r1)
> ld r3, 16(r11)
> +#endif
> + subi r4, r4, MCOUNT_INSN_SIZE
>
> bl prepare_ftrace_return
> nop
> @@ -1277,6 +1297,26 @@ _GLOBAL(ftrace_graph_caller)
> * prepare_ftrace_return gives us the address we divert to.
> * Change the LR in the callers stack frame to this.
> */
> +
> +#ifdef CC_USING_MPROFILE_KERNEL
> + mtlr r3
> +
> + ld r0, 40(r1)
> + mtctr r0
> + ld r10, 104(r1)
> + ld r9, 96(r1)
> + ld r8, 88(r1)
> + ld r7, 80(r1)
> + ld r6, 72(r1)
> + ld r5, 64(r1)
> + ld r4, 56(r1)
> + ld r3, 48(r1)
> +
> + addi r1, r1, 112
> + mflr r0
> + std r0, LRSAVE(r1)
> + bctr
> +#else
> ld r11, 112(r1)
> std r3, 16(r11)
>
> @@ -1284,6 +1324,7 @@ _GLOBAL(ftrace_graph_caller)
> mtlr r0
> addi r1, r1, 112
> blr
> +#endif
>
> _GLOBAL(return_to_handler)
> /* need to save return values */
> diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> index 44d4d8e..080c525 100644
> --- a/arch/powerpc/kernel/ftrace.c
> +++ b/arch/powerpc/kernel/ftrace.c
> @@ -306,11 +306,19 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> * The load offset is different depending on the ABI. For simplicity
> * just mask it out when doing the compare.
> */
> +#ifndef CC_USING_MPROFILE_KERNEL
> if ((op[0] != 0x48000008) || ((op[1] & 0xffff0000) != 0xe8410000)) {
> - pr_err("Unexpected call sequence: %x %x\n", op[0], op[1]);
> + pr_err("Unexpected call sequence at %p: %x %x\n",
> + ip, op[0], op[1]);
> return -EINVAL;
> }
> -
> +#else
> + /* look for patched "NOP" on ppc64 with -mprofile-kernel */
> + if (op[0] != 0x60000000) {
> + pr_err("Unexpected call at %p: %x\n", ip, op[0]);
> + return -EINVAL;
> + }
> +#endif
> /* If we never set up a trampoline to ftrace_caller, then bail */
> if (!rec->arch.mod->arch.tramp) {
> pr_err("No ftrace trampoline\n");
> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
> index 6838451..30f6be1 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -475,6 +475,20 @@ static unsigned long stub_for_addr(Elf64_Shdr *sechdrs,
> static int restore_r2(u32 *instruction, struct module *me)
> {
> if (*instruction != PPC_INST_NOP) {
> +#ifdef CC_USING_MPROFILE_KERNEL
> + /* -mprofile_kernel sequence starting with
> + * mflr r0 and maybe std r0, LRSAVE(r1)
> + */
> + if ((instruction[-3] == 0x7c0802a6 &&
> + instruction[-2] == 0xf8010010) ||
> + instruction[-2] == 0x7c0802a6) {
> + /* Nothing to be done here, it's an _mcount
> + * call location and r2 will have to be
> + * restored in the _mcount function.
> + */
> + return 1;
> + };
> +#endif
> pr_err("%s: Expect noop after relocate, got %08x\n",
> me->name, *instruction);
> return 0;
>
[toc] | [next] | [standalone]
| From | Jiri Kosina <jikos@kernel.org> |
|---|---|
| Date | 2016-02-03 10:00 +0100 |
| Message-ID | <qY1s6-83z-15@gated-at.bofh.it> |
| In reply to | #1324987 |
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
[toc] | [prev] | [next] | [standalone]
| From | Torsten Duwe <duwe@lst.de> |
|---|---|
| Date | 2016-02-03 12:30 +0100 |
| Message-ID | <qY3Ng-1gx-23@gated-at.bofh.it> |
| In reply to | #1325068 |
On Wed, Feb 03, 2016 at 09:55:11AM +0100, Jiri Kosina wrote: > On Wed, 3 Feb 2016, AKASHI Takahiro wrote: > > 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. > 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 :) I was silently assuming that GCC would do this right on ppc64le; add the NOPs right after the TOC load. Or after TOC load and LR save? ... > The part of the prologue where TOC pointer is saved needs to happen before > the fentry/profiling call. Yes, any call, to any profiler/tracer/live patcher is potentially global and needs the _new_ TOC value. This proposal, if implemented in a too naive fashion, will worsen the problem we currently discuss: a few NOPs _never_ cause any global reference. GCC might be even more inclined to not load a new TOC value. That change would need to be fairly smart on ppc64le. Torsten
[toc] | [prev] | [next] | [standalone]
| From | AKASHI Takahiro <takahiro.akashi@linaro.org> |
|---|---|
| Date | 2016-02-04 10:40 +0100 |
| Message-ID | <qYoyl-6KS-1@gated-at.bofh.it> |
| In reply to | #1325232 |
Jiri, Torsten
Thank you for your explanation.
On 02/03/2016 08:24 PM, Torsten Duwe wrote:
> On Wed, Feb 03, 2016 at 09:55:11AM +0100, Jiri Kosina wrote:
>> On Wed, 3 Feb 2016, AKASHI Takahiro wrote:
>>> 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.
>
>> 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 :)
>
> I was silently assuming that GCC would do this right on ppc64le; add the NOPs
> right after the TOC load. Or after TOC load and LR save? ...
On arm/arm64, link register must be saved before any function call. So anyhow
we will have to add something, 3 instructions at the minimum, like:
save lr
branch _mcount
restore lr
<prologue>
...
<body>
...
>> The part of the prologue where TOC pointer is saved needs to happen before
>> the fentry/profiling call.
>
> Yes, any call, to any profiler/tracer/live patcher is potentially global
> and needs the _new_ TOC value.
I don't want to bother you, but for my better understandings, could you show me
an example of asm instructions for a function prologue under -mprofile-kernel, please?
-Takahiro AKASHI
> This proposal, if implemented in a too naive fashion, will worsen the problem
> we currently discuss: a few NOPs _never_ cause any global reference. GCC might
> be even more inclined to not load a new TOC value. That change would need to be
> fairly smart on ppc64le.
>
> Torsten
>
[toc] | [prev] | [next] | [standalone]
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Date | 2016-02-04 12:10 +0100 |
| Message-ID | <qYpXs-7NG-3@gated-at.bofh.it> |
| In reply to | #1326516 |
On Thu 2016-02-04 18:31:40, AKASHI Takahiro wrote:
> Jiri, Torsten
>
> Thank you for your explanation.
>
> On 02/03/2016 08:24 PM, Torsten Duwe wrote:
> >On Wed, Feb 03, 2016 at 09:55:11AM +0100, Jiri Kosina wrote:
> >>On Wed, 3 Feb 2016, AKASHI Takahiro wrote:
> >>>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.
> >
> >>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 :)
> >
> >I was silently assuming that GCC would do this right on ppc64le; add the NOPs
> >right after the TOC load. Or after TOC load and LR save? ...
>
> On arm/arm64, link register must be saved before any function call. So anyhow
> we will have to add something, 3 instructions at the minimum, like:
> save lr
> branch _mcount
> restore lr
> <prologue>
> ...
> <body>
> ...
So, it is similar to PPC that has to handle LR as well.
> >>The part of the prologue where TOC pointer is saved needs to happen before
> >>the fentry/profiling call.
> >
> >Yes, any call, to any profiler/tracer/live patcher is potentially global
> >and needs the _new_ TOC value.
The code below is generated for PPC64LE with -mprofile-kernel using:
$> gcc --version
gcc (SUSE Linux) 6.0.0 20160121 (experimental) [trunk revision 232670]
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0000000000000050 <cmdline_proc_show>:
50: 00 00 4c 3c addis r2,r12,0
50: R_PPC64_REL16_HA .TOC.
54: 00 00 42 38 addi r2,r2,0
54: R_PPC64_REL16_LO .TOC.+0x4
58: a6 02 08 7c mflr r0
5c: 01 00 00 48 bl 5c <cmdline_proc_show+0xc>
5c: R_PPC64_REL24 _mcount
60: a6 02 08 7c mflr r0
64: 10 00 01 f8 std r0,16(r1)
68: a1 ff 21 f8 stdu r1,-96(r1)
6c: 00 00 22 3d addis r9,r2,0
6c: R_PPC64_TOC16_HA .toc
70: 00 00 82 3c addis r4,r2,0
70: R_PPC64_TOC16_HA .rodata.str1.8
74: 00 00 29 e9 ld r9,0(r9)
74: R_PPC64_TOC16_LO_DS .toc
78: 00 00 84 38 addi r4,r4,0
78: R_PPC64_TOC16_LO .rodata.str1.8
7c: 00 00 a9 e8 ld r5,0(r9)
80: 01 00 00 48 bl 80 <cmdline_proc_show+0x30>
80: R_PPC64_REL24 seq_printf
84: 00 00 00 60 nop
88: 00 00 60 38 li r3,0
8c: 60 00 21 38 addi r1,r1,96
90: 10 00 01 e8 ld r0,16(r1)
94: a6 03 08 7c mtlr r0
98: 20 00 80 4e blr
And the same function compiled using:
$> gcc --version
gcc (SUSE Linux) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0000000000000050 <cmdline_proc_show>:
50: 00 00 4c 3c addis r2,r12,0
50: R_PPC64_REL16_HA .TOC.
54: 00 00 42 38 addi r2,r2,0
54: R_PPC64_REL16_LO .TOC.+0x4
58: a6 02 08 7c mflr r0
5c: 10 00 01 f8 std r0,16(r1)
60: 01 00 00 48 bl 60 <cmdline_proc_show+0x10>
60: R_PPC64_REL24 _mcount
64: a6 02 08 7c mflr r0
68: 10 00 01 f8 std r0,16(r1)
6c: a1 ff 21 f8 stdu r1,-96(r1)
70: 00 00 42 3d addis r10,r2,0
70: R_PPC64_TOC16_HA .toc
74: 00 00 82 3c addis r4,r2,0
74: R_PPC64_TOC16_HA .rodata.str1.8
78: 00 00 2a e9 ld r9,0(r10)
78: R_PPC64_TOC16_LO_DS .toc
7c: 00 00 84 38 addi r4,r4,0
7c: R_PPC64_TOC16_LO .rodata.str1.8
80: 00 00 a9 e8 ld r5,0(r9)
84: 01 00 00 48 bl 84 <cmdline_proc_show+0x34>
84: R_PPC64_REL24 seq_printf
88: 00 00 00 60 nop
8c: 00 00 60 38 li r3,0
90: 60 00 21 38 addi r1,r1,96
94: 10 00 01 e8 ld r0,16(r1)
98: a6 03 08 7c mtlr r0
9c: 20 00 80 4e blr
Please, note that are used either 3 or 4 instructions before the
mcount location depending on the compiler version.
Best Regards,
Petr
[toc] | [prev] | [next] | [standalone]
| From | Balbir Singh <bsingharora@gmail.com> |
|---|---|
| Date | 2016-02-05 05:50 +0100 |
| Message-ID | <qYGvg-3P6-3@gated-at.bofh.it> |
| In reply to | #1326669 |
On Thu, Feb 4, 2016 at 10:02 PM, Petr Mladek <pmladek@suse.com> wrote: > On Thu 2016-02-04 18:31:40, AKASHI Takahiro wrote: >> Jiri, Torsten >> >> Thank you for your explanation. >> >> On 02/03/2016 08:24 PM, Torsten Duwe wrote: >> >On Wed, Feb 03, 2016 at 09:55:11AM +0100, Jiri Kosina wrote: >> >>On Wed, 3 Feb 2016, AKASHI Takahiro wrote: >> >>>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. >> > >> >>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 :) >> > >> >I was silently assuming that GCC would do this right on ppc64le; add the NOPs >> >right after the TOC load. Or after TOC load and LR save? ... >> >> On arm/arm64, link register must be saved before any function call. So anyhow >> we will have to add something, 3 instructions at the minimum, like: >> save lr >> branch _mcount >> restore lr >> <prologue> >> ... >> <body> >> ... > > So, it is similar to PPC that has to handle LR as well. > > >> >>The part of the prologue where TOC pointer is saved needs to happen before >> >>the fentry/profiling call. >> > >> >Yes, any call, to any profiler/tracer/live patcher is potentially global >> >and needs the _new_ TOC value. > > The code below is generated for PPC64LE with -mprofile-kernel using: > > $> gcc --version > gcc (SUSE Linux) 6.0.0 20160121 (experimental) [trunk revision 232670] > Copyright (C) 2016 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > > 0000000000000050 <cmdline_proc_show>: > 50: 00 00 4c 3c addis r2,r12,0 > 50: R_PPC64_REL16_HA .TOC. > 54: 00 00 42 38 addi r2,r2,0 > 54: R_PPC64_REL16_LO .TOC.+0x4 > 58: a6 02 08 7c mflr r0 > 5c: 01 00 00 48 bl 5c <cmdline_proc_show+0xc> > 5c: R_PPC64_REL24 _mcount > 60: a6 02 08 7c mflr r0 > 64: 10 00 01 f8 std r0,16(r1) > 68: a1 ff 21 f8 stdu r1,-96(r1) > 6c: 00 00 22 3d addis r9,r2,0 > 6c: R_PPC64_TOC16_HA .toc > 70: 00 00 82 3c addis r4,r2,0 > 70: R_PPC64_TOC16_HA .rodata.str1.8 > 74: 00 00 29 e9 ld r9,0(r9) > 74: R_PPC64_TOC16_LO_DS .toc > 78: 00 00 84 38 addi r4,r4,0 > 78: R_PPC64_TOC16_LO .rodata.str1.8 > 7c: 00 00 a9 e8 ld r5,0(r9) > 80: 01 00 00 48 bl 80 <cmdline_proc_show+0x30> > 80: R_PPC64_REL24 seq_printf > 84: 00 00 00 60 nop > 88: 00 00 60 38 li r3,0 > 8c: 60 00 21 38 addi r1,r1,96 > 90: 10 00 01 e8 ld r0,16(r1) > 94: a6 03 08 7c mtlr r0 > 98: 20 00 80 4e blr > > > And the same function compiled using: > > $> gcc --version > gcc (SUSE Linux) 4.8.5 > Copyright (C) 2015 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > > 0000000000000050 <cmdline_proc_show>: > 50: 00 00 4c 3c addis r2,r12,0 > 50: R_PPC64_REL16_HA .TOC. > 54: 00 00 42 38 addi r2,r2,0 > 54: R_PPC64_REL16_LO .TOC.+0x4 > 58: a6 02 08 7c mflr r0 > 5c: 10 00 01 f8 std r0,16(r1) > 60: 01 00 00 48 bl 60 <cmdline_proc_show+0x10> > 60: R_PPC64_REL24 _mcount > 64: a6 02 08 7c mflr r0 > 68: 10 00 01 f8 std r0,16(r1) > 6c: a1 ff 21 f8 stdu r1,-96(r1) > 70: 00 00 42 3d addis r10,r2,0 > 70: R_PPC64_TOC16_HA .toc > 74: 00 00 82 3c addis r4,r2,0 > 74: R_PPC64_TOC16_HA .rodata.str1.8 > 78: 00 00 2a e9 ld r9,0(r10) > 78: R_PPC64_TOC16_LO_DS .toc > 7c: 00 00 84 38 addi r4,r4,0 > 7c: R_PPC64_TOC16_LO .rodata.str1.8 > 80: 00 00 a9 e8 ld r5,0(r9) > 84: 01 00 00 48 bl 84 <cmdline_proc_show+0x34> > 84: R_PPC64_REL24 seq_printf > 88: 00 00 00 60 nop > 8c: 00 00 60 38 li r3,0 > 90: 60 00 21 38 addi r1,r1,96 > 94: 10 00 01 e8 ld r0,16(r1) > 98: a6 03 08 7c mtlr r0 > 9c: 20 00 80 4e blr > > > Please, note that are used either 3 or 4 instructions before the > mcount location depending on the compiler version. Thanks Petr For big endian builds I saw Dump of assembler code for function alloc_pages_current: 0xc000000000256f00 <+0>: mflr r0 0xc000000000256f04 <+4>: std r0,16(r1) 0xc000000000256f08 <+8>: bl 0xc000000000009e5c <.mcount> 0xc000000000256f0c <+12>: mflr r0 The offset is 8 bytes. Your earlier patch handled this by adding 16, I suspect it needs revisiting Balbir
[toc] | [prev] | [next] | [standalone]
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Date | 2016-02-05 11:30 +0100 |
| Message-ID | <qYLOi-7mC-7@gated-at.bofh.it> |
| In reply to | #1327491 |
On Fri 2016-02-05 15:40:27, Balbir Singh wrote: > On Thu, Feb 4, 2016 at 10:02 PM, Petr Mladek <pmladek@suse.com> wrote: > For big endian builds I saw > > Dump of assembler code for function alloc_pages_current: > 0xc000000000256f00 <+0>: mflr r0 > 0xc000000000256f04 <+4>: std r0,16(r1) > 0xc000000000256f08 <+8>: bl 0xc000000000009e5c <.mcount> > 0xc000000000256f0c <+12>: mflr r0 > > The offset is 8 bytes. Your earlier patch handled this by adding 16, I > suspect it needs revisiting It seems to be one of the funcitons that do not access any global symbol. gcc does not produce TOC handling in this case when compiled with -mprofile-kernel. I believe that it is a gcc bug. More details can be found in the thread starting at http://thread.gmane.org/gmane.linux.kernel/2134759/focus=2141996 Best Regards, Petr
[toc] | [prev] | [next] | [standalone]
| From | Jiri Kosina <jikos@kernel.org> |
|---|---|
| Date | 2016-02-04 22:50 +0100 |
| Message-ID | <qYzWO-7GJ-7@gated-at.bofh.it> |
| In reply to | #1326516 |
On Thu, 4 Feb 2016, AKASHI Takahiro wrote: > On arm/arm64, link register must be saved before any function call. So anyhow > we will have to add something, 3 instructions at the minimum, like: > save lr > branch _mcount > restore lr > <prologue> > ... > <body> > ... This means that we have at least two architectures that need one instruction before the mcount/mfentry call, and the rest of the prologue to follow afterwards. On x86, we don't need any "pre-prologue". Persumably the corresponding opcodes have different sizes. This nicely demonstrates my point -- if this one-gcc-option-to-rule-them-all would exist, it needs to be generic enough to describe these kinds of constraints (who knows what other restrictions will pop up when exploring other, more exotic, architectures later). Thanks, -- Jiri Kosina SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web