hv: remove kick_thread from scheduler module

kick_thread function is only used by kick_vcpu to kick vcpu out of
non-root mode, the implementation in it is sending IPI to target CPU if
target obj is running and target PCPU is not current one; while for
runnable obj, it will just make reschedule request. So the kick_thread
is not actually belong to scheduler module, we can drop it and just do
the cpu notification in kick_vcpu.

Tracked-On: #5057
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Conghui Chen 2020-07-17 22:24:31 +08:00 committed by wenlingz
parent b6422f8985
commit 53d4a7169b
4 changed files with 14 additions and 37 deletions

View File

@ -17,6 +17,7 @@
#include <vmcs.h> #include <vmcs.h>
#include <mmu.h> #include <mmu.h>
#include <sprintf.h> #include <sprintf.h>
#include <lapic.h>
/* stack_frame is linked with the sequence of stack operation in arch_switch_to() */ /* stack_frame is linked with the sequence of stack operation in arch_switch_to() */
struct stack_frame { struct stack_frame {
@ -672,9 +673,19 @@ void offline_vcpu(struct acrn_vcpu *vcpu)
vcpu_set_state(vcpu, VCPU_OFFLINE); vcpu_set_state(vcpu, VCPU_OFFLINE);
} }
void kick_vcpu(const struct acrn_vcpu *vcpu) void kick_vcpu(struct acrn_vcpu *vcpu)
{ {
kick_thread(&vcpu->thread_obj); uint16_t pcpu_id = pcpuid_from_vcpu(vcpu);
if ((get_pcpu_id() != pcpu_id) &&
(per_cpu(vmcs_run, pcpu_id) == vcpu->arch.vmcs)) {
if (is_lapic_pt_enabled(vcpu)) {
/* For lapic-pt vCPUs */
send_single_nmi(pcpu_id);
} else {
send_single_ipi(pcpu_id, NOTIFY_VCPU_VECTOR);
}
}
} }
/* /*

View File

@ -24,11 +24,6 @@ static inline bool is_blocked(const struct thread_object *obj)
return obj->status == THREAD_STS_BLOCKED; return obj->status == THREAD_STS_BLOCKED;
} }
static inline bool is_runnable(const struct thread_object *obj)
{
return obj->status == THREAD_STS_RUNNABLE;
}
static inline bool is_running(const struct thread_object *obj) static inline bool is_running(const struct thread_object *obj)
{ {
return obj->status == THREAD_STS_RUNNING; return obj->status == THREAD_STS_RUNNING;
@ -239,34 +234,6 @@ 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) {
if (obj->notify_mode == SCHED_NOTIFY_IPI) {
send_single_ipi(pcpu_id, NOTIFY_VCPU_VECTOR);
} else {
/* For lapic-pt vCPUs */
send_single_nmi(pcpu_id);
}
}
} else if (is_runnable(obj)) {
if (obj->notify_mode == SCHED_NOTIFY_IPI) {
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
} else {
/* For lapic-pt vCPUs */
make_reschedule_request(pcpu_id, DEL_MODE_NMI);
}
} else {
/* do nothing */
}
release_schedule_lock(pcpu_id, rflag);
}
void yield_current(void) void yield_current(void)
{ {
make_reschedule_request(get_pcpu_id(), DEL_MODE_IPI); make_reschedule_request(get_pcpu_id(), DEL_MODE_IPI);

View File

@ -666,7 +666,7 @@ void launch_vcpu(struct acrn_vcpu *vcpu);
* *
* @return None * @return None
*/ */
void kick_vcpu(const struct acrn_vcpu *vcpu); void kick_vcpu(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.

View File

@ -116,7 +116,6 @@ void run_thread(struct thread_object *obj);
void sleep_thread(struct thread_object *obj); void sleep_thread(struct thread_object *obj);
void sleep_thread_sync(struct thread_object *obj); void sleep_thread_sync(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 yield_current(void); void yield_current(void);
void schedule(void); void schedule(void);