This is a note to let you know that I've just added the patch titled drivers: perf: Fix smp_processor_id() use in preemptible code to the 6.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drivers-perf-fix-smp_processor_id-use-in-preemptible.patch and it can be found in the queue-6.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit e7e913873b300d0c5e12ad65ff58502315ff6b60 Author: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> Date: Mon Aug 26 18:52:10 2024 +0200 drivers: perf: Fix smp_processor_id() use in preemptible code [ Upstream commit 2840dadf0dde92638d13b97998026c5fcddbdceb ] 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@xxxxxxxxxxxxx> Closes: https://lore.kernel.org/linux-riscv/20240820074925.ReMKUPP3@xxxxxxxxxxxxx/ [1] Signed-off-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx> Tested-by: Nam Cao <namcao@xxxxxxxxxxxxx> Fixes: a8625217a054 ("drivers/perf: riscv: Implement SBI PMU snapshot function") Reported-by: Andrea Parri <parri.andrea@xxxxxxxxx> Tested-by: Andrea Parri <parri.andrea@xxxxxxxxx> Link: https://lore.kernel.org/r/20240826165210.124696-1-alexghiti@xxxxxxxxxxxx Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 11c7c85047ed..765bda7924f7 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -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);