From owner-freebsd-current Sat Aug 5 8:47:42 2000 Delivered-To: freebsd-current@freebsd.org Received: from smople.thehub.com.au (smople.thehub.com.au [203.143.240.10]) by hub.freebsd.org (Postfix) with ESMTP id E82BA37B9C8 for ; Sat, 5 Aug 2000 08:47:27 -0700 (PDT) (envelope-from mckay@thehub.com.au) Received: from dungeon.home (ppp124.dyn248.pacific.net.au [203.143.248.124]) by smople.thehub.com.au (8.9.3/8.9.1) with ESMTP id BAA52429; Sun, 6 Aug 2000 01:46:55 +1000 (EST) Received: from dungeon.home (localhost [127.0.0.1]) by dungeon.home (8.9.3/8.9.3) with ESMTP id BAA10791; Sun, 6 Aug 2000 01:49:49 +1000 (EST) (envelope-from mckay) Message-Id: <200008051549.BAA10791@dungeon.home> To: freebsd-current@freebsd.org Cc: mckay@thehub.com.au Subject: Ugly, slow shutdown Date: Sun, 06 Aug 2000 01:49:49 +1000 From: Stephen McKay Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I'm off in a few days for a couple months of tourism in Europe (no, no need for sympathy!), so I'm dumping these couple ideas on you and running. I think shutdown time has gotten uglier and slower than it needs to be. I want to apply these patches (well, at least the first one) before I escape radar range. Your job is to not object much. :-) Patch 1 replaces: Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped with Stopping bufdaemon Also: syncing disks... 10 10 3 done returns to the traditional syncing disks... 10 10 3 done Patch 2 is smaller and possibly controversial. Normally bufdaemon and syncer are sleeping when they are told to suspend. This delays shutdown by a few boring seconds. With this patch, it is zippier. I expect people to complain about this shortcut, but every sleeping process should expect to be woken for no reason at all. Basic kernel premise. I've been running these patches on a 4.x machine for a while now. No problems except I am now surprised by the slow and ugly shutdown of unpatched machines. :-) I apologise that I've not tested these against -current. That's the bit that I've skipped because I'm out of time. There should be no difference between 4.x and -current in this area though. These patches will apply cleanly against both. Cheers, Stephen. Patch 1: Index: kern_shutdown.c =================================================================== RCS file: /cvs/src/sys/kern/kern_shutdown.c,v retrieving revision 1.76 diff -u -r1.76 kern_shutdown.c --- kern_shutdown.c 2000/07/04 11:25:22 1.76 +++ kern_shutdown.c 2000/07/06 15:02:21 @@ -247,7 +247,6 @@ sync(&proc0, NULL); DELAY(50000 * iter); } - printf("\n"); /* * Count only busy local buffers to prevent forcing * a fsck if we're just a client of a wedged NFS server @@ -261,6 +260,8 @@ bp->b_vp->v_mount, mnt_list); continue; } + if (nbusy == 0) + printf("\n"); nbusy++; #if defined(SHOW_BUSYBUFS) || defined(DIAGNOSTIC) printf( @@ -593,12 +594,11 @@ return; p = (struct proc *)arg; - printf("Waiting (max %d seconds) for system process `%s' to stop...", - kproc_shutdown_wait, p->p_comm); + printf("Stopping %s", p->p_comm); error = suspend_kproc(p, kproc_shutdown_wait * hz); if (error == EWOULDBLOCK) - printf("timed out\n"); + printf(": timed out\n"); else - printf("stopped\n"); + printf("\n"); } Patch 2: Index: kern_kthread.c =================================================================== RCS file: /cvs/src/sys/kern/kern_kthread.c,v retrieving revision 1.5 diff -u -r1.5 kern_kthread.c --- kern_kthread.c 2000/01/10 08:00:58 1.5 +++ kern_kthread.c 2000/08/05 15:32:06 @@ -116,6 +116,12 @@ */ if ((p->p_flag & P_SYSTEM) == 0) return (EINVAL); + /* + * The target process is probably just snoozing. Wake it up so + * that it will notice that it should suspend itself. + */ + if (p->p_wchan != NULL) + wakeup(p->p_wchan); SIGADDSET(p->p_siglist, SIGSTOP); return tsleep((caddr_t)&p->p_siglist, PPAUSE, "suspkp", timo); } TheEnd To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message