Re: [PATCH v5 2/2] perf/core: Disable context fast-swap for sigtrap events
From: Peter Zijlstra
Date: Thu Nov 26 2026 - 06:01:33 EST
On Thu, Nov 26, 2026 at 09:59:59AM +0800, Tengda Wu wrote:
> >>> preempt=none
> >>
> >> That option is no longer available.
> >>
>
> Uh, I tested on linux-next, base commit: 84abb955b101 (tag: next-20261113).
> That option is still present at that commit.
d3d16750693b ("sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY")
> > --- a/include/linux/perf_event.h
> > +++ b/include/linux/perf_event.h
> > @@ -1236,6 +1236,7 @@ extern const struct perf_event_attr *per
> > extern void perf_event_print_debug(void);
> > extern void perf_pmu_disable(struct pmu *pmu);
> > extern void perf_pmu_enable(struct pmu *pmu);
> > +extern bool perf_pmu_enabled(struct pmu *pmu);
> > extern void perf_sched_cb_dec(struct pmu *pmu);
> > extern void perf_sched_cb_inc(struct pmu *pmu);
> > extern int perf_event_task_disable(void);
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -1366,6 +1366,12 @@ void perf_pmu_enable(struct pmu *pmu)
> > pmu->pmu_enable(pmu);
> > }
> >
> > +bool perf_pmu_enabled(struct pmu *pmu)
> > +{
> > + int *count = &this_cpc(pmu)->pmu_disable_count;
> > + return *count == 0;
> > +}
> > +
> > static void perf_assert_pmu_disabled(struct pmu *pmu)
> > {
> > int *count = &this_cpc(pmu)->pmu_disable_count;
> > @@ -10955,7 +10961,7 @@ static int __perf_event_overflow(struct
> > * claim the pending_work before task_work_add() recurses.
> > */
> > if (cmpxchg_local(&event->pending_work, 0, 1) == 0) {
> > - if (!task_work_add(current, &event->pending_task, notify_mode)) {
> > + if (!task_work_add(event->ctx->task, &event->pending_task, notify_mode)) {
> > event->pending_work = pending_id;
> > local_inc(&event->ctx->nr_no_switch_fast);
> > WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
> > @@ -11151,6 +11157,9 @@ static int perf_swevent_match(struct per
> > struct perf_sample_data *data,
> > struct pt_regs *regs)
> > {
> > + if (!perf_pmu_enabled(event->pmu))
> > + return 0;
> > +
> > if (event->attr.type != type)
> > return 0;
> >
> > @@ -11531,6 +11540,9 @@ static int perf_tp_event_match(struct pe
> > struct perf_raw_record *raw,
> > struct pt_regs *regs)
> > {
> > + if (!perf_pmu_enabled(event->pmu))
> > + return 0;
> > +
> > if (event->hw.state & PERF_HES_STOPPED)
> > return 0;
> > /*
>
>
> Hmm, I applied that patch to my local environment and tested it, and
> I no longer see the warning. The issue should be resolved.
>
> Tested-by: Tengda Wu <wutengda@xxxxxxxxxxxxxxx>
Excellent, thank you. Let me write up this one and land them in
perf/urgent.