Skip to content

Commit

Permalink
[PATCH] x86_64: Move the SMP time selection earlier
Browse files Browse the repository at this point in the history
SMP time selection originally ran after all CPUs were brought up because
it needed to know the number of CPUs to decide if it needs an MP safe
timer or not.

This is not needed anymore because we know present CPUs early.

This fixes a couple of problems:
 - apicmaintimer didn't always work because it relied on state that was
   set up time_init_gtod too late.
 - The output for the used timer in early kernel log was misleading
   because time_init_gtod could actually change it later.  Now always
   print the final timer choice

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Feb 26, 2006
1 parent e2c0388 commit e8b9177
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions arch/x86_64/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,6 @@ void __init smp_cpus_done(unsigned int max_cpus)
setup_ioapic_dest();
#endif

time_init_gtod();

check_nmi_watchdog();
}

Expand Down
22 changes: 11 additions & 11 deletions arch/x86_64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ static void cpufreq_delayed_get(void);
extern void i8254_timer_resume(void);
extern int using_apic_timer;

static char *time_init_gtod(void);

DEFINE_SPINLOCK(rtc_lock);
DEFINE_SPINLOCK(i8253_lock);

Expand Down Expand Up @@ -901,6 +903,7 @@ static struct irqaction irq0 = {
void __init time_init(void)
{
char *timename;
char *gtod;

#ifdef HPET_HACK_ENABLE_DANGEROUS
if (!vxtime.hpet_address) {
Expand Down Expand Up @@ -945,21 +948,19 @@ void __init time_init(void)
timename = "PIT";
}

printk(KERN_INFO "time.c: Using %ld.%06ld MHz %s timer.\n",
vxtime_hz / 1000000, vxtime_hz % 1000000, timename);
vxtime.mode = VXTIME_TSC;
gtod = time_init_gtod();

printk(KERN_INFO "time.c: Using %ld.%06ld MHz WALL %s GTOD %s timer.\n",
vxtime_hz / 1000000, vxtime_hz % 1000000, timename, gtod);
printk(KERN_INFO "time.c: Detected %d.%03d MHz processor.\n",
cpu_khz / 1000, cpu_khz % 1000);
vxtime.mode = VXTIME_TSC;
vxtime.quot = (1000000L << 32) / vxtime_hz;
vxtime.tsc_quot = (1000L << 32) / cpu_khz;
vxtime.last_tsc = get_cycles_sync();
setup_irq(0, &irq0);

set_cyc2ns_scale(cpu_khz);

#ifndef CONFIG_SMP
time_init_gtod();
#endif
}

/*
Expand All @@ -981,9 +982,9 @@ __cpuinit int unsynchronized_tsc(void)
}

/*
* Decide after all CPUs are booted what mode gettimeofday should use.
* Decide what mode gettimeofday should use.
*/
void __init time_init_gtod(void)
__init static char *time_init_gtod(void)
{
char *timetype;

Expand Down Expand Up @@ -1011,8 +1012,7 @@ void __init time_init_gtod(void)
timetype = hpet_use_timer ? "HPET/TSC" : "PIT/TSC";
vxtime.mode = VXTIME_TSC;
}

printk(KERN_INFO "time.c: Using %s based timekeeping.\n", timetype);
return timetype;
}

__setup("report_lost_ticks", time_setup);
Expand Down
1 change: 0 additions & 1 deletion include/asm-x86_64/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern void config_acpi_tables(void);
extern void ia32_syscall(void);
extern void iommu_hole_init(void);

extern void time_init_gtod(void);
extern int pmtimer_mark_offset(void);
extern void pmtimer_resume(void);
extern void pmtimer_wait(unsigned);
Expand Down

0 comments on commit e8b9177

Please sign in to comment.