Convert acked !GENERIC_TIME architectures to use the generic timekeeping core.
Subsystems (3)
cover Convert acked !GENERIC_TIME architectures to use the generic timekeeping core.
Andrew, All,
Its been two and a half years since the GENERIC_TIME infrastructure
landed. It allowed architectures that have free running counters to only have to provide a clocksource driver and leave the rest of the timekeeping management to generic code.
So far out of the 23 architectures we've fully converted 15 of them over to GENERIC_TIME. The remaining 8 have in some cases been able to convert, but not fully. The issue that keeps most architectures from converting is that they do not have free running counters. They instead use the counter on their tick timer to determine their inter-tick time. This counter usually wraps every interrupt, so its not really efficient to use as a clocksource.
This has created some difficulty as the generic timekeeping core has had to deal with both GENERIC_TIME arches as well as !GENERIC_TIME arches, and since it didn't manage 100% of the calculation in the !GENERIC_TIME case, we've been limited in some of the changes we could make.
So since these last remaining architectures are unlikely to be able to fully convert to GENERIC_TIME as it stands, the generic core should try to adopt to their needs so we can bring them into the fold and reduce code duplication.
The solution is to provide a arch callout from the generic timekeeping
core: arch_gettimeoffset(). On architectures that do not provide a clocksource, the jiffies clocksource is used, and arch_gettimeoffset is added in to create finer grained inter-tick time.
The patchset I'm submitting does the following:
1) Introduces the arch_gettimeoffset infrastructure to the timekeeping core.
2) Converts two Acked arches (sh, sparc) to use the arch_gettimeoffset() hook.
I still have patches for the 6 other arches that need to be converted, but have not received acks for them yet. Instead of stalling the patchset for all of those arches, I'm submitting these, so overloaded arch maintainers can convert their arches or take my patches on their schedule without blocking arches that are ready to go.
Once all 8 arches are converted, I'll send a final cleanup patch that removes all conditionals and references to GENERIC_TIME.
Credits to Roman for initially suggesting the idea quite awhile back.
thanks
-john
PATCH 1/3 Create arch_gettimeoffset infrastructure for use in the generic timekeeping core.
Andrew, please consider for inclusion in -mm in preparation for 2.6.30.
Some arches don't supply their own clocksource. This is mainly the case in architectures that get their inter-tick times by reading the counter on their interval timer. Since these timers wrap every tick, they're not really useful as clocksources. Wrapping them to act like one is possible but not very efficient. So we provide a callout these arches can implement for use with the jiffies clocksource to provide finer then tick granular time.
include/linux/time.h +15 -0
@@ -113,6 +113,21 @@ struct timespec current_kernel_time(void);#define CURRENT_TIME (current_kernel_time())#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) +/* Some architectures do not supply their own clocksource. +* This is mainly the case in architectures that get their +* inter-tick times by reading the counter on their interval +* timer. Since these timers wrap every tick, they're not really +* useful as clocksources. Wrapping them to act like one is possible +* but not very efficient. So we provide a callout these arches +* can implement for use with the jiffies clocksource to provide +* finer then tick granular time. +*/ +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET +extern u32 arch_gettimeoffset (void ); +#else +#define arch_gettimeoffset () (0) +#endif +extern void do_gettimeofday (struct timeval *tv);extern int do_settimeofday (struct timespec *tv);extern int do_sys_settimeofday (struct timespec *tv,struct timezone *tz);
kernel/time/timekeeping.c +7 -0
@@ -77,6 +77,10 @@ static void clocksource_forward_now(void) clock->cycle_last = cycle_now; nsec =cyc2ns (clock, cycle_delta); + +/* If arch requires, add in gettimeoffset() */ + nsec +=arch_gettimeoffset (); +timespec_add_ns (&xtime, nsec); nsec = ((s64 )cycle_delta * clock->mult_orig) >> clock->shift;
@@ -111,6 +115,9 @@ void getnstimeofday(struct timespec *ts)/* convert to nanoseconds: */ nsecs =cyc2ns (clock, cycle_delta); +/* If arch requires, add in gettimeoffset() */ + nsecs +=arch_gettimeoffset (); + }while (read_seqretry (&xtime_lock, seq));timespec_add_ns (ts, nsecs);
PATCH 2/3 Convert sh to use arch_getoffset() infrastructure
Andrew, please consider for inclusion into -mm in preparation for 2.6.30
This patch converts sh to use GENERIC_TIME via the arch_getoffset() infrastructure
I do not have cross compilers for these architectures, and in some cases the architectures can be compiles both with and without clocksources. So I've taken my best swing at converting this, but I'm not confident I got it right. Any assistance from arch maintainers or testers would be great.
arch/sh/Kconfig +5 -1
@@ -72,7 +72,7 @@ config GENERIC_IOMAP bool config GENERIC_TIME - def_bool n + def_bool y config GENERIC_CLOCKEVENTS def_bool n
@@ -406,6 +406,10 @@ config SH_TMU help This enables the use of the TMU as the system timer. +config ARCH_USES_GETTIMEOFFSET + def_bool y + depends on !SH_TMU + config SH_CMT def_bool y prompt "CMT timer support"
arch/sh/include/asm/timer.h +2 -2
@@ -10,7 +10,7 @@ struct sys_timer_ops {int (*start)(void );int (*stop)(void );cycle_t (*read)(void); -#ifndef CONFIG_GENERIC_TIME +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET unsigned long (*get_offset)(void );#endif };
@@ -27,7 +27,7 @@ struct sys_timer {extern struct sys_timer tmu_timer, cmt_timer, mtu2_timer;extern struct sys_timer *sys_timer; -#ifndef CONFIG_GENERIC_TIME +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET static inline unsigned long get_timer_offset (void ) {return sys_timer->ops->get_offset ();
arch/sh/kernel/time_32.c +5 -58
77 lines not on this page · raw message
arch/sh/kernel/time_64.c +2 -51
61 lines not on this page · raw message
arch/sh/kernel/timers/timer-cmt.c +1 -1
@@ -178,7 +178,7 @@ static struct sys_timer_ops cmt_timer_ops = { .init = cmt_timer_init, .start = cmt_timer_start, .stop = cmt_timer_stop, -#ifndef CONFIG_GENERIC_TIME +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET .get_offset = cmt_timer_get_offset,#endif };
arch/sh/kernel/timers/timer-mtu2.c +1 -1
@@ -191,7 +191,7 @@ struct sys_timer_ops mtu2_timer_ops = { .init = mtu2_timer_init, .start = mtu2_timer_start, .stop = mtu2_timer_stop, -#ifndef CONFIG_GENERIC_TIME +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET .get_offset = mtu2_timer_get_offset,#endif };
PATCH 3/3 Convert sparc to use arch_getoffset() infrastructure
Andrew, please consider for inclusion into -mm in preparation for 2.6.30
This patch converts sparc to use GENERIC_TIME via the arch_getoffset() infrastructure
I do not have cross compilers for these architectures, and in some cases the architectures can be compiles both with and without clocksources. So I've taken my best swing at converting this, but I'm not confident I got it right. Any assistance from arch maintainers or testers would be great.
arch/sparc/Kconfig +4 -1
@@ -55,8 +55,11 @@ config BITS default 64 if SPARC64 config GENERIC_TIME + def_bool y + +config ARCH_USES_GETTIMEOFFSET bool - default y if SPARC64 + default y if SPARC32 config GENERIC_CMOS_UPDATE bool
arch/sparc/kernel/time_32.c +2 -79
93 lines not on this page · raw message