direct-io.hg
changeset 6045:704e6cc4a684
Remove dead files.
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Mon Aug 08 11:06:45 2005 +0000 (2005-08-08) |
parents | 6fc0b68b0a9c |
children | 61af128313c8 |
files |
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/timers/Makefile Mon Aug 08 10:59:22 2005 +0000 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,17 +0,0 @@ 1.4 -# 1.5 -# Makefile for x86 timers 1.6 -# 1.7 - 1.8 -XENARCH := $(subst ",,$(CONFIG_XENARCH)) 1.9 - 1.10 -obj-y := timer_tsc.o 1.11 -c-obj-y := 1.12 - 1.13 -c-link := 1.14 - 1.15 -$(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-link)): 1.16 - @ln -fsn $(srctree)/arch/i386/kernel/timers/$(notdir $@) $@ 1.17 - 1.18 -obj-y += $(c-obj-y) 1.19 - 1.20 -clean-files += $(patsubst %.o,%.c,$(c-obj-y) $(c-obj-) $(c-link))
2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c Mon Aug 08 10:59:22 2005 +0000 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,379 +0,0 @@ 2.4 -/* 2.5 - * This code largely moved from arch/i386/kernel/time.c. 2.6 - * See comments there for proper credits. 2.7 - */ 2.8 - 2.9 -#include <linux/spinlock.h> 2.10 -#include <linux/init.h> 2.11 -#include <linux/timex.h> 2.12 -#include <linux/errno.h> 2.13 -#include <linux/cpufreq.h> 2.14 -#include <linux/string.h> 2.15 -#include <linux/jiffies.h> 2.16 - 2.17 -#include <asm/timer.h> 2.18 -#include <asm/io.h> 2.19 -/* processor.h for distable_tsc flag */ 2.20 -#include <asm/processor.h> 2.21 - 2.22 -#include "io_ports.h" 2.23 -#include "mach_timer.h" 2.24 - 2.25 -#include <asm/hpet.h> 2.26 - 2.27 -#ifdef CONFIG_HPET_TIMER 2.28 -static unsigned long hpet_usec_quotient; 2.29 -static unsigned long hpet_last; 2.30 -static struct timer_opts timer_tsc; 2.31 -#endif 2.32 - 2.33 -static inline void cpufreq_delayed_get(void); 2.34 - 2.35 -int tsc_disable __initdata = 0; 2.36 - 2.37 -extern spinlock_t i8253_lock; 2.38 - 2.39 -static int use_tsc; 2.40 - 2.41 -static unsigned long long monotonic_base; 2.42 -static u32 monotonic_offset; 2.43 -static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED; 2.44 - 2.45 -/* convert from cycles(64bits) => nanoseconds (64bits) 2.46 - * basic equation: 2.47 - * ns = cycles / (freq / ns_per_sec) 2.48 - * ns = cycles * (ns_per_sec / freq) 2.49 - * ns = cycles * (10^9 / (cpu_mhz * 10^6)) 2.50 - * ns = cycles * (10^3 / cpu_mhz) 2.51 - * 2.52 - * Then we use scaling math (suggested by george@mvista.com) to get: 2.53 - * ns = cycles * (10^3 * SC / cpu_mhz) / SC 2.54 - * ns = cycles * cyc2ns_scale / SC 2.55 - * 2.56 - * And since SC is a constant power of two, we can convert the div 2.57 - * into a shift. 2.58 - * -johnstul@us.ibm.com "math is hard, lets go shopping!" 2.59 - */ 2.60 -static unsigned long cyc2ns_scale; 2.61 -#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ 2.62 - 2.63 -static inline void set_cyc2ns_scale(unsigned long cpu_mhz) 2.64 -{ 2.65 - cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz; 2.66 -} 2.67 - 2.68 -static inline unsigned long long cycles_2_ns(unsigned long long cyc) 2.69 -{ 2.70 - return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR; 2.71 -} 2.72 - 2.73 -/* Cached *multiplier* to convert TSC counts to microseconds. 2.74 - * (see the equation below). 2.75 - * Equal to 2^32 * (1 / (clocks per usec) ). 2.76 - * Initialized in time_init. 2.77 - */ 2.78 -static unsigned long fast_gettimeoffset_quotient; 2.79 - 2.80 -extern u32 shadow_tsc_stamp; 2.81 -extern u64 shadow_system_time; 2.82 - 2.83 -static unsigned long get_offset_tsc(void) 2.84 -{ 2.85 - register unsigned long eax, edx; 2.86 - 2.87 - /* Read the Time Stamp Counter */ 2.88 - 2.89 - rdtsc(eax,edx); 2.90 - 2.91 - /* .. relative to previous jiffy (32 bits is enough) */ 2.92 - eax -= shadow_tsc_stamp; 2.93 - 2.94 - /* 2.95 - * Time offset = (tsc_low delta) * fast_gettimeoffset_quotient 2.96 - * = (tsc_low delta) * (usecs_per_clock) 2.97 - * = (tsc_low delta) * (usecs_per_jiffy / clocks_per_jiffy) 2.98 - * 2.99 - * Using a mull instead of a divl saves up to 31 clock cycles 2.100 - * in the critical path. 2.101 - */ 2.102 - 2.103 - __asm__("mull %2" 2.104 - :"=a" (eax), "=d" (edx) 2.105 - :"rm" (fast_gettimeoffset_quotient), 2.106 - "0" (eax)); 2.107 - 2.108 - /* our adjusted time offset in microseconds */ 2.109 - return edx; 2.110 -} 2.111 - 2.112 -static unsigned long long monotonic_clock_tsc(void) 2.113 -{ 2.114 - unsigned long long last_offset, this_offset, base; 2.115 - unsigned seq; 2.116 - 2.117 - /* atomically read monotonic base & last_offset */ 2.118 - do { 2.119 - seq = read_seqbegin(&monotonic_lock); 2.120 - last_offset = monotonic_offset; 2.121 - base = monotonic_base; 2.122 - } while (read_seqretry(&monotonic_lock, seq)); 2.123 - 2.124 - /* Read the Time Stamp Counter */ 2.125 - rdtscll(this_offset); 2.126 - 2.127 - /* return the value in ns */ 2.128 - return base + cycles_2_ns(this_offset - last_offset); 2.129 -} 2.130 - 2.131 -/* 2.132 - * Scheduler clock - returns current time in nanosec units. 2.133 - */ 2.134 -unsigned long long sched_clock(void) 2.135 -{ 2.136 - unsigned long long this_offset; 2.137 - 2.138 - /* 2.139 - * In the NUMA case we dont use the TSC as they are not 2.140 - * synchronized across all CPUs. 2.141 - */ 2.142 -#ifndef CONFIG_NUMA 2.143 - if (!use_tsc) 2.144 -#endif 2.145 - /* no locking but a rare wrong value is not a big deal */ 2.146 - return jiffies_64 * (1000000000 / HZ); 2.147 - 2.148 - /* Read the Time Stamp Counter */ 2.149 - rdtscll(this_offset); 2.150 - 2.151 - /* return the value in ns */ 2.152 - return cycles_2_ns(this_offset); 2.153 -} 2.154 - 2.155 - 2.156 -static void mark_offset_tsc(void) 2.157 -{ 2.158 - 2.159 - /* update the monotonic base value */ 2.160 - write_seqlock(&monotonic_lock); 2.161 - monotonic_base = shadow_system_time; 2.162 - monotonic_offset = shadow_tsc_stamp; 2.163 - write_sequnlock(&monotonic_lock); 2.164 -} 2.165 - 2.166 -static void delay_tsc(unsigned long loops) 2.167 -{ 2.168 - unsigned long bclock, now; 2.169 - 2.170 - rdtscl(bclock); 2.171 - do 2.172 - { 2.173 - rep_nop(); 2.174 - rdtscl(now); 2.175 - } while ((now-bclock) < loops); 2.176 -} 2.177 - 2.178 -#ifdef CONFIG_HPET_TIMER 2.179 -static void mark_offset_tsc_hpet(void) 2.180 -{ 2.181 - unsigned long long this_offset, last_offset; 2.182 - unsigned long offset, temp, hpet_current; 2.183 - 2.184 - write_seqlock(&monotonic_lock); 2.185 - last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low; 2.186 - /* 2.187 - * It is important that these two operations happen almost at 2.188 - * the same time. We do the RDTSC stuff first, since it's 2.189 - * faster. To avoid any inconsistencies, we need interrupts 2.190 - * disabled locally. 2.191 - */ 2.192 - /* 2.193 - * Interrupts are just disabled locally since the timer irq 2.194 - * has the SA_INTERRUPT flag set. -arca 2.195 - */ 2.196 - /* read Pentium cycle counter */ 2.197 - 2.198 - hpet_current = hpet_readl(HPET_COUNTER); 2.199 - rdtsc(last_tsc_low, last_tsc_high); 2.200 - 2.201 - /* lost tick compensation */ 2.202 - offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 2.203 - if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { 2.204 - int lost_ticks = (offset - hpet_last) / hpet_tick; 2.205 - jiffies_64 += lost_ticks; 2.206 - } 2.207 - hpet_last = hpet_current; 2.208 - 2.209 - /* update the monotonic base value */ 2.210 - this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low; 2.211 - monotonic_base += cycles_2_ns(this_offset - last_offset); 2.212 - write_sequnlock(&monotonic_lock); 2.213 - 2.214 - /* calculate delay_at_last_interrupt */ 2.215 - /* 2.216 - * Time offset = (hpet delta) * ( usecs per HPET clock ) 2.217 - * = (hpet delta) * ( usecs per tick / HPET clocks per tick) 2.218 - * = (hpet delta) * ( hpet_usec_quotient ) / (2^32) 2.219 - * Where, 2.220 - * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick 2.221 - */ 2.222 - delay_at_last_interrupt = hpet_current - offset; 2.223 - ASM_MUL64_REG(temp, delay_at_last_interrupt, 2.224 - hpet_usec_quotient, delay_at_last_interrupt); 2.225 -} 2.226 -#endif 2.227 - 2.228 - 2.229 -#ifdef CONFIG_CPU_FREQ 2.230 -#include <linux/workqueue.h> 2.231 - 2.232 -static unsigned int cpufreq_delayed_issched = 0; 2.233 -static unsigned int cpufreq_init = 0; 2.234 -static struct work_struct cpufreq_delayed_get_work; 2.235 - 2.236 -static void handle_cpufreq_delayed_get(void *v) 2.237 -{ 2.238 - unsigned int cpu; 2.239 - for_each_online_cpu(cpu) { 2.240 - cpufreq_get(cpu); 2.241 - } 2.242 - cpufreq_delayed_issched = 0; 2.243 -} 2.244 - 2.245 -/* if we notice lost ticks, schedule a call to cpufreq_get() as it tries 2.246 - * to verify the CPU frequency the timing core thinks the CPU is running 2.247 - * at is still correct. 2.248 - */ 2.249 -static inline void cpufreq_delayed_get(void) 2.250 -{ 2.251 - if (cpufreq_init && !cpufreq_delayed_issched) { 2.252 - cpufreq_delayed_issched = 1; 2.253 - printk(KERN_DEBUG "Losing some ticks... checking if CPU frequency changed.\n"); 2.254 - schedule_work(&cpufreq_delayed_get_work); 2.255 - } 2.256 -} 2.257 - 2.258 -/* If the CPU frequency is scaled, TSC-based delays will need a different 2.259 - * loops_per_jiffy value to function properly. 2.260 - */ 2.261 - 2.262 -static unsigned int ref_freq = 0; 2.263 -static unsigned long loops_per_jiffy_ref = 0; 2.264 - 2.265 -#ifndef CONFIG_SMP 2.266 -static unsigned long fast_gettimeoffset_ref = 0; 2.267 -static unsigned long cpu_khz_ref = 0; 2.268 -#endif 2.269 - 2.270 -static int 2.271 -time_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 2.272 - void *data) 2.273 -{ 2.274 - struct cpufreq_freqs *freq = data; 2.275 - 2.276 - if (val != CPUFREQ_RESUMECHANGE) 2.277 - write_seqlock_irq(&xtime_lock); 2.278 - if (!ref_freq) { 2.279 - ref_freq = freq->old; 2.280 - loops_per_jiffy_ref = cpu_data[freq->cpu].loops_per_jiffy; 2.281 -#ifndef CONFIG_SMP 2.282 - fast_gettimeoffset_ref = fast_gettimeoffset_quotient; 2.283 - cpu_khz_ref = cpu_khz; 2.284 -#endif 2.285 - } 2.286 - 2.287 - if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || 2.288 - (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || 2.289 - (val == CPUFREQ_RESUMECHANGE)) { 2.290 - if (!(freq->flags & CPUFREQ_CONST_LOOPS)) 2.291 - cpu_data[freq->cpu].loops_per_jiffy = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); 2.292 -#ifndef CONFIG_SMP 2.293 - if (cpu_khz) 2.294 - cpu_khz = cpufreq_scale(cpu_khz_ref, ref_freq, freq->new); 2.295 - if (use_tsc) { 2.296 - if (!(freq->flags & CPUFREQ_CONST_LOOPS)) { 2.297 - fast_gettimeoffset_quotient = cpufreq_scale(fast_gettimeoffset_ref, freq->new, ref_freq); 2.298 - set_cyc2ns_scale(cpu_khz/1000); 2.299 - } 2.300 - } 2.301 -#endif 2.302 - } 2.303 - 2.304 - if (val != CPUFREQ_RESUMECHANGE) 2.305 - write_sequnlock_irq(&xtime_lock); 2.306 - 2.307 - return 0; 2.308 -} 2.309 - 2.310 -static struct notifier_block time_cpufreq_notifier_block = { 2.311 - .notifier_call = time_cpufreq_notifier 2.312 -}; 2.313 - 2.314 - 2.315 -static int __init cpufreq_tsc(void) 2.316 -{ 2.317 - int ret; 2.318 - INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 2.319 - ret = cpufreq_register_notifier(&time_cpufreq_notifier_block, 2.320 - CPUFREQ_TRANSITION_NOTIFIER); 2.321 - if (!ret) 2.322 - cpufreq_init = 1; 2.323 - return ret; 2.324 -} 2.325 -core_initcall(cpufreq_tsc); 2.326 - 2.327 -#else /* CONFIG_CPU_FREQ */ 2.328 -static inline void cpufreq_delayed_get(void) { return; } 2.329 -#endif 2.330 - 2.331 - 2.332 -static int init_tsc(char* override) 2.333 -{ 2.334 - u64 __cpu_khz; 2.335 - 2.336 - __cpu_khz = HYPERVISOR_shared_info->cpu_freq; 2.337 - do_div(__cpu_khz, 1000); 2.338 - cpu_khz = (u32)__cpu_khz; 2.339 - printk(KERN_INFO "Xen reported: %lu.%03lu MHz processor.\n", 2.340 - cpu_khz / 1000, cpu_khz % 1000); 2.341 - 2.342 - /* (10^6 * 2^32) / cpu_hz = (10^3 * 2^32) / cpu_khz = 2.343 - (2^32 * 1 / (clocks/us)) */ 2.344 - { 2.345 - unsigned long eax=0, edx=1000; 2.346 - __asm__("divl %2" 2.347 - :"=a" (fast_gettimeoffset_quotient), "=d" (edx) 2.348 - :"r" (cpu_khz), 2.349 - "0" (eax), "1" (edx)); 2.350 - } 2.351 - 2.352 - set_cyc2ns_scale(cpu_khz/1000); 2.353 - 2.354 - use_tsc = 1; 2.355 - 2.356 - return 0; 2.357 -} 2.358 - 2.359 -static int __init tsc_setup(char *str) 2.360 -{ 2.361 - printk(KERN_WARNING "notsc: cannot disable TSC in Xen/Linux.\n"); 2.362 - return 1; 2.363 -} 2.364 -__setup("notsc", tsc_setup); 2.365 - 2.366 - 2.367 - 2.368 -/************************************************************/ 2.369 - 2.370 -/* tsc timer_opts struct */ 2.371 -struct timer_opts timer_tsc = { 2.372 - .name = "tsc", 2.373 - .mark_offset = mark_offset_tsc, 2.374 - .get_offset = get_offset_tsc, 2.375 - .monotonic_clock = monotonic_clock_tsc, 2.376 - .delay = delay_tsc, 2.377 -}; 2.378 - 2.379 -struct init_timer_opts timer_tsc_init = { 2.380 - .init = init_tsc, 2.381 - .opts = &timer_tsc, 2.382 -};