From 2771b46b1d8e7628a2800b1e5ded14c48a2a6936 Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Sun, 24 Mar 2019 10:08:25 +0000 Subject: [PATCH] HV: Add one delmode parameter to make_reschedule_request This patch makes make_reschedule_request support for kicking off vCPU using INIT. Tracked-On: #2865 Signed-off-by: Kaige Fu Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vcpu.c | 6 +++--- hypervisor/common/schedule.c | 17 +++++++++++++++-- hypervisor/include/common/schedule.h | 5 ++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index 3a2f22548..38a0f3429 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -598,7 +598,7 @@ void pause_vcpu(struct acrn_vcpu *vcpu, enum vcpu_state new_state) if (atomic_load32(&vcpu->running) == 1U) { remove_from_cpu_runqueue(&vcpu->sched_obj, vcpu->pcpu_id); - make_reschedule_request(vcpu->pcpu_id); + make_reschedule_request(vcpu->pcpu_id, DEL_MODE_IPI); release_schedule_lock(vcpu->pcpu_id); if (vcpu->pcpu_id != pcpu_id) { @@ -620,7 +620,7 @@ void resume_vcpu(struct acrn_vcpu *vcpu) if (vcpu->state == VCPU_RUNNING) { add_to_cpu_runqueue(&vcpu->sched_obj, vcpu->pcpu_id); - make_reschedule_request(vcpu->pcpu_id); + make_reschedule_request(vcpu->pcpu_id, DEL_MODE_IPI); } release_schedule_lock(vcpu->pcpu_id); } @@ -660,7 +660,7 @@ void schedule_vcpu(struct acrn_vcpu *vcpu) get_schedule_lock(vcpu->pcpu_id); add_to_cpu_runqueue(&vcpu->sched_obj, vcpu->pcpu_id); - make_reschedule_request(vcpu->pcpu_id); + make_reschedule_request(vcpu->pcpu_id, DEL_MODE_IPI); release_schedule_lock(vcpu->pcpu_id); } diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index bc4092037..59693d3c1 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -105,13 +105,26 @@ static struct sched_object *get_next_sched_obj(struct sched_context *ctx) return obj; } -void make_reschedule_request(uint16_t pcpu_id) +/** + * @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_INIT + */ +void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode) { struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id); bitmap_set_lock(NEED_RESCHEDULE, &ctx->flags); if (get_cpu_id() != pcpu_id) { - send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU); + switch (delmode) { + case DEL_MODE_IPI: + send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU); + break; + case DEL_MODE_INIT: + send_single_init(pcpu_id); + break; + default: + ASSERT(false, "Unknown delivery mode %u for pCPU%u", delmode, pcpu_id); + break; + } } } diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h index c0a51f3a0..bbf32b1b9 100644 --- a/hypervisor/include/common/schedule.h +++ b/hypervisor/include/common/schedule.h @@ -11,6 +11,9 @@ #define NEED_RESCHEDULE (1U) #define NEED_OFFLINE (2U) +#define DEL_MODE_INIT (1U) +#define DEL_MODE_IPI (2U) + struct sched_object; typedef void (*run_thread_t)(struct sched_object *obj); typedef void (*prepare_switch_t)(struct sched_object *obj); @@ -43,7 +46,7 @@ void free_pcpu(uint16_t pcpu_id); void add_to_cpu_runqueue(struct sched_object *obj, uint16_t pcpu_id); void remove_from_cpu_runqueue(struct sched_object *obj, uint16_t pcpu_id); -void make_reschedule_request(uint16_t pcpu_id); +void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode); bool need_reschedule(uint16_t pcpu_id); void make_pcpu_offline(uint16_t pcpu_id); int32_t need_offline(uint16_t pcpu_id);