Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Tell RCU about idle after hcall tracing

The PowerPC pSeries platform (CONFIG_PPC_PSERIES=y) enables
hypervisor-call tracing for CONFIG_TRACEPOINTS=y kernels. One of the
hypervisor calls that is traced is the H_CEDE call in the idle loop
that tells the hypervisor that this OS instance no longer needs the
current CPU. However, tracing uses RCU, so this combination of kernel
configuration variables needs to avoid telling RCU about the current CPU's
idleness until after the H_CEDE-entry tracing completes on the one hand,
and must tell RCU that the the current CPU is no longer idle before the
H_CEDE-exit tracing starts.

In all other cases, it suffices to inform RCU of CPU idleness upon
idle-loop entry and exit.

This commit makes the required adjustments.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>

authored by

Paul E. McKenney and committed by
Paul E. McKenney
a7b152d5 416eb33c

+18 -2
+14 -2
arch/powerpc/kernel/idle.c
··· 46 46 } 47 47 __setup("powersave=off", powersave_off); 48 48 49 + #if defined(CONFIG_PPC_PSERIES) && defined(CONFIG_TRACEPOINTS) 50 + static const bool idle_uses_rcu = 1; 51 + #else 52 + static const bool idle_uses_rcu; 53 + #endif 54 + 49 55 /* 50 56 * The body of the idle task. 51 57 */ ··· 62 56 63 57 set_thread_flag(TIF_POLLING_NRFLAG); 64 58 while (1) { 65 - tick_nohz_idle_enter_norcu(); 59 + if (idle_uses_rcu) 60 + tick_nohz_idle_enter(); 61 + else 62 + tick_nohz_idle_enter_norcu(); 66 63 while (!need_resched() && !cpu_should_die()) { 67 64 ppc64_runlatch_off(); 68 65 ··· 102 93 103 94 HMT_medium(); 104 95 ppc64_runlatch_on(); 105 - tick_nohz_idle_exit_norcu(); 96 + if (idle_uses_rcu) 97 + tick_nohz_idle_exit(); 98 + else 99 + tick_nohz_idle_exit_norcu(); 106 100 preempt_enable_no_resched(); 107 101 if (cpu_should_die()) 108 102 cpu_die();
+4
arch/powerpc/platforms/pseries/lpar.c
··· 555 555 556 556 (*depth)++; 557 557 trace_hcall_entry(opcode, args); 558 + if (opcode == H_CEDE) 559 + rcu_idle_enter(); 558 560 (*depth)--; 559 561 560 562 out: ··· 577 575 goto out; 578 576 579 577 (*depth)++; 578 + if (opcode == H_CEDE) 579 + rcu_idle_exit(); 580 580 trace_hcall_exit(opcode, retval, retbuf); 581 581 (*depth)--; 582 582