--- linux-2.4.18-pre1/fs/buffer.c Fri Dec 21 11:19:14 2001 +++ linux-akpm/fs/buffer.c Sun Jan 6 01:06:41 2002 @@ -255,12 +255,19 @@ static int wait_for_buffers(kdev_t dev, struct buffer_head * next; int nr; - next = lru_list[index]; nr = nr_buffers_type[index]; +repeat: + next = lru_list[index]; while (next && --nr >= 0) { struct buffer_head *bh = next; next = bh->b_next_free; + if (dev == NODEV && current->need_resched) { + spin_unlock(&lru_list_lock); + conditional_schedule(); + spin_lock(&lru_list_lock); + goto repeat; + } if (!buffer_locked(bh)) { if (refile) __refile_buffer(bh); @@ -1191,8 +1198,10 @@ struct buffer_head * bread(kdev_t dev, i struct buffer_head * bh; bh = getblk(dev, block, size); - if (buffer_uptodate(bh)) + if (buffer_uptodate(bh)) { + conditional_schedule(); return bh; + } ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); if (buffer_uptodate(bh)) --- linux-2.4.18-pre1/fs/dcache.c Fri Dec 21 11:19:14 2001 +++ linux-akpm/fs/dcache.c Sat Jan 5 23:49:00 2002 @@ -71,7 +71,7 @@ static inline void d_free(struct dentry * d_iput() operation if defined. * Called with dcache_lock held, drops it. */ -static inline void dentry_iput(struct dentry * dentry) +static void dentry_iput(struct dentry * dentry) { struct inode *inode = dentry->d_inode; if (inode) { @@ -84,6 +84,7 @@ static inline void dentry_iput(struct de iput(inode); } else spin_unlock(&dcache_lock); + conditional_schedule(); } /* --- linux-2.4.18-pre1/fs/jbd/commit.c Fri Dec 21 11:19:14 2001 +++ linux-akpm/fs/jbd/commit.c Sun Jan 6 02:43:43 2002 @@ -212,6 +212,16 @@ write_out_data_locked: __journal_remove_journal_head(bh); refile_buffer(bh); __brelse(bh); + if (current->need_resched) { + if (commit_transaction->t_sync_datalist) + commit_transaction->t_sync_datalist = + next_jh; + if (bufs) + break; + spin_unlock(&journal_datalist_lock); + conditional_schedule(); + goto write_out_data; + } } } if (bufs == ARRAY_SIZE(wbuf)) { --- linux-2.4.18-pre1/fs/proc/array.c Thu Oct 11 09:00:01 2001 +++ linux-akpm/fs/proc/array.c Sat Jan 5 23:49:00 2002 @@ -414,6 +414,8 @@ static inline void statm_pte_range(pmd_t pte_t page = *pte; struct page *ptpage; + conditional_schedule(); + address += PAGE_SIZE; pte++; if (pte_none(page)) --- linux-2.4.18-pre1/fs/proc/generic.c Fri Sep 7 10:53:59 2001 +++ linux-akpm/fs/proc/generic.c Sat Jan 5 23:49:00 2002 @@ -98,7 +98,9 @@ proc_file_read(struct file * file, char retval = n; break; } - + + conditional_schedule(); + /* This is a hack to allow mangling of file pos independent * of actual bytes read. Simply place the data at page, * return the bytes, and set `start' to the desired offset --- linux-2.4.18-pre1/include/linux/condsched.h Thu Jan 1 00:00:00 1970 +++ linux-akpm/include/linux/condsched.h Sat Jan 5 23:49:00 2002 @@ -0,0 +1,18 @@ +#ifndef _LINUX_CONDSCHED_H +#define _LINUX_CONDSCHED_H + +#ifndef __LINUX_COMPILER_H +#include +#endif + +#ifndef __ASSEMBLY__ +#define conditional_schedule() \ +do { \ + if (unlikely(current->need_resched)) { \ + __set_current_state(TASK_RUNNING); \ + schedule(); \ + } \ +} while(0) +#endif + +#endif --- linux-2.4.18-pre1/include/linux/sched.h Fri Dec 21 11:19:23 2001 +++ linux-akpm/include/linux/sched.h Sun Jan 6 02:44:06 2002 @@ -13,6 +13,7 @@ extern unsigned long event; #include #include #include +#include #include #include --- linux-2.4.18-pre1/mm/filemap.c Wed Dec 26 11:47:41 2001 +++ linux-akpm/mm/filemap.c Sat Jan 5 23:49:00 2002 @@ -295,10 +295,7 @@ static int truncate_list_pages(struct li page_cache_release(page); - if (current->need_resched) { - __set_current_state(TASK_RUNNING); - schedule(); - } + conditional_schedule(); spin_lock(&pagecache_lock); goto restart; @@ -577,6 +575,7 @@ void filemap_fdatasync(struct address_sp UnlockPage(page); page_cache_release(page); + conditional_schedule(); spin_lock(&pagecache_lock); } spin_unlock(&pagecache_lock); @@ -1396,6 +1394,9 @@ page_ok: offset &= ~PAGE_CACHE_MASK; page_cache_release(page); + + conditional_schedule(); + if (ret == nr && desc->count) continue; break; @@ -3063,6 +3064,8 @@ unlock: /* Mark it unlocked again and drop the page.. */ UnlockPage(page); page_cache_release(page); + + conditional_schedule(); if (status < 0) break; --- linux-2.4.18-pre1/drivers/block/ll_rw_blk.c Mon Nov 5 21:01:11 2001 +++ linux-akpm/drivers/block/ll_rw_blk.c Sat Jan 5 23:49:00 2002 @@ -1000,6 +1000,7 @@ void submit_bh(int rw, struct buffer_hea kstat.pgpgin += count; break; } + conditional_schedule(); } /**