vmm: Prioritize task threads over guest threads
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 14 Aug 2017 16:01:09 +0000 (12:01 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 14 Aug 2017 21:02:20 +0000 (17:02 -0400)
commitfd57bb32eeed7fd4d2b8971ae8f6c39f4c5a70b4
treed5ad33a7ccff26c9d72635ee4e48b8b8ea27f53c
parent50ea0450cd886f7abb8f2c6dbb8c3a77d7c6edb3
vmm: Prioritize task threads over guest threads

Originally, we had some task threads that would busy wait, so we had to
alternate between tasks and guests.  Otherwise, the task threads would
starve the guests.

However, with Gan's "thread per timer tick per core" change, multicore VMs
running on an SCP VMMs ran into problems.  The guest cores would starve out
the task threads.  Specifically, every guest LAPIC timer tick we'd create N
task threads.  We'd run one of them, then the next *vcore* tick we'd run a
guest thread - which would spin in Linux in smp_call_function().  The N-1
other alarms would wait.  By the time those threads got their chance to run
(vcore tick), we'd also have N more LAPIC timer threads created.  So we'd
grow the number of threads by N-1 every tick (1 msec).

Anyway, this turned out to be an easy fix: prioritize task threads, like I
originally wanted to.  The old task thread that was busy waiting was
replaced a while ago.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/vmm/sched.c