📄 1021.lowlatency.patch
字号:
++void set_running_and_schedule(void);+#define unconditional_schedule() set_running_and_schedule()++#endif /* LOWLATENCY_DEBUG */++#define conditional_schedule() \+ do { \+ if (conditional_schedule_needed()) \+ unconditional_schedule(); \+ } while (0)++#define DEFINE_RESCHED_COUNT int resched_count = 0+#define TEST_RESCHED_COUNT(n) (enable_lowlatency && (++resched_count > (n)))+#define RESET_RESCHED_COUNT() resched_count = 0+extern int ll_copy_to_user(void *to_user, const void *from, unsigned long len);+extern int ll_copy_from_user(void *to, const void *from_user, unsigned long len);++#else /* LOWLATENCY_NEEDED */++#define conditional_schedule_needed() 0+#define conditional_schedule()+#define unconditional_schedule()++#define DEFINE_RESCHED_COUNT+#define TEST_RESCHED_COUNT(n) 0+#define RESET_RESCHED_COUNT()+#define ll_copy_to_user(to_user, from, len) copy_to_user((to_user), (from), (len))+#define ll_copy_from_user(to, from_user, len) copy_from_user((to), (from_user), (len))++#endif /* LOWLATENCY_NEEDED */++#endif /* LOW_LATENCY_H_INCLUDED */+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/linux/mm.h linuxmips-2.4.30/include/linux/mm.h--- linuxmips-2.4.30.ref/include/linux/mm.h 2005-07-21 19:45:37.000000000 -0700+++ linuxmips-2.4.30/include/linux/mm.h 2005-07-22 09:36:02.000000000 -0700@@ -124,6 +124,8 @@ */ extern pgprot_t protection_map[16]; +/* Actions for zap_page_range() */+#define ZPR_COND_RESCHED 1 /* Do a conditional_schedule() occasionally */ /* * These are the virtual MM functions - opening of an area, closing and@@ -487,7 +489,7 @@ extern void shmem_lock(struct file * file, int lock); extern int shmem_zero_setup(struct vm_area_struct *); -extern void zap_page_range(struct mm_struct *mm, unsigned long address, unsigned long size);+extern void zap_page_range(struct mm_struct *mm, unsigned long address, unsigned long size, int actions); extern int copy_page_range(struct mm_struct *dst, struct mm_struct *src, struct vm_area_struct *vma); extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot); extern int zeromap_page_range(unsigned long from, unsigned long size, pgprot_t prot);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/linux/reiserfs_fs.h linuxmips-2.4.30/include/linux/reiserfs_fs.h--- linuxmips-2.4.30.ref/include/linux/reiserfs_fs.h 2004-11-18 16:28:51.000000000 -0800+++ linuxmips-2.4.30/include/linux/reiserfs_fs.h 2005-07-22 09:36:02.000000000 -0700@@ -1329,8 +1329,8 @@ #define fs_generation(s) ((s)->u.reiserfs_sb.s_generation_counter) #define get_generation(s) atomic_read (&fs_generation(s)) #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)-#define fs_changed(gen,s) (gen != get_generation (s))-+#define __fs_changed(gen,s) (gen != get_generation (s))+#define fs_changed(gen,s) ({conditional_schedule(); __fs_changed(gen,s);}) /***************************************************************************/ /* FIXATE NODES */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/linux/sched.h linuxmips-2.4.30/include/linux/sched.h--- linuxmips-2.4.30.ref/include/linux/sched.h 2005-07-21 19:45:37.000000000 -0700+++ linuxmips-2.4.30/include/linux/sched.h 2005-07-22 09:36:02.000000000 -0700@@ -26,6 +26,7 @@ #include <linux/signal.h> #include <linux/securebits.h> #include <linux/fs_struct.h>+#include <linux/low-latency.h> struct exec_domain; 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/linux/sysctl.h linuxmips-2.4.30/include/linux/sysctl.h--- linuxmips-2.4.30.ref/include/linux/sysctl.h 2005-07-21 19:45:39.000000000 -0700+++ linuxmips-2.4.30/include/linux/sysctl.h 2005-07-22 09:36:02.000000000 -0700@@ -124,6 +124,7 @@ KERN_CORE_USES_PID=52, /* int: use core or core.%pid */ KERN_TAINTED=53, /* int: various kernel tainted flags */ KERN_CADPID=54, /* int: PID of the process to notify on CAD */+ KERN_LOWLATENCY=55, /* int: enable low latency scheduling */ KERN_CORE_PATTERN=56, /* string: pattern for core-files */ KERN_PPC_L3CR=57, /* l3cr register on PPC */ KERN_EXCEPTION_TRACE=58, /* boolean: exception trace */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/kernel/exit.c linuxmips-2.4.30/kernel/exit.c--- linuxmips-2.4.30.ref/kernel/exit.c 2005-07-21 19:15:31.000000000 -0700+++ linuxmips-2.4.30/kernel/exit.c 2005-07-22 09:36:02.000000000 -0700@@ -196,6 +196,7 @@ } i++; set >>= 1;+ conditional_schedule(); /* sys_exit, many files open */ } } }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/kernel/ksyms.c linuxmips-2.4.30/kernel/ksyms.c--- linuxmips-2.4.30.ref/kernel/ksyms.c 2005-07-21 19:15:31.000000000 -0700+++ linuxmips-2.4.30/kernel/ksyms.c 2005-07-22 09:36:02.000000000 -0700@@ -486,6 +486,13 @@ EXPORT_SYMBOL(do_gettimeofday); EXPORT_SYMBOL(do_settimeofday); +#if LOWLATENCY_NEEDED+EXPORT_SYMBOL(set_running_and_schedule);+#ifdef CONFIG_LOLAT_SYSCTL+EXPORT_SYMBOL(__enable_lowlatency);+#endif+#endif+ #if !defined(__ia64__) EXPORT_SYMBOL(loops_per_jiffy); #endifdiff -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/kernel/module.c linuxmips-2.4.30/kernel/module.c--- linuxmips-2.4.30.ref/kernel/module.c 2003-08-13 10:19:29.000000000 -0700+++ linuxmips-2.4.30/kernel/module.c 2005-07-22 09:36:02.000000000 -0700@@ -1187,6 +1187,11 @@ return ERR_PTR(-ENOMEM); lock_kernel(); for (v = module_list, n = *pos; v; n -= v->nsyms, v = v->next) {+#if 0+ /* We can't actually do this, because we'd create a+ * race against module unload. Need a semaphore. */+ conditional_schedule();+#endif if (n < v->nsyms) { p->mod = v; p->index = n;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/kernel/sched.c linuxmips-2.4.30/kernel/sched.c--- linuxmips-2.4.30.ref/kernel/sched.c 2005-07-21 19:15:31.000000000 -0700+++ linuxmips-2.4.30/kernel/sched.c 2005-07-22 09:36:02.000000000 -0700@@ -302,6 +302,17 @@ if (tsk->processor != this_cpu) smp_send_reschedule(tsk->processor); }+#if LOWLATENCY_NEEDED+ if (enable_lowlatency && (p->policy != SCHED_OTHER)) {+ struct task_struct *t;+ for (i = 0; i < smp_num_cpus; i++) {+ cpu = cpu_logical_map(i);+ t = cpu_curr(cpu);+ if (t != tsk)+ t->need_resched = 1;+ }+ }+#endif return; @@ -638,6 +649,11 @@ goto repeat_schedule; } + if (unlikely(prev->need_resched)) {+ prev->need_resched = 0;+ goto repeat_schedule;+ }+ /* * from this point on nothing can prevent us from * switching to the next task, save this fact in@@ -1458,3 +1474,93 @@ atomic_inc(&init_mm.mm_count); enter_lazy_tlb(&init_mm, current, cpu); }++#if LOWLATENCY_NEEDED+#if LOWLATENCY_DEBUG++static struct lolat_stats_t *lolat_stats_head;+static spinlock_t lolat_stats_lock = SPIN_LOCK_UNLOCKED;++void set_running_and_schedule(struct lolat_stats_t *stats)+{+ spin_lock(&lolat_stats_lock);+ if (stats->visited == 0) {+ stats->visited = 1;+ stats->next = lolat_stats_head;+ lolat_stats_head = stats;+ }+ stats->count++;+ spin_unlock(&lolat_stats_lock);++ if (current->state != TASK_RUNNING)+ set_current_state(TASK_RUNNING);+ schedule();+}++void show_lolat_stats(void)+{+ struct lolat_stats_t *stats = lolat_stats_head;++ printk("Low latency scheduling stats:\n");+ while (stats) {+ printk("%s:%d: %lu\n", stats->file, stats->line, stats->count);+ stats->count = 0;+ stats = stats->next;+ }+}++#else /* LOWLATENCY_DEBUG */++void set_running_and_schedule()+{+ if (current->state != TASK_RUNNING)+ __set_current_state(TASK_RUNNING);+ schedule();+}++#endif /* LOWLATENCY_DEBUG */++int ll_copy_to_user(void *to_user, const void *from, unsigned long len)+{+ while (len) {+ unsigned long n_to_copy = len;+ unsigned long remainder;++ if (n_to_copy > 4096)+ n_to_copy = 4096;+ len -= n_to_copy;+ remainder = copy_to_user(to_user, from, n_to_copy);+ if (remainder)+ return remainder + len;+ to_user = ((char *)to_user) + n_to_copy;+ from = ((char *)from) + n_to_copy;+ conditional_schedule();+ }+ return 0;+}++int ll_copy_from_user(void *to, const void *from_user, unsigned long len)+{+ while (len) {+ unsigned long n_to_copy = len;+ unsigned long remainder;++ if (n_to_copy > 4096)+ n_to_copy = 4096;+ len -= n_to_copy;+ remainder = copy_from_user(to, from_user, n_to_copy);+ if (remainder)+ return remainder + len;+ to = ((char *)to) + n_to_copy;+ from_user = ((char *)from_user) + n_to_copy;+ conditional_schedule();+ }+ return 0;+}++#ifdef CONFIG_LOLAT_SYSCTL+struct low_latency_enable_struct __enable_lowlatency = { 0, };+#endif++#endif /* LOWLATENCY_NEEDED */+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/kernel/sysctl.c linuxmips-2.4.30/kernel/sysctl.c--- linuxmips-2.4.30.ref/kernel/sysctl.c 2004-12-26 20:13:55.000000000 -0800+++ linuxmips-2.4.30/kernel/sysctl.c 2005-07-22 09:36:02.000000000 -0700@@ -278,6 +278,10 @@ {KERN_EXCEPTION_TRACE,"exception-trace", &exception_trace,sizeof(int),0644,NULL,&proc_dointvec}, #endif +#ifdef CONFIG_LOLAT_SYSCTL+ {KERN_LOWLATENCY, "lowlatency", &enable_lowlatency, sizeof (int),+ 0644, NULL, &proc_dointvec},+#endif {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/mm/filemap.c linuxmips-2.4.30/mm/filemap.c--- linuxmips-2.4.30.ref/mm/filemap.c 2005-04-05 12:09:58.000000000 -0700+++ linuxmips-2.4.30/mm/filemap.c 2005-07-22 09:36:02.000000000 -0700@@ -185,7 +185,9 @@ { struct list_head *head, *curr; struct page * page;+ int ll_count = 100; +restart: head = &inode->i_mapping->clean_pages; spin_lock(&pagemap_lru_lock);@@ -196,6 +198,14 @@ page = list_entry(curr, struct page, list); curr = curr->next; + if (conditional_schedule_needed() && ll_count) {+ spin_unlock(&pagecache_lock);+ spin_unlock(&pagemap_lru_lock);+ unconditional_schedule();+ ll_count--;+ goto restart;+ }+ /* We cannot invalidate something in dirty.. */ if (PageDirty(page)) continue;@@ -259,8 +269,8 @@ page_cache_release(page); } -static int FASTCALL(truncate_list_pages(struct list_head *, unsigned long, unsigned *));-static int fastcall truncate_list_pages(struct list_head *head, unsigned long start, unsigned *partial)+static int truncate_list_pages(struct list_head *head, unsigned long start,+ unsigned *partial, int *restart_count)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -