📄 1018.kernel-preempt.patch
字号:
#include <linux/string.h>+#include <linux/sched.h> #include <linux/module.h> /* needed for MODULE_PARM */ #include <linux/param.h> #include <linux/spinlock.h>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/drivers/sound/sound_core.c linuxmips-2.4.30/drivers/sound/sound_core.c--- linuxmips-2.4.30.ref/drivers/sound/sound_core.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/drivers/sound/sound_core.c 2005-08-29 11:43:45.000000000 -0700@@ -37,6 +37,7 @@ #include <linux/config.h> #include <linux/module.h> #include <linux/init.h>+#include <linux/sched.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/kernel.h>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/fs/adfs/map.c linuxmips-2.4.30/fs/adfs/map.c--- linuxmips-2.4.30.ref/fs/adfs/map.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/fs/adfs/map.c 2005-08-29 11:43:45.000000000 -0700@@ -12,6 +12,7 @@ #include <linux/fs.h> #include <linux/adfs_fs.h> #include <linux/spinlock.h>+#include <linux/sched.h> #include "adfs.h" 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/fs/exec.c linuxmips-2.4.30/fs/exec.c--- linuxmips-2.4.30.ref/fs/exec.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/fs/exec.c 2005-08-29 11:43:45.000000000 -0700@@ -459,8 +459,8 @@ active_mm = current->active_mm; current->mm = mm; current->active_mm = mm;- task_unlock(current); activate_mm(active_mm, mm);+ task_unlock(current); mm_release(); if (old_mm) { if (active_mm != old_mm) BUG();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/fs/fat/cache.c linuxmips-2.4.30/fs/fat/cache.c--- linuxmips-2.4.30.ref/fs/fat/cache.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/fs/fat/cache.c 2005-08-29 11:43:45.000000000 -0700@@ -14,6 +14,7 @@ #include <linux/string.h> #include <linux/stat.h> #include <linux/fat_cvf.h>+#include <linux/sched.h> #if 0 # define PRINTK(x) printk xdiff -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/fs/nfsd/nfssvc.c linuxmips-2.4.30/fs/nfsd/nfssvc.c--- linuxmips-2.4.30.ref/fs/nfsd/nfssvc.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/fs/nfsd/nfssvc.c 2005-08-29 11:43:45.000000000 -0700@@ -250,6 +250,7 @@ svc_exit_thread(rqstp); /* Release module */+ unlock_kernel(); MOD_DEC_USE_COUNT; } 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/fs/nls/nls_base.c linuxmips-2.4.30/fs/nls/nls_base.c--- linuxmips-2.4.30.ref/fs/nls/nls_base.c 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/fs/nls/nls_base.c 2005-08-29 11:43:45.000000000 -0700@@ -18,6 +18,7 @@ #ifdef CONFIG_KMOD #include <linux/kmod.h> #endif+#include <linux/sched.h> #include <linux/spinlock.h> static struct nls_table *tables;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/include/asm-i386/desc.h linuxmips-2.4.30/include/asm-i386/desc.h--- linuxmips-2.4.30.ref/include/asm-i386/desc.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/desc.h 2005-08-29 11:43:45.000000000 -0700@@ -71,9 +71,12 @@ static inline void clear_LDT(void) {- int cpu = smp_processor_id();+ int cpu;+ preempt_disable();+ cpu = smp_processor_id(); set_ldt_desc(cpu, &default_ldt[0], 5); __load_LDT(cpu);+ preempt_enable(); } /*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/include/asm-i386/hardirq.h linuxmips-2.4.30/include/asm-i386/hardirq.h--- linuxmips-2.4.30.ref/include/asm-i386/hardirq.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/hardirq.h 2005-08-29 11:43:45.000000000 -0700@@ -19,12 +19,16 @@ /* * Are we in an interrupt context? Either doing bottom half- * or hardware interrupt processing?+ * or hardware interrupt processing? Note the preempt check,+ * this is both a bugfix and an optimization. If we are+ * preemptible, we cannot be in an interrupt. */-#define in_interrupt() ({ int __cpu = smp_processor_id(); \- (local_irq_count(__cpu) + local_bh_count(__cpu) != 0); })+#define in_interrupt() (preempt_is_disabled() && \+ ({unsigned long __cpu = smp_processor_id(); \+ (local_irq_count(__cpu) + local_bh_count(__cpu) != 0); })) -#define in_irq() (local_irq_count(smp_processor_id()) != 0)+#define in_irq() (preempt_is_disabled() && \+ (local_irq_count(smp_processor_id()) != 0)) #ifndef CONFIG_SMP @@ -36,6 +40,8 @@ #define synchronize_irq() barrier() +#define release_irqlock(cpu) do { } while (0)+ #else #include <asm/atomic.h>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/include/asm-i386/highmem.h linuxmips-2.4.30/include/asm-i386/highmem.h--- linuxmips-2.4.30.ref/include/asm-i386/highmem.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/highmem.h 2005-08-29 11:43:45.000000000 -0700@@ -91,6 +91,7 @@ enum fixed_addresses idx; unsigned long vaddr; + preempt_disable(); if (page < highmem_start_page) return page_address(page); @@ -112,8 +113,10 @@ unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); - if (vaddr < FIXADDR_START) // FIXME+ if (vaddr < FIXADDR_START) { // FIXME+ preempt_enable(); return;+ } if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx)) out_of_line_bug();@@ -125,6 +128,8 @@ pte_clear(kmap_pte-idx); __flush_tlb_one(vaddr); #endif++ preempt_enable(); } #endif /* __KERNEL__ */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/include/asm-i386/hw_irq.h linuxmips-2.4.30/include/asm-i386/hw_irq.h--- linuxmips-2.4.30.ref/include/asm-i386/hw_irq.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/hw_irq.h 2005-08-29 11:43:45.000000000 -0700@@ -95,6 +95,18 @@ #define __STR(x) #x #define STR(x) __STR(x) +#define GET_CURRENT \+ "movl %esp, %ebx\n\t" \+ "andl $-8192, %ebx\n\t"++#ifdef CONFIG_PREEMPT+#define BUMP_LOCK_COUNT \+ GET_CURRENT \+ "incl 4(%ebx)\n\t"+#else+#define BUMP_LOCK_COUNT+#endif+ #define SAVE_ALL \ "cld\n\t" \ "pushl %es\n\t" \@@ -108,15 +120,12 @@ "pushl %ebx\n\t" \ "movl $" STR(__KERNEL_DS) ",%edx\n\t" \ "movl %edx,%ds\n\t" \- "movl %edx,%es\n\t"+ "movl %edx,%es\n\t" \+ BUMP_LOCK_COUNT #define IRQ_NAME2(nr) nr##_interrupt(void) #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr) -#define GET_CURRENT \- "movl %esp, %ebx\n\t" \- "andl $-8192, %ebx\n\t"- /* * SMP has a few special interrupts for IPI messages */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/include/asm-i386/i387.h linuxmips-2.4.30/include/asm-i386/i387.h--- linuxmips-2.4.30.ref/include/asm-i386/i387.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/i387.h 2005-08-29 11:43:45.000000000 -0700@@ -12,6 +12,7 @@ #define __ASM_I386_I387_H #include <linux/sched.h>+#include <linux/spinlock.h> #include <asm/processor.h> #include <asm/sigcontext.h> #include <asm/user.h>@@ -24,7 +25,7 @@ extern void restore_fpu( struct task_struct *tsk ); extern void kernel_fpu_begin(void);-#define kernel_fpu_end() stts()+#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) #define unlazy_fpu( tsk ) do { \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/include/asm-i386/pgalloc.h linuxmips-2.4.30/include/asm-i386/pgalloc.h--- linuxmips-2.4.30.ref/include/asm-i386/pgalloc.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/pgalloc.h 2005-08-29 11:43:45.000000000 -0700@@ -75,20 +75,26 @@ { unsigned long *ret; + preempt_disable(); if ((ret = pgd_quicklist) != NULL) { pgd_quicklist = (unsigned long *)(*ret); ret[0] = 0; pgtable_cache_size--;- } else+ preempt_enable();+ } else {+ preempt_enable(); ret = (unsigned long *)get_pgd_slow();+ } return (pgd_t *)ret; } static inline void free_pgd_fast(pgd_t *pgd) {+ preempt_disable(); *(unsigned long *)pgd = (unsigned long) pgd_quicklist; pgd_quicklist = (unsigned long *) pgd; pgtable_cache_size++;+ preempt_enable(); } static inline void free_pgd_slow(pgd_t *pgd)@@ -119,19 +125,23 @@ { unsigned long *ret; + preempt_disable(); if ((ret = (unsigned long *)pte_quicklist) != NULL) { pte_quicklist = (unsigned long *)(*ret); ret[0] = ret[1]; pgtable_cache_size--; }+ preempt_enable(); return (pte_t *)ret; } static inline void pte_free_fast(pte_t *pte) {+ preempt_disable(); *(unsigned long *)pte = (unsigned long) pte_quicklist; pte_quicklist = (unsigned long *) pte; pgtable_cache_size++;+ preempt_enable(); } static __inline__ void pte_free_slow(pte_t *pte)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/include/asm-i386/smplock.h linuxmips-2.4.30/include/asm-i386/smplock.h--- linuxmips-2.4.30.ref/include/asm-i386/smplock.h 2005-08-29 11:42:15.000000000 -0700+++ linuxmips-2.4.30/include/asm-i386/smplock.h 2005-08-29 11:43:45.000000000 -0700@@ -14,7 +14,15 @@ extern spinlock_cacheline_t kernel_flag_cacheline; #define kernel_flag kernel_flag_cacheline.lock +#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@@ -46,6 +54,11 @@ */ static __inline__ void lock_kernel(void) {+#ifdef CONFIG_PREEMPT+ if (current->lock_depth == -1)+ spin_lock
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -