Skip to contentSkip to conversation

Convert the remaining !GENERIC_TIME architectures to use the full timekeeping core.

RFC PATCH In review john stultz 2 participants 5 messages Dec 9, 2008 – Dec 10, 2008

Subsystems (17)
lore
Share & tools
lore
#0 lore raw

cover Convert the remaining !GENERIC_TIME architectures to use the full timekeeping core.

Hello,
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 is split up into three parts.
1) Introducing the arch_gettimeoffset infrastructure to the timekeeping core.
2) Converting the remaining arches over to use arch_gettimeoffset()
3) Finally, Removing all conditionals and references to GENERIC_TIME.

The full patchset reduces the kernel by about 550 lines.

 43 files changed, 141 insertions(+), 701 deletions(-)

Any thoughts or feedback would be appreciated. I've been unable to test the arch conversions, so any help in getting those right would be appreciated. I expect this will probably take a few tries.

And credit to Roman for initially suggesting the idea quite awhile back.

thanks
-john

#1 lore raw

RFC PATCH 1/3 Create arch_gettimeoffset infrastructure for use in the generic timekeeping core.

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
index ce321ac..b0ea1d5 100644
@@ -112,6 +112,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
index fa05e88..087a783 100644
@@ -74,6 +74,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;
@@ -106,6 +110,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);
#2 lore raw

RFC PATCH 2/3 Convert !GENERIC_TIME arches to use arch_getoffset() infrastructure.

This converts the following arches to use the arch_getoffset() infrastructure, finally bringing them into the GENERIC_TIME fold:

arm
blackfin
cris
m32r
m68k
sh
sparc
xtensa

I have split out patches for each arch, but I'm sending out the megapatch to keep the RFC patchlist short.

I do not have cross compilers for these architectures, and in some cases (like arm, and sh) 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/arm/Kconfig +24 -15
index 9722f8b..ed4c53b 100644
@@ -38,6 +38,10 @@ config GENERIC_GPIO
 
 config GENERIC_TIME
 	bool
+	default y
+
+config USES_CLOCKSOURCES
+	bool
 	default n
 
 config GENERIC_CLOCKEVENTS
@@ -219,7 +223,7 @@ config ARCH_REALVIEW
 	select ARM_AMBA
 	select HAVE_CLK
 	select ICST307
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	help
 	  This enables support for ARM Ltd RealView boards.
@@ -230,7 +234,7 @@ config ARCH_VERSATILE
 	select ARM_VIC
 	select HAVE_CLK
 	select ICST307
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	help
 	  This enables support for ARM Ltd Versatile board.
@@ -299,7 +303,7 @@ config ARCH_H720X
 config ARCH_IMX
 	bool "IMX"
 	select GENERIC_GPIO
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Motorola's i.MX family of processors (MX1, MXL).
@@ -353,7 +357,7 @@ config ARCH_IXP4XX
 	bool "IXP4xx-based"
 	depends on MMU
 	select GENERIC_GPIO
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select DMABOUNCE if PCI
 	help
@@ -375,7 +379,7 @@ config ARCH_L7200
 config ARCH_KIRKWOOD
 	bool "Marvell Kirkwood"
 	select PCI
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select PLAT_ORION
 	help
@@ -392,7 +396,7 @@ config ARCH_KS8695
 config ARCH_NS9XXX
 	bool "NetSilicon NS9xxx"
 	select GENERIC_GPIO
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
@@ -403,7 +407,7 @@ config ARCH_NS9XXX
 
 config ARCH_LOKI
 	bool "Marvell Loki (88RC8480)"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select PLAT_ORION
 	help
@@ -412,7 +416,7 @@ config ARCH_LOKI
 config ARCH_MV78XX0
 	bool "Marvell MV78xx0"
 	select PCI
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select PLAT_ORION
 	help
@@ -421,7 +425,7 @@ config ARCH_MV78XX0
 
 config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select ARCH_MTD_XIP
 	select GENERIC_GPIO
@@ -434,7 +438,7 @@ config ARCH_ORION5X
 	depends on MMU
 	select PCI
 	select GENERIC_GPIO
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select PLAT_ORION
 	help
@@ -455,7 +459,7 @@ config ARCH_PXA
 	select GENERIC_GPIO
 	select HAVE_CLK
 	select ARCH_REQUIRE_GPIOLIB
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	help
@@ -481,7 +485,7 @@ config ARCH_SA1100
 	select ARCH_SPARSEMEM_ENABLE
 	select ARCH_MTD_XIP
 	select GENERIC_GPIO
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select TICK_ONESHOT
@@ -520,7 +524,7 @@ config ARCH_LH7A40X
 
 config ARCH_DAVINCI
 	bool "TI DaVinci"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select ARCH_REQUIRE_GPIOLIB
@@ -534,14 +538,14 @@ config ARCH_OMAP
 	select GENERIC_GPIO
 	select HAVE_CLK
 	select ARCH_REQUIRE_GPIOLIB
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for TI's OMAP platform (OMAP1 and OMAP2).
 
 config ARCH_MSM
 	bool "Qualcomm MSM"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Qualcomm MSM7K based systems.  This runs on the ARM11
@@ -1287,3 +1291,8 @@ source "security/Kconfig"
 source "crypto/Kconfig"
 
 source "lib/Kconfig"
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+	depends on !USES_CLOCKSOURCES
+
arch/arm/include/asm/mach/time.h +1 -1
index b2cc1fc..20c1d84 100644
@@ -38,7 +38,7 @@ struct sys_timer {
 	void			(*init)(void);
 	void			(*suspend)(void);
 	void			(*resume)(void);
-#ifndef CONFIG_GENERIC_TIME
+#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
 	unsigned long		(*offset)(void);
 #endif
 };
arch/arm/kernel/time.c +6 -57

83 lines not on this page · raw message

arch/arm/mach-at91/Kconfig +7 -7
index 5aafb2e..3b3815b 100644
@@ -7,37 +7,37 @@ choice
 
 config ARCH_AT91RM9200
 	bool "AT91RM9200"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91SAM9260
 	bool "AT91SAM9260 or AT91SAM9XE"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91SAM9261
 	bool "AT91SAM9261"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91SAM9263
 	bool "AT91SAM9263"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91SAM9RL
 	bool "AT91SAM9RL"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91SAM9G20
 	bool "AT91SAM9G20"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91CAP9
 	bool "AT91CAP9"
-	select GENERIC_TIME
+	select USES_CLOCKSOURCES
 	select GENERIC_CLOCKEVENTS
 
 config ARCH_AT91X40
arch/blackfin/Kconfig +5 -2
index 29e71ed..38e8996 100644
@@ -458,8 +458,7 @@ comment "Kernel Timer/Scheduler"
 source kernel/Kconfig.hz
 
 config GENERIC_TIME
-	bool "Generic time"
-	default y
+	def_bool y
 
 config GENERIC_CLOCKEVENTS
 	bool "Generic clock events"
@@ -479,6 +478,10 @@ config CYCLES_CLOCKSOURCE
 	  still be able to read it (such as for performance monitoring), but
 	  writing the registers will most likely crash the kernel.
 
+config ARCH_USES_GETTIMEOFFSET
+	depends on !CYCLES_CLOCKSOURCE
+	def_bool y
+
 source kernel/time/Kconfig
 
 comment "Misc"
arch/blackfin/kernel/time.c +18 -75

116 lines not on this page · raw message

arch/cris/Kconfig +6 -0
index b17aeea..edf8f7f 100644
@@ -20,6 +20,12 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	bool
 
+config GENERIC_TIME
+	def_bool y
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+
 config GENERIC_IOMAP
        bool
        default y
arch/cris/kernel/time.c +2 -66

77 lines not on this page · raw message

arch/m32r/Kconfig +6 -0
index dbaed4a..f10e315 100644
@@ -40,6 +40,12 @@ config HZ
 	int
 	default 100
 
+config GENERIC_TIME
+	def_bool y
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
arch/m32r/kernel/time.c +3 -71

95 lines not on this page · raw message

arch/m68k/Kconfig +6 -0
index 836fb66..9fd83da 100644
@@ -58,6 +58,12 @@ config HZ
 	int
 	default 100
 
+config GENERIC_TIME
+	def_bool y
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+
 mainmenu "Linux/68k Kernel Configuration"
 
 source "init/Kconfig"
arch/m68k/kernel/time.c +2 -67

74 lines not on this page · raw message

arch/sh/Kconfig +5 -1
index 80119b3..2bc451f 100644
@@ -69,7 +69,7 @@ config GENERIC_IOMAP
 	bool
 
 config GENERIC_TIME
-	def_bool n
+	def_bool y
 
 config GENERIC_CLOCKEVENTS
 	def_bool n
@@ -391,6 +391,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
index a7ca3a1..da122a3 100644
@@ -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
index c127293..6c729db 100644
@@ -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
index fe453c0..22d0c6f 100644
@@ -186,7 +186,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
 };
arch/sparc/Kconfig +6 -0
index e594559..76b5008 100644
@@ -35,6 +35,12 @@ config HZ
 	int
 	default 100
 
+config GENERIC_TIME
+	def_bool y
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
arch/sparc/kernel/time.c +2 -79

93 lines not on this page · raw message

arch/xtensa/Kconfig +6 -0
index 6c873dc..ea3fdfe 100644
@@ -54,6 +54,12 @@ config HZ
 	int
 	default 100
 
+config GENERIC_TIME
+	def_bool y
+
+config ARCH_USES_GETTIMEOFFSET
+	def_bool y
+
 source "init/Kconfig"
 source "kernel/Kconfig.freezer"
 
arch/xtensa/kernel/time.c +4 -59

72 lines not on this page · raw message

#3 lore raw

RFC PATCH 3/3 Remove CONFIG_GENERIC_TIME

This removes all references to CONFIG_GENERIC_TIME in the timekeeping core as well as the arch Kconfig files.

Arch defconfig files were left alone.

arch/arm/Kconfig +0 -4
index ed4c53b..a859f28 100644
@@ -36,10 +36,6 @@ config GENERIC_GPIO
 	bool
 	default n
 
-config GENERIC_TIME
-	bool
-	default y
-
 config USES_CLOCKSOURCES
 	bool
 	default n
arch/avr32/Kconfig +0 -3
index 26eca87..f856283 100644
@@ -45,9 +45,6 @@ config GENERIC_IRQ_PROBE
 config RWSEM_GENERIC_SPINLOCK
 	def_bool y
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_CLOCKEVENTS
 	def_bool y
 
arch/blackfin/Kconfig +0 -4
index 38e8996..c724053 100644
@@ -457,12 +457,8 @@ comment "Kernel Timer/Scheduler"
 
 source kernel/Kconfig.hz
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_CLOCKEVENTS
 	bool "Generic clock events"
-	depends on GENERIC_TIME
 	default y
 
 config CYCLES_CLOCKSOURCE
arch/cris/Kconfig +0 -3
index edf8f7f..a859438 100644
@@ -20,9 +20,6 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	bool
 
-config GENERIC_TIME
-	def_bool y
-
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
arch/frv/Kconfig +0 -4
index 9d1552a..42c3497 100644
@@ -38,10 +38,6 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config TIME_LOW_RES
 	bool
 	default y
arch/h8300/Kconfig +0 -4
index 28f06fd..da58658 100644
@@ -58,10 +58,6 @@ config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_BUG
         bool
         depends on BUG
arch/ia64/Kconfig +0 -4
index 6bd91ed..aa9f1a2 100644
@@ -76,10 +76,6 @@ config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_TIME_VSYSCALL
 	bool
 	default y
arch/m32r/Kconfig +0 -3
index f10e315..f2f8883 100644
@@ -40,9 +40,6 @@ config HZ
 	int
 	default 100
 
-config GENERIC_TIME
-	def_bool y
-
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
arch/m68k/Kconfig +0 -3
index 9fd83da..988a734 100644
@@ -58,9 +58,6 @@ config HZ
 	int
 	default 100
 
-config GENERIC_TIME
-	def_bool y
-
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
arch/m68knommu/Kconfig +0 -4
index 76b66fe..cc673c3 100644
@@ -54,10 +54,6 @@ config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_CMOS_UPDATE
 	bool
 	default y
arch/mips/Kconfig +0 -4
index f4af967..cc3754b 100644
@@ -645,10 +645,6 @@ config GENERIC_CLOCKEVENTS
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_CMOS_UPDATE
 	bool
 	default y
arch/mn10300/Kconfig +0 -3
index 9a9f433..0792a47 100644
@@ -41,9 +41,6 @@ config GENERIC_FIND_NEXT_BIT
 config GENERIC_HWEIGHT
 	def_bool y
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_BUG
 	def_bool y
 
arch/parisc/Kconfig +0 -4
index 644a70b..d6140de 100644
@@ -59,10 +59,6 @@ config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
 
-config GENERIC_TIME
-	bool
-	default y
-
 config TIME_LOW_RES
 	bool
 	depends on SMP
arch/powerpc/Kconfig +0 -3
index 525c13a..68d165a 100644
@@ -29,9 +29,6 @@ config MMU
 config GENERIC_CMOS_UPDATE
 	def_bool y
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_TIME_VSYSCALL
 	def_bool y
 
arch/s390/Kconfig +0 -3
index 8116a33..e9db7c6 100644
@@ -40,9 +40,6 @@ config ARCH_HAS_ILOG2_U64
 config GENERIC_HWEIGHT
 	def_bool y
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_CLOCKEVENTS
 	def_bool y
 
arch/sh/Kconfig +0 -4
index 2bc451f..b358f10 100644
@@ -68,9 +68,6 @@ config GENERIC_CALIBRATE_DELAY
 config GENERIC_IOMAP
 	bool
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_CLOCKEVENTS
 	def_bool n
 
@@ -386,7 +383,6 @@ config SH_TMU
 	def_bool y
 	prompt "TMU timer support"
 	depends on CPU_SH3 || CPU_SH4
-	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
 	  This enables the use of the TMU as the system timer.
arch/sparc/Kconfig +0 -3
index 76b5008..8508a59 100644
@@ -35,9 +35,6 @@ config HZ
 	int
 	default 100
 
-config GENERIC_TIME
-	def_bool y
-
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
arch/sparc64/Kconfig +0 -4
index 3b96e70..45d2546 100644
@@ -25,10 +25,6 @@ config SPARC64
 	select RTC_DRV_SUN4V
 	select RTC_DRV_STARFIRE
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_CMOS_UPDATE
 	bool
 	default y
arch/um/Kconfig.common +0 -4
index 0d207e7..7c8e277 100644
@@ -55,10 +55,6 @@ config GENERIC_BUG
 	default y
 	depends on BUG
 
-config GENERIC_TIME
-	bool
-	default y
-
 config GENERIC_CLOCKEVENTS
 	bool
 	default y
arch/x86/Kconfig +2 -5
index ac22bb7..8307f0a 100644
@@ -40,9 +40,6 @@ config ARCH_DEFCONFIG
 	default "arch/x86/configs/i386_defconfig" if X86_32
 	default "arch/x86/configs/x86_64_defconfig" if X86_64
 
-config GENERIC_TIME
-	def_bool y
-
 config GENERIC_CMOS_UPDATE
 	def_bool y
 
@@ -1824,7 +1821,7 @@ config SCx200
 
 config SCx200HR_TIMER
 	tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
-	depends on SCx200 && GENERIC_TIME
+	depends on SCx200
 	default y
 	help
 	  This driver provides a clocksource built upon the on-chip
@@ -1836,7 +1833,7 @@ config SCx200HR_TIMER
 config GEODE_MFGPT_TIMER
 	def_bool y
 	prompt "Geode Multi-Function General Purpose Timer (MFGPT) events"
-	depends on MGEODE_LX && GENERIC_TIME && GENERIC_CLOCKEVENTS
+	depends on MGEODE_LX && GENERIC_CLOCKEVENTS
 	help
 	  This driver provides a clock event source based on the MFGPT
 	  timer(s) in the CS5535 and CS5536 companion chip for the geode.
arch/xtensa/Kconfig +0 -3
index ea3fdfe..95b6061 100644
@@ -54,9 +54,6 @@ config HZ
 	int
 	default 100
 
-config GENERIC_TIME
-	def_bool y
-
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
drivers/Makefile +3 -1
index fceb71a..6fc16fe 100644
@@ -92,7 +92,9 @@ obj-$(CONFIG_SGI_SN)		+= sn/
 obj-y				+= firmware/
 obj-$(CONFIG_CRYPTO)		+= crypto/
 obj-$(CONFIG_SUPERH)		+= sh/
-obj-$(CONFIG_GENERIC_TIME)	+= clocksource/
+ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
+obj-y				+= clocksource/
+endif
 obj-$(CONFIG_DMA_ENGINE)	+= dma/
 obj-$(CONFIG_DCA)		+= dca/
 obj-$(CONFIG_HID)		+= hid/
drivers/acpi/processor_idle.c +5 -5
index 5f8d746..14bdeee 100644
@@ -369,7 +369,7 @@ int acpi_processor_resume(struct acpi_device * device)
 	return 0;
 }
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
+#if defined(CONFIG_X86)
 static int tsc_halts_in_c(int state)
 {
 	switch (boot_cpu_data.x86_vendor) {
@@ -552,7 +552,7 @@ static void acpi_processor_idle(void)
 		/* Get end time (ticks) */
 		t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
+#if defined(CONFIG_X86)
 		/* TSC halts in C2, so notify users */
 		if (tsc_halts_in_c(ACPI_STATE_C2))
 			mark_tsc_unstable("possible TSC halt in C2");
@@ -617,7 +617,7 @@ static void acpi_processor_idle(void)
 			acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
 		}
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
+#if defined(CONFIG_X86)
 		/* TSC halts in C3, so notify users */
 		if (tsc_halts_in_c(ACPI_STATE_C3))
 			mark_tsc_unstable("TSC halts in C3");
@@ -1538,7 +1538,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	acpi_idle_do_entry(cx);
 	t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
+#if defined(CONFIG_X86)
 	/* TSC could halt in idle, so notify users */
 	if (tsc_halts_in_c(cx->type))
 		mark_tsc_unstable("TSC halts in idle");;
@@ -1655,7 +1655,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 		spin_unlock(&c3_lock);
 	}
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
+#if defined(CONFIG_X86)
 	/* TSC could halt in idle, so notify users */
 	if (tsc_halts_in_c(ACPI_STATE_C3))
 		mark_tsc_unstable("TSC halts in idle");
drivers/misc/Kconfig +1 -1
index fee7304..7fccb27 100644
@@ -32,7 +32,7 @@ config ATMEL_TCLIB
 
 config ATMEL_TCB_CLKSRC
 	bool "TC Block Clocksource"
-	depends on ATMEL_TCLIB && GENERIC_TIME
+	depends on ATMEL_TCLIB
 	default y
 	help
 	  Select this to get a high precision clocksource based on a
kernel/time.c +0 -16
index d63a433..1e610cd 100644
@@ -300,22 +300,6 @@ struct timespec timespec_trunc(struct timespec t, unsigned gran)
 }
 EXPORT_SYMBOL(timespec_trunc);
 
-#ifndef CONFIG_GENERIC_TIME
-/*
- * Simulate gettimeofday using do_gettimeofday which only allows a timeval
- * and therefore only yields usec accuracy
- */
-void getnstimeofday(struct timespec *tv)
-{
-	struct timeval x;
-
-	do_gettimeofday(&x);
-	tv->tv_sec = x.tv_sec;
-	tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
-}
-EXPORT_SYMBOL_GPL(getnstimeofday);
-#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
  * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
kernel/time/Kconfig +2 -2
index 95ed429..f06a8a3 100644
@@ -6,7 +6,7 @@ config TICK_ONESHOT
 
 config NO_HZ
 	bool "Tickless System (Dynamic Ticks)"
-	depends on GENERIC_TIME && GENERIC_CLOCKEVENTS
+	depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	help
 	  This option enables a tickless system: timer interrupts will
@@ -15,7 +15,7 @@ config NO_HZ
 
 config HIGH_RES_TIMERS
 	bool "High Resolution Timer Support"
-	depends on GENERIC_TIME && GENERIC_CLOCKEVENTS
+	depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	help
 	  This option enables high resolution timer support. If your
kernel/time/timekeeping.c +4 -5
index 087a783..e07ca9c 100644
@@ -56,7 +56,6 @@ void update_xtime_cache(u64 nsec)
 struct clocksource *clock;
 
 
-#ifdef CONFIG_GENERIC_TIME
 /**
  * clocksource_forward_now - update clock to the current time
  *
@@ -177,6 +176,7 @@ int do_settimeofday(struct timespec *tv)
 
 EXPORT_SYMBOL(do_settimeofday);
 
+#ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
 /**
  * change_clocksource - Swaps clocksources if a new one is available
  *
@@ -212,7 +212,6 @@ static void change_clocksource(void)
 	 */
 }
 #else
-static inline void clocksource_forward_now(void) { }
 static inline void change_clocksource(void) { }
 #endif
 
@@ -489,10 +488,10 @@ void update_wall_time(void)
 	if (unlikely(timekeeping_suspended))
 		return;
 
-#ifdef CONFIG_GENERIC_TIME
-	offset = (clocksource_read(clock) - clock->cycle_last) & clock->mask;
-#else
+#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
 	offset = clock->cycle_interval;
+#else
+	offset = (clocksource_read(clock) - clock->cycle_last) & clock->mask;
 #endif
 	clock->xtime_nsec = (s64)xtime.tv_nsec << clock->shift;
 
kernel/trace/Kconfig +2 -2
index 33dbefd..20cd333 100644
@@ -51,7 +51,7 @@ config IRQSOFF_TRACER
 	bool "Interrupts-off Latency Tracer"
 	default n
 	depends on TRACE_IRQFLAGS_SUPPORT
-	depends on GENERIC_TIME
+	depends on !ARCH_USES_GETTIMEOFFSET
 	depends on DEBUG_KERNEL
 	select TRACE_IRQFLAGS
 	select TRACING
@@ -73,7 +73,7 @@ config IRQSOFF_TRACER
 config PREEMPT_TRACER
 	bool "Preemption-off Latency Tracer"
 	default n
-	depends on GENERIC_TIME
+	depends on !ARCH_USES_GETTIMEOFFSET
 	depends on PREEMPT
 	depends on DEBUG_KERNEL
 	select TRACING
Acked-by on v1 2/3
#4 lore raw

Re: [RFC][PATCH 2/3] Convert !GENERIC_TIME arches to use arch_getoffset() infrastructure.

In reply to john stultz
Quoted 15 lines · john stultz

This converts the following arches to use the arch_getoffset() infrastructure, finally bringing them into the GENERIC_TIME fold:

arm
blackfin
cris
m32r
m68k
sh
sparc
xtensa

I have split out patches for each arch, but I'm sending out the megapatch to keep the RFC patchlist short.

Quoted 8 lines

I do not have cross compilers for these architectures, and in some cases (like arm, and sh) 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.

Just got around to testing the SH bits, works fine in both configurations.