From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Mukesh Kumar Chaurasiya <mkchauras@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
linux-kernel@vger.kernel.org, chleroy@kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
stable@vger.kernel.org
Subject: Re: [PATCHv3 4/4] powerpc/kvm-hv-pmu: Free hostwide stats buffers if perf_pmu_register() fails
Date: Wed, 25 Nov 2026 15:18:30 +0530 [thread overview]
Message-ID: <pkvtjl75.ritesh.list@gmail.com> (raw)
In-Reply-To: <awZ4ZhK1GFHKi9Tr@li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com>
Mukesh Kumar Chaurasiya <mkchauras@gmail.com> writes:
> On Mon, Nov 23, 2026 at 07:21:53PM +0530, Ritesh Harjani (IBM) wrote:
>> kvmppc_register_pmu() calls kvmppc_init_hostwide(), which allocates
>> gsm_l0_stats and gsb_l0_stats. It then registers the pmu. If
>> perf_pmu_register() fails we return without freeing them.
>>
>> Call kvmppc_cleanup_hostwide() on that error path.
>>
>> Fixes: f0c9c49c5067 ("powerpc/kvm-hv-pmu: Implement GSB message-ops for hostwide counters")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> ---
>> arch/powerpc/perf/kvm-hv-pmu.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/perf/kvm-hv-pmu.c b/arch/powerpc/perf/kvm-hv-pmu.c
>> index a58634f656e9..ec05b4855736 100644
>> --- a/arch/powerpc/perf/kvm-hv-pmu.c
>> +++ b/arch/powerpc/perf/kvm-hv-pmu.c
>> @@ -402,8 +402,10 @@ static int __init kvmppc_register_pmu(void)
>>
>> /* Register the pmu */
>> rc = perf_pmu_register(&kvmppc_pmu, kvmppc_pmu.name, -1);
>> - if (rc)
>> + if (rc) {
>> + kvmppc_cleanup_hostwide();
> Just a question.
> Inside this function, should we also take lock just to set the pointers
> NULL rather than putting the whole logic(free also) inside the lock like
> we did in previous patch?
>
In the previous patch, we brought GFP_KERNEL (sleepable) allocation
outside of atomic context. However, in here, there is no harm in keeping
the lock to assign the null values to pointers. But I guess what you are
suggesting is - Do we need to keep the lock around in the cleanup? Looks
like no, we don't, since if the perf pmu register failed then we won't
get a perf pmu update event for this - which is the only other user of
this lock which can race.
However, this patch is mostly an error handling fix (reported as a bug
by Sashiko). One can pickup the cleanup of that path as a separate
patch. There is also a powerpc wide clang's context analysis work that
is going on, so as part of that - we could maybe optimize away taking of
the lock in kvmppc_cleanup_hostwide() as well. As for this patch series,
I think let's go with this, as most of the patches in the series are
with Fixes tag to be backported.
> Apart from this, all looks good.
>
> Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Thanks for the review!
prev parent reply other threads:[~2026-11-25 9:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1795441238.git.ritesh.list@gmail.com>
2026-11-23 13:51 ` [PATCHv3 1/4] powerpc/64: Leave lockdep hardirq context around replayed interrupts Ritesh Harjani (IBM)
2026-11-25 5:19 ` Mukesh Kumar Chaurasiya
2026-11-23 13:51 ` [PATCHv3 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog() Ritesh Harjani (IBM)
2026-11-25 5:50 ` Mukesh Kumar Chaurasiya
2026-11-23 13:51 ` [PATCHv3 3/4] powerpc/kvm-hv-pmu: Don't allocate gsm/gsb GFP_KERNEL allocations under spinlock Ritesh Harjani (IBM)
2026-11-25 5:53 ` Mukesh Kumar Chaurasiya
2026-11-23 13:51 ` [PATCHv3 4/4] powerpc/kvm-hv-pmu: Free hostwide stats buffers if perf_pmu_register() fails Ritesh Harjani (IBM)
2026-11-25 5:58 ` Mukesh Kumar Chaurasiya
2026-11-25 9:48 ` Ritesh Harjani [this message]
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=pkvtjl75.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mkchauras@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=sshegde@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=venkat88@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