From: Jan Beulich Date: Fri, 27 Apr 2018 12:35:35 +0000 (+0200) Subject: x86/cpuidle: don't init stats lock more than once X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~145 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2f64a251fa10dd4d62f84967e3dafa709f5e96ab;p=xen.git x86/cpuidle: don't init stats lock more than once Osstest flight 122363, having hit an NMI watchdog timeout, shows CPU1 at Xen call trace: [] _spin_lock+0x30/0x57 [] update_last_cx_stat+0x29/0x42 [] cpu_idle.c#acpi_processor_idle+0x2ff/0x596 [] domain.c#idle_loop+0xa8/0xc3 and CPU0 at Xen call trace: [] on_selected_cpus+0xb7/0xde [] powernow.c#powernow_cpufreq_target+0x110/0x1cb [] __cpufreq_driver_target+0x43/0xa6 [] cpufreq_governor_dbs+0x324/0x37a [] __cpufreq_set_policy+0xfa/0x19d [] cpufreq_add_cpu+0x3a1/0x5df [] cpufreq_cpu_init+0x17/0x1a [] set_px_pminfo+0x2b6/0x2f7 [] do_platform_op+0xe75/0x1977 [] pv_hypercall+0x1f4/0x440 [] lstar_enter+0x115/0x120 That is, Dom0's ACPI processor driver is in the process of uploading Px and Cx data. Looking at the ticket lock state in CPU1's registers, it is waiting for ticket 0x0000 to have its turn, while the supposed current owner's ticket is 0x0001, which is an invalid state (and neither of the other two CPUs holds the lock anyway). Hence I can only conclude that cpuidle_init_cpu(1) ran on CPU 0 while some other CPU held the lock (the unlock then put the lock in the state that CPU1 is observing). Signed-off-by: Jan Beulich Acked-by: Andrew Cooper Release-acked-by: Juergen Gross --- diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 226059cbfd..7ecf443562 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -842,6 +842,9 @@ int cpuidle_init_cpu(unsigned int cpu) acpi_power->states[i].idx = i; acpi_power->cpu = cpu; + + spin_lock_init(&acpi_power->stat_lock); + processor_powers[cpu] = acpi_power; } @@ -849,7 +852,6 @@ int cpuidle_init_cpu(unsigned int cpu) acpi_power->states[1].type = ACPI_STATE_C1; acpi_power->states[1].entry_method = ACPI_CSTATE_EM_HALT; acpi_power->safe_state = &acpi_power->states[1]; - spin_lock_init(&acpi_power->stat_lock); return 0; }