From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Thorsten Blum <blum@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
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>,
Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/x86/core: Simplify hybrid PMU registration failure path
Date: Wed, 9 Sep 2026 09:35:44 +0800 [thread overview]
Message-ID: <de698eb3-94ba-4545-bb4f-951014c98008@linux.intel.com> (raw)
In-Reply-To: <20260904201313.271421-3-blum@kernel.org>
LGTM. Thanks.
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
On 9/5/2026 4:13 AM, Thorsten Blum wrote:
> Handle perf_pmu_register() errors directly instead of breaking out of
> the registration loop and checking the index separately. Reuse the loop
> index i to unregister any previously registered PMUs in reverse order
> and drop the extra index j.
>
> Also log the failing PMU's name and error code.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> arch/x86/events/core.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 8eb14add44c8..0a8fcfd52ad0 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -2256,7 +2256,7 @@ static int __init init_hw_perf_events(void)
> goto out2;
> } else {
> struct x86_hybrid_pmu *hybrid_pmu;
> - int i, j;
> + int i;
>
> for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
> hybrid_pmu = &x86_pmu.hybrid_pmu[i];
> @@ -2268,15 +2268,13 @@ static int __init init_hw_perf_events(void)
>
> err = perf_pmu_register(&hybrid_pmu->pmu, hybrid_pmu->name,
> (hybrid_pmu->pmu_type == hybrid_big) ? PERF_TYPE_RAW : -1);
> - if (err)
> - break;
> - }
> -
> - if (i < x86_pmu.num_hybrid_pmus) {
> - for (j = 0; j < i; j++)
> - perf_pmu_unregister(&x86_pmu.hybrid_pmu[j].pmu);
> - pr_warn("Failed to register hybrid PMUs\n");
> - goto out2;
> + if (err) {
> + while (i--)
> + perf_pmu_unregister(&x86_pmu.hybrid_pmu[i].pmu);
> + pr_warn("Failed to register hybrid PMU %s: %d\n",
> + hybrid_pmu->name, err);
> + goto out2;
> + }
> }
> }
>
prev parent reply other threads:[~2026-09-09 1:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 20:13 Thorsten Blum
2026-09-09 1:35 ` Mi, Dapeng [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=de698eb3-94ba-4545-bb4f-951014c98008@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=blum@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--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 \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@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®