hv: add priority based scheduler

This patch adds a new priority based scheduler to support
vCPU scheduling based on their pre-configured priorities.
A vCPU can be running only if there is no higher priority
vCPU running on the same pCPU.

Tracked-On: #6571
Signed-off-by: Jie Deng <jie.deng@intel.com>
This commit is contained in:
Jie Deng
2021-09-09 16:21:30 +08:00
committed by wenlingz
parent dfe49ee972
commit 064fd7647f
12 changed files with 149 additions and 2 deletions

View File

@@ -28,6 +28,14 @@ enum sched_notify_mode {
SCHED_NOTIFY_IPI
};
/* Tools can configure a VM to use PRIO_LOW or PRIO_HIGH */
enum thread_priority {
PRIO_IDLE = 0,
PRIO_LOW,
PRIO_HIGH,
PRIO_MAX
};
struct thread_object;
typedef void (*thread_entry_t)(struct thread_object *obj);
typedef void (*switch_t)(struct thread_object *obj);
@@ -44,6 +52,8 @@ struct thread_object {
switch_t switch_out;
switch_t switch_in;
int priority;
uint8_t data[THREAD_DATA_SIZE];
};
@@ -97,6 +107,11 @@ struct sched_bvt_control {
struct hv_timer tick_timer;
};
extern struct acrn_scheduler sched_prio;
struct sched_prio_control {
struct list_head prio_queue;
};
bool is_idle_thread(const struct thread_object *obj);
uint16_t sched_get_pcpuid(const struct thread_object *obj);
struct thread_object *sched_get_current(uint16_t pcpu_id);