mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
hv: sched: add kick_thread to support notification
kick means to notify one thread_object. If the target thread object is running, send a IPI to notify it; if the target thread object is runnable, make reschedule on it. Also add kick_vcpu API in vcpu layer to notify vcpu. Tracked-On: #3813 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Signed-off-by: Yu Wang <yu1.wang@intel.com> Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
810305be98
commit
5f8e7a6cb7
@ -598,6 +598,11 @@ void offline_vcpu(struct acrn_vcpu *vcpu)
|
|||||||
vcpu->state = VCPU_OFFLINE;
|
vcpu->state = VCPU_OFFLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kick_vcpu(const struct acrn_vcpu *vcpu)
|
||||||
|
{
|
||||||
|
kick_thread(&vcpu->thread_obj);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @pre (&vcpu->stack[CONFIG_STACK_SIZE] & (CPU_STACK_ALIGN - 1UL)) == 0
|
* @pre (&vcpu->stack[CONFIG_STACK_SIZE] & (CPU_STACK_ALIGN - 1UL)) == 0
|
||||||
*/
|
*/
|
||||||
|
@ -106,21 +106,8 @@ static bool is_guest_irq_enabled(struct acrn_vcpu *vcpu)
|
|||||||
|
|
||||||
void vcpu_make_request(struct acrn_vcpu *vcpu, uint16_t eventid)
|
void vcpu_make_request(struct acrn_vcpu *vcpu, uint16_t eventid)
|
||||||
{
|
{
|
||||||
uint16_t pcpu_id = pcpuid_from_vcpu(vcpu);
|
|
||||||
|
|
||||||
bitmap_set_lock(eventid, &vcpu->arch.pending_req);
|
bitmap_set_lock(eventid, &vcpu->arch.pending_req);
|
||||||
/*
|
kick_vcpu(vcpu);
|
||||||
* if current hostcpu is not the target vcpu's hostcpu, we need
|
|
||||||
* to invoke IPI to wake up target vcpu
|
|
||||||
*
|
|
||||||
* TODO: Here we just compare with cpuid, since cpuid currently is
|
|
||||||
* global under pCPU / vCPU 1:1 mapping. If later we enabled vcpu
|
|
||||||
* scheduling, we need change here to determine it target vcpu is
|
|
||||||
* VMX non-root or root mode
|
|
||||||
*/
|
|
||||||
if (get_pcpu_id() != pcpu_id) {
|
|
||||||
send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -222,6 +222,24 @@ void wake_thread(struct thread_object *obj)
|
|||||||
release_schedule_lock(pcpu_id, rflag);
|
release_schedule_lock(pcpu_id, rflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kick_thread(const struct thread_object *obj)
|
||||||
|
{
|
||||||
|
uint16_t pcpu_id = obj->pcpu_id;
|
||||||
|
uint64_t rflag;
|
||||||
|
|
||||||
|
obtain_schedule_lock(pcpu_id, &rflag);
|
||||||
|
if (is_running(obj)) {
|
||||||
|
if (get_pcpu_id() != pcpu_id) {
|
||||||
|
send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
|
||||||
|
}
|
||||||
|
} else if (is_runnable(obj)) {
|
||||||
|
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
|
||||||
|
} else {
|
||||||
|
/* do nothing */
|
||||||
|
}
|
||||||
|
release_schedule_lock(pcpu_id, rflag);
|
||||||
|
}
|
||||||
|
|
||||||
void run_thread(struct thread_object *obj)
|
void run_thread(struct thread_object *obj)
|
||||||
{
|
{
|
||||||
uint64_t rflag;
|
uint64_t rflag;
|
||||||
|
@ -636,6 +636,17 @@ void resume_vcpu(struct acrn_vcpu *vcpu);
|
|||||||
*/
|
*/
|
||||||
void launch_vcpu(struct acrn_vcpu *vcpu);
|
void launch_vcpu(struct acrn_vcpu *vcpu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief kick the vcpu and let it handle pending events
|
||||||
|
*
|
||||||
|
* Kick a vCPU to handle the pending events.
|
||||||
|
*
|
||||||
|
* @param[in] vcpu pointer to vcpu data structure
|
||||||
|
*
|
||||||
|
* @return None
|
||||||
|
*/
|
||||||
|
void kick_vcpu(const struct acrn_vcpu *vcpu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief create a vcpu for the vm and mapped to the pcpu.
|
* @brief create a vcpu for the vm and mapped to the pcpu.
|
||||||
*
|
*
|
||||||
|
@ -100,6 +100,7 @@ bool need_reschedule(uint16_t pcpu_id);
|
|||||||
void run_thread(struct thread_object *obj);
|
void run_thread(struct thread_object *obj);
|
||||||
void sleep_thread(struct thread_object *obj);
|
void sleep_thread(struct thread_object *obj);
|
||||||
void wake_thread(struct thread_object *obj);
|
void wake_thread(struct thread_object *obj);
|
||||||
|
void kick_thread(const struct thread_object *obj);
|
||||||
void schedule(void);
|
void schedule(void);
|
||||||
|
|
||||||
void arch_switch_to(void *prev_sp, void *next_sp);
|
void arch_switch_to(void *prev_sp, void *next_sp);
|
||||||
|
Loading…
Reference in New Issue
Block a user