summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2013-12-31 04:41:51 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2013-12-31 04:41:51 +0100
commit50bda3d5225190cd8e2b3c7ce7aa3c1ea1759e40 (patch)
treef836bf1c091c6d6f4ed81967453cccec4232a6e3
parent4c8cfe7284b13c8b445cf278c319cad716bdbbea (diff)
downloadplan9front-50bda3d5225190cd8e2b3c7ce7aa3c1ea1759e40.tar.xz
kernel: halt idle processors on mp system by default (from sources)
one can add: int idle_spin = 1; in the kernel configuration to enable the old behaviour. see the comment at idlehands().
-rw-r--r--sys/src/9/pc/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c
index 7dbd9ad5e..bc12d5608 100644
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -31,6 +31,7 @@ char *confval[MAXCONF];
int nconf;
uchar *sp; /* user stack of init proc */
int delaylink;
+int idle_spin;
static void
multibootargs(void)
@@ -1083,6 +1084,15 @@ cistrncmp(char *a, char *b, int n)
/*
* put the processor in the halt state if we've no processes to run.
* an interrupt will get us going again.
+ *
+ * halting in an smp system can result in a startup latency for
+ * processes that become ready.
+ * if idle_spin is zero, we care more about saving energy
+ * than reducing this latency.
+ *
+ * the performance loss with idle_spin == 0 seems to be slight
+ * and it reduces lock contention (thus system time and real time)
+ * on many-core systems with large values of NPROC.
*/
void
idlehands(void)
@@ -1093,4 +1103,6 @@ idlehands(void)
halt();
else if(m->cpuidcx & Monitor)
mwait(&nrdy);
+ else if(idle_spin == 0)
+ halt();
}