kswapd initialization bug fix

Erik Andersen (andersee@debian.org)
Tue, 15 Jul 1997 22:53:35 -0600


Please include the following into pre-patch-2.0.31-3

The following patch is against 2.0.30 + pre-patch-2.0.31-2 + the
perfect-buffer-swap patch. This modifies the initialization of kswapd
so that it prints out its init message before the kswapd kernel thread
is spawned. This ensures that the kswapd initialization message will
never be printed in the middle of another driver's init message. This
is mostly based on a patch by Aaron Tiensivu (tiensivu@pilot.msu.edu)
that was submitted Dec 2, 1996. I updated it to patch cleanly into the
latest and (stable) greatest. I have tested this on my machine, and it
fixes the problem.

Before:

Partition check:
hda:Started kswapd v 1.4.2.2
hda1 hda2 hda3
hdc: hdc1 hdc2 < hdc5 hdc6 >
VFS: Mounted root (ext2 filesystem) readonly.

After:

Starting kswapd v 1.4.2.2
[--------Several driver init messages snipped--------]
Partition check:
hda: hda1 hda2 hda3
hdc: hdc1 hdc2 < hdc5 hdc6 >
VFS: Mounted root (ext2 filesystem) readonly.

-Erik

--
Erik B. Andersen   Web:    http://www.inconnect.com/~andersen/ 
                   email:  andersee@debian.org
--This message was written using 73% post-consumer electrons--

The kswapd_init patch follows:

diff -u --recursive --new-file linux-2.0.30.old/init/main.c linux/init/main.c --- linux-2.0.30.old/init/main.c Tue Jul 15 21:50:59 1997 +++ linux/init/main.c Tue Jul 15 20:29:36 1997 @@ -59,6 +59,7 @@ static int init(void *); extern int bdflush(void *); extern int kswapd(void *); +extern void kswapd_setup(void); extern void init_IRQ(void); extern void init_modules(void); @@ -934,6 +935,7 @@ /* Launch bdflush from here, instead of the old syscall way. */ kernel_thread(bdflush, NULL, 0); /* Start the background pageout daemon. */ + kswapd_setup(); kernel_thread(kswapd, NULL, 0); #ifdef CONFIG_BLK_DEV_INITRD diff -u --recursive --new-file linux-2.0.30.old/mm/vmscan.c linux/mm/vmscan.c --- linux-2.0.30.old/mm/vmscan.c Tue Jul 15 22:00:01 1997 +++ linux/mm/vmscan.c Tue Jul 15 20:27:16 1997 @@ -374,6 +374,24 @@ return 0; } +/* + * Before we start the kernel thread, print out the + * kswapd initialization message (otherwise the init message + * may be printed in the middle of another driver's init + * message). It looks very bad when that happens. + */ +void kswapd_setup(void) +{ + int i; + char *revision="$Revision: 1.4.2.2 $", *s, *e; + + if ((s = strchr(revision, ':')) && + (e = strchr(s, '$'))) + s++, i = e - s; + else + s = revision, i = -1; + printk ("Starting kswapd v%.*s\n", i, s); +} /* * The background pageout daemon. @@ -382,7 +400,6 @@ int kswapd(void *unused) { int i; - char *revision="$Revision: 1.4.2.2 $", *s, *e; current->session = 1; current->pgrp = 1; @@ -408,13 +425,6 @@ init_swap_timer(); - if ((s = strchr(revision, ':')) && - (e = strchr(s, '$'))) - s++, i = e - s; - else - s = revision, i = -1; - printk ("Started kswapd v%.*s\n", i, s); - while (1) { /* low on memory, we need to start swapping soon */ next_swap_jiffies = jiffies +