ia64/xen-unstable

changeset 11008:0caf8d9218cc

[XEN] Make per-cpu time information explicitly PER_CPU.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Aug 08 14:02:14 2006 +0100 (2006-08-08)
parents 5e8c254c9dcd
children 7e9699af7e12
files xen/arch/x86/time.c
line diff
     1.1 --- a/xen/arch/x86/time.c	Tue Aug 08 13:55:22 2006 +0100
     1.2 +++ b/xen/arch/x86/time.c	Tue Aug 08 14:02:14 2006 +0100
     1.3 @@ -58,7 +58,7 @@ struct cpu_time {
     1.4      struct timer calibration_timer;
     1.5  } __cacheline_aligned;
     1.6  
     1.7 -static struct cpu_time cpu_time[NR_CPUS];
     1.8 +static DEFINE_PER_CPU(struct cpu_time, cpu_time);
     1.9  
    1.10  /*
    1.11   * Protected by platform_timer_lock, which must be acquired with interrupts
    1.12 @@ -263,7 +263,7 @@ void calibrate_tsc_ap(void)
    1.13      rdtscll(t2);
    1.14  
    1.15      ticks_per_sec = (t2 - t1) * (u64)CALIBRATE_FRAC;
    1.16 -    set_time_scale(&cpu_time[smp_processor_id()].tsc_scale, ticks_per_sec);
    1.17 +    set_time_scale(&this_cpu(cpu_time).tsc_scale, ticks_per_sec);
    1.18  
    1.19      atomic_dec(&tsc_calibrate_gang);
    1.20  }
    1.21 @@ -646,7 +646,7 @@ static unsigned long get_cmos_time(void)
    1.22  
    1.23  s_time_t get_s_time(void)
    1.24  {
    1.25 -    struct cpu_time *t = &cpu_time[smp_processor_id()];
    1.26 +    struct cpu_time *t = &this_cpu(cpu_time);
    1.27      u64 tsc, delta;
    1.28      s_time_t now;
    1.29  
    1.30 @@ -675,7 +675,7 @@ static inline void __update_vcpu_system_
    1.31      struct cpu_time       *t;
    1.32      struct vcpu_time_info *u;
    1.33  
    1.34 -    t = &cpu_time[smp_processor_id()];
    1.35 +    t = &this_cpu(cpu_time);
    1.36      u = &v->domain->shared_info->vcpu_info[v->vcpu_id].time;
    1.37  
    1.38      version_update_begin(&u->version);
    1.39 @@ -691,7 +691,7 @@ static inline void __update_vcpu_system_
    1.40  void update_vcpu_system_time(struct vcpu *v)
    1.41  {
    1.42      if ( v->domain->shared_info->vcpu_info[v->vcpu_id].time.tsc_timestamp != 
    1.43 -         cpu_time[smp_processor_id()].local_tsc_stamp )
    1.44 +         this_cpu(cpu_time).local_tsc_stamp )
    1.45          __update_vcpu_system_time(v);
    1.46  }
    1.47  
    1.48 @@ -728,7 +728,7 @@ void do_settime(unsigned long secs, unsi
    1.49  
    1.50  static void local_time_calibration(void *unused)
    1.51  {
    1.52 -    unsigned int cpu = smp_processor_id();
    1.53 +    struct cpu_time *t = &this_cpu(cpu_time);
    1.54  
    1.55      /*
    1.56       * System timestamps, extrapolated from local and master oscillators,
    1.57 @@ -759,9 +759,9 @@ static void local_time_calibration(void 
    1.58      /* The overall calibration scale multiplier. */
    1.59      u32 calibration_mul_frac;
    1.60  
    1.61 -    prev_tsc          = cpu_time[cpu].local_tsc_stamp;
    1.62 -    prev_local_stime  = cpu_time[cpu].stime_local_stamp;
    1.63 -    prev_master_stime = cpu_time[cpu].stime_master_stamp;
    1.64 +    prev_tsc          = t->local_tsc_stamp;
    1.65 +    prev_local_stime  = t->stime_local_stamp;
    1.66 +    prev_master_stime = t->stime_master_stamp;
    1.67  
    1.68      /* Disable IRQs to get 'instantaneous' current timestamps. */
    1.69      local_irq_disable();
    1.70 @@ -772,9 +772,9 @@ static void local_time_calibration(void 
    1.71  
    1.72  #if 0
    1.73      printk("PRE%d: tsc=%lld stime=%lld master=%lld\n",
    1.74 -           cpu, prev_tsc, prev_local_stime, prev_master_stime);
    1.75 +           smp_processor_id(), prev_tsc, prev_local_stime, prev_master_stime);
    1.76      printk("CUR%d: tsc=%lld stime=%lld master=%lld -> %lld\n",
    1.77 -           cpu, curr_tsc, curr_local_stime, curr_master_stime,
    1.78 +           smp_processor_id(), curr_tsc, curr_local_stime, curr_master_stime,
    1.79             curr_master_stime - curr_local_stime);
    1.80  #endif
    1.81  
    1.82 @@ -844,41 +844,41 @@ static void local_time_calibration(void 
    1.83          calibration_mul_frac = mul_frac(calibration_mul_frac, error_factor);
    1.84  
    1.85  #if 0
    1.86 -    printk("---%d: %08x %08x %d\n", cpu,
    1.87 +    printk("---%d: %08x %08x %d\n", smp_processor_id(),
    1.88             error_factor, calibration_mul_frac, tsc_shift);
    1.89  #endif
    1.90  
    1.91      /* Record new timestamp information. */
    1.92 -    cpu_time[cpu].tsc_scale.mul_frac = calibration_mul_frac;
    1.93 -    cpu_time[cpu].tsc_scale.shift    = tsc_shift;
    1.94 -    cpu_time[cpu].local_tsc_stamp    = curr_tsc;
    1.95 -    cpu_time[cpu].stime_local_stamp  = curr_local_stime;
    1.96 -    cpu_time[cpu].stime_master_stamp = curr_master_stime;
    1.97 +    t->tsc_scale.mul_frac = calibration_mul_frac;
    1.98 +    t->tsc_scale.shift    = tsc_shift;
    1.99 +    t->local_tsc_stamp    = curr_tsc;
   1.100 +    t->stime_local_stamp  = curr_local_stime;
   1.101 +    t->stime_master_stamp = curr_master_stime;
   1.102  
   1.103   out:
   1.104 -    set_timer(&cpu_time[cpu].calibration_timer, NOW() + EPOCH);
   1.105 +    set_timer(&t->calibration_timer, NOW() + EPOCH);
   1.106  
   1.107 -    if ( cpu == 0 )
   1.108 +    if ( smp_processor_id() == 0 )
   1.109          platform_time_calibration();
   1.110  }
   1.111  
   1.112  void init_percpu_time(void)
   1.113  {
   1.114 -    unsigned int cpu = smp_processor_id();
   1.115 +    struct cpu_time *t = &this_cpu(cpu_time);
   1.116      unsigned long flags;
   1.117      s_time_t now;
   1.118  
   1.119      local_irq_save(flags);
   1.120 -    rdtscll(cpu_time[cpu].local_tsc_stamp);
   1.121 -    now = (cpu == 0) ? 0 : read_platform_stime();
   1.122 +    rdtscll(t->local_tsc_stamp);
   1.123 +    now = (smp_processor_id() == 0) ? 0 : read_platform_stime();
   1.124      local_irq_restore(flags);
   1.125  
   1.126 -    cpu_time[cpu].stime_master_stamp = now;
   1.127 -    cpu_time[cpu].stime_local_stamp  = now;
   1.128 +    t->stime_master_stamp = now;
   1.129 +    t->stime_local_stamp  = now;
   1.130  
   1.131 -    init_timer(&cpu_time[cpu].calibration_timer,
   1.132 -                  local_time_calibration, NULL, cpu);
   1.133 -    set_timer(&cpu_time[cpu].calibration_timer, NOW() + EPOCH);
   1.134 +    init_timer(&t->calibration_timer, local_time_calibration,
   1.135 +               NULL, smp_processor_id());
   1.136 +    set_timer(&t->calibration_timer, NOW() + EPOCH);
   1.137  }
   1.138  
   1.139  /* Late init function (after all CPUs are booted). */
   1.140 @@ -904,7 +904,7 @@ void __init early_time_init(void)
   1.141  {
   1.142      u64 tmp = calibrate_boot_tsc();
   1.143  
   1.144 -    set_time_scale(&cpu_time[0].tsc_scale, tmp);
   1.145 +    set_time_scale(&per_cpu(cpu_time, 0).tsc_scale, tmp);
   1.146  
   1.147      do_div(tmp, 1000);
   1.148      cpu_khz = (unsigned long)tmp;