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 <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Kaige Fu 2019-03-24 10:08:25 +00:00 committed by ACRN System Integration
parent ef9be0208a
commit 2771b46b1d
3 changed files with 22 additions and 6 deletions

View File

@ -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);
}

View File

@ -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;
}
}
}

View File

@ -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);