From: Aboorva Devarajan <aboorvad@linux.ibm.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Christophe Leroy <chleroy@kernel.org>,
linux-kernel@vger.kernel.org,
Sourabh Jain <sourabhjain@linux.ibm.com>,
Ritesh Harjani <ritesh.list@gmail.com>
Subject: Re: [PATCH 1/3] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del
Date: Wed, 03 Jun 2026 11:29:08 +0530 [thread overview]
Message-ID: <d54ba34b23e83a525ca2f3bb22af5294c4c12616.camel@linux.ibm.com> (raw)
In-Reply-To: <1e31821a-2c9d-4394-83b4-e850f96ad662@linux.ibm.com>
On Mon, 2026-05-18 at 11:43 +0530, Shrikanth Hegde wrote:
>
>
> On 5/18/26 10:38 AM, Aboorva Devarajan wrote:
> > fsl_emb_pmu_del() unconditionally calls put_cpu_var(cpu_hw_events)
> > at
> > the 'out:' label, but only calls the matching get_cpu_var() after
> > the
> > 'i < 0' early-return check. When event->hw.idx is negative the
> > function jumps to 'out:' without having taken get_cpu_var(), and
> > the
> > trailing put_cpu_var() then issues an unmatched preempt_enable(),
> > underflowing preempt_count.
> >
> > On a CONFIG_PREEMPT=y kernel preempt_count would underflow and
> > eventually present as a 'scheduling while atomic' BUG.
> >
> > Move put_cpu_var() to pair with get_cpu_var() so the percpu access
> > is
> > correctly bracketed and the 'out:' label only handles
> > perf_pmu_enable.
> >
> > Fixes: a11106544f33c ("powerpc/perf: e500 support")
> > Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
> > ---
> > arch/powerpc/perf/core-fsl-emb.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/perf/core-fsl-emb.c
> > b/arch/powerpc/perf/core-fsl-emb.c
> > index 7120ab20cbfec..02b5dd74c187a 100644
> > --- a/arch/powerpc/perf/core-fsl-emb.c
> > +++ b/arch/powerpc/perf/core-fsl-emb.c
> > @@ -366,9 +366,10 @@ static void fsl_emb_pmu_del(struct perf_event
> > *event, int flags)
> >
> > cpuhw->n_events--;
> >
> > + put_cpu_var(cpu_hw_events);
> > +
> > out:
> > perf_pmu_enable(event->pmu);
> > - put_cpu_var(cpu_hw_events);
> > }
> >
> > static void fsl_emb_pmu_start(struct perf_event *event, int
> > ef_flags)
>
> Thanks for fixing this. Looks good to me.
>
> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Hi Shrikanth,
Thanks for the review.
Regards,
Aboorva
next prev parent reply other threads:[~2026-06-03 5:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 5:08 [PATCH 0/3] powerpc: fix preempt_count imbalances in perf and kexec paths Aboorva Devarajan
2026-05-18 5:08 ` [PATCH 1/3] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del Aboorva Devarajan
2026-05-18 6:13 ` Shrikanth Hegde
2026-06-03 5:59 ` Aboorva Devarajan [this message]
2026-05-18 5:08 ` [PATCH 2/3] powerpc/powernv: fix preempt count leak in pnv_kexec_wait_secondaries_down Aboorva Devarajan
2026-05-18 7:56 ` Shrikanth Hegde
2026-06-03 6:08 ` Aboorva Devarajan
2026-05-18 5:08 ` [PATCH 3/3] powerpc/kexec: fix double get_cpu() imbalance in kexec_prepare_cpus Aboorva Devarajan
2026-05-18 6:02 ` Shrikanth Hegde
2026-06-03 6:14 ` Aboorva Devarajan
2026-06-03 6:16 ` Shrikanth Hegde
2026-05-18 8:08 ` [PATCH 0/3] powerpc: fix preempt_count imbalances in perf and kexec paths Shrikanth Hegde
2026-06-03 6:16 ` Aboorva Devarajan
-- strict thread matches above, loose matches on Subject: below --
2026-06-03 6:27 [PATCH v2 " Aboorva Devarajan
2026-06-03 6:27 ` [PATCH 1/3] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del Aboorva Devarajan
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=d54ba34b23e83a525ca2f3bb22af5294c4c12616.camel@linux.ibm.com \
--to=aboorvad@linux.ibm.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sourabhjain@linux.ibm.com \
--cc=sshegde@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox