* [RFC] per-CPU usage in perf core-book3s
@ 2020-01-27 15:06 Sebastian Andrzej Siewior
2020-02-05 1:40 ` maddy
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2020-01-27 15:06 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Mark Rutland, Peter Zijlstra, Arnaldo Carvalho de Melo,
Alexander Shishkin, Ingo Molnar, Paul Mackerras, Namhyung Kim,
Thomas Gleixner, Jiri Olsa
I've been looking at usage of per-CPU variable cpu_hw_events in
arch/powerpc/perf/core-book3s.c.
power_pmu_enable() and power_pmu_disable() (pmu::pmu_enable() and
pmu::pmu_disable()) are accessing the variable and the callbacks are
invoked always with disabled interrupts.
power_pmu_event_init() (pmu::event_init()) is invoked from preemptible
context and uses get_cpu_var() to obtain a stable pointer (by disabling
preemption).
pmu::pmu_enable() and pmu::pmu_disable() can be invoked via a hrtimer
(perf_mux_hrtimer_handler()) and it invokes pmu::pmu_enable() and
pmu::pmu_disable() as part of the callback.
Is there anything that prevents the timer callback to interrupt
pmu::event_init() while it is accessing per-CPU data?
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] per-CPU usage in perf core-book3s
2020-01-27 15:06 [RFC] per-CPU usage in perf core-book3s Sebastian Andrzej Siewior
@ 2020-02-05 1:40 ` maddy
2020-02-05 14:11 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 3+ messages in thread
From: maddy @ 2020-02-05 1:40 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-kernel, linuxppc-dev
Cc: Mark Rutland, Peter Zijlstra, Arnaldo Carvalho de Melo,
Alexander Shishkin, Ingo Molnar, Paul Mackerras, Namhyung Kim,
Thomas Gleixner, Jiri Olsa
On 1/27/20 8:36 PM, Sebastian Andrzej Siewior wrote:
> I've been looking at usage of per-CPU variable cpu_hw_events in
> arch/powerpc/perf/core-book3s.c.
>
> power_pmu_enable() and power_pmu_disable() (pmu::pmu_enable() and
> pmu::pmu_disable()) are accessing the variable and the callbacks are
> invoked always with disabled interrupts.
>
> power_pmu_event_init() (pmu::event_init()) is invoked from preemptible
> context and uses get_cpu_var() to obtain a stable pointer (by disabling
> preemption).
>
> pmu::pmu_enable() and pmu::pmu_disable() can be invoked via a hrtimer
> (perf_mux_hrtimer_handler()) and it invokes pmu::pmu_enable() and
> pmu::pmu_disable() as part of the callback.
>
> Is there anything that prevents the timer callback to interrupt
> pmu::event_init() while it is accessing per-CPU data?
Sorry for the delayed response.
Yes, currently we dont have anything that prevents the timer
callback to interrupt pmu::event_init. Nice catch. Thanks for
pointing this out.
Looking at the code, per-cpu variable access are made to
check for constraints and for Branch Stack (BHRB). So could
wrap this block of pmu::event_init with local_irq_save/restore.
Will send a patch to fix it.
Maddy
>
> Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] per-CPU usage in perf core-book3s
2020-02-05 1:40 ` maddy
@ 2020-02-05 14:11 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2020-02-05 14:11 UTC (permalink / raw)
To: maddy
Cc: Mark Rutland, Peter Zijlstra, Jiri Olsa, linux-kernel,
Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
Paul Mackerras, Namhyung Kim, Thomas Gleixner, linuxppc-dev
On 2020-02-05 07:10:59 [+0530], maddy wrote:
> Yes, currently we dont have anything that prevents the timer
> callback to interrupt pmu::event_init. Nice catch. Thanks for
> pointing this out.
You are welcome.
> Looking at the code, per-cpu variable access are made to
> check for constraints and for Branch Stack (BHRB). So could
> wrap this block of pmu::event_init with local_irq_save/restore.
> Will send a patch to fix it.
Okay. Please keep me in the loop :)
>
> Maddy
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-05 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-27 15:06 [RFC] per-CPU usage in perf core-book3s Sebastian Andrzej Siewior
2020-02-05 1:40 ` maddy
2020-02-05 14:11 ` Sebastian Andrzej Siewior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).