From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753249AbcGSHOu (ORCPT ); Tue, 19 Jul 2016 03:14:50 -0400 Received: from terminus.zytor.com ([198.137.202.10]:45618 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752827AbcGSHOr (ORCPT ); Tue, 19 Jul 2016 03:14:47 -0400 Date: Tue, 19 Jul 2016 00:14:13 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: gleb@kernel.org, tglx@linutronix.de, anna-maria@linutronix.de, peterz@infradead.org, pbonzini@redhat.com, mingo@kernel.org, hpa@zytor.com, bigeasy@linutronix.de, rkrcmar@redhat.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Reply-To: hpa@zytor.com, peterz@infradead.org, mingo@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, bigeasy@linutronix.de, tglx@linutronix.de, gleb@kernel.org, anna-maria@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org In-Reply-To: <20160713153335.542880859@linutronix.de> References: <20160713153335.542880859@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] x86/kvm/kvmclock: Convert to hotplug state machine Git-Commit-ID: 251a5fd64b720a0646eddb8c54f5e9ddba066e72 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 251a5fd64b720a0646eddb8c54f5e9ddba066e72 Gitweb: http://git.kernel.org/tip/251a5fd64b720a0646eddb8c54f5e9ddba066e72 Author: Sebastian Andrzej Siewior AuthorDate: Wed, 13 Jul 2016 17:16:33 +0000 Committer: Ingo Molnar CommitDate: Fri, 15 Jul 2016 10:40:21 +0200 x86/kvm/kvmclock: Convert to hotplug state machine Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. We assumed that the priority ordering was ment to invoke the online callback as the last step. In the original code this also invoked the down prepare callback as the last step. With the symmetric state machine the down prepare callback is now the first step. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Anna-Maria Gleixner Acked-by: Paolo Bonzini Cc: Gleb Natapov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Radim Krcmar Cc: Thomas Gleixner Cc: kvm@vger.kernel.org Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20160713153335.542880859@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/kvm/x86.c | 33 ++++++++------------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6f90595..f899127 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5552,9 +5552,10 @@ int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port) } EXPORT_SYMBOL_GPL(kvm_fast_pio_out); -static void tsc_bad(void *info) +static int kvmclock_cpu_down_prep(unsigned int cpu) { __this_cpu_write(cpu_tsc_khz, 0); + return 0; } static void tsc_khz_changed(void *data) @@ -5659,33 +5660,18 @@ static struct notifier_block kvmclock_cpufreq_notifier_block = { .notifier_call = kvmclock_cpufreq_notifier }; -static int kvmclock_cpu_notifier(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int kvmclock_cpu_online(unsigned int cpu) { - switch (action) { - case CPU_ONLINE: - case CPU_DOWN_FAILED: - tsc_khz_changed(NULL); - break; - case CPU_DOWN_PREPARE: - tsc_bad(NULL); - break; - } - return NOTIFY_OK; + tsc_khz_changed(NULL); + return 0; } -static struct notifier_block kvmclock_cpu_notifier_block = { - .notifier_call = kvmclock_cpu_notifier, - .priority = -INT_MAX -}; - static void kvm_timer_init(void) { int cpu; max_tsc_khz = tsc_khz; - cpu_notifier_register_begin(); if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) { #ifdef CONFIG_CPU_FREQ struct cpufreq_policy policy; @@ -5700,12 +5686,9 @@ static void kvm_timer_init(void) CPUFREQ_TRANSITION_NOTIFIER); } pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz); - for_each_online_cpu(cpu) - smp_call_function_single(cpu, tsc_khz_changed, NULL, 1); - - __register_hotcpu_notifier(&kvmclock_cpu_notifier_block); - cpu_notifier_register_done(); + cpuhp_setup_state(CPUHP_AP_X86_KVM_CLK_ONLINE, "AP_X86_KVM_CLK_ONLINE", + kvmclock_cpu_online, kvmclock_cpu_down_prep); } static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu); @@ -5894,7 +5877,7 @@ void kvm_arch_exit(void) if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); - unregister_hotcpu_notifier(&kvmclock_cpu_notifier_block); + cpuhp_remove_state_nocalls(CPUHP_AP_X86_KVM_CLK_ONLINE); #ifdef CONFIG_X86_64 pvclock_gtod_unregister_notifier(&pvclock_gtod_notifier); #endif diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 7449081..8c190a8 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -56,6 +56,7 @@ enum cpuhp_state { CPUHP_AP_ONLINE_DYN, CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30, CPUHP_AP_X86_HPET_ONLINE, + CPUHP_AP_X86_KVM_CLK_ONLINE, CPUHP_AP_ACTIVE, CPUHP_ONLINE, };