File tree Expand file tree Collapse file tree 5 files changed +36
-14
lines changed Expand file tree Collapse file tree 5 files changed +36
-14
lines changed Original file line number Diff line number Diff line change @@ -598,6 +598,11 @@ void offline_vcpu(struct acrn_vcpu *vcpu)
598
598
vcpu -> state = VCPU_OFFLINE ;
599
599
}
600
600
601
+ void kick_vcpu (const struct acrn_vcpu * vcpu )
602
+ {
603
+ kick_thread (& vcpu -> thread_obj );
604
+ }
605
+
601
606
/*
602
607
* @pre (&vcpu->stack[CONFIG_STACK_SIZE] & (CPU_STACK_ALIGN - 1UL)) == 0
603
608
*/
Original file line number Diff line number Diff line change @@ -106,21 +106,8 @@ static bool is_guest_irq_enabled(struct acrn_vcpu *vcpu)
106
106
107
107
void vcpu_make_request (struct acrn_vcpu * vcpu , uint16_t eventid )
108
108
{
109
- uint16_t pcpu_id = pcpuid_from_vcpu (vcpu );
110
-
111
109
bitmap_set_lock (eventid , & vcpu -> arch .pending_req );
112
- /*
113
- * if current hostcpu is not the target vcpu's hostcpu, we need
114
- * to invoke IPI to wake up target vcpu
115
- *
116
- * TODO: Here we just compare with cpuid, since cpuid currently is
117
- * global under pCPU / vCPU 1:1 mapping. If later we enabled vcpu
118
- * scheduling, we need change here to determine it target vcpu is
119
- * VMX non-root or root mode
120
- */
121
- if (get_pcpu_id () != pcpu_id ) {
122
- send_single_ipi (pcpu_id , VECTOR_NOTIFY_VCPU );
123
- }
110
+ kick_vcpu (vcpu );
124
111
}
125
112
126
113
/*
Original file line number Diff line number Diff line change @@ -222,6 +222,24 @@ void wake_thread(struct thread_object *obj)
222
222
release_schedule_lock (pcpu_id , rflag );
223
223
}
224
224
225
+ void kick_thread (const struct thread_object * obj )
226
+ {
227
+ uint16_t pcpu_id = obj -> pcpu_id ;
228
+ uint64_t rflag ;
229
+
230
+ obtain_schedule_lock (pcpu_id , & rflag );
231
+ if (is_running (obj )) {
232
+ if (get_pcpu_id () != pcpu_id ) {
233
+ send_single_ipi (pcpu_id , VECTOR_NOTIFY_VCPU );
234
+ }
235
+ } else if (is_runnable (obj )) {
236
+ make_reschedule_request (pcpu_id , DEL_MODE_IPI );
237
+ } else {
238
+ /* do nothing */
239
+ }
240
+ release_schedule_lock (pcpu_id , rflag );
241
+ }
242
+
225
243
void run_thread (struct thread_object * obj )
226
244
{
227
245
uint64_t rflag ;
Original file line number Diff line number Diff line change @@ -636,6 +636,17 @@ void resume_vcpu(struct acrn_vcpu *vcpu);
636
636
*/
637
637
void launch_vcpu (struct acrn_vcpu * vcpu );
638
638
639
+ /**
640
+ * @brief kick the vcpu and let it handle pending events
641
+ *
642
+ * Kick a vCPU to handle the pending events.
643
+ *
644
+ * @param[in] vcpu pointer to vcpu data structure
645
+ *
646
+ * @return None
647
+ */
648
+ void kick_vcpu (const struct acrn_vcpu * vcpu );
649
+
639
650
/**
640
651
* @brief create a vcpu for the vm and mapped to the pcpu.
641
652
*
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ bool need_reschedule(uint16_t pcpu_id);
100
100
void run_thread (struct thread_object * obj );
101
101
void sleep_thread (struct thread_object * obj );
102
102
void wake_thread (struct thread_object * obj );
103
+ void kick_thread (const struct thread_object * obj );
103
104
void schedule (void );
104
105
105
106
void arch_switch_to (void * prev_sp , void * next_sp );
You can’t perform that action at this time.
0 commit comments