Skip to content

Commit 8af334c

Browse files
lifeixacrnsi
authored andcommitted
hv: vcpu: operation in vcpu_create don't need to be atomic
For pre-launched VMs and SOS, vCPUs are created on BSP one by one; For post-launched VMs, vCPUs are created under vmm_hypercall_lock protection. So vcpu_create is called sequentially. Operation in vcpu_create don't need to be atomic. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 540841a commit 8af334c

File tree

1 file changed

+2
-2
lines changed
  • hypervisor/arch/x86/guest

1 file changed

+2
-2
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
362362
* vcpu->vcpu_id = vm->hw.created_vcpus;
363363
* vm->hw.created_vcpus++;
364364
*/
365-
vcpu_id = atomic_xadd16(&vm->hw.created_vcpus, 1U);
365+
vcpu_id = vm->hw.created_vcpus;
366366
if (vcpu_id < CONFIG_MAX_VCPUS_PER_VM) {
367367
/* Allocate memory for VCPU */
368368
vcpu = &(vm->hw.vcpu_array[vcpu_id]);
@@ -422,9 +422,9 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
422422

423423
reset_vcpu_regs(vcpu);
424424
(void)memset((void *)&vcpu->req, 0U, sizeof(struct io_request));
425+
vm->hw.created_vcpus++;
425426
ret = 0;
426427
} else {
427-
vm->hw.created_vcpus -= 1U;
428428
pr_err("%s, vcpu id is invalid!\n", __func__);
429429
ret = -EINVAL;
430430
}

0 commit comments

Comments
 (0)