mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
hv: sched: remove runqueue from current schedule logic
Currently we are using a 1:1 mapping logic for pcpu:vcpu. So don't need a runqueue for it. Removing it as preparation work to abstract scheduler framework. 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
837e4d8788
commit
de157ab96c
@ -667,7 +667,7 @@ void pause_vcpu(struct acrn_vcpu *vcpu, enum vcpu_state new_state)
|
||||
vcpu->state = new_state;
|
||||
|
||||
if (vcpu->running) {
|
||||
remove_from_cpu_runqueue(&vcpu->thread_obj);
|
||||
remove_thread_obj(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
|
||||
if (is_lapic_pt_enabled(vcpu)) {
|
||||
make_reschedule_request(vcpu->pcpu_id, DEL_MODE_INIT);
|
||||
@ -683,7 +683,7 @@ void pause_vcpu(struct acrn_vcpu *vcpu, enum vcpu_state new_state)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
remove_from_cpu_runqueue(&vcpu->thread_obj);
|
||||
remove_thread_obj(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
release_schedule_lock(vcpu->pcpu_id);
|
||||
}
|
||||
}
|
||||
@ -696,7 +696,7 @@ void resume_vcpu(struct acrn_vcpu *vcpu)
|
||||
vcpu->state = vcpu->prev_state;
|
||||
|
||||
if (vcpu->state == VCPU_RUNNING) {
|
||||
add_to_cpu_runqueue(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
insert_thread_obj(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
make_reschedule_request(vcpu->pcpu_id, DEL_MODE_IPI);
|
||||
}
|
||||
release_schedule_lock(vcpu->pcpu_id);
|
||||
@ -733,7 +733,7 @@ void schedule_vcpu(struct acrn_vcpu *vcpu)
|
||||
pr_dbg("vcpu%hu scheduled", vcpu->vcpu_id);
|
||||
|
||||
get_schedule_lock(vcpu->pcpu_id);
|
||||
add_to_cpu_runqueue(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
insert_thread_obj(&vcpu->thread_obj, vcpu->pcpu_id);
|
||||
make_reschedule_request(vcpu->pcpu_id, DEL_MODE_IPI);
|
||||
release_schedule_lock(vcpu->pcpu_id);
|
||||
}
|
||||
@ -747,7 +747,6 @@ int32_t prepare_vcpu(struct acrn_vm *vm, uint16_t pcpu_id)
|
||||
|
||||
ret = create_vcpu(pcpu_id, vm, &vcpu);
|
||||
if (ret == 0) {
|
||||
INIT_LIST_HEAD(&vcpu->thread_obj.run_list);
|
||||
snprintf(thread_name, 16U, "vm%hu:vcpu%hu", vm->vm_id, vcpu->vcpu_id);
|
||||
(void)strncpy_s(vcpu->thread_obj.name, 16U, thread_name, 16U);
|
||||
vcpu->thread_obj.thread_entry = vcpu_thread;
|
||||
|
@ -23,7 +23,6 @@ void init_scheduler(void)
|
||||
ctl = &per_cpu(sched_ctl, i);
|
||||
|
||||
spinlock_init(&ctl->scheduler_lock);
|
||||
INIT_LIST_HEAD(&ctl->runqueue);
|
||||
ctl->flags = 0UL;
|
||||
ctl->curr_obj = NULL;
|
||||
}
|
||||
@ -41,31 +40,23 @@ void release_schedule_lock(uint16_t pcpu_id)
|
||||
spinlock_release(&ctl->scheduler_lock);
|
||||
}
|
||||
|
||||
void add_to_cpu_runqueue(struct thread_object *obj, uint16_t pcpu_id)
|
||||
void insert_thread_obj(struct thread_object *obj, uint16_t pcpu_id)
|
||||
{
|
||||
struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id);
|
||||
|
||||
if (list_empty(&obj->run_list)) {
|
||||
list_add_tail(&obj->run_list, &ctl->runqueue);
|
||||
}
|
||||
ctl->thread_obj = obj;
|
||||
}
|
||||
|
||||
void remove_from_cpu_runqueue(struct thread_object *obj)
|
||||
void remove_thread_obj(__unused struct thread_object *obj, uint16_t pcpu_id)
|
||||
{
|
||||
list_del_init(&obj->run_list);
|
||||
struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id);
|
||||
|
||||
ctl->thread_obj = NULL;
|
||||
}
|
||||
|
||||
static struct thread_object *get_next_sched_obj(struct sched_control *ctl)
|
||||
static struct thread_object *get_next_sched_obj(const struct sched_control *ctl)
|
||||
{
|
||||
struct thread_object *obj = NULL;
|
||||
|
||||
if (!list_empty(&ctl->runqueue)) {
|
||||
obj = get_first_item(&ctl->runqueue, struct thread_object, run_list);
|
||||
} else {
|
||||
obj = &get_cpu_var(idle);
|
||||
}
|
||||
|
||||
return obj;
|
||||
return ctl->thread_obj == NULL ? &get_cpu_var(idle) : ctl->thread_obj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@ typedef void (*thread_entry_t)(struct thread_object *obj);
|
||||
typedef void (*switch_t)(struct thread_object *obj);
|
||||
struct thread_object {
|
||||
char name[16];
|
||||
struct list_head run_list;
|
||||
uint64_t host_sp;
|
||||
thread_entry_t thread_entry;
|
||||
switch_t switch_out;
|
||||
@ -26,10 +25,11 @@ struct thread_object {
|
||||
};
|
||||
|
||||
struct sched_control {
|
||||
struct list_head runqueue;
|
||||
uint64_t flags;
|
||||
struct thread_object *curr_obj;
|
||||
spinlock_t scheduler_lock; /* to protect sched_control and thread_object */
|
||||
|
||||
struct thread_object *thread_obj;
|
||||
};
|
||||
|
||||
void init_scheduler(void);
|
||||
@ -37,8 +37,8 @@ void switch_to_idle(thread_entry_t idle_thread);
|
||||
void get_schedule_lock(uint16_t pcpu_id);
|
||||
void release_schedule_lock(uint16_t pcpu_id);
|
||||
|
||||
void add_to_cpu_runqueue(struct thread_object *obj, uint16_t pcpu_id);
|
||||
void remove_from_cpu_runqueue(struct thread_object *obj);
|
||||
void insert_thread_obj(struct thread_object *obj, uint16_t pcpu_id);
|
||||
void remove_thread_obj(struct thread_object *obj, uint16_t pcpu_id);
|
||||
|
||||
void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode);
|
||||
bool need_reschedule(uint16_t pcpu_id);
|
||||
|
Loading…
Reference in New Issue
Block a user