[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6d20b21d-7e88-4072-b33d-dbb45d2f0965@rivosinc.com>
Date: Fri, 30 Aug 2024 09:39:52 -0700
From: Atish Patra <atishp@...osinc.com>
To: Alexandre Ghiti <alexghiti@...osinc.com>,
Atish Patra <atishp@...shpatra.org>, Anup Patel <anup@...infault.org>,
Will Deacon <will@...nel.org>, Mark Rutland <mark.rutland@....com>,
Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt
<palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
linux-riscv@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: Andrea Parri <parri.andrea@...il.com>, Nam Cao <namcao@...utronix.de>
Subject: Re: [PATCH -fixes v2] drivers: perf: Fix smp_processor_id() use in
preemptible code
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@...il.com>
> Reported-by: Nam Cao <namcao@...utronix.de>
> Closes: https://lore.kernel.org/linux-riscv/20240820074925.ReMKUPP3@linutronix.de/ [1]
> Signed-off-by: Alexandre Ghiti <alexghiti@...osinc.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@...osinc.com>
Powered by blists - more mailing lists