From: Atish Patra <atishp@rivosinc.com>
To: Alexandre Ghiti <alexghiti@rivosinc.com>,
Atish Patra <atishp@atishpatra.org>,
Anup Patel <anup@brainfault.org>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
linux-riscv@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Andrea Parri <parri.andrea@gmail.com>, Nam Cao <namcao@linutronix.de>
Subject: Re: [PATCH -fixes v2] drivers: perf: Fix smp_processor_id() use in preemptible code
Date: Fri, 30 Aug 2024 09:39:52 -0700 [thread overview]
Message-ID: <6d20b21d-7e88-4072-b33d-dbb45d2f0965@rivosinc.com> (raw)
In-Reply-To: <20240829090034.15777-1-alexghiti@rivosinc.com>
On 8/29/24 2:00 AM, Alexandre Ghiti wrote:
> As reported in [1], the use of smp_processor_id() in
> pmu_sbi_device_probe() must be protected by disabling the preemption, so
> simply use get_cpu()/put_cpu() instead.
>
> Reported-by: Andrea Parri <parri.andrea@gmail.com>
> Reported-by: Nam Cao <namcao@linutronix.de>
> Closes: https://lore.kernel.org/linux-riscv/20240820074925.ReMKUPP3@linutronix.de/ [1]
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
>
> Changes in v2:
> - Do not disable the preemption in static_key_enable() (Will)
>
> drivers/perf/riscv_pmu_sbi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index 31a17a56eb3b..febd8e74a72f 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -1373,11 +1373,16 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
>
> /* SBI PMU Snapsphot is only available in SBI v2.0 */
> if (sbi_v2_available) {
> + int cpu;
> +
> ret = pmu_sbi_snapshot_alloc(pmu);
> if (ret)
> goto out_unregister;
>
> - ret = pmu_sbi_snapshot_setup(pmu, smp_processor_id());
> + cpu = get_cpu();
> + ret = pmu_sbi_snapshot_setup(pmu, cpu);
> + put_cpu();
> +
> if (ret) {
> /* Snapshot is an optional feature. Continue if not available */
> pmu_sbi_snapshot_free(pmu);
Reviewed-by: Atish Patra <atishp@rivosinc.com>
next prev parent reply other threads:[~2024-08-30 16:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 9:00 Alexandre Ghiti
2024-08-30 16:39 ` Atish Patra [this message]
2024-09-05 21:55 ` Nam Cao
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=6d20b21d-7e88-4072-b33d-dbb45d2f0965@rivosinc.com \
--to=atishp@rivosinc.com \
--cc=alexghiti@rivosinc.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=namcao@linutronix.de \
--cc=palmer@dabbelt.com \
--cc=parri.andrea@gmail.com \
--cc=paul.walmsley@sifive.com \
--cc=will@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®