From ed4008630d00635ae2cacc991afd955cdbc90aa0 Mon Sep 17 00:00:00 2001 From: Shuo A Liu Date: Thu, 20 Jun 2019 11:10:53 +0800 Subject: [PATCH] hv: sched_iorr: Add IO sensitive Round-robin scheduler IO sensitive Round-robin scheduler aim to schedule threads with round-robin policy. Meanwhile, we also enhance it with some fairness configuration, such as thread will be scheduled out without properly timeslice. IO request on thread will be handled in high priority. This patch only add a skeleton for the sched_iorr scheduler. Tracked-On: #4178 Signed-off-by: Jason Chen CJ Signed-off-by: Yu Wang Signed-off-by: Shuo A Liu Acked-by: Eddie Dong --- hypervisor/Makefile | 1 + hypervisor/common/sched_iorr.c | 54 +++++++++++++++++++++++++++ hypervisor/include/arch/x86/per_cpu.h | 1 + hypervisor/include/common/schedule.h | 8 ++++ 4 files changed, 64 insertions(+) create mode 100644 hypervisor/common/sched_iorr.c diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 3b841685e..fc19bb8c4 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -212,6 +212,7 @@ HW_C_SRCS += arch/x86/sgx.c HW_C_SRCS += common/softirq.c HW_C_SRCS += common/schedule.c HW_C_SRCS += common/sched_noop.c +HW_C_SRCS += common/sched_iorr.c HW_C_SRCS += hw/pci.c HW_C_SRCS += arch/x86/configs/vm_config.c HW_C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c diff --git a/hypervisor/common/sched_iorr.c b/hypervisor/common/sched_iorr.c new file mode 100644 index 000000000..65195bd0f --- /dev/null +++ b/hypervisor/common/sched_iorr.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +struct sched_iorr_data { + /* keep list as the first item */ + struct list_head list; + + uint64_t slice_cycles; + uint64_t last_cycles; + int64_t left_cycles; +}; + +int sched_iorr_init(__unused struct sched_control *ctl) +{ + return 0; +} + +void sched_iorr_deinit(__unused struct sched_control *ctl) +{ +} + +void sched_iorr_init_data(__unused struct thread_object *obj) +{ +} + +static struct thread_object *sched_iorr_pick_next(__unused struct sched_control *ctl) +{ + return NULL; +} + +static void sched_iorr_sleep(__unused struct thread_object *obj) +{ +} + +static void sched_iorr_wake(__unused struct thread_object *obj) +{ +} + +struct acrn_scheduler sched_iorr = { + .name = "sched_iorr", + .init = sched_iorr_init, + .init_data = sched_iorr_init_data, + .pick_next = sched_iorr_pick_next, + .sleep = sched_iorr_sleep, + .wake = sched_iorr_wake, + .deinit = sched_iorr_deinit, +}; diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index cb71325c9..1a667ab31 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -38,6 +38,7 @@ struct per_cpu_region { struct per_cpu_timers cpu_timers; struct sched_control sched_ctl; struct sched_noop_control sched_noop_ctl; + struct sched_iorr_control sched_iorr_ctl; struct thread_object idle; struct host_gdt gdt; struct tss_64 tss; diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h index 808beacca..5179b5243 100644 --- a/hypervisor/include/common/schedule.h +++ b/hypervisor/include/common/schedule.h @@ -7,6 +7,8 @@ #ifndef SCHEDULE_H #define SCHEDULE_H #include +#include +#include #define NEED_RESCHEDULE (1U) @@ -77,11 +79,17 @@ struct acrn_scheduler { void (*deinit)(struct sched_control *ctl); }; extern struct acrn_scheduler sched_noop; +extern struct acrn_scheduler sched_iorr; struct sched_noop_control { struct thread_object *noop_thread_obj; }; +struct sched_iorr_control { + struct list_head runqueue; + struct hv_timer tick_timer; +}; + 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);