[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260108103214.GG272712@noisy.programming.kicks-ass.net>
Date: Thu, 8 Jan 2026 11:32:14 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
James Clark <james.clark@...aro.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
Jan H. Schönherr <jschoenh@...zon.de>
Subject: Re: [PATCH] perf/core: Speed up kexec shutdown by avoiding
unnecessary cross CPU calls
On Thu, Jan 08, 2026 at 11:14:24AM +0100, David Woodhouse wrote:
> From: Jan H. Schönherr <jschoenh@...zon.de>
>
> 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@...zon.de>
> Signed-off-by: David Woodhouse <dwmw@...zon.co.uk>
> ---
Fair enough I suppose. Let me go queue this.
> kernel/events/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 413b88a4e00f..e36372b3c83f 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -14712,7 +14712,8 @@ static void perf_event_exit_cpu_context(int cpu)
> ctx = &cpuctx->ctx;
>
> mutex_lock(&ctx->mutex);
> - smp_call_function_single(cpu, __perf_event_exit_context, ctx, 1);
> + if (ctx->nr_events)
> + smp_call_function_single(cpu, __perf_event_exit_context, ctx, 1);
> cpuctx->online = 0;
> mutex_unlock(&ctx->mutex);
> mutex_unlock(&pmus_lock);
> --
> 2.43.0
>
>
Powered by blists - more mailing lists