Skip to content

Commit e05eb42

Browse files
conghuic23wenlingz
authored andcommitted
hv: sched_bvt: add init and deinit function
Add init function for bvt scheduler, creating a runqueue and a period timer, the timer interval is default as 1ms. The interval is the minimum charging unit. Tracked-On: #4410 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent a7563cb commit e05eb42

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

hypervisor/common/sched_bvt.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,52 @@ struct sched_bvt_data {
3030
uint64_t start_tsc;
3131
};
3232

33-
static int sched_bvt_init(__unused struct sched_control *ctl)
33+
static void sched_tick_handler(__unused void *param)
3434
{
35-
return 0;
3635
}
3736

38-
static void sched_bvt_deinit(__unused struct sched_control *ctl)
37+
/*
38+
*@pre: ctl->pcpu_id == get_pcpu_id()
39+
*/
40+
static int sched_bvt_init(struct sched_control *ctl)
3941
{
42+
struct sched_bvt_control *bvt_ctl = &per_cpu(sched_bvt_ctl, ctl->pcpu_id);
43+
uint64_t tick_period = BVT_MCU_MS * CYCLES_PER_MS;
44+
int ret = 0;
45+
46+
ASSERT(ctl->pcpu_id == get_pcpu_id(), "Init scheduler on wrong CPU!");
47+
48+
ctl->priv = bvt_ctl;
49+
INIT_LIST_HEAD(&bvt_ctl->runqueue);
50+
51+
/* The tick_timer is periodically */
52+
initialize_timer(&bvt_ctl->tick_timer, sched_tick_handler, ctl,
53+
rdtsc() + tick_period, TICK_MODE_PERIODIC, tick_period);
54+
55+
if (add_timer(&bvt_ctl->tick_timer) < 0) {
56+
pr_err("Failed to add schedule tick timer!");
57+
ret = -1;
58+
}
59+
60+
return ret;
4061
}
4162

42-
static void sched_bvt_init_data(__unused struct thread_object *obj)
63+
static void sched_bvt_deinit(struct sched_control *ctl)
4364
{
65+
struct sched_bvt_control *bvt_ctl = (struct sched_bvt_control *)ctl->priv;
66+
del_timer(&bvt_ctl->tick_timer);
67+
}
68+
69+
static void sched_bvt_init_data(struct thread_object *obj)
70+
{
71+
struct sched_bvt_data *data;
72+
73+
data = (struct sched_bvt_data *)obj->data;
74+
INIT_LIST_HEAD(&data->list);
75+
data->mcu = BVT_MCU_MS * CYCLES_PER_MS;
76+
/* TODO: virtual time advance ratio should be proportional to weight. */
77+
data->vt_ratio = 1U;
78+
data->run_countdown = BVT_CSA_MCU;
4479
}
4580

4681
static struct thread_object *sched_bvt_pick_next(__unused struct sched_control *ctl)

0 commit comments

Comments
 (0)