summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-02-11 20:36:07 +0000
committerneel <neel@FreeBSD.org>2013-02-11 20:36:07 +0000
commit3a9eeaa765cdfd3940dbf4b881957c057c6d6576 (patch)
tree08d417f2f979935bc451028d59ec525a42e021c6 /usr.sbin/bhyve
parent7bafa2ca4141fce3978c17cea165f86ce0c9ac69 (diff)
downloadFreeBSD-src-3a9eeaa765cdfd3940dbf4b881957c057c6d6576.zip
FreeBSD-src-3a9eeaa765cdfd3940dbf4b881957c057c6d6576.tar.gz
Implement guest vcpu pinning using 'pthread_setaffinity_np(3)'.
Prior to this change pinning was implemented via an ioctl (VM_SET_PINNING) that called 'sched_bind()' on behalf of the user thread. The ULE implementation of 'sched_bind()' bumps up 'td_pinned' which in turn runs afoul of the assertion '(td_pinned == 0)' in userret(). Using the cpuset affinity to implement pinning of the vcpu threads works with both 4BSD and ULE schedulers and has the happy side-effect of getting rid of a bunch of code in vmm.ko. Discussed with: grehan
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r--usr.sbin/bhyve/bhyverun.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 8d03649..ea4b68c 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -520,13 +520,17 @@ static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
static void
vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip)
{
+ cpuset_t mask;
int error, rc, prevcpu;
if (guest_vcpu_mux)
setup_timeslice();
if (pincpu >= 0) {
- error = vm_set_pinning(ctx, vcpu, pincpu + vcpu);
+ CPU_ZERO(&mask);
+ CPU_SET(pincpu + vcpu, &mask);
+ error = pthread_setaffinity_np(pthread_self(),
+ sizeof(mask), &mask);
assert(error == 0);
}
OpenPOWER on IntegriCloud