From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: x86: kvmclock: abstract save/restore sched_clock_state Date: Thu, 1 Mar 2012 10:58:19 +0100 (CET) Message-ID: References: <20120207210542.GC20618@amt.cnet> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: kvm@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, johnstul@us.ibm.com, riel@redhat.com, avi@redhat.com, imammedo@redhat.com To: Marcelo Tosatti Return-path: Received: from www.linutronix.de ([62.245.132.108]:36617 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756818Ab2CAJ60 (ORCPT ); Thu, 1 Mar 2012 04:58:26 -0500 In-Reply-To: <20120207210542.GC20618@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 7 Feb 2012, Marcelo Tosatti wrote: > > Upon resume from hibernation, CPU 0's hvclock area contains the old > values for system_time and tsc_timestamp. It is necessary for the > hypervisor to update these values with uptodate ones before the CPU uses > them. > > Abstract TSC's save/restore sched_clock_state functions and use > restore_state to write to KVM_SYSTEM_TIME MSR, forcing an update. > > Fixes suspend-to-disk with kvmclock. > > Signed-off-by: Marcelo Tosatti > > diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h > index 15d9915..c91e8b9 100644 > --- a/arch/x86/include/asm/tsc.h > +++ b/arch/x86/include/asm/tsc.h > @@ -61,7 +61,7 @@ extern void check_tsc_sync_source(int cpu); > extern void check_tsc_sync_target(void); > > extern int notsc_setup(char *); > -extern void save_sched_clock_state(void); > -extern void restore_sched_clock_state(void); > +extern void tsc_save_sched_clock_state(void); > +extern void tsc_restore_sched_clock_state(void); > > #endif /* _ASM_X86_TSC_H */ > diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h > index 5d0afac..baaca8d 100644 > --- a/arch/x86/include/asm/x86_init.h > +++ b/arch/x86/include/asm/x86_init.h > @@ -162,6 +162,8 @@ struct x86_cpuinit_ops { > * @is_untracked_pat_range exclude from PAT logic > * @nmi_init enable NMI on cpus > * @i8042_detect pre-detect if i8042 controller exists > + * @save_sched_clock_state: save state for sched_clock() on suspend > + * @restore_sched_clock_state: restore state for sched_clock() on resume > */ > struct x86_platform_ops { > unsigned long (*calibrate_tsc)(void); > @@ -173,6 +175,8 @@ struct x86_platform_ops { > void (*nmi_init)(void); > unsigned char (*get_nmi_reason)(void); > int (*i8042_detect)(void); > + void (*save_sched_clock_state)(void); > + void (*restore_sched_clock_state)(void); > }; > > struct pci_dev; > diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > index ca4e735..57e6b78 100644 > --- a/arch/x86/kernel/kvmclock.c > +++ b/arch/x86/kernel/kvmclock.c > @@ -136,6 +136,15 @@ int kvm_register_clock(char *txt) > return ret; > } > > +void kvm_save_sched_clock_state(void) static ? > +{ > +} > + > +void kvm_restore_sched_clock_state(void) Ditto > +{ > + kvm_register_clock("primary cpu clock, resume"); > +} > + Otherwise: Reviewed-by: Thomas Gleixner