drivers: perf: Fix smp_processor_id() use in preemptible code
[ Upstream commit2840dadf0d] As reported in [1], the use of smp_processor_id() in pmu_sbi_device_probe() must be protected by disabling the preemption, so simple use get_cpu()/put_cpu() instead. 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> Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Nam Cao <namcao@linutronix.de> Fixes:a8625217a0("drivers/perf: riscv: Implement SBI PMU snapshot function") Reported-by: Andrea Parri <parri.andrea@gmail.com> Tested-by: Andrea Parri <parri.andrea@gmail.com> Link: https://lore.kernel.org/r/20240826165210.124696-1-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
176b6a0675
commit
edcab8d5bc
@@ -1368,11 +1368,15 @@ 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);
|
||||
if (ret) {
|
||||
/* Snapshot is an optional feature. Continue if not available */
|
||||
pmu_sbi_snapshot_free(pmu);
|
||||
@@ -1386,6 +1390,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
|
||||
*/
|
||||
static_branch_enable(&sbi_pmu_snapshot_available);
|
||||
}
|
||||
put_cpu();
|
||||
}
|
||||
|
||||
register_sysctl("kernel", sbi_pmu_sysctl_table);
|
||||
|
||||
Reference in New Issue
Block a user