OS-6848: vm_localize_resources() CPU check is wrong

Details

Issue Type:Bug
Priority:4 - Normal
Status:Resolved
Created at:2018-03-29T09:03:59.602Z
Updated at:2018-03-29T20:26:49.281Z

People

Created by:John Levon [X]
Reported by:John Levon [X]
Assigned to:John Levon [X]

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2018-03-29T20:26:49.268Z)

Fix Versions

2018-04-12 Promised Land (Release Date: 2018-04-12)

Related Issues

Related Links

Labels

bhyve

Description

This routine begins with:

         if (vcpu->hostcpu == curcpu)
                return;

Unfortunately I missed during code review that this check is always false: here, vcpu->state is VCPU_FROZEN, and vcpu_set_state_locked} resets ->hostcpu to NOCPU in such a case.

This means we will be calling cyclic_move_here a bunch of times - and taking cpu_lock. However, we typically won't actually be juggling, as the cyclic will already have moved. So the impact here is essentially unnecessary contention on cpu_lock.

To fix, we will track the last CPU we were VCPU_RUNNING on with ->lasthostcpu, and use that.

Comments

Comment by John Levon [X]
Created at 2018-03-29T09:48:27.641Z

To test the fix, I ran a DTrace script to verify that xc traffic wasn't related to the cyclics (i.e. they have been correctly moved still), and we're not needlessly calling into cyclic_move_here() (i.e. this bug has been fixed).


Comment by Jira Bot
Created at 2018-03-29T20:24:58.681Z

illumos-joyent commit 966ea1794ae987e496f16d40f7b45be7e16445cf (branch master, by John Levon)

OS-6848 vm_localize_resources() CPU check is wrong
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: Patrick Mooney <patrick.mooney@joyent.com>