Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys Pull up (approved by thorpej):
details: https://anonhg.NetBSD.org/src/rev/8556cde5c748
branches: netbsd-1-5
changeset: 489392:8556cde5c748
user: bouyer <bouyer%NetBSD.org@localhost>
date: Wed Sep 06 08:41:41 2000 +0000
description:
Pull up (approved by thorpej):
sys/proc.h 1.104 -> 1.105
sys/kern/kern_synch.c 1.93 -> 1.94 (via patch to remove SMPism)
sys/kern/vfs_subr.c 1.137 -> 1.138
Add a suspendsched() fuctions, which stops scheduling of users processes
(exept curproc) by putting all SRUN and SSLEEP non-P_SYSTEM processes
in SSTOP state.
In vfs_shutdown() use suspendsched() suspend scheduling, and use tsleep()
instead of DELAY to give kernel threads a chance to run (needed to flush
buffers to a RAID disk). Also, keep trying flushing buffers when the number of
dirty buffers decreases (20 rounds may not be enouth for a very large buffer
cache).
diffstat:
sys/kern/kern_synch.c | 38 +++++++++++++++++++++++++++++++++++++-
sys/kern/vfs_subr.c | 19 ++++++++++++++-----
sys/sys/proc.h | 3 ++-
3 files changed, 53 insertions(+), 7 deletions(-)
diffs (128 lines):
diff -r 9a416a388b15 -r 8556cde5c748 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Wed Sep 06 06:08:33 2000 +0000
+++ b/sys/kern/kern_synch.c Wed Sep 06 08:41:41 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.78.2.2 2000/08/11 23:10:15 thorpej Exp $ */
+/* $NetBSD: kern_synch.c,v 1.78.2.3 2000/09/06 08:41:42 bouyer Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -960,3 +960,39 @@
if (p->p_priority >= PUSER)
p->p_priority = p->p_usrpri;
}
+
+void
+suspendsched()
+{
+ int s, i;
+ struct proc *p, *next;
+
+ s = splclock();
+
+ /*
+ * Convert all non-P_SYSTEM SSLEEP processes to SSTOP. Curproc is
+ * necesserelly SONPROC.
+ */
+ for (p = LIST_FIRST(&allproc); p != NULL; p = next) {
+ next = LIST_NEXT(p, p_list);
+ if (p->p_stat != SSLEEP || p == curproc ||
+ (p->p_flag & P_SYSTEM) != 0)
+ continue;
+ p->p_stat = SSTOP;
+ }
+ /* go through the run queues, remove non-P_SYSTEM processes */
+ for (i = 0; i < RUNQUE_NQS; i++) {
+ for (p = (struct proc *)&sched_qs[i];
+ p->p_forw != (struct proc *)&sched_qs[i]; p = next) {
+ next = p->p_forw;
+ if ((p->p_flag & P_SYSTEM) == 0) {
+ if (p->p_flag & P_INMEM)
+ remrunqueue(p);
+ p->p_stat = SSTOP;
+ }
+ }
+ }
+ /* XXX SMP: we need to deal with processes on others CPU ! */
+
+ splx(s);
+}
diff -r 9a416a388b15 -r 8556cde5c748 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Wed Sep 06 06:08:33 2000 +0000
+++ b/sys/kern/vfs_subr.c Wed Sep 06 08:41:41 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.128.2.3 2000/07/20 00:14:40 fvdl Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.128.2.4 2000/09/06 08:41:42 bouyer Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -88,6 +88,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/time.h>
#include <sys/fcntl.h>
@@ -2352,7 +2353,7 @@
vfs_shutdown()
{
struct buf *bp;
- int iter, nbusy, dcount, s;
+ int iter, nbusy, nbusy_prev = 0, dcount, s;
struct proc *p = curproc;
/* XXX we're certainly not running in proc0's context! */
@@ -2361,7 +2362,8 @@
printf("syncing disks... ");
- /* XXX Should suspend scheduling. */
+ /* remove user process from run queue */
+ suspendsched();
(void) spl0();
/* avoid coming back this way again if we panic. */
@@ -2371,7 +2373,7 @@
/* Wait for sync to finish. */
dcount = 10000;
- for (iter = 0; iter < 20; iter++) {
+ for (iter = 0; iter < 20;) {
nbusy = 0;
for (bp = &buf[nbuf]; --bp >= buf; ) {
if ((bp->b_flags & (B_BUSY|B_INVAL|B_READ)) == B_BUSY)
@@ -2398,8 +2400,15 @@
}
if (nbusy == 0)
break;
+ if (nbusy_prev == 0)
+ nbusy_prev = nbusy;
printf("%d ", nbusy);
- DELAY(40000 * iter);
+ tsleep(&nbusy, PRIBIO, "bflush",
+ (iter == 0) ? 1 : hz / 25 * iter);
+ if (nbusy >= nbusy_prev) /* we didn't flush anything */
+ iter++;
+ else
+ nbusy_prev = nbusy;
}
if (nbusy) {
fail:
diff -r 9a416a388b15 -r 8556cde5c748 sys/sys/proc.h
--- a/sys/sys/proc.h Wed Sep 06 06:08:33 2000 +0000
+++ b/sys/sys/proc.h Wed Sep 06 08:41:41 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.98.2.1 2000/08/11 23:07:41 thorpej Exp $ */
+/* $NetBSD: proc.h,v 1.98.2.2 2000/09/06 08:41:41 bouyer Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@@ -386,6 +386,7 @@
void resetpriority __P((struct proc *));
void setrunnable __P((struct proc *));
void setrunqueue __P((struct proc *));
+void suspendsched __P((void));
int ltsleep __P((void *chan, int pri, const char *wmesg, int timo,
__volatile struct simplelock *));
void unsleep __P((struct proc *));
Home |
Main Index |
Thread Index |
Old Index