From: Robert Love <rml@mvista.com>
To: linux-kernel@vger.kernel.org
Cc: kpreempt-tech@lists.sourceforge.net
Subject: [PATCH] 2.4: preempt-kernel for MIPS
Date: 08 May 2002 16:06:58 -0700 [thread overview]
Message-ID: <1020899219.880.17.camel@summit> (raw)
[-- Attachment #1: Type: text/plain, Size: 454 bytes --]
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
[-- Attachment #2: preempt-kernel-mips-2.4.19-pre8-1.patch --]
[-- Type: text/x-patch, Size: 5064 bytes --]
diff -urN linux-2.4.19-pre8-preempt/arch/mips/config.in linux/arch/mips/config.in
--- linux-2.4.19-pre8-preempt/arch/mips/config.in Wed May 8 15:09:53 2002
+++ linux/arch/mips/config.in Wed May 8 15:54:35 2002
@@ -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
diff -urN linux-2.4.19-pre8-preempt/arch/mips/kernel/i8259.c linux/arch/mips/kernel/i8259.c
--- linux-2.4.19-pre8-preempt/arch/mips/kernel/i8259.c Wed May 8 15:09:53 2002
+++ linux/arch/mips/kernel/i8259.c Wed May 8 15:54:35 2002
@@ -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>
diff -urN linux-2.4.19-pre8-preempt/arch/mips/kernel/irq.c linux/arch/mips/kernel/irq.c
--- linux-2.4.19-pre8-preempt/arch/mips/kernel/irq.c Wed May 8 15:09:53 2002
+++ linux/arch/mips/kernel/irq.c Wed May 8 15:56:16 2002
@@ -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;
}
diff -urN linux-2.4.19-pre8-preempt/arch/mips/mm/extable.c linux/arch/mips/mm/extable.c
--- linux-2.4.19-pre8-preempt/arch/mips/mm/extable.c Wed May 8 15:09:53 2002
+++ linux/arch/mips/mm/extable.c Wed May 8 15:54:35 2002
@@ -3,6 +3,7 @@
*/
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/sched.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h>
diff -urN linux-2.4.19-pre8-preempt/include/asm-mips/smplock.h linux/include/asm-mips/smplock.h
--- linux-2.4.19-pre8-preempt/include/asm-mips/smplock.h Wed May 8 15:09:11 2002
+++ linux/include/asm-mips/smplock.h Wed May 8 15:57:41 2002
@@ -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)
diff -urN linux-2.4.19-pre8-preempt/include/asm-mips/softirq.h linux/include/asm-mips/softirq.h
--- linux-2.4.19-pre8-preempt/include/asm-mips/softirq.h Wed May 8 15:09:11 2002
+++ linux/include/asm-mips/softirq.h Wed May 8 15:54:35 2002
@@ -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)
diff -urN linux-2.4.19-pre8-preempt/include/asm-mips/system.h linux/include/asm-mips/system.h
--- linux-2.4.19-pre8-preempt/include/asm-mips/system.h Wed May 8 15:09:11 2002
+++ linux/include/asm-mips/system.h Wed May 8 15:54:35 2002
@@ -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 */
reply other threads:[~2002-05-08 23:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1020899219.880.17.camel@summit \
--to=rml@mvista.com \
--cc=kpreempt-tech@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox