📄 1018.kernel-preempt.patch
字号:
diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/alpha/kernel/process.c linuxmips-2.4.30/arch/alpha/kernel/process.c--- linuxmips-2.4.30.ref/arch/alpha/kernel/process.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/alpha/kernel/process.c 2005-08-29 11:43:45.000000000 -0700@@ -186,6 +186,7 @@ args.mode = mode; args.restart_cmd = restart_cmd; #ifdef CONFIG_SMP+ preempt_disable(); smp_call_function(common_shutdown_1, &args, 1, 0); #endif common_shutdown_1(&args);diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/config.in linuxmips-2.4.30/arch/i386/config.in--- linuxmips-2.4.30.ref/arch/i386/config.in 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/config.in 2005-08-29 11:43:45.000000000 -0700@@ -225,6 +225,7 @@ bool 'Math emulation' CONFIG_MATH_EMULATION bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR bool 'Symmetric multi-processing support' CONFIG_SMP+bool 'Preemptible Kernel' CONFIG_PREEMPT if [ "$CONFIG_SMP" != "y" ]; then bool 'Local APIC support on uniprocessors' CONFIG_X86_UP_APIC dep_bool 'IO-APIC support on uniprocessors' CONFIG_X86_UP_IOAPIC $CONFIG_X86_UP_APIC@@ -258,9 +259,12 @@ fi fi -if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then- define_bool CONFIG_HAVE_DEC_LOCK y+if [ "$CONFIG_SMP" = "y" -o "$CONFIG_PREEMPT" = "y" ]; then+ if [ "$CONFIG_X86_CMPXCHG" = "y" ]; then+ define_bool CONFIG_HAVE_DEC_LOCK y+ fi fi+ endmenu mainmenu_option next_commentdiff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/cpuid.c linuxmips-2.4.30/arch/i386/kernel/cpuid.c--- linuxmips-2.4.30.ref/arch/i386/kernel/cpuid.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/cpuid.c 2005-08-29 11:43:45.000000000 -0700@@ -60,7 +60,8 @@ static inline void do_cpuid(int cpu, u32 reg, u32 *data) { struct cpuid_command cmd;- ++ preempt_disable(); if ( cpu == smp_processor_id() ) { cpuid(reg, &data[0], &data[1], &data[2], &data[3]); } else {@@ -70,6 +71,7 @@ smp_call_function(cpuid_smp_cpuid, &cmd, 1, 1); }+ preempt_enable(); } #else /* ! CONFIG_SMP */ diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/entry.S linuxmips-2.4.30/arch/i386/kernel/entry.S--- linuxmips-2.4.30.ref/arch/i386/kernel/entry.S 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/entry.S 2005-08-29 11:43:45.000000000 -0700@@ -73,7 +73,7 @@ * these are offsets into the task-struct. */ state = 0-flags = 4+preempt_count = 4 sigpending = 8 addr_limit = 12 exec_domain = 16@@ -81,8 +81,28 @@ tsk_ptrace = 24 processor = 52 +/* These are offsets into the irq_stat structure+ * There is one per cpu and it is aligned to 32+ * byte boundry (we put that here as a shift count)+ */+irq_array_shift = CONFIG_X86_L1_CACHE_SHIFT++irq_stat_local_irq_count = 4+irq_stat_local_bh_count = 8+ ENOSYS = 38 +#ifdef CONFIG_SMP+#define GET_CPU_INDX movl processor(%ebx),%eax; \+ shll $irq_array_shift,%eax+#define GET_CURRENT_CPU_INDX GET_CURRENT(%ebx); \+ GET_CPU_INDX+#define CPU_INDX (,%eax)+#else+#define GET_CPU_INDX+#define GET_CURRENT_CPU_INDX GET_CURRENT(%ebx)+#define CPU_INDX+#endif #define SAVE_ALL \ cld; \@@ -255,12 +275,30 @@ ALIGN ENTRY(ret_from_intr) GET_CURRENT(%ebx)+#ifdef CONFIG_PREEMPT+ cli+ decl preempt_count(%ebx)+#endif ret_from_exception: movl EFLAGS(%esp),%eax # mix EFLAGS and CS movb CS(%esp),%al testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor? jne ret_from_sys_call+#ifdef CONFIG_PREEMPT+ cmpl $0,preempt_count(%ebx)+ jnz restore_all+ cmpl $0,need_resched(%ebx)+ jz restore_all+ movl SYMBOL_NAME(irq_stat)+irq_stat_local_bh_count CPU_INDX,%ecx+ addl SYMBOL_NAME(irq_stat)+irq_stat_local_irq_count CPU_INDX,%ecx+ jnz restore_all+ incl preempt_count(%ebx)+ sti+ call SYMBOL_NAME(preempt_schedule)+ jmp ret_from_intr+#else jmp restore_all+#endif ALIGN reschedule:@@ -297,6 +335,9 @@ GET_CURRENT(%ebx) call *%edi addl $8,%esp+#ifdef CONFIG_PREEMPT+ cli+#endif jmp ret_from_exception ENTRY(coprocessor_error)@@ -316,12 +357,18 @@ movl %cr0,%eax testl $0x4,%eax # EM (math emulation bit) jne device_not_available_emulate+#ifdef CONFIG_PREEMPT+ cli+#endif call SYMBOL_NAME(math_state_restore) jmp ret_from_exception device_not_available_emulate: pushl $0 # temporary storage for ORIG_EIP call SYMBOL_NAME(math_emulate) addl $4,%esp+#ifdef CONFIG_PREEMPT+ cli+#endif jmp ret_from_exception ENTRY(debug)diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/i387.c linuxmips-2.4.30/arch/i386/kernel/i387.c--- linuxmips-2.4.30.ref/arch/i386/kernel/i387.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/i387.c 2005-08-29 11:43:45.000000000 -0700@@ -10,6 +10,7 @@ #include <linux/config.h> #include <linux/sched.h>+#include <linux/spinlock.h> #include <linux/init.h> #include <asm/processor.h> #include <asm/i387.h>@@ -89,6 +90,8 @@ { struct task_struct *tsk = current; + preempt_disable();+ if (tsk->flags & PF_USEDFPU) { __save_init_fpu(tsk); return;diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/ioport.c linuxmips-2.4.30/arch/i386/kernel/ioport.c--- linuxmips-2.4.30.ref/arch/i386/kernel/ioport.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/ioport.c 2005-08-29 11:43:45.000000000 -0700@@ -55,7 +55,7 @@ asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) { struct thread_struct * t = ¤t->thread;- struct tss_struct * tss = init_tss + smp_processor_id();+ struct tss_struct * tss; if ((from + num <= from) || (from + num > IO_BITMAP_SIZE*32)) return -EINVAL;@@ -66,6 +66,8 @@ * IO bitmap up. ioperm() is much less timing critical than clone(), * this is why we delay this operation until now: */+ preempt_disable();+ tss = init_tss + smp_processor_id(); if (!t->ioperm) { /* * just in case ...@@ -84,6 +86,7 @@ memcpy(tss->io_bitmap, t->io_bitmap, IO_BITMAP_BYTES); tss->bitmap = IO_BITMAP_OFFSET; /* Activate it in the TSS */ }+ preempt_enable(); return 0; }diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/irq.c linuxmips-2.4.30/arch/i386/kernel/irq.c--- linuxmips-2.4.30.ref/arch/i386/kernel/irq.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/irq.c 2005-08-29 11:43:45.000000000 -0700@@ -284,9 +284,11 @@ show("wait_on_irq"); count = ~0; }+ preempt_disable(); __sti(); SYNC_OTHER_CORES(cpu); __cli();+ preempt_enable_no_resched(); if (irqs_running()) continue; if (global_irq_lock)@@ -360,8 +362,9 @@ __save_flags(flags); if (flags & (1 << EFLAGS_IF_SHIFT)) {- int cpu = smp_processor_id();+ int cpu; __cli();+ cpu = smp_processor_id(); if (!local_irq_count(cpu)) get_irqlock(cpu); }@@ -369,11 +372,14 @@ void __global_sti(void) {- int cpu = smp_processor_id();+ int cpu; + preempt_disable();+ cpu = smp_processor_id(); if (!local_irq_count(cpu)) release_irqlock(cpu); __sti();+ preempt_enable(); } /*@@ -388,13 +394,15 @@ int retval; int local_enabled; unsigned long flags;- int cpu = smp_processor_id();+ int cpu; __save_flags(flags); local_enabled = (flags >> EFLAGS_IF_SHIFT) & 1; /* default to local */ retval = 2 + local_enabled; + preempt_disable();+ cpu = smp_processor_id(); /* check for global flags if we're not in an interrupt */ if (!local_irq_count(cpu)) { if (local_enabled)@@ -402,6 +410,7 @@ if (global_irq_holder == cpu) retval = 0; }+ preempt_enable(); return retval; } diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/i386/kernel/microcode.c linuxmips-2.4.30/arch/i386/kernel/microcode.c--- linuxmips-2.4.30.ref/arch/i386/kernel/microcode.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/arch/i386/kernel/microcode.c 2005-08-29 11:43:45.000000000 -0700@@ -400,15 +400,18 @@ { int i, error; + preempt_disable(); if (smp_call_function(collect_cpu_info, NULL, 1, 1) != 0) { printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); error = -EIO;+ preempt_enable(); goto out; } collect_cpu_info(NULL); if ((error = find_matching_ucodes())) { printk(KERN_ERR "microcode: Error in the microcode data\n");+ preempt_enable(); goto out_free; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -