Skip to contentSkip to conversation

linux-2.5.34_timer-change_A2

RFC PATCH In review john stultz 2 participants 2 messages Sep 9, 2002 – Sep 10, 2002

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 linux-2.5.34_timer-change_A2

Just a resync/resend:

Hi all,
Here is my timer-change patch resynced with 2.5.34. As I said
before, this patch breaks up arch/i386/kernel/time.c into various timer_pit, timer_tsc chunks. The hope is to cleanup the existing code so it doesn't care what type of clock is providing the high-resolution offset for gettimeofday. This will also simplify adding support for my cyclone-timer patch as well as ACPI pm timer or any other high res counter.

Right now I've just taken the existing code put all TSC releated code into one file, all PIT related code into another, and created struct timer_ops that provides a generic interface. I've avoided making any changes to the actual code, so its as transparent a change as possible.

Future plans include moving __udelay into these ops as well.

It compiles and boots on a few boxes here without problems, but I'd really like further testing and review. I'd also really appreciate any comments at all on this patch.

Might this be considered as a -dj candidate?

Flames and comments always welcome.

thanks
-john

arch/i386/kernel/Makefile +2 -2
diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
@@ -6,12 +6,12 @@
 
 O_TARGET := kernel.o
 
-export-objs     := mca.o i386_ksyms.o time.o
+export-objs     := mca.o i386_ksyms.o time.o timer_pit.o
 
 obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
 		ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \
 		pci-dma.o i386_ksyms.o i387.o bluesmoke.o dmi_scan.o \
-		bootflag.o
+		bootflag.o timer.o timer_pit.o timer_tsc.o
 
 obj-y				+= cpu/
 obj-$(CONFIG_MCA)		+= mca.o
arch/i386/kernel/time.c +8 -337

404 lines not on this page · raw message

arch/i386/kernel/timer.c new file +28 -0
diff -Nru a/arch/i386/kernel/timer.c b/arch/i386/kernel/timer.c
@@ -0,0 +1,28 @@
+#include <linux/kernel.h>
+#include <asm/timer.h>
+
+/*list of externed timers*/
+extern struct timer_opts timer_pit;
+extern struct timer_opts timer_tsc;
+
+/*list of timers, ordered by preference*/
+struct timer_opts* timers[] = {
+	&timer_tsc,
+	&timer_pit
+};
+
+#define NR_TIMERS (sizeof(timers)/sizeof(timers[0]))
+
+/* iterates through the list of timers, returning the first 
+ * one that initializes successfully.
+ */
+struct timer_opts* select_timer(void)
+{
+	int i;
+	/*find most preferred working timer*/
+	for(i=0; i < NR_TIMERS; i++)
+		if(timers[i]->init())
+			return timers[i];
+	panic("select_timer: Cannot find a suitable timer\n");
+	return 0;
+}
arch/i386/kernel/timer_pit.c new file +185 -0

185 lines not on this page · raw message

arch/i386/kernel/timer_tsc.c new file +215 -0

215 lines not on this page · raw message

include/asm-i386/timer.h new file +13 -0
diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
@@ -0,0 +1,13 @@
+
+#ifndef _ASMi386_TIMER_H
+#define _ASMi386_TIMER_H
+
+struct timer_opts{
+	int (*init)(void);
+	void (*mark_offset)(void);
+	unsigned long (*get_offset)(void);
+};
+
+#define TICK_SIZE tick
+struct timer_opts* select_timer(void);
+#endif
#1 lore raw
Quoted 10 lines · john stultz

Just a resync/resend:

Hi all,
Here is my timer-change patch resynced with 2.5.34. As I said
before, this patch breaks up arch/i386/kernel/time.c into various timer_pit, timer_tsc chunks. The hope is to cleanup the existing code so it doesn't care what type of clock is providing the high-resolution offset for gettimeofday. This will also simplify adding support for my cyclone-timer patch as well as ACPI pm timer or any other high res counter.

while at it, could we also finaly drop the broken CMOS clock update "feature" from arch/*/kenrel/time.c?

It was already mentioned a few times on this list and iirc there was never any argument against removing it.
In short the code does nothing that couldn't be done much better from userspace, it implements policy that belongs into userspace and wastes time in an interrupt handler.

At least one architecture has it already completely disabled.

Richard