Time: Generic Timekeeping (v.C0)
Subsystems (5)
cover Time: Generic Timekeeping (v.C0)
All,
So after after the last round of feedback on this series, I've
gone back to the drawing board and have tried to further cut the patch set down to the bare minimum.
I've realized that much of the trouble getting this into mainline have come from my falling into the well known "here's a new subsystem that duplicates the old one, but is better and cleaner and fixes bugs" trap. Thus now I'm trying the time-tested "fix what is there with small patches" method (which I would have used from the start, but I didn't think I could make such drastic changes without breaking everyone first).
The majority of this new incremental design should be credited to Roman Zippel, but it is my implementation, so he gets the credit and I get the blame. :)
This is the rough first cut, so it will probably need a few extra passes to be cleaned up and ready for mainline. And while there should not be any behaviour changes, since this method also affects all arches from the start, extra testing will be needed to make sure it has been done correctly. Also more work is needed before this can be re-integrated w/ the -RT tree, as timekeeping is still done from interrupt context.
Summary:
This patchset provides a generic timekeeping interfaces that
are independent of the timer interrupt. This allows for robust and correct behavior in cases of late or lost ticks, avoids interpolation errors, reduces duplication in arch specific code, and allows or assists future changes such as high-res timers, dynamic ticks, or realtime preemption. Additionally, it provides finer nanosecond resolution values to the clock_gettime functions.
Changes since the B20 release:
o Threw out old NTP changes
o Threw out all code cleanups
o New minimal core implementation for all arches
o Added sysfs clocksource fix
o Added slow TSC detection
On my TODO list:
o Get x86-64 and powerpc patches back up and running
o Try to restore cleanups via small patches
The patchset applies against the current 2.6.16-rc6-git.
The complete patchset can be found here:
http://sr71.net/~jstultz/tod/
I'd like to thank the following people who have contributed ideas, criticism, testing and code that has helped shape this work:
George Anzinger, Nish Aravamudan, Max Asbock, Serge Belyshev,
Dominik Brodowski, Adrian Bunk, Thomas Gleixner, Darren Hart, Christoph Lameter, Matt Mackal, Keith Mannthey, Ingo Molnar, Andrew Morton, Paul Munt, Martin Schwidefsky, Frank Sorenson, Ulrich Windl, Jonathan Woithe, Darrick Wong, Roman Zippel and any others whom I've accidentally left off this list.
thanks
-john
PATCH 1/10 Time: Clocksource Infrastructure
This introduces the clocksource management infrastructure. A
clocksource is a driver-like architecture generic abstraction of a free-running counter. This code defines the clocksource structure, and provides management code for registering, selecting, accessing and scaling clocksources.
Additionally, this includes the trivial jiffies clocksource, a lowest common denominator clocksource, provided mainly for use as an example.
Documentation/kernel-parameters.txt | 14 + include/linux/clocksource.h | 269 ++++++++++++++++++++++++++++ kernel/time/Makefile | 1 kernel/time/clocksource.c | 343 ++++++++++++++++++++++++++++++++++++ kernel/time/jiffies.c | 73 +++++++ 5 files changed, 696 insertions(+), 4 deletions(-)
linux-2.6.16-rc6_timeofday-clocksource-core_C0.patch
============================================
Documentation/kernel-parameters.txt +10 -4
@@ -52,6 +52,7 @@ restrictions referred to are that the re MTD MTD support is enabled. NET Appropriate network support is enabled. NUMA NUMA support is enabled. + GENERIC_TIME The generic timeofday code is enabled. NFS Appropriate NFS support is enabled. OSS OSS sound support is enabled. PARIDE The ParIDE subsystem is enabled.
@@ -329,10 +330,11 @@ running once the system is up. Value can be changed at runtime via /selinux/checkreqprot. - clock= [BUGS=IA-32,HW] gettimeofday timesource override. - Forces specified timesource (if avaliable) to be used - when calculating gettimeofday(). If specicified - timesource is not avalible, it defaults to PIT. + clock= [BUGS=IA-32, HW] gettimeofday clocksource override. + [Deprecated] + Forces specified clocksource (if avaliable) to be used + when calculating gettimeofday(). If specified + clocksource is not avalible, it defaults to PIT. Format: { pit | tsc | cyclone | pmtmr } disable_8254_timer
@@ -1579,6 +1581,10 @@ running once the system is up. time Show timing data prefixed to each printk message line + clocksource= [GENERIC_TIME] Override the default clocksource + Override the default clocksource and use the clocksource + with the name specified. + tipar.timeout= [HW,PPT] Set communications timeout in tenths of a second (default 15).
include/linux/clocksource.h new file +269 -0
269 lines not on this page · raw message
kernel/time/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += clocksource.o jiffies.o
kernel/time/clocksource.c new file +343 -0
343 lines not on this page · raw message
kernel/time/jiffies.c new file +73 -0
73 lines not on this page · raw message
PATCH 2/10 Time: Use clocksource infrastructure for update_wall_time
In reply to john stultz This patch modifies the update_wall_time function so it
increments time using the clocksource abstraction instead of jiffies. Since the only clocksource driver currently provided is the jiffies clocksource, this should result in no functional change. Additionally, a timekeeping_init and timekeeping_resume function has been added to initialize and maintain some of the new timekeping state.
Signed-off-by John Stultz <[email protected]>
include/linux/time.h | 2 + init/main.c | 1 kernel/Makefile | 1 kernel/timer.c | 89 +++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 80 insertions(+), 13 deletions(-)
linux-2.6.16-rc6_timeofday-core1_C0.patch
============================================
include/linux/time.h +2 -0
@@ -83,6 +83,8 @@ extern struct timespec xtime;extern struct timespec wall_to_monotonic;extern seqlock_t xtime_lock; +void timekeeping_init (void ); +static inline unsigned long get_seconds (void ) {return xtime.tv_sec;
init/main.c +1 -0
@@ -486,6 +486,7 @@ asmlinkage void __init start_kernel(voidhrtimers_init ();softirq_init ();time_init (); +timekeeping_init ();/* * HACK ALERT! This is early. We're enabling the console before
kernel/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-y = sched.o fork.o exec_domain.o kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o +obj-y += time/ obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/timer.c +76 -13
110 lines not on this page · raw message
PATCH 3/10 Time: Let user request precision from current_tick_length()
In reply to john stultz Change the current_tick_length() function so it takes an
argument which specifies how much precision to return in shifted nanoseconds. This provides a simple way to convert between NTPs internal nanoseconds shifted by (SHIFT_SCALE - 10) to other shifted nanosecond units that are used by the clocksource abstraction.
Signed-off-by John Stultz <[email protected]>
arch/powerpc/kernel/time.c | 2 +- include/linux/timex.h | 2 +- kernel/timer.c | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-)
linux-2.6.16-rc6_timeofday-core2_C0.patch
============================================
arch/powerpc/kernel/time.c +1 -1
@@ -315,7 +315,7 @@ static __inline__ void timer_recalc_offsif (__USE_RTC ())return ; - tlen =current_tick_length (); + tlen =current_tick_length (SHIFT_SCALE -10 ); offset = cur_tb - do_gtod.varp->tb_orig_stamp;if (tlen == last_tick_len && offset <0x80000000u )return ;
include/linux/timex.h +1 -1
@@ -346,7 +346,7 @@ time_interpolator_reset(void)#endif /* !CONFIG_TIME_INTERPOLATION */ /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ -extern u64 current_tick_length (void ); +extern u64 current_tick_length (long );#endif /* KERNEL */
kernel/timer.c +17 -4
@@ -791,16 +791,29 @@ static void update_wall_time_one_tick(vo* Return how long ticks are at the moment, that is, how much time * update_wall_time_one_tick will add to xtime next time we call it * (assuming no calls to do_adjtimex in the meantime). -* The return value is in fixed-point nanoseconds with SHIFT_SCALE-10 -* bits to the right of the binary point. +* The return value is in fixed-point nanoseconds shifted by the +* specified number of bits to the right of the binary point. * This function has no side-effects. */ -u64 current_tick_length (void ) +u64 current_tick_length (long shift) {long delta_nsec; +u64 ret; +/* calculate the finest interval NTP will allow. +* ie: nanosecond value shifted by (SHIFT_SCALE - 10) +*/ delta_nsec = tick_nsec +adjtime_adjustment () *1000 ; -return ((u64 ) delta_nsec << (SHIFT_SCALE -10 )) + time_adj; + ret = ((u64 ) delta_nsec << (SHIFT_SCALE -10 )) + time_adj; + +/* convert from (SHIFT_SCALE - 10) to specified shift scale: */ + shift = shift - (SHIFT_SCALE -10 ); +if (shift <0 ) + ret >>= -shift; +else + ret <<= shift; + +return ret; }/* XXX - all of this timekeeping code should be later moved to time.c */
PATCH 4/10 Time: Use clocksource abstraction for NTP adjustments
In reply to john stultz Instead of incrementing xtime by tick_nsec + ntp adjustments,
use the clocksource abstraction. This removes the need to keep time_phase adjustments as we just use the current_tick_length() function and accumulate using shifted nanoseconds.
By using the clocksource abstraction to increment time, this allows other clocksources to be used consistently in the face of late or lost ticks, while preserving the existing behavior via the jiffies clocksource.
timer.c | 49 ++++++++++++++++++++++++++++++------------------- 1 files changed, 30 insertions(+), 19 deletions(-)
linux-2.6.16-rc6_timeofday-core3_C0.patch
============================================
kernel/timer.c +30 -19
@@ -599,7 +599,6 @@ long time_tolerance = MAXFREQ; /* frequlong time_precision =1 ;/* clock precision (us) */ long time_maxerror =NTP_PHASE_LIMIT ;/* maximum error (us) */ long time_esterror =NTP_PHASE_LIMIT ;/* estimated error (us) */ -static long time_phase;/* phase offset (scaled us) */ long time_freq = (((NSEC_PER_SEC +HZ /2 ) %HZ -HZ /2 ) <<SHIFT_USEC ) /NSEC_PER_USEC ;/* frequency offset (scaled ppm)*/ static long time_adj;/* tick adjust (scaled 1 / HZ) */
@@ -758,27 +757,14 @@ static long adjtime_adjustment(void) }/* in the NTP reference this is called "hardclock()" */ -static void update_wall_time_one_tick (void ) +static void update_ntp_one_tick (void ) { -long time_adjust_step, delta_nsec; +long time_adjust_step; time_adjust_step =adjtime_adjustment ();if (time_adjust_step)/* Reduce by this step the amount of time left */ time_adjust -= time_adjust_step; - delta_nsec = tick_nsec + time_adjust_step *1000 ; -/* -* Advance the phase, once it gets to one microsecond, then -* advance the tick more. -*/ - time_phase += time_adj; -if ((time_phase >=FINENSEC ) || (time_phase <= -FINENSEC )) { -long ltemp =shift_right (time_phase, (SHIFT_SCALE -10 )); - time_phase -= ltemp << (SHIFT_SCALE -10 ); - delta_nsec += ltemp; - } - xtime.tv_nsec += delta_nsec; -time_interpolator_update (delta_nsec);/* Changes by adjtime() do not take effect till next tick. */ if (time_next_adjust !=0 ) {
@@ -883,8 +869,13 @@ device_initcall(timekeeping_init_device)*/ static void update_wall_time (void ) { +static s64 remainder_snsecs, error; +s64 snsecs_per_sec;cycle_t now, offset; + snsecs_per_sec = (s64 )NSEC_PER_SEC << clock->shift; + remainder_snsecs += (s64 )xtime.tv_nsec << clock->shift; + now =read_clocksource (clock); offset = (now - last_clock_cycle)&clock->mask;
@@ -892,13 +883,33 @@ static void update_wall_time(void)* case of lost or late ticks, it will accumulate correctly. */ while (offset > clock->interval_cycles) { -update_wall_time_one_tick (); -if (xtime.tv_nsec >=1000000000 ) { - xtime.tv_nsec -=1000000000 ; +s64 ntp_snsecs =current_tick_length (clock->shift); + +/* increment the last cycle, offset and remainder snsec vals */ + last_clock_cycle += clock->interval_cycles; + offset -= clock->interval_cycles; + remainder_snsecs += clock->interval_snsecs; + +/* accumulate error between NTP and clock tick interval */ + error += (ntp_snsecs - (s64 )clock->interval_snsecs); + +/* interpolator bits */ +time_interpolator_update (clock->interval_snsecs + >> clock->shift); + +update_ntp_one_tick (); + +/* correct the clock when NTP error is too big */ + remainder_snsecs +=make_ntp_adj (clock, offset, &error); + +if (remainder_snsecs >= snsecs_per_sec) { + remainder_snsecs -= snsecs_per_sec; xtime.tv_sec++;second_overflow (); } } + xtime.tv_nsec = remainder_snsecs >> clock->shift; + remainder_snsecs -= (s64 )xtime.tv_nsec << clock->shift; }/*
PATCH 5/10 Time: Introduce arch generic time accessors
In reply to john stultz Introduces clocksource switching code and the arch generic time
accessor functions that use the clocksource infrastructure.
include/linux/time.h | 14 ++++ kernel/time.c | 2 kernel/timer.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+)
linux-2.6.16-rc6_timeofday-core4_C0.patch
============================================
include/linux/time.h +14 -0
@@ -149,6 +149,20 @@ extern struct timespec ns_to_timespec(co*/ extern struct timeval ns_to_timeval (const nsec_t nsec); +/** +* timespec_add_ns - Adds nanoseconds to a timespec +* @a: pointer to timespec to be incremented +* @ns: unsigned nanoseconds value to be added +*/ +static inline void timespec_add_ns (struct timespec *a,u64 ns) +{ + ns += a->tv_nsec; +while (unlikely (ns >=NSEC_PER_SEC )) { + ns -=NSEC_PER_SEC ; + a->tv_sec++; + } + a->tv_nsec = ns; +}#endif /* __KERNEL__ */ #define NFDBITS __NFDBITS
kernel/time.c +2 -0
@@ -550,6 +550,7 @@ EXPORT_SYMBOL(do_gettimeofday);#else +#ifndef CONFIG_GENERIC_TIME /* * Simulate gettimeofday using do_gettimeofday which only allows a timeval * and therefore only yields usec accuracy
@@ -564,6 +565,7 @@ void getnstimeofday(struct timespec *tv) }EXPORT_SYMBOL_GPL (getnstimeofday);#endif +#endif /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
kernel/timer.c +151 -0
163 lines not on this page · raw message
PATCH 6/10 Time: i386 Conversion - part 1: Move timer_pit.c to i8253.c
In reply to john stultz This patch is just a simple cleanup for the i386 arch in
preparation of moving to the generic timeofday infrastructure. It simply moves the PIT initialization code, locks, and other code we want to keep from some code from timer_pit.c (which will be removed) to i8253.c.
thanks
-john
Makefile | 2 +- i8253.c | 32 ++++++++++++++++++++++++++++++++ time.c | 5 ----- timers/timer_pit.c | 13 ------------- 4 files changed, 33 insertions(+), 19 deletions(-)
linux-2.6.16-rc6_timeofday-arch-i386-part1_C0.patch
============================================
arch/i386/kernel/Makefile +1 -1
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.ld obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ - quirks.o i8237.o topology.o + quirks.o i8237.o i8253.o topology.o obj-y += cpu/ obj-y += timers/
arch/i386/kernel/i8253.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* i8253.c 8253/PIT functions +* +*/ +#include <linux/spinlock.h> +#include <linux/jiffies.h> +#include <linux/sysdev.h> +#include <linux/module.h> +#include <linux/init.h> + +#include <asm/smp.h> +#include <asm/delay.h> +#include <asm/i8253.h> +#include <asm/io.h> + +#include "io_ports.h" + +DEFINE_SPINLOCK (i8253_lock); +EXPORT_SYMBOL (i8253_lock); + +void setup_pit_timer (void ) +{ +unsigned long flags; + +spin_lock_irqsave (&i8253_lock, flags); +outb_p (0x34 ,PIT_MODE );/* binary, mode 2, LSB/MSB, ch 0 */ +udelay (10 ); +outb_p (LATCH &0xff ,PIT_CH0 );/* LSB */ +udelay (10 ); +outb (LATCH >>8 ,PIT_CH0 );/* MSB */ +spin_unlock_irqrestore (&i8253_lock, flags); +}
arch/i386/kernel/time.c +0 -5
@@ -82,11 +82,6 @@ extern unsigned long wall_jiffies;DEFINE_SPINLOCK (rtc_lock);EXPORT_SYMBOL (rtc_lock); -#include <asm/i8253.h> - -DEFINE_SPINLOCK (i8253_lock); -EXPORT_SYMBOL (i8253_lock); -struct timer_opts *cur_timer__read_mostly = &timer_none;/*
arch/i386/kernel/timers/timer_pit.c +0 -13
@@ -162,16 +162,3 @@ struct init_timer_opts __initdata timer_ .init = init_pit, .opts = &timer_pit, }; - -void setup_pit_timer (void ) -{ -unsigned long flags; - -spin_lock_irqsave (&i8253_lock, flags); -outb_p (0x34 ,PIT_MODE );/* binary, mode 2, LSB/MSB, ch 0 */ -udelay (10 ); -outb_p (LATCH &0xff ,PIT_CH0 );/* LSB */ -udelay (10 ); -outb (LATCH >>8 ,PIT_CH0 );/* MSB */ -spin_unlock_irqrestore (&i8253_lock, flags); -}
PATCH 7/10 Time: i386 Conversion - part 2: Rework TSC Support
In reply to john stultz As part of the i386 conversion to the generic timekeeping
infrastructure, this introduces a new tsc.c file. The code in this file replaces the TSC initialization, management and access code currently in timer_tsc.c (which will be removed) that we want to preserve.
The code also introduces the following functionality:
o tsc_khz: like cpu_khz but stores the TSC frequency on systems that do not change TSC frequency w/ CPU frequency
o check/mark_tsc_unstable: accessor/modifier flag for TSC timekeeping usability
o minor cleanups to calibration math.
This patch also includes a one line __cpuinitdata fix from Zwane Mwaikambo.
thanks
-john
arch/i386/kernel/Makefile | 2 arch/i386/kernel/numaq.c | 10 arch/i386/kernel/setup.c | 1 arch/i386/kernel/timers/timer_tsc.c | 178 --------------- arch/i386/kernel/tsc.c | 316 ++++++++++++++++++++++++++++ drivers/acpi/processor_idle.c | 9 include/asm-i386/mach-default/mach_timer.h | 4 include/asm-i386/mach-summit/mach_mpparse.h | 3 include/asm-i386/timex.h | 34 --- include/asm-i386/tsc.h | 49 ++++ 10 files changed, 389 insertions(+), 217 deletions(-)
linux-2.6.16-rc6_timeofday-arch-i386-part2_C0.patch
============================================
arch/i386/kernel/Makefile +1 -1
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.ld obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ - quirks.o i8237.o i8253.o topology.o + quirks.o i8237.o i8253.o tsc.o topology.o obj-y += cpu/ obj-y += timers/
arch/i386/kernel/numaq.c +6 -4
@@ -79,10 +79,12 @@ int __init get_memcfg_numaq(void)return 1 ; } -static int __init numaq_dsc_disable (void ) +static int __init numaq_tsc_disable (void ) { -printk (KERN_DEBUG "NUMAQ: disabling TSC\n" ); - tsc_disable =1 ; +if (num_online_nodes () >1 ) { +printk (KERN_DEBUG "NUMAQ: disabling TSC\n" ); + tsc_disable =1 ; + }return 0 ; } -core_initcall (numaq_dsc_disable); +arch_initcall (numaq_tsc_disable);
arch/i386/kernel/setup.c +1 -0
@@ -1632,6 +1632,7 @@ void __init setup_arch(char **cmdline_p) conswitchp = &dummy_con;#endif #endif +tsc_init (); }#include "setup_arch_post.h"
arch/i386/kernel/timers/timer_tsc.c +0 -178
208 lines not on this page · raw message
arch/i386/kernel/tsc.c new file +316 -0
316 lines not on this page · raw message
drivers/acpi/processor_idle.c +9 -0
@@ -369,6 +369,11 @@ static void acpi_processor_idle(void) t2 =inl (acpi_fadt.xpm_tmr_blk.address);/* Get end time (ticks) */ t2 =inl (acpi_fadt.xpm_tmr_blk.address); + +#ifdef CONFIG_GENERIC_TIME +/* TSC halts in C2, so notify users */ +mark_tsc_unstable (); +#endif /* Re-enable interrupts */ local_irq_enable ();set_thread_flag (TIF_POLLING_NRFLAG );
@@ -409,6 +414,10 @@ static void acpi_processor_idle(void) ACPI_MTX_DO_NOT_LOCK); } +#ifdef CONFIG_GENERIC_TIME +/* TSC halts in C3, so notify users */ +mark_tsc_unstable (); +#endif /* Re-enable interrupts */ local_irq_enable ();set_thread_flag (TIF_POLLING_NRFLAG );
include/asm-i386/mach-default/mach_timer.h +3 -1
@@ -15,7 +15,9 @@#ifndef _MACH_TIMER_H#define _MACH_TIMER_H -#define CALIBRATE_LATCH (5 * LATCH) +#define CALIBRATE_TIME_MSEC 30/* 30 msecs */ +#define CALIBRATE_LATCH \ + ((CLOCK_TICK_RATE * CALIBRATE_TIME_MSEC + 1000/2)/1000)static inline void mach_prepare_counter (void ) {
include/asm-i386/mach-summit/mach_mpparse.h +3 -0
@@ -2,6 +2,7 @@#define __ASM_MACH_MPPARSE_H#include <mach_apic.h> +#include <asm/tsc.h> extern int use_cyclone;
@@ -29,6 +30,7 @@ static inline int mps_oem_check(struct m (!strncmp(productid, "VIGIL SMP", 9) || !strncmp(productid, "EXA", 3) || !strncmp(productid, "RUTHLESS SMP", 12))){ +mark_tsc_unstable (); use_cyclone =1 ;/*enable cyclone-timer*/ setup_summit ();return 1 ;
@@ -42,6 +44,7 @@ static inline int acpi_madt_oem_check(chif (!strncmp (oem_id,"IBM" ,3 ) && (!strncmp (oem_table_id,"SERVIGIL" ,8 ) || !strncmp (oem_table_id,"EXA" ,3 ))){ +mark_tsc_unstable (); use_cyclone =1 ;/*enable cyclone-timer*/ setup_summit ();return 1 ;
include/asm-i386/timex.h +1 -33
@@ -8,6 +8,7 @@#include <linux/config.h> #include <asm/processor.h> +#include <asm/tsc.h> #ifdef CONFIG_X86_ELAN # define CLOCK_TICK_RATE 1189200/* AMD Elan has different frequency! */
@@ -16,39 +17,6 @@#endif -/* -* Standard way to access the cycle counter on i586+ CPUs. -* Currently only used on SMP. -* -* If you really have a SMP machine with i486 chips or older, -* compile for that, and this will just always return zero. -* That's ok, it just means that the nicer scheduling heuristics -* won't work for you. -* -* We only use the low 32 bits, and we'd simply better make sure -* that we reschedule before that wraps. Scheduling at least every -* four billion cycles just basically sounds like a good idea, -* regardless of how fast the machine is. -*/ -typedef unsigned long long cycles_t ; - -static inline cycles_t get_cycles (void ) -{ -unsigned long long ret=0 ; - -#ifndef CONFIG_X86_TSC -if (!cpu_has_tsc) -return 0 ; -#endif - -#if defined(CONFIG_X86_GENERIC ) || defined(CONFIG_X86_TSC ) -rdtscll (ret); -#endif -return ret; -} - -extern unsigned int cpu_khz; -extern int read_current_timer (unsigned long *timer_value);#define ARCH_HAS_READ_CURRENT_TIMER 1
include/asm-i386/tsc.h new file +49 -0
49 lines not on this page · raw message
PATCH 8/10 Time: i386 Conversion - part 3: Enable Generic Timekeeping
In reply to john stultz This converts the i386 arch to use the generic timeofday
subsystem. It enabled the GENERIC_TIME option, disables the timer_opts code and other arch specific timekeeping code and reworks the delay code.
While this patch enables the generic timekeeping, please note that this patch does not provide any i386 clocksource. Thus only the jiffies clocksource will be available. To get full replacements for the code being disabled here, the timeofday-clocks-i386 patch will needed.
thanks
-john
arch/i386/Kconfig | 4 + arch/i386/kernel/Makefile | 1 arch/i386/kernel/time.c | 152 +++++----------------------------------------- arch/i386/kernel/tsc.c | 3 arch/i386/lib/delay.c | 65 +++++++++++++++++-- include/asm-i386/delay.h | 2 include/asm-i386/timer.h | 57 ----------------- 7 files changed, 82 insertions(+), 202 deletions(-)
linux-2.6.16-rc6_timeofday-arch-i386-part3_C0.patch
============================================
arch/i386/Kconfig +4 -0
@@ -14,6 +14,10 @@ config X86_32 486, 586, Pentiums, and various instruction-set-compatible chips by AMD, Cyrix, and others. +config GENERIC_TIME + bool + default y + config SEMAPHORE_SLEEPERS bool default y
arch/i386/kernel/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-y := process.o semaphore.o signal.o quirks.o i8237.o i8253.o tsc.o topology.o obj-y += cpu/ -obj-y += timers/ obj-y += acpi/ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o obj-$(CONFIG_MCA) += mca.o
arch/i386/kernel/time.c +17 -135
222 lines not on this page · raw message
arch/i386/kernel/tsc.c +2 -1
@@ -10,6 +10,7 @@#include <linux/init.h> #include <asm/tsc.h> +#include <asm/delay.h> #include <asm/io.h> #include "mach_timer.h"
@@ -45,7 +46,6 @@ static int __init tsc_setup(char *str)__setup ("notsc" , tsc_setup); -/* * code to mark and check if the TSC is unstable * due to cpufreq or due to unsynced TSCs
@@ -205,6 +205,7 @@ void tsc_init(void) (unsigned long)cpu_khz % 1000);set_cyc2ns_scale (cpu_khz); +use_tsc_delay (); }#ifdef CONFIG_CPU_FREQ
arch/i386/lib/delay.c +57 -8
100 lines not on this page · raw message
include/asm-i386/delay.h +2 -0
@@ -23,4 +23,6 @@ extern void __delay(unsigned long loops) ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ __ndelay(n)) +void use_tsc_delay (void ); +#endif /* defined(_I386_DELAY_H) */
include/asm-i386/timer.h +0 -57
68 lines not on this page · raw message
PATCH 9/10 Time: i386 Conversion - part 4: Remove Old timer_opts Code
In reply to john stultz This patch removes the old timers/timer_opts infrastructure
which has been disabled. It is a fairly straightforward set of deletions
Note that this does not provide any i386 clocksources, so you will only have the jiffies clocksource. To get full replacements for the code being removed here, the timeofday-clocks-i386 patch will be needed.
thanks
-john
Makefile | 9 - common.c | 172 --------------------- timer.c | 75 --------- timer_cyclone.c | 259 --------------------------------- timer_hpet.c | 217 --------------------------- timer_none.c | 39 ---- timer_pit.c | 164 -------------------- timer_pm.c | 268 ---------------------------------- timer_tsc.c | 439 -------------------------------------------------------- 9 files changed, 1642 deletions(-)
linux-2.6.16-rc6_timeofday-arch-i386-part4_C0.patch
============================================
arch/i386/kernel/timers/Makefile deleted +0 -9
@@ -1,9 +0,0 @@ -# -# Makefile for x86 timers -# - -obj-y := timer.o timer_none.o timer_tsc.o timer_pit.o common.o - -obj-$(CONFIG_X86_CYCLONE_TIMER) += timer_cyclone.o -obj-$(CONFIG_HPET_TIMER) += timer_hpet.o -obj-$(CONFIG_X86_PM_TIMER) += timer_pm.o
arch/i386/kernel/timers/common.c deleted +0 -172
172 lines not on this page · raw message
arch/i386/kernel/timers/timer.c deleted +0 -75
75 lines not on this page · raw message
arch/i386/kernel/timers/timer_cyclone.c deleted +0 -259
259 lines not on this page · raw message
arch/i386/kernel/timers/timer_hpet.c deleted +0 -217
217 lines not on this page · raw message
arch/i386/kernel/timers/timer_none.c deleted +0 -39
@@ -1,39 +0,0 @@ -#include <linux/init.h> -#include <asm/timer.h> - -static void mark_offset_none (void ) -{ -/* nothing needed */ -} - -static unsigned long get_offset_none (void ) -{ -return 0 ; -} - -static unsigned long long monotonic_clock_none (void ) -{ -return 0 ; -} - -static void delay_none (unsigned long loops) -{ -int d0; - __asm__ __volatile__( -"\tjmp 1f\n" -".align 16\n" -"1:\tjmp 2f\n" -".align 16\n" -"2:\tdecl %0\n\tjns 2b" - :"=&a" (d0) - :"0" (loops)); -} - -/* none timer_opts struct */ -struct timer_opts timer_none = { - .name ="none" , - .mark_offset = mark_offset_none, - .get_offset = get_offset_none, - .monotonic_clock = monotonic_clock_none, - .delay = delay_none, -};
arch/i386/kernel/timers/timer_pit.c deleted +0 -164
164 lines not on this page · raw message
arch/i386/kernel/timers/timer_pm.c deleted +0 -268
268 lines not on this page · raw message
arch/i386/kernel/timers/timer_tsc.c deleted +0 -439
439 lines not on this page · raw message
PATCH 10/10 Time: i386 Clocksource Drivers
In reply to john stultz This patch implements the time sources for i386 (acpi_pm,
cyclone, hpet, pit, and tsc). With this patch, the conversion of the i386 arch to the generic timekeeping code should be complete.
The patch should be fairly straight forward, only adding the new clocksources.
thanks
-john
arch/i386/kernel/Makefile | 1 arch/i386/kernel/hpet.c | 67 +++++++++++++++++ arch/i386/kernel/i8253.c | 53 +++++++++++++ arch/i386/kernel/tsc.c | 163 ++++++++++++++++++++++++++++++++++++++++++ drivers/Makefile | 1 drivers/clocksource/Makefile | 2 drivers/clocksource/acpi_pm.c | 89 ++++++++++++++++++++++ drivers/clocksource/cyclone.c | 119 ++++++++++++++++++++++++++++++ kernel/time/clocksource.c | 9 +- 9 files changed, 502 insertions(+), 2 deletions(-)
linux-2.6.16-rc6_timeofday-clocks-i386_C0.patch
============================================
arch/i386/kernel/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_EFI) += efi.o efi_stub.o obj-$(CONFIG_DOUBLEFAULT) += doublefault.o obj-$(CONFIG_VM86) += vm86.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o +obj-$(CONFIG_HPET_TIMER) += hpet.o EXTRA_AFLAGS := -traditional
arch/i386/kernel/hpet.c new file +67 -0
67 lines not on this page · raw message
arch/i386/kernel/i8253.c +53 -0
62 lines not on this page · raw message
arch/i386/kernel/tsc.c +163 -0
177 lines not on this page · raw message
drivers/Makefile +1 -0
@@ -73,3 +73,4 @@ obj-$(CONFIG_SGI_SN) += sn/ obj-y += firmware/ obj-$(CONFIG_CRYPTO) += crypto/ obj-$(CONFIG_SUPERH) += sh/ +obj-$(CONFIG_GENERIC_TIME) += clocksource/
drivers/clocksource/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o +obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
drivers/clocksource/acpi_pm.c new file +89 -0
89 lines not on this page · raw message
drivers/clocksource/cyclone.c new file +119 -0
119 lines not on this page · raw message
kernel/time/clocksource.c +7 -2
@@ -335,8 +335,13 @@ __setup("clocksource=", boot_override_cl*/ static int __init boot_override_clock (char * str) { -printk ("Warning! clock= boot option is deprecated.\n" ); - +if (!strcmp (str,"pmtmr" )) { +printk ("Warning: clock=pmtmr is depricated. " +"Use clocksource=acpi_pm.\n" ); +return boot_override_clocksource ("acpi_pm" ); + } +printk ("Warning! clock= boot option is deprecated. " +"Use clocksource=xyz\n" );return boot_override_clocksource (str); }