Skip to content

Commit eebe644

Browse files
schnhrrPeter Zijlstra
authored andcommitted
perf/core: Speed up kexec shutdown by avoiding unnecessary cross CPU calls
There are typically a lot of PMUs registered, but in many cases only few of them have an event registered (like the "cpu" PMU in the presence of the watchdog). As the mutex is already held, it's safe to just check for existing events before doing the cross CPU call. This change saves tens of milliseconds from kexec time (perceived as steal time during a hypervisor host update), with <2ms remaining for this step in the shutdown. There might be additional potential for parallelization or we could just disable performance monitoring during the actual shutdown and be less graceful about it. Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
1 parent a491c02 commit eebe644

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

kernel/events/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15066,7 +15066,8 @@ static void perf_event_exit_cpu_context(int cpu)
1506615066
ctx = &cpuctx->ctx;
1506715067

1506815068
mutex_lock(&ctx->mutex);
15069-
smp_call_function_single(cpu, __perf_event_exit_context, ctx, 1);
15069+
if (ctx->nr_events)
15070+
smp_call_function_single(cpu, __perf_event_exit_context, ctx, 1);
1507015071
cpuctx->online = 0;
1507115072
mutex_unlock(&ctx->mutex);
1507215073
mutex_unlock(&pmus_lock);

0 commit comments

Comments
 (0)