[JFFS2] Use yield() between GC passes in background thread.

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Mar 8 05:59:03 EST 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f8a922c7bb4d93bd84b7371a8e2571e667d2afb5
Commit:     f8a922c7bb4d93bd84b7371a8e2571e667d2afb5
Parent:     89e2bf61da9d7664293a57100a419f8116252607
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Thu Mar 8 10:28:30 2007 +0000
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Thu Mar 8 10:28:30 2007 +0000

    [JFFS2] Use yield() between GC passes in background thread.
    
    The garbage collection thread is strictly an optimisation. Everything it
    does would also be done just-in-time in the context of something in
    userspace trying to access the file system.
    
    Sometimes, however, it's a pessimisation. Especially during early boot
    when it's checksumming nodes and scanning inodes which are shortly going
    to be pulled in by read_inode anyway. We end up building the rbtree of
    node coverage twice for the same inode.
    
    By switching to yield() instead of cond_resched() in the main loop, we
    observe boot times on the OLPC system going down from about 100 seconds to
    60.
    
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 fs/jffs2/background.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 6eb3dae..888f236 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -99,7 +99,13 @@ static int jffs2_garbage_collect_thread(void *_c)
 		if (try_to_freeze())
 			continue;
 
-		cond_resched();
+		/* This thread is purely an optimisation. But if it runs when
+		   other things could be running, it actually makes things a
+		   lot worse. Use yield() and put it at the back of the runqueue
+		   every time. Especially during boot, pulling an inode in
+		   with read_inode() is much preferable to having the GC thread
+		   get there first. */
+		yield();
 
 		/* Put_super will send a SIGKILL and then wait on the sem.
 		 */



More information about the linux-mtd-cvs mailing list