:p
atchew
Login
NOW() (in particular) can be used ahead of init_percpu_time(). As the initial scale value set is merely the BSP's, we can as well set it before actually launching the AP. Don't introduce yet another notifier function though; do this from smpboot.c's. Setting the scale alone, however, doesn't work, so the entire struct cpu_time is copied. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- RFC: Copying the entire struct won't work very well when tsc_adjust[] is in use (and values there differ between sockets). This in particular eliminates an anomaly with log messages issued early while APs are coming up, when "boot" console timestamps are in use. --- a/xen/arch/x86/include/asm/time.h +++ b/xen/arch/x86/include/asm/time.h @@ -XXX,XX +XXX,XX @@ mktime (unsigned int year, unsigned int int time_suspend(void); int time_resume(void); +void preinit_percpu_time(unsigned int cpu); void init_percpu_time(void); void time_latch_stamps(void); --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -XXX,XX +XXX,XX @@ static int cf_check cpu_smpboot_callback { case CPU_UP_PREPARE: rc = cpu_smpboot_alloc(cpu); + preinit_percpu_time(cpu); break; case CPU_UP_CANCELED: case CPU_DEAD: --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -XXX,XX +XXX,XX @@ void time_latch_stamps(void) ap_bringup_ref.local_stime = get_s_time_fixed(ap_bringup_ref.local_tsc); } +void preinit_percpu_time(unsigned int cpu) +{ + /* Initial estimate for TSC rate etc. */ + per_cpu(cpu_time, cpu) = this_cpu(cpu_time); +} + void init_percpu_time(void) { struct cpu_time *t = &this_cpu(cpu_time); @@ -XXX,XX +XXX,XX @@ void init_percpu_time(void) u64 tsc; s_time_t now; - /* Initial estimate for TSC rate. */ - t->tsc_scale = per_cpu(cpu_time, 0).tsc_scale; - if ( tsc_adjust ) { unsigned int socket = cpu_to_socket(smp_processor_id());
NOW() (in particular) can be used ahead of init_percpu_time(). As the initial scale value set is merely the BSP's, we can as well set it very early when the AP is coming up. Setting the scale alone, however, doesn't work, so the entire struct cpu_time is copied. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- RFC: Copying the entire struct won't work very well when tsc_adjust[] is in use (and values there differ between sockets). This in particular mostly eliminates an anomaly with log messages issued early while APs are coming up, when "boot" console timestamps are in use. --- v2: Call the function from very early in start_secondary() --- a/xen/arch/x86/include/asm/time.h +++ b/xen/arch/x86/include/asm/time.h @@ -XXX,XX +XXX,XX @@ mktime (unsigned int year, unsigned int int time_suspend(void); int time_resume(void); +void preinit_percpu_time(unsigned int cpu); void init_percpu_time(void); void time_latch_stamps(void); --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -XXX,XX +XXX,XX @@ void asmlinkage start_secondary(void) /* Safe to enable feature such as CR4.MCE with the IDT set up now. */ write_cr4(mmu_cr4_features); + preinit_percpu_time(cpu); + percpu_traps_init(); cpu_init(); --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -XXX,XX +XXX,XX @@ void time_latch_stamps(void) ap_bringup_ref.local_stime = get_s_time_fixed(ap_bringup_ref.local_tsc); } +void preinit_percpu_time(unsigned int cpu) +{ + /* Initial estimate for TSC rate etc. */ + per_cpu(cpu_time, cpu) = per_cpu(cpu_time, 0); +} + void init_percpu_time(void) { struct cpu_time *t = &this_cpu(cpu_time); @@ -XXX,XX +XXX,XX @@ void init_percpu_time(void) u64 tsc; s_time_t now; - /* Initial estimate for TSC rate. */ - t->tsc_scale = per_cpu(cpu_time, 0).tsc_scale; - if ( tsc_adjust ) { unsigned int socket = cpu_to_socket(smp_processor_id());