Skip to content

Commit d103978

Browse files
rnavmpe
authored andcommitted
powerpc64/ftrace: Delay enabling ftrace on secondary cpus
On the boot cpu, though we enable paca->ftrace_enabled in early_setup() (via cpu_ready_for_interrupts()), we don't start tracing until much later since ftrace is not initialized yet and since we only support DYNAMIC_FTRACE on powerpc. However, it is possible that ftrace has been initialized by the time some of the secondary cpus start up. In this case, we will try to trace some of the early boot code which can cause problems. To address this, move setting paca->ftrace_enabled from cpu_ready_for_interrupts() to early_setup() for the boot cpu, and towards the end of start_secondary() for secondary cpus. Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent acd55b1 commit d103978

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

arch/powerpc/kernel/setup_64.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ static void cpu_ready_for_interrupts(void)
252252

253253
/* Set IR and DR in PACA MSR */
254254
get_paca()->kernel_msr = MSR_KERNEL;
255-
256-
/* We are now ok to enable ftrace */
257-
get_paca()->ftrace_enabled = 1;
258255
}
259256

260257
unsigned long spr_default_dscr = 0;
@@ -349,6 +346,13 @@ void __init early_setup(unsigned long dt_ptr)
349346
*/
350347
cpu_ready_for_interrupts();
351348

349+
/*
350+
* We enable ftrace here, but since we only support DYNAMIC_FTRACE, it
351+
* will only actually get enabled on the boot cpu much later once
352+
* ftrace itself has been initialized.
353+
*/
354+
this_cpu_enable_ftrace();
355+
352356
DBG(" <- early_setup()\n");
353357

354358
#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX

arch/powerpc/kernel/smp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include <asm/kexec.h>
6060
#include <asm/asm-prototypes.h>
6161
#include <asm/cpu_has_feature.h>
62+
#include <asm/ftrace.h>
6263

6364
#ifdef DEBUG
6465
#include <asm/udbg.h>
@@ -1066,6 +1067,9 @@ void start_secondary(void *unused)
10661067

10671068
local_irq_enable();
10681069

1070+
/* We can enable ftrace for secondary cpus now */
1071+
this_cpu_enable_ftrace();
1072+
10691073
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
10701074

10711075
BUG();

0 commit comments

Comments
 (0)