From: Peter Zijlstra <peterz@infradead.org>
To: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Eranian Stephane <eranian@google.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Dapeng Mi <dapeng1.mi@intel.com>, Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Xudong Hao <xudong.hao@intel.com>
Subject: Re: [Patch v2] perf/x86/intel: Prevent drain_pebs() reentry
Date: Wed, 9 Sep 2026 15:03:31 +0200 [thread overview]
Message-ID: <20260909130331.GT4121339@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <d6ccff7d-df31-4308-b60b-8ec5f630415e@linux.intel.com>
On Wed, Sep 09, 2026 at 07:09:11PM +0800, Mi, Dapeng wrote:
> Hi Peter,
>
> Could you please review and queue this patch if it's good enough? This
> version addresses your comments. Thanks.
>
>
> On 8/13/2026 2:43 PM, Dapeng Mi wrote:
> > The PEBS buffer is shared by all events on a CPU, so drain_pebs() must
> > not be reentered. If so, one instance may observe stale buffer state and
> > potentially access out-of-bound memory.
> >
> > Most invocations happen in NMI context, which naturally prevents reentry.
> > However, drain_pebs() is also reachable from process context via
> > intel_pmu_drain_pebs_buffer().
> >
> > In those paths, the PMU is often already disabled, but not guaranteed.
> > For example, __intel_pmu_pebs_disable() only disables the target counter,
> > so other active counters can still raise a PMI and interrupt an in-flight
> > drain_pebs(). Here is an example,
> >
> > __perf_addr_filters_adjust()
> > perf_event_stop()
> > __perf_event_stop()
> > x86_pmu_stop() (event->pmu->stop)
> > intel_pmu_disable_event()
> > intel_pmu_pebs_disable()
> > __intel_pmu_pebs_disable()
> > intel_pmu_drain_large_pebs()
> > intel_pmu_drain_pebs_buffer()
> >
> > Introduce __intel_pmu_quiesce() and __intel_pmu_resume() helpers and
> > use them in intel_pmu_drain_large_pebs() to disable the full PMU
> > around the intel_pmu_drain_pebs_buffer() call, preventing reentry.
> >
> > Also add a warning in intel_pmu_drain_pebs_buffer() when the full PMU is
> > not disabled.
> >
> > Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Ah yes. Can you get me a Fixes tag to go with this?
next prev parent reply other threads:[~2026-09-09 13:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 6:43 [Patch v2] perf/x86/intel: Prevent drain_pebs() reentry Dapeng Mi
2026-08-13 7:06 ` sashiko-bot
2026-08-17 19:28 ` Ian Rogers
2026-08-18 1:35 ` Mi, Dapeng
2026-09-09 11:09 ` Mi, Dapeng
2026-09-09 13:03 ` Peter Zijlstra [this message]
2026-09-10 0:02 ` Mi, Dapeng
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=20260909130331.GT4121339@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
--cc=zide.chen@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.