Skip to contentSkip to conversation

remove i386 dynamic ticks ifdefs

PATCH In review Con Kolivas 2 participants 3 messages Jul 29, 2005 – Aug 5, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove i386 dynamic ticks ifdefs

Hi Tony

I assume you're maintaining the dyn tick patches for i386 posted on the muru website as your email is listed there. I thought you might be interested in this patch for dyn-ticks which removes most of the #ifdefs out of common code paths as per linux kernel style and moves more code into dyn-tick.c. Most of it is straight forward code reorganisation, but to keep do_timer_interrupt inlined I'd have to move it's code around somewhat. That may be a better option but I've tried to fiddle with the mainline code as little as possible.

Patch applies to 2.6.12 with patch-dynamic-tick-2.6.12-rc6-050610-1 applied

cc'ed lkml just for public record of the patch.

Cheers,
Con

Move most of the dynamic ticks code that is #ifdef'd out of code paths and put it into dyn-tick.c

 arch/i386/kernel/Makefile   |    2
 arch/i386/kernel/apic.c     |   36 ----------
 arch/i386/kernel/dyn-tick.c |  146 ++++++++++++++++++++++++++++++++++++++++++++
 arch/i386/kernel/irq.c      |    5 -
 arch/i386/kernel/time.c     |   72 ---------------------
 include/asm/dyn-tick.h      |    4 -
 include/linux/dyn-tick.h    |   12 +++
 7 files changed, 165 insertions(+), 112 deletions(-)
arch/i386/kernel/apic.c +3 -33
Index: linux-2.6.12-dt/arch/i386/kernel/apic.c
===================================================================
@@ -932,11 +932,8 @@ static void __setup_APIC_LVTT(unsigned i
 
 	apic_timer_val = clocks/APIC_DIVISOR;
 
-#ifdef CONFIG_NO_IDLE_HZ
-	/* Local APIC timer is 24-bit */
 	if (apic_timer_val)
-		dyn_tick->max_skip = 0xffffff / apic_timer_val;
-#endif
+		set_dyn_tick_max_skip(apic_timer_val);
 
 	apic_write_around(APIC_TMICT, apic_timer_val);
 }
@@ -1051,12 +1048,7 @@ void __init setup_boot_APIC_clock(void)
 	 */
 	setup_APIC_timer(calibration_result);
 
-#ifdef CONFIG_NO_IDLE_HZ
-	if (calibration_result)
-		dyn_tick->state |= DYN_TICK_USE_APIC;
-	else
-		printk(KERN_INFO "dyn-tick: Cannot use local APIC\n");
-#endif
+	setup_dyn_tick_use_apic(calibration_result);
 
 	local_irq_enable();
 }
@@ -1086,18 +1078,6 @@ void enable_APIC_timer(void)
 	}
 }
 
-#if defined(CONFIG_NO_IDLE_HZ)
-void reprogram_apic_timer(unsigned int count)
-{
-	unsigned long flags;
-
-	count *= apic_timer_val;
-	local_irq_save(flags);
-	apic_write_around(APIC_TMICT, count);
-	local_irq_restore(flags);
-}
-#endif
-
 /*
  * the frequency of the profiling timer can be changed
  * by writing a multiplier value into /proc/profile.
@@ -1210,21 +1190,11 @@ fastcall void smp_apic_timer_interrupt(s
 	 */
 	irq_enter();
 
-#ifdef CONFIG_NO_IDLE_HZ
 	/*
 	 * Check if we need to wake up PIT interrupt handler.
 	 * Otherwise just wake up local APIC timer.
 	 */
-	do {
-		seq = read_seqbegin(&xtime_lock);
-		if (dyn_tick->state & (DYN_TICK_ENABLED | DYN_TICK_SKIPPING)) {
-			if (dyn_tick->skip_cpu == cpu && dyn_tick->skip > DYN_TICK_MIN_SKIP)
-				dyn_tick->interrupt(99, NULL, regs);
-			else
-				reprogram_apic_timer(1);
-		}
-	} while (read_seqretry(&xtime_lock, seq));
-#endif
+	wakeup_pit_or_apic(seq, cpu, &regs);
 
 	smp_local_timer_interrupt(regs);
 	irq_exit();
arch/i386/kernel/dyn-tick.c +146 -0

155 lines not on this page · raw message

arch/i386/kernel/irq.c +1 -4
Index: linux-2.6.12-dt/arch/i386/kernel/irq.c
===================================================================
@@ -74,10 +74,7 @@ fastcall unsigned int do_IRQ(struct pt_r
 	}
 #endif
 
-#ifdef CONFIG_NO_IDLE_HZ
-	if (dyn_tick->state & (DYN_TICK_ENABLED | DYN_TICK_SKIPPING) && irq != 0)
-		dyn_tick->interrupt(irq, NULL, regs);
-#endif
+	dyn_tick_interrupt(irq, regs);
 
 #ifdef CONFIG_4KSTACKS
 
arch/i386/kernel/Makefile +1 -1
Index: linux-2.6.12-dt/arch/i386/kernel/Makefile
===================================================================
@@ -31,7 +31,7 @@ obj-$(CONFIG_MODULES)		+= module.o
 obj-y				+= sysenter.o vsyscall.o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat.o
 obj-$(CONFIG_HPET_TIMER) 	+= time_hpet.o
-obj-$(CONFIG_NO_IDLE_HZ) 	+= dyn-tick.o
+obj-y			 	+= dyn-tick.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
arch/i386/kernel/time.c +2 -70

96 lines not on this page · raw message

include/asm/dyn-tick.h +0 -4
Index: linux-2.6.12-dt/include/asm/dyn-tick.h
===================================================================
@@ -19,11 +19,7 @@ extern void reprogram_pit_timer(int jiff
 extern void reprogram_apic_timer(unsigned int count);
 extern void replace_timer_interrupt(void * new_handler);
 
-#if defined(CONFIG_NO_IDLE_HZ) && defined(CONFIG_X86_LOCAL_APIC)
 extern void reprogram_apic_timer(unsigned int count);
-#else
-#define reprogram_apic_timer(x)	do {} while (0)
-#endif
 
 #if defined(CONFIG_DYN_TICK_USE_APIC) && (defined(CONFIG_SMP) || defined(CONFIG_X86_UP_APIC))
 #define cpu_has_local_apic()	(dyn_tick->state & DYN_TICK_USE_APIC)
include/linux/dyn-tick.h +12 -0
Index: linux-2.6.12-dt/include/linux/dyn-tick.h
===================================================================
@@ -14,6 +14,7 @@
 #define _DYN_TICK_TIMER_H
 
 #include <linux/interrupt.h>
+#include <asm/timer.h>
 
 #define DYN_TICK_TIMER_INT	(1 << 4)
 #define DYN_TICK_USE_APIC	(1 << 3)
@@ -39,6 +40,14 @@ struct dyn_tick_timer {
 
 extern struct dyn_tick_state * dyn_tick;
 extern void dyn_tick_register(struct dyn_tick_timer * new_timer);
+extern inline void set_dyn_tick_max_skip(u32 apic_timer_val);
+extern void reprogram_apic_timer(unsigned int count);
+extern inline void setup_dyn_tick_use_apic(unsigned int calibration_result);
+extern void wakeup_pit_or_apic(unsigned long seq, int cpu, struct pt_regs *regs);
+extern void dyn_tick_interrupt(int irq, struct pt_regs *regs);
+extern void dyn_tick_time_init(struct timer_opts *cur_timer);
+extern void do_timer_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs);
 
 #define NS_TICK_LEN		((1 * 1000000000)/HZ)
 #define DYN_TICK_MIN_SKIP	2
@@ -47,6 +56,9 @@ extern void dyn_tick_register(struct dyn
 #ifdef CONFIG_NO_IDLE_HZ
 
 extern unsigned long dyn_tick_reprogram_timer(void);
+extern irqreturn_t dyn_tick_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+extern int __init dyn_tick_arch_init(void);
+
 #define dyn_tick_enabled()		(dyn_tick->state & DYN_TICK_ENABLED)
 
 #else
#1 lore raw

Hi!

Quoted 11 lines

I assume you're maintaining the dyn tick patches for i386 posted on the muru website as your email is listed there. I thought you might be interested in this patch for dyn-ticks which removes most of the #ifdefs out of common code paths as per linux kernel style and moves more code into dyn-tick.c. Most of it is straight forward code reorganisation, but to keep do_timer_interrupt inlined I'd have to move it's code around somewhat. That may be a better option but I've tried to fiddle with the mainline code as little as possible.

Patch applies to 2.6.12 with patch-dynamic-tick-2.6.12-rc6-050610-1 applied

cc'ed lkml just for public record of the patch.

Please inline patches...

You broke indentation in one of first hunks, and you probably want empty functions to be static inline, so that we do not eat function call overhead.
Pavel

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#2 lore raw
Quoted 11 lines · Pavel Machek

Hi!

Quoted 9 lines

I assume you're maintaining the dyn tick patches for i386 posted on the muru website as your email is listed there. I thought you might be interested in this patch for dyn-ticks which removes most of the #ifdefs out of common code paths as per linux kernel style and moves more code into dyn-tick.c. Most of it is straight forward code reorganisation, but to keep do_timer_interrupt inlined I'd have to move it's code around somewhat. That may be a better option but I've tried to fiddle with the mainline code as little as possible.

Quoted 6 lines
Quoted 4 lines

Patch applies to 2.6.12 with patch-dynamic-tick-2.6.12-rc6-050610-1 applied

cc'ed lkml just for public record of the patch.

Please inline patches...

Not everyone uses console email clients :| It was an inlined attachment rather than an ordinary attachment but clearly that doesn't suit those with console clients. I'm sorry.

Quoted 4 lines

You broke indentation in one of first hunks, and you probably want empty functions to be static inline, so that we do not eat function call overhead.

Will examine. Thanks very much for your code comments!

Cheers,
Con