[PATCH] ppc64 ftrace: mark data_access callees "notrace" (pt.1)

2015-05-13 Thread Torsten Duwe
fine-grained (but probably yet incomplete). This patch is necessary albeit not sufficient for FTRACE_WITH_REGS on ppc64. Patch is against 3.17; fuzz+force should do no harm. Signed-off-by: Torsten Duwe diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index bf44ae9..29ed85f

Re: [PATCH] ppc64 ftrace: mark data_access callees "notrace" (pt.1)

2015-05-15 Thread Torsten Duwe
On Fri, May 15, 2015 at 11:34:47AM +1000, Michael Ellerman wrote: > On Wed, 2015-05-13 at 18:11 +0200, Torsten Duwe wrote: > > In order to avoid an endless recursion, functions that may get > > called from the data access handler must not call into tracing > > functions,

Re: [PATCH] ppc64 ftrace: mark data_access callees "notrace" (pt.1)

2015-05-16 Thread Torsten Duwe
On Fri, May 15, 2015 at 10:45:42AM +0200, Torsten Duwe wrote: > On Fri, May 15, 2015 at 11:34:47AM +1000, Michael Ellerman wrote: > > > > There's got to be a better solution than this. > > Can you think of a better approach? Maybe a per thread variable to lock out a recu

Re: [PATCH] ppc64 ftrace: mark data_access callees "notrace" (pt.1)

2015-05-20 Thread Torsten Duwe
On Tue, May 19, 2015 at 01:27:07PM +1000, Michael Ellerman wrote: > On Mon, 2015-05-18 at 14:29 +0200, Jiri Kosina wrote: > > > > ftrace already handles recursion protection by itself (depending on the > > per-ftrace-ops FTRACE_OPS_FL_RECURSION_SAFE flag). > > OK, so I wonder why that's not work

Re: [PATCH] ppc64 ftrace: mark data_access callees "notrace" (pt.1)

2015-05-26 Thread Torsten Duwe
On Wed, May 20, 2015 at 11:03:25AM +0200, Torsten Duwe wrote: > On Tue, May 19, 2015 at 01:27:07PM +1000, Michael Ellerman wrote: > > On Mon, 2015-05-18 at 14:29 +0200, Jiri Kosina wrote: > > > > > > ftrace already handles recursion protection by itself (depending o

[PATCH 0/4] ppc64 ftrace implementation

2015-06-03 Thread Torsten Duwe
On Tue, May 19, 2015 at 11:52:47AM +0200, Jiri Kosina wrote: > On Tue, 19 May 2015, Michael Ellerman wrote: > > > > ftrace already handles recursion protection by itself (depending on the > > > per-ftrace-ops FTRACE_OPS_FL_RECURSION_SAFE flag). > > > > OK, so I wonder why that's not working for

Re: [PATCH 1/4] ppc64 ftrace implementation

2015-06-03 Thread Torsten Duwe
Implement ftrace on ppc64 Signed-off-by: Torsten Duwe diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index e366187..691 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -46,6 +46,8 @@ extern void _mcount(void

Re: [PATCH 2/4] ppc64 ftrace configuration

2015-06-03 Thread Torsten Duwe
Add Kconfig variables and Makefile magic for ftrace with -mprofile-kernel Signed-off-by: Torsten Duwe diff --git a/Makefile b/Makefile index 3d16bcc..bbd5e87 100644 --- a/Makefile +++ b/Makefile @@ -733,7 +733,10 @@ export CC_FLAGS_FTRACE ifdef CONFIG_HAVE_FENTRY CC_USING_FENTRY

Re: [PATCH 3/4] ppc64 ftrace: spare early boot and low level code

2015-06-03 Thread Torsten Duwe
Using -mprofile-kernel on early boot code not only confuses the checker but is also useless, as the infrastructure is not yet in place. Proceed like with -pg, equally with time.o and ftrace itself. Signed-off-by: Torsten Duwe diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel

Re: [PATCH 4/4] ppc64 ftrace recursion protection

2015-06-03 Thread Torsten Duwe
As suggested by You and Jikos, a flag in task_struct's trace_recursion is used to block a tracer function to recurse into itself, especially on a data access fault. This should catch all functions called by the fault handlers which are not yet attributed notrace. Signed-off-by: Torsten

Re: [PATCH 1/4] ppc64 ftrace implementation

2015-06-08 Thread Torsten Duwe
On Mon, Jun 08, 2015 at 11:30:32AM -0400, Steven Rostedt wrote: > > Why are your patches all as replies? Because I cared too much about the threading and the series that the "Re:" escaped me. > > Implement ftrace on ppc64 > > What do you mean "Implement ftrace on ppc64"? It's already implemente

[PATCH 0/4] resend: ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-11 Thread Torsten Duwe
Hi again, with the previous submission I was too much into the details to state a few obvious things. Now with nicer explanations and changelog. Torsten ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listin

[PATCH 1/4] ppc64 FTRACE_WITH_REGS implementation

2015-06-11 Thread Torsten Duwe
wise... - relax is_module_trampoline() to recognise the modified trampoline. Signed-off-by: Torsten Duwe -- arch/powerpc/include/asm/ftrace.h |5 + arch/powerpc/kernel/entry_64.S| 112 +++--- arch/powerpc/kernel/ftrace.c | 67 -- arch/pow

[PATCH 2/4] ppc64 ftrace_with_regs configuration variables

2015-06-11 Thread Torsten Duwe
* Makefile: - globally use -mprofile-kernel in case it's configured. * arch/powerpc/Kconfig / kernel/trace/Kconfig: - declare that ppc64 HAVE_MPROFILE_KERNEL and HAVE_DYNAMIC_FTRACE_WITH_REGS, and use it. Signed-off-by: Torsten Duwe -- Makefile |5 -

[PATCH 3/4] ppc64 ftrace_with_regs: spare early boot and low level code

2015-06-11 Thread Torsten Duwe
level and boot code objects' CFLAGS for FUNCTION_TRACER configurations. Signed-off-by: Torsten Duwe -- arch/powerpc/kernel/Makefile | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) -- diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 50

[PATCH 4/4] ppc64 ftrace_with_regs recursion protection

2015-06-11 Thread Torsten Duwe
is fill-in. It will later serve as a backup protection. * arch/powerpc/kernel/entry_64.S: - test-and-set TRACE_FTRACE_BIT in task_struct's trace_recursion, do not call the actual tracer function if set, clear flag on return. Signed-off-by: Torsten Duwe -- arch/powerpc/kerne

[RESEND PATCH 0/4] ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-18 Thread Torsten Duwe
Did I miss anything else? I have the notrace optimisations and kernel live patching in the queue, which depends on this, so I'd really appreciate a comment whether it is acceptable in this form or not. Thanks in advance! Torsten ___ Linuxppc-dev

[RESEND PATCH 1/4] ppc64 FTRACE_WITH_REGS implementation

2015-06-18 Thread Torsten Duwe
wise... - relax is_module_trampoline() to recognise the modified trampoline. Signed-off-by: Torsten Duwe -- arch/powerpc/include/asm/ftrace.h |5 + arch/powerpc/kernel/entry_64.S| 112 +++--- arch/powerpc/kernel/ftrace.c | 67 -- arch/pow

[RESEND PATCH 2/4] ppc64 ftrace_with_regs configuration variables

2015-06-18 Thread Torsten Duwe
* Makefile: - globally use -mprofile-kernel in case it's configured. * arch/powerpc/Kconfig / kernel/trace/Kconfig: - declare that ppc64 HAVE_MPROFILE_KERNEL and HAVE_DYNAMIC_FTRACE_WITH_REGS, and use it. Signed-off-by: Torsten Duwe -- Makefile |5 -

[RESEND PATCH 3/4] ppc64 ftrace_with_regs: spare early boot and low level code

2015-06-18 Thread Torsten Duwe
level and boot code objects' CFLAGS for FUNCTION_TRACER configurations. Signed-off-by: Torsten Duwe -- arch/powerpc/kernel/Makefile | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) -- diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 50

[RESEND PATCH 4/4] ppc64 ftrace_with_regs recursion protection

2015-06-18 Thread Torsten Duwe
is fill-in. It will later serve as a backup protection. * arch/powerpc/kernel/entry_64.S: - test-and-set TRACE_FTRACE_BIT in task_struct's trace_recursion, do not call the actual tracer function if set, clear flag on return. Signed-off-by: Torsten Duwe -- arch/powerpc/kerne

Re: [RESEND PATCH 0/4] ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-19 Thread Torsten Duwe
On Thu, Jun 18, 2015 at 12:55:39PM -0400, Steven Rostedt wrote: > > I applied these patches against v4.1-rc8 and I get this compiling it > for my electra: > > /work/autotest/nobackup/powerpc-test.git/arch/powerpc/kernel/entry_64.S: > Assembler messages: > /work/autotest/nobackup/powerpc-test.git

Re: [RESEND PATCH 1/4] ppc64 FTRACE_WITH_REGS implementation

2015-06-19 Thread Torsten Duwe
On Thu, Jun 18, 2015 at 12:49:00PM -0400, Steven Rostedt wrote: > On Thu, 18 Jun 2015 18:21:07 +0200 > Torsten Duwe wrote: > > > + > > _GLOBAL(ftrace_stub) > > + nop > > + nop > > +.localentry ftrace_stub,.-ftrace_stub > > You might w

Re: [RESEND PATCH 0/4] ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-19 Thread Torsten Duwe
On Fri, Jun 19, 2015 at 10:15:44AM +0300, Denis Kirjanov wrote: > > Hi Torsten, > > could you provide a description how you did test that. Vanilla kernel, those patches on top, built as described to Steven in the previous mail (.config attached there, built natively on ppc64le ABIv2, mentioned t

Re: [RESEND PATCH 0/4] ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-19 Thread Torsten Duwe
On Fri, Jun 19, 2015 at 08:40:44AM -0400, Steven Rostedt wrote: > On Fri, 19 Jun 2015 14:00:44 +0200 > Torsten Duwe wrote: > > > > | kernel/bounds.c:1:0: error: -mcall-aixdesc incompatible with -mabi=elfv2 > > > > Are you building ppc64, little endian, ELF ABIv

[PATCH v2 0/4] ppc64 LE ABI v2 ftrace-with-regs implementation

2015-06-19 Thread Torsten Duwe
Changes since v1: adjusted dashes, whitespace, make checkpatch happy. No functional changes. Do NOT select FTRACE_WITH_REGS on ELF ABI v1 ! For C source, there's #if defined(_CALL_ELF) && _CALL_ELF == 2 Maybe there's something for Kconfig, too. Torsten ___

[PATCH v2 1/4] ppc64 FTRACE_WITH_REGS implementation

2015-06-19 Thread Torsten Duwe
ppen otherwise... - relax is_module_trampoline() to recognise the modified trampoline. Signed-off-by: Torsten Duwe --- arch/powerpc/include/asm/ftrace.h |5 + arch/powerpc/kernel/entry_64.S| 112 +++--- arch/powerpc/kernel/ftrace.c |

[PATCH v2 2/4] ppc64 ftrace_with_regs configuration variables

2015-06-19 Thread Torsten Duwe
* Makefile: - globally use -mprofile-kernel in case it's configured. * arch/powerpc/Kconfig / kernel/trace/Kconfig: - declare that ppc64 HAVE_MPROFILE_KERNEL and HAVE_DYNAMIC_FTRACE_WITH_REGS, and use it. Signed-off-by: Torsten Duwe --- Makefile |5 -

[PATCH v2 3/4] ppc64 ftrace_with_regs: spare early boot and low level code

2015-06-19 Thread Torsten Duwe
level and boot code objects' CFLAGS for FUNCTION_TRACER configurations. Signed-off-by: Torsten Duwe --- arch/powerpc/kernel/Makefile | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 50

[PATCH v2 4/4] ppc64 ftrace_with_regs recursion protection

2015-06-19 Thread Torsten Duwe
is fill-in. It will later serve as a backup protection. * arch/powerpc/kernel/entry_64.S: - test-and-set TRACE_FTRACE_BIT in task_struct's trace_recursion, do not call the actual tracer function if set, clear flag on return. Signed-off-by: Torsten Duwe --- arch/powerpc/kerne

RFC: Kernel Live Patching for ppc64le (ABIv2)

2015-07-27 Thread Torsten Duwe
sistency models. Please skim over this patch and tell me if you see any problems. (This is on top of my ftrace with regs series, which probably needs another iteration) Signed-off-by: Torsten Duwe diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 4768104..57af111 10

[PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-06 Thread Torsten Duwe
. The pSeries directed yield for vCPUs is taken care of by an additional "holder" field in the lock. Signed-off-by: Torsten Duwe -- arch/powerpc/include/asm/spinlock_types.h | 27 - arch/powerpc/include/asm/spinlock.h | 157 +++--- arch/powerpc/l

Re: [PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-06 Thread Torsten Duwe
On Thu, Feb 06, 2014 at 05:38:37PM +0100, Peter Zijlstra wrote: > On Thu, Feb 06, 2014 at 11:37:37AM +0100, Torsten Duwe wrote: > > x86 has them, MIPS has them, ARM has them, even ia64 has them: > > ticket locks. They reduce memory bus and cache pressure especially > > fo

Re: [PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-07 Thread Torsten Duwe
On Thu, Feb 06, 2014 at 07:08:26PM +0100, Peter Zijlstra wrote: > On Thu, Feb 06, 2014 at 06:37:27PM +0100, Torsten Duwe wrote: > > I must admit that I haven't tested the patch on non-pseries ppc64 nor on > > ppc32. Only ppc64 has the ldarx and I tried to atomically replace t

Re: [PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-07 Thread Torsten Duwe
On Thu, Feb 06, 2014 at 02:19:52PM -0600, Scott Wood wrote: > On Thu, 2014-02-06 at 18:37 +0100, Torsten Duwe wrote: > > On Thu, Feb 06, 2014 at 05:38:37PM +0100, Peter Zijlstra wrote: > > > > Can you pair lwarx with sthcx ? I couldn't immediately find the answer > &

Re: [PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-07 Thread Torsten Duwe
On Fri, Feb 07, 2014 at 11:45:30AM +0100, Peter Zijlstra wrote: > > That might need to be lhz too, I'm confused on all the load variants. ;-) > > unlock: > > lhz %0, 0, &tail > > addic %0, %0, 1 No carry with this one, I'd say. Besides, unlock increments the head. > > lwsync

[PATCH v2] powerpc ticket locks

2014-02-07 Thread Torsten Duwe
Ticket locks for ppc, version 2. Changes since v1: * The atomically exchanged entity is always 32 bits. * asm inline string variations thus removed. * Carry the additional holder hint only #if defined(CONFIG_PPC_SPLPAR) Signed-off-by: Torsten Duwe -- arch/powerpc/include/asm/spinlock_types.h

Re: [PATCH] Convert powerpc simple spinlocks into ticket locks

2014-02-07 Thread Torsten Duwe
On Fri, Feb 07, 2014 at 04:18:47PM +0100, Peter Zijlstra wrote: > On Fri, Feb 07, 2014 at 01:28:37PM +0100, Peter Zijlstra wrote: > > Anyway, you can do a version with lwarx/stwcx if you're looking get rid > > of lharx. > > the below seems to compile into relatively ok asm. It can be done better >

Re: [PATCH v2] powerpc ticket locks

2014-02-07 Thread Torsten Duwe
On Fri, Feb 07, 2014 at 06:12:24PM +0100, Peter Zijlstra wrote: > On Fri, Feb 07, 2014 at 05:58:01PM +0100, Torsten Duwe wrote: > > +static __always_inline void arch_spin_lock(arch_spinlock_t *lock) > > { > > + register struct __raw_tickets old, tmp, > >

Re: [PATCH v2] powerpc ticket locks

2014-02-10 Thread Torsten Duwe
On Mon, Feb 10, 2014 at 02:10:23PM +1100, Benjamin Herrenschmidt wrote: > On Fri, 2014-02-07 at 17:58 +0100, Torsten Duwe wrote: > > typedef struct { > > - volatile unsigned int slock; > > -} arch_spinlock_t; > > + union { > > +

Re: [PATCH v2] powerpc ticket locks

2014-02-11 Thread Torsten Duwe
On Tue, Feb 11, 2014 at 03:23:51PM +0530, Raghavendra KT wrote: > How much important to have holder information for PPC? From my > previous experiment > on x86, it was lock-waiter preemption which is problematic rather than > lock-holder preemption. It's something very special to IBM pSeries: the

Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR

2015-03-12 Thread Torsten Duwe
On Thu, Mar 12, 2015 at 10:13:27PM +1100, Benjamin Herrenschmidt wrote: > On Thu, 2015-03-12 at 18:55 +0800, Kevin Hao wrote: > > I know Torsten Duwe has tried to add the ticket spinlock for powerpc > > one year ago [1]. But it make no progress due to the conflict between

[PATCH v0 0/4] ppc64le: dynamic ftrace and kgraft support

2015-03-19 Thread Torsten Duwe
Here's an initial version of dynamic ftrace for ABIv2 (ppc64le), the code maturity is somewhere between proof of concept and pre-alpha. I have split it into 4 parts, for ftrace and kgraft, a configuration enablement and the actual code, respectively. Please have a look and tell me whether this is t

Re: [PATCH v0 1/4] ppc64le: dynamic ftrace

2015-03-19 Thread Torsten Duwe
I'm pretty sure not everything is ifdef'd properly, and the FIXME needs to be solved in order to disable ftracing again. Built upon some original code by Vojtech Pavlik. diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index e366187..a69d47e 100644 --- a/arch/pow

[PATCH v0 2/4] ppc64le: dynamic ftrace configuration options

2015-03-19 Thread Torsten Duwe
Switch on -mprofile-kernel, and remove it again from directories involved in exception handling. This needs to be done more fine grained, of course. diff --git a/Makefile b/Makefile index 1a60bdd..72644e6 100644 --- a/Makefile +++ b/Makefile @@ -732,7 +732,10 @@ ifdef CONFIG_FUNCTION_TRACER ifdef

[PATCH v0 3/4] ppc64le: kgraft support

2015-03-19 Thread Torsten Duwe
The kgraft hooks for ppc64. Just massaged a bit to get them to compile and not interfere. Feel free to test them if you're daring ;) diff --git a/arch/powerpc/include/asm/kgraft.h b/arch/powerpc/include/asm/kgraft.h new file mode 100644 index 000..7f8600d --- /dev/null +++ b/arch/powerpc/incl

[PATCH v0 4/4] ppc64le: kgraft config options

2015-03-19 Thread Torsten Duwe
Enable kgraft on ppc, fairly trivial. diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 4bc7b62..d82d7c8 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -102,6 +104,7 @@ config PPC select HAVE_IOREMAP_PROT select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_

Re: [PATCH v8 8/8] livepatch: Detect offset for the ftrace location during build

2016-02-16 Thread Torsten Duwe
On Tue, Feb 16, 2016 at 11:17:02AM +0530, Kamalesh Babulal wrote: > * Petr Mladek [2016-02-12 17:45:17]: > > int test(int a) > > { > > + printk("%d\n", a); > > return ++a; > > } > > Thanks. This workaround, helped to load sample livepatch module. N.b.: if you try to livepatch/trace such

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-16 Thread Torsten Duwe
On Tue, Feb 16, 2016 at 09:09:16PM +1100, Michael Ellerman wrote: > On Mon, 2016-02-15 at 15:04 +0100, Torsten Duwe wrote: > > If you use "-pg -mprofile-kernel", gcc seems to forget that, and omits the > > TOC > > load, for a similar assembler calling sequence.

Re: [PATCH v8 8/8] livepatch: Detect offset for the ftrace location during build

2016-02-16 Thread Torsten Duwe
On Tue, Feb 16, 2016 at 04:00:30PM +0530, Kamalesh Babulal wrote: > * Torsten Duwe [2016-02-16 09:23:02]: > > > > N.b.: if you try to livepatch/trace such a leaf function without > > global dependencies, it will crash if that function got called with > > a different

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

2016-02-17 Thread Torsten Duwe
On Wed, Feb 17, 2016 at 09:55:40PM +1100, Michael Ellerman wrote: > On Wed, 2016-02-10 at 17:21 +0100, Torsten Duwe wrote: > > > --- a/arch/powerpc/kernel/module_64.c > > +++ b/arch/powerpc/kernel/module_64.c > > @@ -476,17 +474,44 @@ static unsigned long stub_for_addr(

Re: [PATCH v8 8/8] livepatch: Detect offset for the ftrace location during build

2016-02-23 Thread Torsten Duwe
On Wed, Feb 17, 2016 at 02:08:41PM +1100, Michael Ellerman wrote: > > That stub uses r2 to find the location of itself, but it only works if r2 > holds > the TOC for scsi_mod.ko. In this case r2 still contains ibmvscsi.ko's TOC. Here's my solution, a bit rough still. This replaces the module_64.

Re: [PATCH v8 8/8] livepatch: Detect offset for the ftrace location during build

2016-02-24 Thread Torsten Duwe
On Wed, Feb 24, 2016 at 05:55:35PM +1100, Balbir Singh wrote: > > > We need to remove the SQUASH_TOC_SAVE_INSNS bits as well, now that the > ppc64_profile_stub_insns does not save r2 Sure -- this was meant to _replace_ the changes from patch 2/8, not on top. And yes, it exposes duplicate defini

Re: [PATCH 01/12] powerpc/module: Only try to generate the ftrace_caller() stub once

2016-02-25 Thread Torsten Duwe
ce_caller() stub once, > from module_finalize(). An additional benefit is we can clean the ifdefs > up a little. > > Finally we must propagate the const'ness of some of the pointers passed > to module_finalize(), but that is also an improvement. > >

Re: [PATCH 02/12] powerpc/module: Mark module stubs with a magic value

2016-02-25 Thread Torsten Duwe
practice. The actual magic value is sort of debatable; it should be "improbable" enough. But this can be changed easily, for each kernel compile, even. > Signed-off-by: Michael Ellerman Reviewed-by: Torsten Duwe [for reference:] > > +#define STUB_MAGIC 0x737475

Re: [PATCH 03/12] powerpc/module: Create a special stub for ftrace_caller()

2016-02-25 Thread Torsten Duwe
at runtime each time? It's a bit tricky to get the +- 0x8000 right OTOH... I wrote: extern unsigned long __toc_start; reladdr = addr - ((unsigned long)(&__toc_start) + 0x8000UL); looks a bit odd, but evaluates to a constant for ftrace_caller. Either way is fine with me: Signed-o

Re: [PATCH 04/12] powerpc/ftrace: Prepare for -mprofile-kernel

2016-02-25 Thread Torsten Duwe
) return 1; return 0; leaves less freedom for the compiler to "optimise". Signed-off-by: Torsten Duwe Torsten ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 05/12] powerpc/ftrace: ftrace_graph_caller() needs to save/restore toc

2016-02-25 Thread Torsten Duwe
estore callee's TOC */ > > + ld r2, 24(r1) > > + > > addir1, r1, 112 > > mflrr0 > > std r0, LRSAVE(r1) > > Reviewed-by: Balbir Singh Reviewed-by: Torsten Duwe Torsten ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 06/12] powerpc/module: Rework is_early_mcount_callsite()

2016-02-25 Thread Torsten Duwe
o this anymore? > > Yes. Otherwise the code in apply_relocate_add() will see a far call with no > nop > slot after it to do the toc restore, and it considers that a bug (which it > usually is, except mcount is special). > > As we discussed to

Re: [PATCH 08/12] powerpc/ftrace: Rework ftrace_caller()

2016-02-25 Thread Torsten Duwe
the SPR loads to hopefully speed them up a bit. > Also comment the asm much more, to hopefully make it clearer. > > Signed-off-by: Michael Ellerman Reviewed-by: Torsten Duwe Torsten ___ Linuxppc-dev mailing list Linuxppc-dev@lists.oz

Re: [PATCH 10/12] powerpc/ftrace: FTRACE_WITH_REGS configuration variables

2016-02-25 Thread Torsten Duwe
a bug when I wrote this test, Michael insisted it was a feature :-) > > +/bin/echo -e "#include \nnotrace int func() { return 0; > > }" | \ > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ > > +grep -q "mcount" > > + > > +notrace_r

Re: [PATCH 07/12] powerpc/ftrace: FTRACE_WITH_REGS implementation for ppc64le

2016-02-25 Thread Torsten Duwe
On Thu, Feb 25, 2016 at 11:48:59AM +1100, Balbir Singh wrote: > > @@ -608,6 +621,9 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, > > return -ENOENT; > > if (!restore_r2((u32 *)location + 1, me)) > >

Re: [PATCH v2 1/8] powerpc: Create a helper for getting the kernel toc value

2016-03-01 Thread Torsten Duwe
On Mon, Feb 29, 2016 at 08:26:22PM +1100, Michael Ellerman wrote: > Move the logic to work out the kernel toc pointer into a header. This is > a good cleanup, and also means we can use it elsewhere in future. Yes, looks better, very nice. > Signed-off-by: Michael Ellerman Reviewed-by

Re: [PATCH v2 2/8] powerpc/module: Only try to generate the ftrace_caller() stub once

2016-03-01 Thread Torsten Duwe
On Mon, Feb 29, 2016 at 08:26:23PM +1100, Michael Ellerman wrote: [...] > diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c > index 2c01665eb410..dd095496d225 100644 > --- a/arch/powerpc/kernel/module_32.c > +++ b/arch/powerpc/kernel/module_32.c > @@ -294,11 +294,19 @@

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc

2016-03-04 Thread Torsten Duwe
On Thu, Mar 03, 2016 at 05:52:01PM +0100, Petr Mladek wrote: [...] > index ec7f8aada697..2d5333c228f1 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -1265,6 +1271,31 @@ ftrace_call: > ld r0, LRSAVE(r1) > mtlrr0 > > +#ifdef CONFIG_LIV

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc

2016-03-04 Thread Torsten Duwe
On Fri, Mar 04, 2016 at 02:01:37PM +0100, Petr Mladek wrote: > > Do I understand it correctly that we could not patch functions that > pass arguments on the stack with this implementation? If yes, how hard > would be to get it working, please? At least, it would be great to > catch this problem an

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc

2016-03-04 Thread Torsten Duwe
On Fri, Mar 04, 2016 at 07:16:57PM +0100, Torsten Duwe wrote: > On Fri, Mar 04, 2016 at 02:01:37PM +0100, Petr Mladek wrote: > > > > Do I understand it correctly that we could not patch functions that > > pass arguments on the stack with this implementation? If yes, how har

Re: [v5][PATCH] livepatch/ppc: Enable livepatching on powerpc

2016-03-08 Thread Torsten Duwe
std r0, LRSAVE(r1) /* save the real return address */ > + mtlrr0 > + blr > +#endif NAKed-by: Torsten Duwe Torsten ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc

2016-03-08 Thread Torsten Duwe
On Fri, Mar 04, 2016 at 08:22:22PM +0100, Torsten Duwe wrote: > On Fri, Mar 04, 2016 at 07:16:57PM +0100, Torsten Duwe wrote: > > On Fri, Mar 04, 2016 at 02:01:37PM +0100, Petr Mladek wrote: > > > > > > Do I understand it correctly that we could not patch functions t

Re: [v5][PATCH] livepatch/ppc: Enable livepatching on powerpc

2016-03-08 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 12:52:03AM +1100, Balbir Singh wrote: > > On 08/03/16 21:45, Torsten Duwe wrote: > > To be fair, my last mail still was not 100% correct, but the conclusion Wrote a correction to the correction. It should be clear now. Please nag me if it isn't clear why

Re: [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc

2016-03-09 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 05:59:40PM +1100, Balbir Singh wrote: > > The previous revision was nacked by Torsten, but compared to the alternatives I nacked it because I was confident it couldn't work. Same goes for this one, sorry. My good intention was to save us all some work. > @@ -1265,6 +1271,

Re: [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc

2016-03-09 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 10:44:23AM +0100, Petr Mladek wrote: > find a solution that would work transparently. I mean that adding > an extra hacks into selected functions in the patch might be quite > error prone and problems hard to debug. I think that we all want this > but I wanted to be sure :-)

Re: [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc

2016-03-09 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 11:13:05AM +0100, Jiri Kosina wrote: > On Wed, 9 Mar 2016, Torsten Duwe wrote: > > was my first choice. Arguments on the stack? I thought we'll deal with them > > once we get there (e.g. _really_ need to patch a varargs function or one > > with a s

Re: [v5][PATCH] livepatch/ppc: Enable livepatching on powerpc

2016-03-09 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 05:10:25PM +0100, Petr Mladek wrote: > On Tue 2016-03-08 16:34:35, Torsten Duwe wrote: > > /* compile using "-ffixed-r14"! */ > > register unsigned long pass_TOC asm("r14"); > > BTW: Is this reentrant, please? I mean, is it poss

[PATCH 1/2] ppc64le live patch: clear out storage location(s) in mini stack frame

2016-03-09 Thread Torsten Duwe
ller will restore its TOC anyway from the ABI compliant location 24(r1) right after return. Signed-off-by: Torsten Duwe --- This is only the preparation for dumping the mini stack frame. It shouldn't break anything, bisecting-wise. --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/k

[PATCH 2/2] ppc64le live patch: get rid of mini stack frame

2016-03-09 Thread Torsten Duwe
r0, LRSAVE(r0) /* get the real return address */ add r2, r2, r0 /* Add the current LR to offset */ Signed-off-by: Torsten Duwe --- This is solution 1 now. Do we really want that? I don't think so; this is merely to illustrate what the alternative to klp_return_helper and

Re: [PATCH 2/2] ppc64le live patch: get rid of mini stack frame

2016-03-10 Thread Torsten Duwe
On Thu, Mar 10, 2016 at 01:51:16PM +0100, Petr Mladek wrote: > On Thu 2016-03-10 13:25:08, Petr Mladek wrote: > > On Wed 2016-03-09 18:30:17, Torsten Duwe wrote: > > > After the mini stack frame is no longer required for TOC storage, it can > > > be eliminat

Re: [v3,1/8] powerpc: Create a helper for getting the kernel toc value

2016-03-19 Thread Torsten Duwe
On Thu, Mar 17, 2016 at 10:58:42AM +1100, Balbir Singh wrote: > > To be honest I think my v6 works well, but I don't have complete confidence > due to the lack of proper testing. livepatch samples plus some others I wrote > and I one Petr wrote all work (calling patched from within patched), I ha

Re: [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc

2016-03-19 Thread Torsten Duwe
On Wed, Mar 09, 2016 at 05:59:40PM +1100, Balbir Singh wrote: > > Changelog v6: > 1. Experimental changes -- need loads of testing > Based on the assumption that very far TOC and LR values > indicate the call happened through a stub and the > stub return works diff

Re: [v3,1/8] powerpc: Create a helper for getting the kernel toc value

2016-03-19 Thread Torsten Duwe
On Wed, Mar 16, 2016 at 09:23:19PM +1100, Michael Ellerman wrote: > > Sure. I'll try and get something working, though this merge window is not > starting well so I may not get time for a few weeks :) Do you already have something in mind? Can you give us a hint? Torsten

[PATCH/RFC] ppc64 livepatch: frameless klp_return_helper using odd TOC

2016-03-23 Thread Torsten Duwe
ll need to be compiled using the -fno-optimize-sibling-calls compiler flag! Thanks go to Michael Matz and Richard Biener for reassurance about heuristics and pointers to the compiler flag. Signed-off-by: Torsten Duwe diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_

Re: [PATCH/RFC] ppc64 livepatch: frameless klp_return_helper using odd TOC

2016-03-24 Thread Torsten Duwe
On Thu, Mar 24, 2016 at 01:23:01PM +1100, Balbir Singh wrote: > On 24/03/16 02:58, Torsten Duwe wrote: > > > > 1. Heuristics are bad. The better they are, the more subtly the > >way they might fail. [...] > I missed this yesterday, not on cc, but caught it on the

Re: [PATCH/RFC] ppc64 livepatch: frameless klp_return_helper using odd TOC

2016-03-24 Thread Torsten Duwe
On Thu, Mar 24, 2016 at 03:44:55PM +0530, Kamalesh Babulal wrote: > * Torsten Duwe [2016-03-23 16:58:58]: > > > > > Since nobody liked the extra stack frame nor its workarounds, here is > > the next attempt. Assumptions: > > > > 1. Heuristics are bad. The

Re: [PATCH 6/6] powerpc/livepatch: Add live patching support on ppc64le

2016-03-24 Thread Torsten Duwe
loc that area and realloc in klp_arch_set_pc when it's full? Maybe along with a warning message? That way a live patched kernel will not run into stack size problems any earlier than an unpatched kernel would. Just a thought. Anyway, patch 5+6 Reviewed-by: Torsten Duwe Torsten ___

Re: [PATCH 0/5] Live patching for powerpc

2016-04-14 Thread Torsten Duwe
On Thu, Apr 14, 2016 at 04:49:50PM +1000, Michael Ellerman wrote: > On Wed, 2016-04-13 at 15:22 +0200, Jiri Kosina wrote: > > On Wed, 13 Apr 2016, Miroslav Benes wrote: > > > > This series adds live patching support for powerpc (ppc64le only ATM). > > > > > > > > It's unchanged since the version I

Re: [PATCH 0/5] Live patching for powerpc

2016-04-14 Thread Torsten Duwe
On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote: > On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote: > > > FTR: then I still have a few ppc64 hunks floating around to support certain > > consistency > > models... > > OK. I'm not quite s

-mprofile-kernel vs. notrace in ppc64(le) Linux kernels

2015-09-26 Thread Torsten Duwe
As I mentioned earlier this year, it's a bad idea to call _mcount from MMU helper functions (e.g. hash_page...), when the profiling/tracing/ live-patching/whatever framewok might in turn cause another such fault. Jikos suggested to use fine-grained control of these functions with the "notrace" keyw

Re: -mprofile-kernel vs. notrace in ppc64(le) Linux kernels

2015-09-27 Thread Torsten Duwe
On Sun, Sep 27, 2015 at 09:03:48AM +1000, Anton Blanchard wrote: > > On Sat, Sep 26, 2015 at 04:30:08PM +0200, Torsten Duwe wrote: > > > kernel. It is mapped to GCC's (4.8, FWIW) > > > __attribute__((no_instrument_function)), which, to my surprise, > > > wor

[PATCH v3 0/8] ftrace with regs + live patching for ppc64 LE (ABI v2)

2015-10-26 Thread Torsten Duwe
very useful during development; as mentioned earlier, many of these functions may get called during a recoverable fault. The whole recursion will probably terminate if all goes well, but I'd rather be defensive here. Torsten Duwe (8): ppc64le FTRACE_WITH_REGS implementation ppc use ftrace_modif

[PATCH v3 1/8] ppc64le FTRACE_WITH_REGS implementation

2015-10-26 Thread Torsten Duwe
recognise the modified trampoline. Signed-off-by: Torsten Duwe --- arch/powerpc/include/asm/ftrace.h | 5 ++ arch/powerpc/kernel/entry_64.S| 113 +- arch/powerpc/kernel/ftrace.c | 72 +--- arch/powerpc/kernel/module_64.c

[PATCH v3 2/8] ppc use ftrace_modify_all_code default

2015-10-26 Thread Torsten Duwe
ff-by: Torsten Duwe --- arch/powerpc/kernel/ftrace.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index 310137f..e419c7b 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftr

Re: [PATCH v3 0/8] ftrace with regs + live patching for ppc64 LE (ABI v2)

2015-10-26 Thread Torsten Duwe
* Makefile: - globally use -mprofile-kernel in case it's configured. * arch/powerpc/Kconfig / kernel/trace/Kconfig: - declare that ppc64 HAVE_MPROFILE_KERNEL and HAVE_DYNAMIC_FTRACE_WITH_REGS, and use it. Signed-off-by: Torsten Duwe --- arch/powerpc/Kconfig | 2 ++

[PATCH v3 4/8] ppc64 ftrace_with_regs: spare early boot and low level

2015-10-26 Thread Torsten Duwe
level and boot code objects' CFLAGS for FUNCTION_TRACER configurations. Signed-off-by: Torsten Duwe --- arch/powerpc/kernel/Makefile | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index ba

[PATCH v3 5/8] ppc64 ftrace: disable profiling for some functions

2015-10-26 Thread Torsten Duwe
At least POWER7/8 have MMUs that don't completely autoload; a normal, recoverable memory fault might pass through these functions. If a dynamic tracer function causes such a fault, any of these functions being traced with -mprofile-kernel may cause an endless recursion. Signed-off-by: To

[PATCH v3 6/8] ppc64 ftrace: disable profiling for some files

2015-10-26 Thread Torsten Duwe
This adds -mprofile-kernel to the cc flags to be stripped from the command line for code-patching.o and feature-fixups.o, in addition to "-pg" Signed-off-by: Torsten Duwe --- arch/powerpc/lib/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/p

[PATCH v3 7/8] Implement kernel live patching for ppc64le (ABIv2)

2015-10-26 Thread Torsten Duwe
fixup in arch/powerpc/kernel/entry_64.S for local calls that are becoming global due to live patching. And of course do the main KLP thing: return to a maybe different address, possibly altered by the live patching ftrace op. Signed-off-by: Torsten Duwe --- arch/powerpc/include/asm

[PATCH v3 8/8] Enable LIVEPATCH to be configured on ppc64le and add livepatch.o if it is selected.

2015-10-26 Thread Torsten Duwe
Signed-off-by: Torsten Duwe --- arch/powerpc/Kconfig | 5 + arch/powerpc/kernel/Makefile | 1 + 2 files changed, 6 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0e6011c..341ebe9 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -163,6

[PATCH v3 3/8] ppc64 ftrace_with_regs configuration variables

2015-10-26 Thread Torsten Duwe
* Makefile: - globally use -mprofile-kernel in case it's configured. * arch/powerpc/Kconfig / kernel/trace/Kconfig: - declare that ppc64 HAVE_MPROFILE_KERNEL and HAVE_DYNAMIC_FTRACE_WITH_REGS, and use it. Signed-off-by: Torsten Duwe --- arch/powerpc/Kconfig | 2 ++

[PATCH v3 1/8] ppc64le FTRACE_WITH_REGS implementation

2015-10-26 Thread Torsten Duwe
recognise the modified trampoline. Signed-off-by: Torsten Duwe --- arch/powerpc/include/asm/ftrace.h | 5 ++ arch/powerpc/kernel/entry_64.S| 113 +- arch/powerpc/kernel/ftrace.c | 72 +--- arch/powerpc/kernel/module_64.c

Re: [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change

2015-11-25 Thread Torsten Duwe
On Tue, Sep 15, 2015 at 03:48:34PM +1000, Ian Munsie wrote: > --- a/drivers/misc/cxl/Makefile > +++ b/drivers/misc/cxl/Makefile > @@ -1,4 +1,4 @@ > -ccflags-y := -Werror > +ccflags-y := -Werror -Wno-unused-const-variable JFYI, my gcc-4.3 does not like this switch. What's the minimum compiler versi

  1   2   3   >