📄 1021.lowlatency.patch
字号:
--- linuxmips-2.4.30.ref/fs/jbd/checkpoint.c 2003-01-11 09:53:17.000000000 -0800+++ linuxmips-2.4.30/fs/jbd/checkpoint.c 2005-07-22 09:36:02.000000000 -0700@@ -431,7 +431,11 @@ { transaction_t *transaction, *last_transaction, *next_transaction; int ret = 0;+ int ll_retries = 4; /* lowlatency addition */ +restart:+ if (ll_retries-- == 0)+ goto out; transaction = journal->j_checkpoint_transactions; if (transaction == 0) goto out;@@ -451,6 +455,12 @@ jh = next_jh; next_jh = jh->b_cpnext; ret += __try_to_free_cp_buf(jh);+ if (conditional_schedule_needed()) {+ spin_unlock(&journal_datalist_lock);+ unconditional_schedule();+ spin_lock(&journal_datalist_lock);+ goto restart;+ } } while (jh != last_jh); } } while (transaction != last_transaction);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/jbd/commit.c linuxmips-2.4.30/fs/jbd/commit.c--- linuxmips-2.4.30.ref/fs/jbd/commit.c 2005-04-05 12:09:57.000000000 -0700+++ linuxmips-2.4.30/fs/jbd/commit.c 2005-07-22 09:36:02.000000000 -0700@@ -280,8 +280,7 @@ journal_brelse_array(wbuf, bufs); lock_journal(journal); spin_lock(&journal_datalist_lock);- if (bufs)- goto write_out_data_locked;+ goto write_out_data_locked; } /*@@ -317,6 +316,15 @@ */ while ((jh = commit_transaction->t_async_datalist)) { struct buffer_head *bh = jh2bh(jh);++ if (conditional_schedule_needed()) {+ spin_unlock(&journal_datalist_lock);+ unlock_journal(journal);+ unconditional_schedule();+ lock_journal(journal);+ spin_lock(&journal_datalist_lock);+ continue; /* List may have changed */+ } if (__buffer_state(bh, Freed)) { BUFFER_TRACE(bh, "Cleaning freed buffer"); clear_bit(BH_Freed, &bh->b_state);@@ -347,6 +355,16 @@ if (bh->b_list != BUF_CLEAN) refile_buffer(bh); __brelse(bh);+ if (conditional_schedule_needed()) {+ if (commit_transaction->t_sync_datalist)+ commit_transaction->t_sync_datalist =+ next_jh;+ if (bufs)+ break;+ spin_unlock(&journal_datalist_lock);+ unconditional_schedule();+ goto write_out_data;+ } } } spin_unlock(&journal_datalist_lock);@@ -536,6 +554,8 @@ wait_for_iobuf: while (commit_transaction->t_iobuf_list != NULL) { struct buffer_head *bh;++ conditional_schedule(); jh = commit_transaction->t_iobuf_list->b_tprev; bh = jh2bh(jh); if (buffer_locked(bh)) {@@ -695,6 +715,8 @@ struct buffer_head *bh; int was_freed = 0; + conditional_schedule(); /* journal is locked */+ jh = commit_transaction->t_forget; J_ASSERT_JH(jh, jh->b_transaction == commit_transaction || jh->b_transaction == journal->j_running_transaction);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/proc/array.c linuxmips-2.4.30/fs/proc/array.c--- linuxmips-2.4.30.ref/fs/proc/array.c 2004-11-29 09:47:18.000000000 -0800+++ linuxmips-2.4.30/fs/proc/array.c 2005-07-22 09:36:02.000000000 -0700@@ -422,9 +422,11 @@ if (end > PMD_SIZE) end = PMD_SIZE; do {- pte_t page = *pte;+ pte_t page; struct page *ptpage; + conditional_schedule(); /* For `top' and `ps' */+ page = *pte; address += PAGE_SIZE; pte++; if (pte_none(page))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/proc/generic.c linuxmips-2.4.30/fs/proc/generic.c--- linuxmips-2.4.30.ref/fs/proc/generic.c 2004-11-29 09:47:18.000000000 -0800+++ linuxmips-2.4.30/fs/proc/generic.c 2005-07-22 09:36:02.000000000 -0700@@ -101,6 +101,8 @@ retval = n; break; }++ conditional_schedule(); /* Some /proc files are large */ /* This is a hack to allow mangling of file pos independent * of actual bytes read. Simply place the data at page,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/reiserfs/buffer2.c linuxmips-2.4.30/fs/reiserfs/buffer2.c--- linuxmips-2.4.30.ref/fs/reiserfs/buffer2.c 2003-08-13 10:19:25.000000000 -0700+++ linuxmips-2.4.30/fs/reiserfs/buffer2.c 2005-07-22 09:36:02.000000000 -0700@@ -54,6 +54,7 @@ PROC_EXP( unsigned int ctx_switches = kstat.context_swtch ); result = bread (super -> s_dev, n_block, n_size);+ conditional_schedule(); PROC_INFO_INC( super, breads ); PROC_EXP( if( kstat.context_swtch != ctx_switches ) PROC_INFO_INC( super, bread_miss ) );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/reiserfs/journal.c linuxmips-2.4.30/fs/reiserfs/journal.c--- linuxmips-2.4.30.ref/fs/reiserfs/journal.c 2004-08-14 11:39:01.000000000 -0700+++ linuxmips-2.4.30/fs/reiserfs/journal.c 2005-07-22 09:36:02.000000000 -0700@@ -577,6 +577,7 @@ /* lock the current transaction */ inline static void lock_journal(struct super_block *p_s_sb) { PROC_INFO_INC( p_s_sb, journal.lock_journal );+ conditional_schedule(); while(atomic_read(&(SB_JOURNAL(p_s_sb)->j_wlock)) > 0) { PROC_INFO_INC( p_s_sb, journal.lock_journal_wait ); sleep_on(&(SB_JOURNAL(p_s_sb)->j_wait)) ;@@ -707,6 +708,7 @@ mark_buffer_dirty(tbh) ; } ll_rw_block(WRITE, 1, &tbh) ;+ conditional_schedule(); count++ ; put_bh(tbh) ; /* once for our get_hash */ } @@ -836,6 +838,7 @@ set_bit(BH_Dirty, &(SB_JOURNAL(p_s_sb)->j_header_bh->b_state)) ; ll_rw_block(WRITE, 1, &(SB_JOURNAL(p_s_sb)->j_header_bh)) ; wait_on_buffer((SB_JOURNAL(p_s_sb)->j_header_bh)) ; + conditional_schedule(); if (!buffer_uptodate(SB_JOURNAL(p_s_sb)->j_header_bh)) { reiserfs_warning( p_s_sb, "reiserfs: journal-837: IO error during journal replay\n" ); return -EIO ;@@ -2363,6 +2366,7 @@ } int journal_begin(struct reiserfs_transaction_handle *th, struct super_block * p_s_sb, unsigned long nblocks) {+ conditional_schedule(); return do_journal_begin_r(th, p_s_sb, nblocks, 0) ; } @@ -2503,6 +2507,7 @@ } int journal_end(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {+ conditional_schedule(); return do_journal_end(th, p_s_sb, nblocks, 0) ; } @@ -2974,6 +2979,7 @@ RFALSE( buffer_locked(bh) && cur_tb != NULL, "waiting while do_balance was running\n") ; wait_on_buffer(bh) ;+ conditional_schedule(); } PROC_INFO_INC( p_s_sb, journal.prepare_retry ); retry_count++ ;@@ -3148,6 +3154,7 @@ /* copy all the real blocks into log area. dirty log blocks */ if (test_bit(BH_JDirty, &cn->bh->b_state)) { struct buffer_head *tmp_bh ;+ conditional_schedule(); tmp_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + ((cur_write_start + jindex) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ; mark_buffer_uptodate(tmp_bh, 1) ;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/reiserfs/stree.c linuxmips-2.4.30/fs/reiserfs/stree.c--- linuxmips-2.4.30.ref/fs/reiserfs/stree.c 2003-08-13 10:19:25.000000000 -0700+++ linuxmips-2.4.30/fs/reiserfs/stree.c 2005-07-22 09:36:02.000000000 -0700@@ -652,9 +652,8 @@ stop at leaf level - set to DISK_LEAF_NODE_LEVEL */ ) {- int n_block_number = SB_ROOT_BLOCK (p_s_sb),- expected_level = SB_TREE_HEIGHT (p_s_sb),- n_block_size = p_s_sb->s_blocksize;+ int n_block_number, expected_level;+ int n_block_size = p_s_sb->s_blocksize; struct buffer_head * p_s_bh; struct path_element * p_s_last_element; int n_node_level, n_retval;@@ -666,7 +665,8 @@ #endif PROC_INFO_INC( p_s_sb, search_by_key );- + conditional_schedule();+ /* As we add each node to a path we increase its count. This means that we must be careful to release all nodes in a path before we either discard the path struct or re-use the path struct, as we do here. */@@ -678,6 +678,8 @@ /* With each iteration of this loop we search through the items in the current node, and calculate the next current node(next path element) for the next iteration of this loop.. */+ n_block_number = SB_ROOT_BLOCK (p_s_sb);+ expected_level = SB_TREE_HEIGHT (p_s_sb); while ( 1 ) { #ifdef CONFIG_REISERFS_CHECK@@ -1104,6 +1106,8 @@ for (n_counter = *p_n_removed; n_counter < n_unfm_number; n_counter++, p_n_unfm_pointer-- ) { + conditional_schedule();+ if (item_moved (&s_ih, p_s_path)) { need_research = 1 ; break;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/low-latency.h linuxmips-2.4.30/include/linux/low-latency.h--- linuxmips-2.4.30.ref/include/linux/low-latency.h 1969-12-31 16:00:00.000000000 -0800+++ linuxmips-2.4.30/include/linux/low-latency.h 2005-07-22 09:36:02.000000000 -0700@@ -0,0 +1,109 @@+/*+ * include/linux/low-latency.h+ *+ * Andrew Morton <akpm@zip.com.au>+ */++#ifndef LOW_LATENCY_H_INCLUDED+#define LOW_LATENCY_H_INCLUDED++#if defined(CONFIG_LOLAT)+#define LOWLATENCY_NEEDED 1+#else+#define LOWLATENCY_NEEDED 0+#endif++#if LOWLATENCY_NEEDED++#include <linux/cache.h> /* For ____cacheline_aligned */++#ifdef CONFIG_LOLAT_SYSCTL+extern struct low_latency_enable_struct {+ int yep;+} ____cacheline_aligned __enable_lowlatency;+#define enable_lowlatency __enable_lowlatency.yep++#else+#define enable_lowlatency 1+#endif++/*+ * Set this non-zero to generate low-latency instrumentation+ */+#define LOWLATENCY_DEBUG 0++/*+ * Set this non-zero for robustness testing+ */+#define LOWLATENCY_ALWAYS_SCHEDULE 0++#if LOWLATENCY_DEBUG++#if LOWLATENCY_ALWAYS_SCHEDULE+#define conditional_schedule_needed() ((enable_lowlatency == 2) || (enable_lowlatency && current->need_resched))+#else+#define conditional_schedule_needed() (enable_lowlatency && current->need_resched)+#endif++struct lolat_stats_t {+ unsigned long count;+ int visited;+ const char *file;+ int line;+ struct lolat_stats_t *next;+};++void set_running_and_schedule(struct lolat_stats_t *stats);++#define unconditional_schedule() \+ do { \+ static struct lolat_stats_t stats = { \+ file: __FILE__, \+ line: __LINE__, \+ }; \+ set_running_and_schedule(&stats); \+ } while (0)++extern void show_lolat_stats(void);++#else /* LOWLATENCY_DEBUG */++#if LOWLATENCY_ALWAYS_SCHEDULE+#define conditional_schedule_needed() 1+#else+#define conditional_schedule_needed() (current->need_resched)+#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -