hv: sched_iorr: add init functions of sched_iorr

We set timeslice to 10ms as default, and set tick interval to 1ms.
When init sched_iorr scheduler, we init a periodic timer as the tick and
init the runqueue to maintain objects in the sched_control. Destroy
the timer in deinit.

Tracked-On: #4178
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:
Shuo A Liu 2019-12-02 15:36:11 +08:00 committed by wenlingz
parent ed4008630d
commit f44aa4e4c9
1 changed files with 39 additions and 7 deletions

View File

@ -8,6 +8,7 @@
#include <per_cpu.h>
#include <schedule.h>
#define CONFIG_SLICE_MS 10UL
struct sched_iorr_data {
/* keep list as the first item */
struct list_head list;
@ -17,17 +18,48 @@ struct sched_iorr_data {
int64_t left_cycles;
};
int sched_iorr_init(__unused struct sched_control *ctl)
{
return 0;
}
void sched_iorr_deinit(__unused struct sched_control *ctl)
static void sched_tick_handler(__unused void *param)
{
}
void sched_iorr_init_data(__unused struct thread_object *obj)
/*
* @pre ctl->pcpu_id == get_pcpu_id()
*/
int sched_iorr_init(struct sched_control *ctl)
{
struct sched_iorr_control *iorr_ctl = &per_cpu(sched_iorr_ctl, ctl->pcpu_id);
uint64_t tick_period = CYCLES_PER_MS;
int ret = 0;
ASSERT(get_pcpu_id() == ctl->pcpu_id, "Init scheduler on wrong CPU!");
ctl->priv = iorr_ctl;
INIT_LIST_HEAD(&iorr_ctl->runqueue);
/* The tick_timer is periodically */
initialize_timer(&iorr_ctl->tick_timer, sched_tick_handler, ctl,
rdtsc() + tick_period, TICK_MODE_PERIODIC, tick_period);
if (add_timer(&iorr_ctl->tick_timer) < 0) {
pr_err("Failed to add schedule tick timer!");
ret = -1;
}
return ret;
}
void sched_iorr_deinit(struct sched_control *ctl)
{
struct sched_iorr_control *iorr_ctl = (struct sched_iorr_control *)ctl->priv;
del_timer(&iorr_ctl->tick_timer);
}
void sched_iorr_init_data(struct thread_object *obj)
{
struct sched_iorr_data *data;
data = (struct sched_iorr_data *)obj->data;
INIT_LIST_HEAD(&data->list);
data->left_cycles = data->slice_cycles = CONFIG_SLICE_MS * CYCLES_PER_MS;
}
static struct thread_object *sched_iorr_pick_next(__unused struct sched_control *ctl)