linux-stable/drivers/perf
Eric Lin 66843b14fb
perf: RISC-V: Remove PERF_HES_STOPPED flag checking in riscv_pmu_start()
Since commit 096b52fd2b ("perf: RISC-V: throttle perf events") the
perf_sample_event_took() function was added to report time spent in
overflow interrupts. If the interrupt takes too long, the perf framework
will lower the sysctl_perf_event_sample_rate and max_samples_per_tick.
When hwc->interrupts is larger than max_samples_per_tick, the
hwc->interrupts will be set to MAX_INTERRUPTS, and events will be
throttled within the __perf_event_account_interrupt() function.

However, the RISC-V PMU driver doesn't call riscv_pmu_stop() to update the
PERF_HES_STOPPED flag after perf_event_overflow() in pmu_sbi_ovf_handler()
function to avoid throttling. When the perf framework unthrottled the event
in the timer interrupt handler, it triggers riscv_pmu_start() function
and causes a WARN_ON_ONCE() warning, as shown below:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 240 at drivers/perf/riscv_pmu.c:184 riscv_pmu_start+0x7c/0x8e
 Modules linked in:
 CPU: 0 PID: 240 Comm: ls Not tainted 6.4-rc4-g19d0788e9ef2 #1
 Hardware name: SiFive (DT)
 epc : riscv_pmu_start+0x7c/0x8e
  ra : riscv_pmu_start+0x28/0x8e
 epc : ffffffff80aef864 ra : ffffffff80aef810 sp : ffff8f80004db6f0
  gp : ffffffff81c83750 tp : ffffaf80069f9bc0 t0 : ffff8f80004db6c0
  t1 : 0000000000000000 t2 : 000000000000001f s0 : ffff8f80004db720
  s1 : ffffaf8008ca1068 a0 : 0000ffffffffffff a1 : 0000000000000000
  a2 : 0000000000000001 a3 : 0000000000000870 a4 : 0000000000000000
  a5 : 0000000000000000 a6 : 0000000000000840 a7 : 0000000000000030
  s2 : 0000000000000000 s3 : ffffaf8005165800 s4 : ffffaf800424da00
  s5 : ffffffffffffffff s6 : ffffffff81cc7590 s7 : 0000000000000000
  s8 : 0000000000000006 s9 : 0000000000000001 s10: ffffaf807efbc340
  s11: ffffaf807efbbf00 t3 : ffffaf8006a16028 t4 : 00000000dbfbb796
  t5 : 0000000700000000 t6 : ffffaf8005269870
 status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
 [<ffffffff80aef864>] riscv_pmu_start+0x7c/0x8e
 [<ffffffff80185b56>] perf_adjust_freq_unthr_context+0x15e/0x174
 [<ffffffff80188642>] perf_event_task_tick+0x88/0x9c
 [<ffffffff800626a8>] scheduler_tick+0xfe/0x27c
 [<ffffffff800b5640>] update_process_times+0x9a/0xba
 [<ffffffff800c5bd4>] tick_sched_handle+0x32/0x66
 [<ffffffff800c5e0c>] tick_sched_timer+0x64/0xb0
 [<ffffffff800b5e50>] __hrtimer_run_queues+0x156/0x2f4
 [<ffffffff800b6bdc>] hrtimer_interrupt+0xe2/0x1fe
 [<ffffffff80acc9e8>] riscv_timer_interrupt+0x38/0x42
 [<ffffffff80090a16>] handle_percpu_devid_irq+0x90/0x1d2
 [<ffffffff8008a9f4>] generic_handle_domain_irq+0x28/0x36

After referring other PMU drivers like Arm, Loongarch, Csky, and Mips,
they don't call *_pmu_stop() to update with PERF_HES_STOPPED flag
after perf_event_overflow() function nor do they add PERF_HES_STOPPED
flag checking in *_pmu_start() which don't cause this warning.

Thus, it's recommended to remove this unnecessary check in
riscv_pmu_start() function to prevent this warning.

Signed-off-by: Eric Lin <eric.lin@sifive.com>
Link: https://lore.kernel.org/r/20230710154328.19574-1-eric.lin@sifive.com
Fixes: 096b52fd2b ("perf: RISC-V: throttle perf events")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-07-12 07:41:23 -07:00
..
amlogic arm64 updates for 6.4 2023-04-25 12:39:01 -07:00
arm_cspmu perf: arm_cspmu: Add missing MODULE_DEVICE_TABLE 2023-06-16 10:32:32 +01:00
hisilicon drivers/perf: hisi: Add support for HiSilicon UC PMU driver 2023-06-16 12:27:38 +01:00
Kconfig cxl for v6.5 2023-07-01 08:58:41 -07:00
Makefile cxl for v6.5 2023-07-01 08:58:41 -07:00
alibaba_uncore_drw_pmu.c drivers/perf: Use devm_platform_get_and_ioremap_resource() 2023-03-27 15:09:09 +01:00
apple_m1_cpu_pmu.c drivers/perf: apple_m1: Force 63bit counters for M2 CPUs 2023-06-05 15:39:59 +01:00
arm-cci.c perf/arm-cci: Slightly optimize cci_pmu_sync_counters() 2023-06-05 14:53:04 +01:00
arm-ccn.c drivers/perf:Directly use ida_alloc()/free() 2022-06-23 15:44:45 +01:00
arm-cmn.c perf/arm-cmn: Add sysfs identifier 2023-06-16 10:28:21 +01:00
arm_dmc620_pmu.c perf/arm_dmc620: Add cpumask 2023-06-16 10:24:12 +01:00
arm_dsu_pmu.c perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init() 2022-11-15 13:45:01 +00:00
arm_pmu.c - Arnd Bergmann has fixed a bunch of -Wmissing-prototypes in 2023-06-28 10:59:38 -07:00
arm_pmu_acpi.c arm_pmu: acpi: handle allocation failure 2022-11-08 12:42:46 +00:00
arm_pmu_platform.c perf/arm_pmu_platform: fix tests for platform_get_irq() failure 2022-09-01 12:01:40 +01:00
arm_pmuv3.c - Arnd Bergmann has fixed a bunch of -Wmissing-prototypes in 2023-06-28 10:59:38 -07:00
arm_smmuv3_pmu.c perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init() 2022-11-15 13:47:04 +00:00
arm_spe_pmu.c perf: arm_spe: Print the version of SPE detected 2023-02-07 11:52:21 +00:00
cxl_pmu.c perf: CXL Performance Monitoring Unit driver 2023-06-25 17:47:09 -07:00
fsl_imx8_ddr_perf.c drivers/perf: fsl_imx8_ddr_perf: Remove set-but-not-used variable 2023-02-03 13:04:22 +00:00
fsl_imx9_ddr_perf.c drivers/perf: imx_ddr: Add support for NXP i.MX9 SoC DDRC PMU driver 2023-06-09 12:01:10 +01:00
marvell_cn10k_ddr_pmu.c perf/marvell: Add ACPI support to DDR uncore driver 2023-01-19 18:30:21 +00:00
marvell_cn10k_tad_pmu.c perf/marvell: Add ACPI support to TAD uncore driver 2023-01-19 18:30:22 +00:00
qcom_l2_pmu.c perf: qcom_l2_pmu: Make l2_cache_pmu_probe_cluster() more robust 2023-06-05 15:01:27 +01:00
qcom_l3_pmu.c perf: qcom: Use devm_platform_get_and_ioremap_resource() 2023-03-27 15:03:01 +01:00
riscv_pmu.c perf: RISC-V: Remove PERF_HES_STOPPED flag checking in riscv_pmu_start() 2023-07-12 07:41:23 -07:00
riscv_pmu_legacy.c RISC-V Patches for the 6.1 Merge Window, Part 1 2022-10-09 13:24:01 -07:00
riscv_pmu_sbi.c perf: RISC-V: Limit the number of counters returned from SBI 2023-06-20 12:55:24 -07:00
thunderx2_pmu.c perf: Replace acpi_bus_get_device() 2022-02-08 15:14:53 +00:00
xgene_pmu.c perf: replace bitmap_weight with bitmap_empty where appropriate 2022-02-15 14:38:57 +00:00