From: "Chen, Zide" <zide.chen@intel.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 6/6] perf/x86/intel/uncore: Implement global init callback for GNR uncore
Date: Wed, 13 May 2026 11:26:55 -0700 [thread overview]
Message-ID: <ff021ab2-19a9-4d36-b59e-d354035805c0@intel.com> (raw)
In-Reply-To: <20260513042548.E22A4C2BCB7@smtp.kernel.org>
On 5/12/2026 9:25 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The return value of `wrmsrq_on_cpu()` is ignored in `uncore_msr_global_init()`, masking hardware initialization failures caused by a CPU hotplug TOCTOU race.
> --
>
> commit d795e124f297e8f2c0cfee9efd29cdf4ec1993ce
> Author: Zide Chen <zide.chen@intel.com>
>
> perf/x86/intel/uncore: Implement global init callback for GNR uncore
>
> This commit adds a generic uncore_msr_global_init() callback for GNR, GRR,
> SRF, and CWF. It writes 0 to the global control register during boot to
> ensure the UBOX PMON units are properly initialized.
>
>> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
>> index 19056514b0812..a7780c5cd419a 100644
>> --- a/arch/x86/events/intel/uncore.c
>> +++ b/arch/x86/events/intel/uncore.c
>
> [ ... ]
>
>> @@ -1731,6 +1731,17 @@ static int uncore_mmio_global_init(u64 ctl)
>> return 0;
>> }
>>
>> +static int uncore_msr_global_init(int die, u64 msr)
>> +{
>> + int cpu = uncore_die_to_cpu(die);
>> +
>> + if (cpu == -1)
>> + return -ENODEV;
>> +
>> + wrmsrq_on_cpu(cpu, msr, 0);
>> + return 0;
>> +}
>
> uncore_die_to_cpu() acquires and releases cpus_read_lock() to find an
> online CPU, meaning the selected CPU could be hot-unplugged concurrently
> before wrmsrq_on_cpu() executes.
>
> If the CPU goes offline, the underlying smp_call_function_single() will
> fail and wrmsrq_on_cpu() will return an error.
As you pointed out in PATCH 4/6, I would move the lock out of
uncore_die_to_cpu() and rely on the caller to manage the lock, then
between uncore_die_to_cpu() and wrmsrq_on_cpu(), CPU hot-unplug cannot
occur.
> Because this function unconditionally returns 0, the caller will assume
> success and proceed to register the PMON units. As noted in the commit
> message, the units will not work unless the MSR is written, which could
> lead to a silent functional failure.
>
> Does this code need to check and propagate the return value of
> wrmsrq_on_cpu() to prevent this regression?
No, wrmsrq_on_cpu() returns 0 always.
>
prev parent reply other threads:[~2026-05-13 18:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 23:05 [PATCH 0/6] perf/x86/intel/uncore: Bug fixes and cleanups Zide Chen
2026-05-11 23:05 ` [PATCH 1/6] perf/x86/intel/uncore: Fix discovery unit lookup for multi-die systems Zide Chen
2026-05-13 1:49 ` sashiko-bot
2026-05-13 18:35 ` Chen, Zide
2026-05-11 23:05 ` [PATCH 2/6] perf/x86/intel/uncore: Fix PCI device refcount leak in UPI discovery Zide Chen
2026-05-12 9:27 ` Mi, Dapeng
2026-05-12 17:35 ` Chen, Zide
2026-05-13 0:31 ` Mi, Dapeng
2026-05-11 23:05 ` [PATCH 3/6] perf/x86/intel/uncore: Defer ADL global PMON enable to enable_box() Zide Chen
2026-05-13 2:33 ` sashiko-bot
2026-05-13 17:58 ` Chen, Zide
2026-05-11 23:05 ` [PATCH 4/6] perf/x86/intel/uncore: Move die_to_cpu() to uncore.c Zide Chen
2026-05-13 2:58 ` sashiko-bot
2026-05-13 18:11 ` Chen, Zide
2026-05-11 23:05 ` [PATCH 5/6] perf/x86/intel/uncore: Fix uncore_die_to_cpu() for offline dies Zide Chen
2026-05-11 23:05 ` [PATCH 6/6] perf/x86/intel/uncore: Implement global init callback for GNR uncore Zide Chen
2026-05-13 4:25 ` sashiko-bot
2026-05-13 18:26 ` Chen, Zide [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=ff021ab2-19a9-4d36-b59e-d354035805c0@intel.com \
--to=zide.chen@intel.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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