summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblambert <blambert@openbsd.org>2014-09-09 07:07:39 +0000
committerblambert <blambert@openbsd.org>2014-09-09 07:07:39 +0000
commit574e7ffd094778505e6242ae5b53a745de28cc89 (patch)
tree6dc11ac68c6963aa3c7a2642a011bf9fd92fd875
parentReplace last usage of awk in sysmerge with a shell equivalent. (diff)
downloadwireguard-openbsd-574e7ffd094778505e6242ae5b53a745de28cc89.tar.xz
wireguard-openbsd-574e7ffd094778505e6242ae5b53a745de28cc89.zip
Make the cleaner, syncer, pagedaemon, aiodone daemons all
yield() if the cpu is marked SHOULDYIELD. ok miod@ tedu@ phessler@
-rw-r--r--sys/kern/vfs_bio.c4
-rw-r--r--sys/kern/vfs_sync.c4
-rw-r--r--sys/sys/sched.h8
-rw-r--r--sys/uvm/uvm_pdaemon.c6
4 files changed, 18 insertions, 4 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 53bd6abf5f6..37b8e32c3b4 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.161 2014/08/31 21:08:48 tedu Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.162 2014/09/09 07:07:39 blambert Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*
@@ -1057,6 +1057,8 @@ buf_daemon(struct proc *p)
bawrite(bp);
pushed++;
+ sched_pause();
+
/* Never allow processing to run for more than 1 sec */
getmicrouptime(&tv);
timersub(&tv, &starttime, &timediff);
diff --git a/sys/kern/vfs_sync.c b/sys/kern/vfs_sync.c
index 6fbbb36a87b..af1bfd1ae84 100644
--- a/sys/kern/vfs_sync.c
+++ b/sys/kern/vfs_sync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_sync.c,v 1.51 2013/07/02 01:04:23 guenther Exp $ */
+/* $OpenBSD: vfs_sync.c,v 1.52 2014/09/09 07:07:39 blambert Exp $ */
/*
* Portions of this code are:
@@ -194,6 +194,8 @@ sched_sync(struct proc *p)
*/
vn_syncer_add_to_worklist(vp, syncdelay);
}
+
+ sched_pause();
}
splx(s);
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 10223323822..731d9dcbfd1 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.35 2014/03/29 18:09:31 guenther Exp $ */
+/* $OpenBSD: sched.h,v 1.36 2014/09/09 07:07:39 blambert Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -174,6 +174,12 @@ void remrunqueue(struct proc *);
(parent)->p_estcpu = ESTCPULIM((parent)->p_estcpu + (child)->p_estcpu);\
} while (0)
+/* Allow other processes to progress */
+#define sched_pause() do { \
+ if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) \
+ yield(); \
+} while (0)
+
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
#include <sys/lock.h>
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 38cc8476f65..02827de793c 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.71 2014/07/12 09:02:24 kettenis Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.72 2014/09/09 07:07:39 blambert Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -273,6 +273,8 @@ uvm_pageout(void *arg)
/* scan done. unlock page queues (only lock we are holding) */
uvm_unlock_pageq();
+
+ sched_pause();
}
/*NOTREACHED*/
}
@@ -313,6 +315,8 @@ uvm_aiodone_daemon(void *arg)
(*bp->b_iodone)(bp);
splx(s);
bp = nbp;
+
+ sched_pause();
}
uvm_lock_fpageq();
wakeup(free <= uvmexp.reserve_kernel ? &uvm.pagedaemon :