2.4: preempt-kernel for MIPS
PATCH 1/1 2.4: preempt-kernel for MIPS
MontaVista has provided the community with MIPS architecture support for the preemptive kernel patch. Thanks specifically to Jun Sun of MontaVista for the work.
This patch will be integrated with the base 2.4 preempt-kernel patch soon. For now, this is diffed on _top_ of preempt-kernel for 2.4.19-pre8. While it is against 2.4.19-pre8, it should hopefully also apply to a recent MIPS tree checkout.
Comments are welcome. Enjoy,
Robert Love
arch/mips/config.in +1 -0
@@ -468,6 +468,7 @@ # bool ' Access.Bus support' CONFIG_ACCESSBUS # fi fi +dep_bool 'Preemptible Kernel' CONFIG_PREEMPT $CONFIG_NEW_IRQ endmenu if [ "$CONFIG_ISA" = "y" ]; then
arch/mips/kernel/i8259.c +1 -0
@@ -8,6 +8,7 @@* Copyright (C) 1992 Linus Torvalds * Copyright (C) 1994 - 2000 Ralf Baechle */ +#include <linux/sched.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/ioport.h>
arch/mips/kernel/irq.c +28 -1
@@ -8,6 +8,8 @@* Copyright (C) 1992 Linus Torvalds * Copyright (C) 1994 - 2000 Ralf Baechle */ + +#include <linux/sched.h> #include <linux/config.h> #include <linux/kernel.h> #include <linux/delay.h>
@@ -19,11 +21,13 @@#include <linux/slab.h> #include <linux/mm.h> #include <linux/random.h> -#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/ptrace.h> #include <asm/atomic.h> #include <asm/system.h> #include <asm/uaccess.h> +#include <asm/debug.h> /* * Controller mappings for all interrupt sources:
@@ -420,6 +424,8 @@struct irqaction * action;unsigned int status; +preempt_disable (); + kstat.irqs[cpu][irq]++;spin_lock (&desc->lock); desc->handler->ack (irq);
@@ -481,6 +487,27 @@if (softirq_pending (cpu))do_softirq (); + +#if defined(CONFIG_PREEMPT ) +while (--current->preempt_count ==0 ) { +db_assert (intr_off ()); +db_assert (!in_interrupt ()); + +if (current->need_resched ==0 ) { +break ; + } + + current->preempt_count ++; +sti (); +if (user_mode (regs)) { +schedule (); + }else { +preempt_schedule (); + } +cli (); + } +#endif +return 1 ; }
arch/mips/mm/extable.c +1 -0
@@ -3,6 +3,7 @@*/ #include <linux/config.h> #include <linux/module.h> +#include <linux/sched.h> #include <linux/spinlock.h> #include <asm/uaccess.h>
include/asm-mips/smplock.h +15 -0
@@ -5,12 +5,21 @@* * Default SMP lock implementation */ +#include <linux/config.h> #include <linux/interrupt.h> #include <linux/spinlock.h> extern spinlock_t kernel_flag; +#ifdef CONFIG_SMP #define kernel_locked () spin_is_locked(&kernel_flag) +#else +#ifdef CONFIG_PREEMPT +#define kernel_locked () preempt_get_count() +#else +#define kernel_locked () 1 +#endif +#endif /* * Release global kernel lock and global interrupt lock
@@ -42,8 +51,14 @@*/ extern __inline__void lock_kernel (void ) { +#ifdef CONFIG_PREEMPT +if (current->lock_depth ==-1 ) +spin_lock (&kernel_flag); + ++current->lock_depth; +#else if (!++current->lock_depth)spin_lock (&kernel_flag); +#endif }extern __inline__void unlock_kernel (void )
include/asm-mips/softirq.h +3 -0
@@ -15,6 +15,7 @@static inline void cpu_bh_disable (int cpu) { +preempt_disable ();local_bh_count (cpu)++;barrier (); }
@@ -23,6 +24,7 @@ {barrier ();local_bh_count (cpu)--; +preempt_enable (); }
@@ -36,6 +38,7 @@ cpu =smp_processor_id (); \if (!--local_bh_count (cpu) &&softirq_pending (cpu)) \do_softirq (); \ +preempt_enable (); \ }while (0 ) #define in_softirq() (local_bh_count(smp_processor_id()) != 0)
include/asm-mips/system.h +12 -0
@@ -285,4 +285,16 @@#define die_if_kernel (msg, regs) \ __die_if_kernel(msg, regs, __FILE__ ":"__FUNCTION__, __LINE__) +extern __inline__int intr_on (void ) +{ +unsigned long flags; +save_flags (flags); +return flags &1 ; +} + +extern __inline__int intr_off (void ) +{ +return !intr_on (); +} +#endif /* _ASM_SYSTEM_H */