mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: "Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James Clark" <james.clark@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jan H. Schönherr" <jschoenh@amazon.de>
Subject: Re: [PATCH] perf/core: Speed up kexec shutdown by avoiding unnecessary cross CPU calls
Date: Thu, 8 Jan 2026 11:32:14 +0100	[thread overview]
Message-ID: <20260108103214.GG272712@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <0d0b7fe70e6dfa7979cb83b05317deb21187f74d.camel@infradead.org>

On Thu, Jan 08, 2026 at 11:14:24AM +0100, David Woodhouse wrote:
> From: Jan H. Schönherr <jschoenh@amazon.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@amazon.de>
> Signed-off-by: David Woodhouse <dwmw@amazon.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
> 
> 



  reply	other threads:[~2026-01-08 10:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 10:14 David Woodhouse
2026-01-08 10:32 ` Peter Zijlstra [this message]
2026-01-13 10:50 ` [tip: perf/core] " tip-bot2 for Jan H. Sch=C3=B6nherr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260108103214.GG272712@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=jschoenh@amazon.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®