mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Jeff Garzik <jgarzik@mandrakesoft.com>,
	dhowells@redhat.com, linux-kernel@vger.kernel.org,
	akpm@zip.com.au
Subject: Re: [PATCH] need_resched abstraction
Date: Wed, 16 Jan 2002 16:16:39 +1100	[thread overview]
Message-ID: <E16QiRE-0006zc-00@wagner.rustcorp.com.au> (raw)
In-Reply-To: Your message of "Tue, 15 Jan 2002 19:06:05 -0800." <Pine.LNX.4.33.0201151904120.1357-100000@penguin.transmeta.com>

In message <Pine.LNX.4.33.0201151904120.1357-100000@penguin.transmeta.com> you 
write:
> 
> On Wed, 16 Jan 2002, Rusty Russell wrote:
> > ... And I prefer maybe_schedule().
> 
> My tree calls them "cond_resched()" and "need_resched()" respectively.

Bastard!  Then please apply (thanks to Andrew Morton):

diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/drivers/block/ll_rw_blk.c working-2.5.3-pre1-ll/drivers/block/ll_rw_blk.c
--- linux-2.5.3-pre1/drivers/block/ll_rw_blk.c	Tue Jan 15 17:25:32 2002
+++ working-2.5.3-pre1-ll/drivers/block/ll_rw_blk.c	Wed Jan 16 16:15:10 2002
@@ -996,6 +996,7 @@
 		if (++rl->count >= batch_requests &&waitqueue_active(&rl->wait))
 			wake_up(&rl->wait);
 	}
+	cond_resched();
 }
 
 /*
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/fs/buffer.c working-2.5.3-pre1-ll/fs/buffer.c
--- linux-2.5.3-pre1/fs/buffer.c	Tue Jan 15 17:25:47 2002
+++ working-2.5.3-pre1-ll/fs/buffer.c	Wed Jan 16 16:15:10 2002
@@ -250,12 +250,19 @@
 	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 && need_resched()) {
+			spin_unlock(&lru_list_lock);
+			cond_resched();
+			spin_lock(&lru_list_lock);
+			goto repeat;
+		}
 		if (!buffer_locked(bh)) {
 			if (refile)
 				__refile_buffer(bh);
@@ -1180,8 +1187,10 @@
 	struct buffer_head * bh = __getblk(bdev, block, size);
 
 	touch_buffer(bh);
-	if (buffer_uptodate(bh))
+	if (buffer_uptodate(bh)) {
+		cond_resched();
 		return bh;
+	}
 	ll_rw_block(READ, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/fs/dcache.c working-2.5.3-pre1-ll/fs/dcache.c
--- linux-2.5.3-pre1/fs/dcache.c	Tue Jan 15 17:25:47 2002
+++ working-2.5.3-pre1-ll/fs/dcache.c	Wed Jan 16 16:15:10 2002
@@ -84,6 +84,7 @@
 			iput(inode);
 	} else
 		spin_unlock(&dcache_lock);
+	cond_resched();
 }
 
 /* 
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/fs/jbd/commit.c working-2.5.3-pre1-ll/fs/jbd/commit.c
--- linux-2.5.3-pre1/fs/jbd/commit.c	Tue Jan 15 17:25:48 2002
+++ working-2.5.3-pre1-ll/fs/jbd/commit.c	Wed Jan 16 16:15:10 2002
@@ -212,6 +212,16 @@
 				__journal_remove_journal_head(bh);
 				refile_buffer(bh);
 				__brelse(bh);
+				if (need_resched()) {
+					if (commit_transaction->t_sync_datalist)
+						commit_transaction->t_sync_datalist =
+							next_jh;
+					if (bufs)
+						break;
+					spin_unlock(&journal_datalist_lock);
+					cond_resched();
+					goto write_out_data;
+				}
 			}
 		}
 		if (bufs == ARRAY_SIZE(wbuf)) {
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/fs/proc/array.c working-2.5.3-pre1-ll/fs/proc/array.c
--- linux-2.5.3-pre1/fs/proc/array.c	Wed Jan 16 10:52:29 2002
+++ working-2.5.3-pre1-ll/fs/proc/array.c	Wed Jan 16 16:15:10 2002
@@ -419,6 +419,8 @@
 		pte_t page = *pte;
 		struct page *ptpage;
 
+		cond_resched();
+
 		address += PAGE_SIZE;
 		pte++;
 		if (pte_none(page))
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/fs/proc/generic.c working-2.5.3-pre1-ll/fs/proc/generic.c
--- linux-2.5.3-pre1/fs/proc/generic.c	Sat Sep  8 03:53:59 2001
+++ working-2.5.3-pre1-ll/fs/proc/generic.c	Wed Jan 16 16:15:10 2002
@@ -98,7 +98,9 @@
 				retval = n;
 			break;
 		}
-		
+
+		cond_resched();
+
 		/* 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
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.3-pre1/mm/filemap.c working-2.5.3-pre1-ll/mm/filemap.c
--- linux-2.5.3-pre1/mm/filemap.c	Wed Jan 16 10:52:30 2002
+++ working-2.5.3-pre1-ll/mm/filemap.c	Wed Jan 16 16:15:10 2002
@@ -603,6 +603,7 @@
 			UnlockPage(page);
 
 		page_cache_release(page);
+		cond_resched();
 		spin_lock(&pagecache_lock);
 	}
 	spin_unlock(&pagecache_lock);
@@ -1386,6 +1387,9 @@
 		offset &= ~PAGE_CACHE_MASK;
 
 		page_cache_release(page);
+
+		cond_resched();
+
 		if (ret == nr && desc->count)
 			continue;
 		break;
@@ -3019,6 +3023,8 @@
 		SetPageReferenced(page);
 		UnlockPage(page);
 		page_cache_release(page);
+
+		cond_resched();
 
 		if (status < 0)
 			break;
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

      reply	other threads:[~2002-01-16  5:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-15  9:13 David Howells
2002-01-15  9:29 ` Jeff Garzik
2002-01-16  3:03 ` Rusty Russell
2002-01-16  3:06   ` Linus Torvalds
2002-01-16  5:16     ` Rusty Russell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E16QiRE-0006zc-00@wagner.rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@zip.com.au \
    --cc=dhowells@redhat.com \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®