From cf9401b0f4ea6b753c739ebff97c02275aba0af2 Mon Sep 17 00:00:00 2001 From: "cl349@freefall.cl.cam.ac.uk" Date: Thu, 21 Oct 2004 10:30:36 +0000 Subject: [PATCH] bitkeeper revision 1.1159.1.250 (41778fccML9t77yAOOuhoIJlCQGgKQ) Remove fbvt scheduler. --- .rootkeys | 2 - tools/libxc/Makefile | 1 - tools/libxc/xc.h | 20 - tools/libxc/xc_domain.c | 5 - tools/libxc/xc_fbvtsched.c | 89 ---- tools/python/xen/lowlevel/xc/xc.c | 124 ----- tools/python/xen/xend/XendClient.py | 13 - tools/python/xen/xend/XendDomain.py | 19 - tools/python/xen/xend/XendNode.py | 6 - tools/python/xen/xend/server/SrvDomain.py | 10 - tools/python/xen/xend/server/SrvNode.py | 6 - tools/python/xen/xm/main.py | 34 -- xen/common/sched_fair_bvt.c | 621 ---------------------- xen/common/schedule.c | 2 - xen/include/hypervisor-ifs/sched_ctl.h | 15 - 15 files changed, 967 deletions(-) delete mode 100644 tools/libxc/xc_fbvtsched.c delete mode 100644 xen/common/sched_fair_bvt.c diff --git a/.rootkeys b/.rootkeys index a464b6e04e..68d490af9f 100644 --- a/.rootkeys +++ b/.rootkeys @@ -333,7 +333,6 @@ 3fbba6dbasJQV-MVElDC0DGSHMiL5w tools/libxc/xc_domain.c 40278d99BLsfUv3qxv0I8C1sClZ0ow tools/libxc/xc_elf.h 403e0977Bjsm_e82pwvl9VvaJxh8Gg tools/libxc/xc_evtchn.c -40ec1922Nq_Rur5KUH0MvRNKczPGxg tools/libxc/xc_fbvtsched.c 40e03333Eegw8czSWvHsbKxrRZJjRA tools/libxc/xc_io.c 40e03333vrWGbLAhyJjXlqCHaJt7eA tools/libxc/xc_io.h 3fbba6dbNCU7U6nsMYiXzKkp3ztaJg tools/libxc/xc_linux_build.c @@ -640,7 +639,6 @@ 3ddb79bdHqdQpATqC0rmUZNbsb6L6A xen/common/resource.c 4064773cJ31vZt-zhbSoxqft1Jaw0w xen/common/sched_atropos.c 40589968dD2D1aejwSOvrROg7fOvGQ xen/common/sched_bvt.c -40ec1922He_dRhVJdOicTcHvT8v1NQ xen/common/sched_fair_bvt.c 40589968be_t_n0-w6ggceW7h-sx0w xen/common/sched_rrobin.c 3e397e6619PgAfBbw2XFbXkewvUWgw xen/common/schedule.c 3ddb79bdB9RNMnkQnUyZ5C9hhMSQQw xen/common/slab.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 770ecb4225..8b3a7c95dc 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -20,7 +20,6 @@ INCLUDES += -I $(XEN_LIBXUTIL) SRCS := SRCS += xc_atropos.c SRCS += xc_bvtsched.c -SRCS += xc_fbvtsched.c SRCS += xc_domain.c SRCS += xc_evtchn.c SRCS += xc_io.c diff --git a/tools/libxc/xc.h b/tools/libxc/xc.h index dfc9a9f5d7..803b768d81 100644 --- a/tools/libxc/xc.h +++ b/tools/libxc/xc.h @@ -120,26 +120,6 @@ int xc_bvtsched_domain_get(int xc_handle, long long *warpl, long long *warpu); -int xc_fbvtsched_global_set(int xc_handle, - unsigned long ctx_allow); - -int xc_fbvtsched_domain_set(int xc_handle, - u32 domid, - unsigned long mcuadv, - unsigned long warp, - unsigned long warpl, - unsigned long warpu); - -int xc_fbvtsched_global_get(int xc_handle, - unsigned long *ctx_allow); - -int xc_fbvtsched_domain_get(int xc_handle, - u32 domid, - unsigned long *mcuadv, - unsigned long *warp, - unsigned long *warpl, - unsigned long *warpu); - int xc_atropos_domain_set(int xc_handle, u32 domid, u64 period, u64 slice, u64 latency, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index d50276fe3b..601f338c42 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -213,11 +213,6 @@ int xc_domain_setcpuweight(int xc_handle, break; } - case SCHED_FBVT: - { - // TODO - break; - } case SCHED_RROBIN: { /* The weight cannot be set for RRobin */ diff --git a/tools/libxc/xc_fbvtsched.c b/tools/libxc/xc_fbvtsched.c deleted file mode 100644 index 55adafe0d1..0000000000 --- a/tools/libxc/xc_fbvtsched.c +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * xc_fbvtsched.c - * - * API for manipulating parameters of the Fair Borrowed Virtual Time scheduler. - * - * Copyright (c) 2004, G. Milos - * Based on K. Fraiser's xc_bvtsched.c - */ - -#include "xc_private.h" - -int xc_fbvtsched_global_set(int xc_handle, - unsigned long ctx_allow) -{ - dom0_op_t op; - - op.cmd = DOM0_SCHEDCTL; - op.u.schedctl.sched_id = SCHED_FBVT; - op.u.schedctl.direction = SCHED_INFO_PUT; - op.u.schedctl.u.fbvt.ctx_allow = ctx_allow; - - return do_dom0_op(xc_handle, &op); -} - -int xc_fbvtsched_global_get(int xc_handle, - unsigned long *ctx_allow) -{ - dom0_op_t op; - int ret; - - op.cmd = DOM0_SCHEDCTL; - op.u.schedctl.sched_id = SCHED_FBVT; - op.u.schedctl.direction = SCHED_INFO_GET; - - ret = do_dom0_op(xc_handle, &op); - - *ctx_allow = op.u.schedctl.u.fbvt.ctx_allow; - - return ret; -} - -int xc_fbvtsched_domain_set(int xc_handle, - u32 domid, - unsigned long mcuadv, - unsigned long warp, - unsigned long warpl, - unsigned long warpu) -{ - dom0_op_t op; - struct fbvt_adjdom *fbvtadj = &op.u.adjustdom.u.fbvt; - - op.cmd = DOM0_ADJUSTDOM; - op.u.adjustdom.domain = (domid_t)domid; - op.u.adjustdom.sched_id = SCHED_FBVT; - op.u.adjustdom.direction = SCHED_INFO_PUT; - - fbvtadj->mcu_adv = mcuadv; - fbvtadj->warp = warp; - fbvtadj->warpl = warpl; - fbvtadj->warpu = warpu; - return do_dom0_op(xc_handle, &op); -} - - -int xc_fbvtsched_domain_get(int xc_handle, - u32 domid, - unsigned long *mcuadv, - unsigned long *warp, - unsigned long *warpl, - unsigned long *warpu) -{ - - dom0_op_t op; - int ret; - struct fbvt_adjdom *adjptr = &op.u.adjustdom.u.fbvt; - - op.cmd = DOM0_ADJUSTDOM; - op.u.adjustdom.domain = (domid_t)domid; - op.u.adjustdom.sched_id = SCHED_FBVT; - op.u.adjustdom.direction = SCHED_INFO_GET; - - ret = do_dom0_op(xc_handle, &op); - - *mcuadv = adjptr->mcu_adv; - *warp = adjptr->warp; - *warpl = adjptr->warpl; - *warpu = adjptr->warpu; - return ret; -} diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 9d73b04114..69eadf205a 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -491,92 +491,6 @@ static PyObject *pyxc_bvtsched_domain_get(PyObject *self, "warpu", warpu); } -static PyObject *pyxc_fbvtsched_global_set(PyObject *self, - PyObject *args, - PyObject *kwds) -{ - XcObject *xc = (XcObject *)self; - - unsigned long ctx_allow; - - static char *kwd_list[] = { "ctx_allow", NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "l", kwd_list, &ctx_allow) ) - return NULL; - - if ( xc_fbvtsched_global_set(xc->xc_handle, ctx_allow) != 0 ) - return PyErr_SetFromErrno(xc_error); - - Py_INCREF(zero); - return zero; -} - -static PyObject *pyxc_fbvtsched_global_get(PyObject *self, - PyObject *args, - PyObject *kwds) -{ - XcObject *xc = (XcObject *)self; - - unsigned long ctx_allow; - - if ( !PyArg_ParseTuple(args, "") ) - return NULL; - - if ( xc_fbvtsched_global_get(xc->xc_handle, &ctx_allow) != 0 ) - return PyErr_SetFromErrno(xc_error); - - return Py_BuildValue("s:l", "ctx_allow", ctx_allow); -} - -static PyObject *pyxc_fbvtsched_domain_set(PyObject *self, - PyObject *args, - PyObject *kwds) -{ - XcObject *xc = (XcObject *)self; - - u32 dom; - unsigned long mcuadv, warp, warpl, warpu; - - static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl", - "warpu", NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illll", kwd_list, - &dom, &mcuadv, &warp, &warpl, &warpu) ) - return NULL; - - if ( xc_fbvtsched_domain_set(xc->xc_handle, dom, mcuadv, - warp, warpl, warpu) != 0 ) - return PyErr_SetFromErrno(xc_error); - - Py_INCREF(zero); - return zero; -} - -static PyObject *pyxc_fbvtsched_domain_get(PyObject *self, - PyObject *args, - PyObject *kwds) -{ - XcObject *xc = (XcObject *)self; - u32 dom; - unsigned long mcuadv, warp, warpl, warpu; - - static char *kwd_list[] = { "dom", NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) ) - return NULL; - - if ( xc_fbvtsched_domain_get(xc->xc_handle, dom, &mcuadv, &warp, - &warpl, &warpu) != 0 ) - return PyErr_SetFromErrno(xc_error); - - return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}", - "domain", dom, - "mcuadv", mcuadv, - "warp", warp, - "warpl", warpl, - "warpu", warpu); -} - static PyObject *pyxc_evtchn_bind_interdomain(PyObject *self, PyObject *args, PyObject *kwds) @@ -1074,44 +988,6 @@ static PyMethodDef pyxc_methods[] = { " warpl [long]: Warp limit,\n" }, - { "fbvtsched_global_set", - (PyCFunction)pyxc_fbvtsched_global_set, - METH_VARARGS | METH_KEYWORDS, "\n" - "Set global tuning parameters for Fair Borrowed Virtual Time scheduler.\n" - " ctx_allow [int]: Minimal guaranteed quantum.\n\n" - "Returns: [int] 0 on success; -1 on error.\n" }, - - { "fbvtsched_global_get", - (PyCFunction)pyxc_fbvtsched_global_get, - METH_KEYWORDS, "\n" - "Get global tuning parameters for FBVT scheduler.\n" - "Returns: [dict]:\n" - " ctx_allow [int]: context switch allowance\n" }, - - { "fbvtsched_domain_set", - (PyCFunction)pyxc_fbvtsched_domain_set, - METH_VARARGS | METH_KEYWORDS, "\n" - "Set per-domain tuning parameters for Fair Borrowed Virtual Time scheduler.\n" - " dom [int]: Identifier of domain to be tuned.\n" - " mcuadv [int]: Proportional to the inverse of the domain's weight.\n" - " warp [int]: How far to warp domain's EVT on unblock.\n" - " warpl [int]: How long the domain can run warped.\n" - " warpu [int]: How long before the domain can warp again.\n\n" - "Returns: [int] 0 on success; -1 on error.\n" }, - - { "fbvtsched_domain_get", - (PyCFunction)pyxc_fbvtsched_domain_get, - METH_KEYWORDS, "\n" - "Get per-domain tuning parameters under the FBVT scheduler.\n" - " dom [int]: Identifier of domain to be queried.\n" - "Returns [dict]:\n" - " domain [int]: Domain ID.\n" - " mcuadv [long]: MCU Advance.\n" - " warp [long]: Warp.\n" - " warpu [long]: Unwarp requirement.\n" - " warpl [long]: Warp limit,\n" - }, - { "atropos_domain_set", (PyCFunction)pyxc_atropos_domain_set, METH_KEYWORDS, "\n" diff --git a/tools/python/xen/xend/XendClient.py b/tools/python/xen/xend/XendClient.py index 13a2d63b52..8d77e15082 100644 --- a/tools/python/xen/xend/XendClient.py +++ b/tools/python/xen/xend/XendClient.py @@ -195,11 +195,6 @@ class Xend: {'op' : 'cpu_bvt_slice_set', 'ctx_allow' : ctx_allow }) - def xend_node_cpu_fbvt_slice_set(self, ctx_allow): - return self.xendPost(self.nodeurl(), - {'op' : 'cpu_fbvt_slice_set', - 'ctx_allow' : ctx_allow }) - def xend_domains(self): return self.xendGet(self.domainurl()) @@ -264,14 +259,6 @@ class Xend: 'warpl' : warpl, 'warpu' : warpu }) - def xend_domain_cpu_fbvt_set(self, id, mcuadv, warp, warpl, warpu): - return self.xendPost(self.domainurl(id), - {'op' : 'cpu_fbvt_set', - 'mcuadv' : mcuadv, - 'warp' : warp, - 'warpl' : warpl, - 'warpu' : warpu }) - def xend_domain_cpu_atropos_set(self, id, period, slice, latency, xtratime): return self.xendPost(self.domainurl(id), {'op' : 'cpu_atropos_set', diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index e79357e82f..72e004edb2 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -651,25 +651,6 @@ class XendDomain: except Exception, ex: raise XendError(str(ex)) - def domain_cpu_fbvt_set(self, id, mcuadv, warp, warpl, warpu): - """Set FBVT (Fair Borrowed Virtual Time) scheduler parameters for a domain. - """ - dominfo = self.domain_lookup(id) - try: - return xc.fbvtsched_domain_set(dom=dominfo.dom, mcuadv=mcuadv, - warp=warp, warpl=warpl, warpu=warpu) - except Exception, ex: - raise XendError(str(ex)) - - def domain_cpu_fbvt_get(self, id): - """Get FBVT (Fair Borrowed Virtual Time) scheduler parameters for a domain. - """ - dominfo = self.domain_lookup(id) - try: - return xc.fbvtsched_domain_get(dominfo.dom) - except Exception, ex: - raise XendError(str(ex)) - def domain_cpu_atropos_set(self, id, period, slice, latency, xtratime): """Set Atropos scheduler parameters for a domain. """ diff --git a/tools/python/xen/xend/XendNode.py b/tools/python/xen/xend/XendNode.py index 4bc0b420e8..5fff0f62dd 100644 --- a/tools/python/xen/xend/XendNode.py +++ b/tools/python/xen/xend/XendNode.py @@ -30,12 +30,6 @@ class XendNode: def cpu_bvt_slice_get(self): return self.xc.bvtsched_global_get() - def cpu_fbvt_slice_set(self, ctx_allow): - return self.xc.bvtsched_global_set(ctx_allow=ctx_allow) - - def cpu_fbvt_slice_get(self): - return self.xc.bvtsched_global_get() - def cpu_rrobin_slice_set(self, slice): return self.xc.rrobin_global_set(slice=slice) diff --git a/tools/python/xen/xend/server/SrvDomain.py b/tools/python/xen/xend/server/SrvDomain.py index ef3b64c8d0..093097046a 100644 --- a/tools/python/xen/xend/server/SrvDomain.py +++ b/tools/python/xen/xend/server/SrvDomain.py @@ -122,16 +122,6 @@ class SrvDomain(SrvDir): val = fn(req.args, {'dom': self.dom.id}) return val - def op_cpu_fbvt_set(self, op, req): - fn = FormFn(self.xd.domain_cpu_fbvt_set, - [['dom', 'str'], - ['mcuadv', 'int'], - ['warp', 'int'], - ['warpl', 'int'], - ['warpu', 'int']]) - val = fn(req.args, {'dom': self.dom.id}) - return val - def op_cpu_atropos_set(self, op, req): fn = FormFn(self.xd.domain_cpu_atropos_set, [['dom', 'str'], diff --git a/tools/python/xen/xend/server/SrvNode.py b/tools/python/xen/xend/server/SrvNode.py index b68b33ea84..c1b3ab560e 100644 --- a/tools/python/xen/xend/server/SrvNode.py +++ b/tools/python/xen/xend/server/SrvNode.py @@ -37,12 +37,6 @@ class SrvNode(SrvDir): val = fn(req.args, {}) return val - def op_cpu_fbvt_slice_set(self, op, req): - fn = FormFn(self.xn.cpu_fbvt_slice_set, - [['ctx_allow', 'int']]) - val = fn(req.args, {}) - return val - def render_POST(self, req): return self.perform(req) diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 82acffddc5..2d40669e23 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -552,40 +552,6 @@ class ProgBvtslice(Prog): xm.prog(ProgBvtslice) -class ProgFbvt(Prog): - group = 'scheduler' - name = "fbvt" - info = """Set FBVT scheduler parameters.""" - - def help(self, args): - print args[0], "DOM MCUADV WARP WARPL WARPU" - print '\nSet Fair Borrowed Virtual Time scheduler parameters.' - - def main(self, args): - if len(args) != 6: self.err("%s: Invalid argument(s)" % args[0]) - dom = args[1] - v = map(int, args[2:6]) - server.xend_domain_cpu_fbvt_set(dom, *v) - -xm.prog(ProgFbvt) - -class ProgFbvtslice(Prog): - group = 'scheduler' - name = "fbvt_ctxallow" - info = """Set the FBVT scheduler context switch allowance.""" - - def help(self, args): - print args[0], 'CTX_ALLOW' - print '\nSet Fair Borrowed Virtual Time scheduler context switch allowance.' - - def main(self, args): - if len(args) < 2: self.err('%s: Missing context switch allowance.' - % args[0]) - ctx_allow = int(args[1]) - server.xend_node_cpu_fbvt_slice_set(ctx_allow) - -xm.prog(ProgFbvtslice) - class ProgAtropos(Prog): group = 'scheduler' diff --git a/xen/common/sched_fair_bvt.c b/xen/common/sched_fair_bvt.c deleted file mode 100644 index 293fea6032..0000000000 --- a/xen/common/sched_fair_bvt.c +++ /dev/null @@ -1,621 +0,0 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- - **************************************************************************** - * (C) 2004 Grzegorz Milos - University of Cambridge - * Based on the implementation of the BVT scheduler by Rolf Neugebauer - * and Mark Williamson (look in sched_bvt.c) - **************************************************************************** - * - * File: common/sched_fair_bvt.c - * Author: Grzegorz Milos - * - * Description: CPU scheduling - * implements Fair Borrowed Virtual Time Scheduler. - * FBVT is modification of BVT (see Duda & Cheriton SOSP'99) - * which tries to allocate fair shares of processor even - * when there is mix between CPU and I/O bound domains. - * TODO - more information about the scheduler in TODO - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* For tracing - TODO - put all the defines in some common hearder file */ -#define TRC_SCHED_FBVT_DO_SCHED 0x00020000 -#define TRC_SCHED_FBVT_DO_SCHED_UPDATE 0x00020001 - -/* all per-domain BVT-specific scheduling info is stored here */ -struct fbvt_dom_info -{ - struct domain *domain; /* domain this info belongs to */ - struct list_head run_list; /* runqueue pointers */ - unsigned long mcu_advance; /* inverse of weight */ - u32 avt; /* actual virtual time */ - u32 evt; /* effective virtual time */ - u32 time_slept; /* amount of time slept */ - int warpback; /* warp? */ - long warp; /* virtual time warp */ - long warpl; /* warp limit */ - long warpu; /* unwarp time requirement */ - s_time_t warped; /* time it ran warped last time */ - s_time_t uwarped; /* time it ran unwarped last time */ -}; - -struct fbvt_cpu_info -{ - struct list_head runqueue; - unsigned long svt; - u32 vtb; /* virtual time bonus */ - u32 r_time; /* last time to run */ -}; - - -#define FBVT_INFO(p) ((struct fbvt_dom_info *)(p)->sched_priv) -#define CPU_INFO(cpu) ((struct fbvt_cpu_info *)(schedule_data[cpu]).sched_priv) -#define RUNLIST(p) ((struct list_head *)&(FBVT_INFO(p)->run_list)) -#define RUNQUEUE(cpu) ((struct list_head *)&(CPU_INFO(cpu)->runqueue)) -#define CPU_SVT(cpu) (CPU_INFO(cpu)->svt) -#define LAST_VTB(cpu) (CPU_INFO(cpu)->vtb) -#define R_TIME(cpu) (CPU_INFO(cpu)->r_time) - -#define MCU (s32)MICROSECS(100) /* Minimum unit */ -#define MCU_ADVANCE 10 /* default weight */ -#define TIME_SLOP (s32)MICROSECS(50) /* allow time to slip a bit */ -static s32 ctx_allow = (s32)MILLISECS(5); /* context switch allowance */ -static s32 max_vtb = (s32)MILLISECS(5); - -static xmem_cache_t *dom_info_cache; - -static inline void __add_to_runqueue_head(struct domain *d) -{ - list_add(RUNLIST(d), RUNQUEUE(d->processor)); -} - -static inline void __add_to_runqueue_tail(struct domain *d) -{ - list_add_tail(RUNLIST(d), RUNQUEUE(d->processor)); -} - -static inline void __del_from_runqueue(struct domain *d) -{ - struct list_head *runlist = RUNLIST(d); - list_del(runlist); - runlist->next = NULL; -} - -static inline int __task_on_runqueue(struct domain *d) -{ - return (RUNLIST(d))->next != NULL; -} - -/* - * Calculate the effective virtual time for a domain. Take into account - * warping limits - */ -static void __calc_evt(struct fbvt_dom_info *inf) -{ - s_time_t now = NOW(); - - if ( inf->warpback ) - { - if ( ((now - inf->warped) < inf->warpl) && - ((now - inf->uwarped) > inf->warpu) ) - { - /* allowed to warp */ - inf->evt = inf->avt - inf->warp; - } - else - { - /* warped for too long -> unwarp */ - inf->evt = inf->avt; - inf->uwarped = now; - inf->warpback = 0; - } - } - else - { - inf->evt = inf->avt; - } -} - -/** - * fbvt_alloc_task - allocate FBVT private structures for a task - * @p: task to allocate private structures for - * - * Returns non-zero on failure. - */ -int fbvt_alloc_task(struct domain *d) -{ - if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL ) - return -1; - memset(d->sched_priv, 0, sizeof(struct fbvt_dom_info)); - return 0; -} - -/* - * Add and remove a domain - */ -void fbvt_add_task(struct domain *p) -{ - struct fbvt_dom_info *inf = FBVT_INFO(p); - - ASSERT(inf != NULL); - ASSERT(p != NULL); - - inf->mcu_advance = MCU_ADVANCE; - inf->domain = p; - if ( p->domain == IDLE_DOMAIN_ID ) - { - inf->avt = inf->evt = ~0U; - } - else - { - /* Set avt and evt to system virtual time. */ - inf->avt = CPU_SVT(p->processor); - inf->evt = CPU_SVT(p->processor); - /* Set some default values here. */ - inf->time_slept = 0; - inf->warpback = 0; - inf->warp = 0; - inf->warpl = 0; - inf->warpu = 0; - } - - return; -} - -int fbvt_init_idle_task(struct domain *p) -{ - if ( fbvt_alloc_task(p) < 0 ) - return -1; - - fbvt_add_task(p); - - set_bit(DF_RUNNING, &p->flags); - if ( !__task_on_runqueue(p) ) - __add_to_runqueue_head(p); - - return 0; -} - -static void fbvt_wake(struct domain *d) -{ - struct fbvt_dom_info *inf = FBVT_INFO(d); - struct domain *curr; - s_time_t now, min_time; - int cpu = d->processor; - s32 io_warp; - - if ( unlikely(__task_on_runqueue(d)) ) - return; - - __add_to_runqueue_head(d); - - now = NOW(); - - /* Set the BVT parameters. */ - if ( inf->avt < CPU_SVT(cpu) ) - { - /* - * We want IO bound processes to gain dispatch precedence. It is - * especially for device driver domains. Therefore AVT - * not be updated to SVT but to a value marginally smaller. - * Since frequently sleeping domains have high time_slept - * values, the virtual time can be determined as: - * SVT - const * TIME_SLEPT - */ - io_warp = inf->time_slept/2; - if ( io_warp > 1000 ) - io_warp = 1000; - - ASSERT(inf->time_slept + CPU_SVT(cpu) > inf->avt + io_warp); - inf->time_slept += CPU_SVT(cpu) - inf->avt - io_warp; - inf->avt = CPU_SVT(cpu) - io_warp; - } - - /* Deal with warping here. */ - inf->warpback = 1; - inf->warped = now; - __calc_evt(inf); - - curr = schedule_data[cpu].curr; - - /* Currently-running domain should run at least for ctx_allow. */ - min_time = curr->lastschd + ctx_allow; - - if ( is_idle_task(curr) || (min_time <= now) ) - cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); - else if ( schedule_data[cpu].s_timer.expires > (min_time + TIME_SLOP) ) - mod_ac_timer(&schedule_data[cpu].s_timer, min_time); -} - - -static void fbvt_sleep(struct domain *d) -{ - if ( test_bit(DF_RUNNING, &d->flags) ) - cpu_raise_softirq(d->processor, SCHEDULE_SOFTIRQ); - else if ( __task_on_runqueue(d) ) - __del_from_runqueue(d); -} - - -/** - * fbvt_free_task - free FBVT private structures for a task - * @d: task - */ -void fbvt_free_task(struct domain *d) -{ - ASSERT(d->sched_priv != NULL); - xmem_cache_free(dom_info_cache, d->sched_priv); -} - -/* - * Block the currently-executing domain until a pertinent event occurs. - */ -static void fbvt_do_block(struct domain *d) -{ - FBVT_INFO(d)->warpback = 0; -} - -/* Control the scheduler. */ -int fbvt_ctl(struct sched_ctl_cmd *cmd) -{ - struct fbvt_ctl *params = &cmd->u.fbvt; - - if ( cmd->direction == SCHED_INFO_PUT ) - { - ctx_allow = params->ctx_allow; - /* The max_vtb should be of the order o the ctx_allow */ - max_vtb = ctx_allow; - } - else - { - params->ctx_allow = ctx_allow; - } - - return 0; -} - -/* Adjust scheduling parameter for a given domain. */ -int fbvt_adjdom(struct domain *p, - struct sched_adjdom_cmd *cmd) -{ - struct fbvt_adjdom *params = &cmd->u.fbvt; - - if ( cmd->direction == SCHED_INFO_PUT ) - { - unsigned long mcu_adv = params->mcu_adv, - warp = params->warp, - warpl = params->warpl, - warpu = params->warpu; - - struct fbvt_dom_info *inf = FBVT_INFO(p); - - DPRINTK("Get domain %u fbvt mcu_adv=%ld, warp=%ld, " - "warpl=%ld, warpu=%ld\n", - p->domain, inf->mcu_advance, inf->warp, - inf->warpl, inf->warpu ); - - /* Sanity -- this can avoid divide-by-zero. */ - if ( mcu_adv == 0 ) - return -EINVAL; - - inf->mcu_advance = mcu_adv; - inf->warp = warp; - inf->warpl = warpl; - inf->warpu = warpu; - - DPRINTK("Set domain %u fbvt mcu_adv=%ld, warp=%ld, " - "warpl=%ld, warpu=%ld\n", - p->domain, inf->mcu_advance, inf->warp, - inf->warpl, inf->warpu ); - } - else if ( cmd->direction == SCHED_INFO_GET ) - { - struct fbvt_dom_info *inf = FBVT_INFO(p); - params->mcu_adv = inf->mcu_advance; - params->warp = inf->warp; - params->warpl = inf->warpl; - params->warpu = inf->warpu; - } - - return 0; -} - - -/* - * The main function - * - deschedule the current domain. - * - pick a new domain. - * i.e., the domain with lowest EVT. - * The runqueue should be ordered by EVT so that is easy. - */ -static task_slice_t fbvt_do_schedule(s_time_t now) -{ - struct domain *prev = current, *next = NULL, *next_prime, *p; - struct list_head *tmp; - int cpu = prev->processor; - s32 r_time; /* time for new dom to run */ - s32 ranfor; /* assume we never run longer than 2.1s! */ - s32 mcus; - u32 next_evt, next_prime_evt, min_avt; - u32 sl_decrement; - struct fbvt_dom_info *prev_inf = FBVT_INFO(prev); - struct fbvt_dom_info *p_inf = NULL; - struct fbvt_dom_info *next_inf = NULL; - struct fbvt_dom_info *next_prime_inf = NULL; - task_slice_t ret; - - ASSERT(prev->sched_priv != NULL); - ASSERT(prev_inf != NULL); - ASSERT(__task_on_runqueue(prev)); - - if ( likely(!is_idle_task(prev)) ) - { - ranfor = (s32)(now - prev->lastschd); - /* Calculate mcu and update avt. */ - mcus = (ranfor + MCU - 1) / MCU; - - TRACE_3D(TRC_SCHED_FBVT_DO_SCHED_UPDATE, prev->domain, - mcus, LAST_VTB(cpu)); - - sl_decrement = mcus * LAST_VTB(cpu) / R_TIME(cpu); - prev_inf->time_slept -= sl_decrement; - prev_inf->avt += mcus * prev_inf->mcu_advance - sl_decrement; - - /*if(mcus * prev_inf->mcu_advance < LAST_VTB(cpu)) - { - ASSERT(prev_inf->time_slept >= mcus * prev_inf->mcu_advance); - prev_inf->time_slept -= mcus * prev_inf->mcu_advance; - } - else - { - prev_inf->avt += mcus * prev_inf->mcu_advance - LAST_VTB(cpu); - - ASSERT(prev_inf->time_slept >= LAST_VTB(cpu)); - prev_inf->time_slept -= LAST_VTB(cpu); - }*/ - - __calc_evt(prev_inf); - - __del_from_runqueue(prev); - - if ( domain_runnable(prev) ) - __add_to_runqueue_tail(prev); - } - - /* We should at least have the idle task */ - ASSERT(!list_empty(RUNQUEUE(cpu))); - - /* - * scan through the run queue and pick the task with the lowest evt - * *and* the task the second lowest evt. - * this code is O(n) but we expect n to be small. - */ - next_inf = FBVT_INFO(schedule_data[cpu].idle); - next_prime_inf = NULL; - - next_evt = ~0U; - next_prime_evt = ~0U; - min_avt = ~0U; - - list_for_each ( tmp, RUNQUEUE(cpu) ) - { - p_inf = list_entry(tmp, struct fbvt_dom_info, run_list); - - if ( p_inf->evt < next_evt ) - { - next_prime_inf = next_inf; - next_prime_evt = next_evt; - next_inf = p_inf; - next_evt = p_inf->evt; - } - else if ( next_prime_evt == ~0U ) - { - next_prime_evt = p_inf->evt; - next_prime_inf = p_inf; - } - else if ( p_inf->evt < next_prime_evt ) - { - next_prime_evt = p_inf->evt; - next_prime_inf = p_inf; - } - - /* Determine system virtual time. */ - if ( p_inf->avt < min_avt ) - min_avt = p_inf->avt; - } - - /* Extract the domain pointers from the dom infos */ - next = next_inf->domain; - next_prime = next_prime_inf->domain; - - - /* Update system virtual time. */ - if ( min_avt != ~0U ) - CPU_SVT(cpu) = min_avt; - - /* check for virtual time overrun on this cpu */ - if ( CPU_SVT(cpu) >= 0xf0000000 ) - { - ASSERT(!local_irq_is_enabled()); - - write_lock(&tasklist_lock); - - for_each_domain ( p ) - { - if ( p->processor == cpu ) - { - p_inf = FBVT_INFO(p); - p_inf->evt -= 0xe0000000; - p_inf->avt -= 0xe0000000; - } - } - - write_unlock(&tasklist_lock); - - CPU_SVT(cpu) -= 0xe0000000; - } - - /* check for time_slept overrun for the domain we schedule to run*/ - if(next_inf->time_slept >= 0xf0000000) - { - printk("Domain %d is assigned more CPU then it is able to use.\n" - "FBVT slept_time=%d, halving. Mcu_advance=%ld\n",next->domain, - next_inf->time_slept, next_inf->mcu_advance); - - next_inf->time_slept /= 2; - } - - - /* - * In here we decide on Virtual Time Bonus. The idea is, for the - * domains that have large time_slept values to be allowed to run - * for longer. Thus regaining the share of CPU originally allocated. - * This is acompanied by the warp mechanism (which moves IO-bound - * domains earlier in virtual time). Together this should give quite - * good control both for CPU and IO-bound domains. - */ - LAST_VTB(cpu) = next_inf->time_slept/5; - if(LAST_VTB(cpu) / next_inf->mcu_advance > max_vtb / MCU) - LAST_VTB(cpu) = max_vtb * next_inf->mcu_advance / MCU; - - - /* work out time for next run through scheduler */ - if ( is_idle_task(next) ) - { - r_time = ctx_allow; - goto sched_done; - } - - if ( (next_prime == NULL) || is_idle_task(next_prime) ) - { - /* We have only one runnable task besides the idle task. */ - r_time = 10 * ctx_allow; /* RN: random constant */ - goto sched_done; - } - - /* - * If we are here then we have two runnable tasks. - * Work out how long 'next' can run till its evt is greater than - * 'next_prime's evt. Take context switch allowance into account. - */ - ASSERT(next_prime_inf->evt >= next_inf->evt); - - ASSERT(LAST_VTB(cpu) >= 0); - - r_time = MCU * ((next_prime_inf->evt + LAST_VTB(cpu) - next_inf->evt)/next_inf->mcu_advance) - + ctx_allow; - - ASSERT(r_time >= ctx_allow); - - sched_done: - R_TIME(cpu) = r_time / MCU; - TRACE_3D(TRC_SCHED_FBVT_DO_SCHED, next->domain, r_time, LAST_VTB(cpu)); - ret.task = next; - ret.time = r_time; - return ret; -} - - -static void fbvt_dump_runq_el(struct domain *p) -{ - struct fbvt_dom_info *inf = FBVT_INFO(p); - - printk("mcua=0x%04lX ev=0x%08X av=0x%08X ", - inf->mcu_advance, inf->evt, inf->avt); -} - -static void fbvt_dump_settings(void) -{ - printk("BVT: mcu=0x%08Xns ctx_allow=0x%08Xns ", (u32)MCU, (s32)ctx_allow ); -} - -static void fbvt_dump_cpu_state(int i) -{ - struct list_head *list, *queue; - int loop = 0; - struct fbvt_dom_info *d_inf; - struct domain *d; - - printk("svt=0x%08lX ", CPU_SVT(i)); - - queue = RUNQUEUE(i); - printk("QUEUE rq %lx n: %lx, p: %lx\n", (unsigned long)queue, - (unsigned long) queue->next, (unsigned long) queue->prev); - - list_for_each ( list, queue ) - { - d_inf = list_entry(list, struct fbvt_dom_info, run_list); - d = d_inf->domain; - printk("%3d: %u has=%c ", loop++, d->domain, - test_bit(DF_RUNNING, &d->flags) ? 'T':'F'); - fbvt_dump_runq_el(d); - printk("c=0x%X%08X\n", (u32)(d->cpu_time>>32), (u32)d->cpu_time); - printk(" l: %lx n: %lx p: %lx\n", - (unsigned long)list, (unsigned long)list->next, - (unsigned long)list->prev); - } -} - -/* Initialise the data structures. */ -int fbvt_init_scheduler() -{ - int i; - - for ( i = 0; i < NR_CPUS; i++ ) - { - schedule_data[i].sched_priv = xmalloc(sizeof(struct fbvt_cpu_info)); - - if ( schedule_data[i].sched_priv == NULL ) - { - printk("Failed to allocate FBVT scheduler per-CPU memory!\n"); - return -1; - } - - INIT_LIST_HEAD(RUNQUEUE(i)); - - CPU_SVT(i) = 0; /* XXX do I really need to do this? */ - } - - dom_info_cache = xmem_cache_create( - "FBVT dom info", sizeof(struct fbvt_dom_info), 0, 0, NULL, NULL); - if ( dom_info_cache == NULL ) - { - printk("FBVT: Failed to allocate domain info SLAB cache"); - return -1; - } - - return 0; -} - - -struct scheduler sched_fbvt_def = { - .name = "Fair Borrowed Virtual Time", - .opt_name = "fbvt", - .sched_id = SCHED_FBVT, - - .init_scheduler = fbvt_init_scheduler, - .init_idle_task = fbvt_init_idle_task, - .alloc_task = fbvt_alloc_task, - .add_task = fbvt_add_task, - .free_task = fbvt_free_task, - .do_block = fbvt_do_block, - .do_schedule = fbvt_do_schedule, - .control = fbvt_ctl, - .adjdom = fbvt_adjdom, - .dump_settings = fbvt_dump_settings, - .dump_cpu_state = fbvt_dump_cpu_state, - .sleep = fbvt_sleep, - .wake = fbvt_wake, -}; - diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 251fc8b4f4..032f1bd271 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -68,12 +68,10 @@ static void fallback_timer_fn(unsigned long unused); schedule_data_t schedule_data[NR_CPUS]; extern struct scheduler sched_bvt_def; -extern struct scheduler sched_fbvt_def; extern struct scheduler sched_rrobin_def; extern struct scheduler sched_atropos_def; static struct scheduler *schedulers[] = { &sched_bvt_def, - &sched_fbvt_def, &sched_rrobin_def, &sched_atropos_def, NULL diff --git a/xen/include/hypervisor-ifs/sched_ctl.h b/xen/include/hypervisor-ifs/sched_ctl.h index 0131cc4bb3..0c298f76d6 100644 --- a/xen/include/hypervisor-ifs/sched_ctl.h +++ b/xen/include/hypervisor-ifs/sched_ctl.h @@ -9,7 +9,6 @@ /* Scheduler types */ #define SCHED_BVT 0 -#define SCHED_FBVT 1 #define SCHED_ATROPOS 2 #define SCHED_RROBIN 3 @@ -33,12 +32,6 @@ struct sched_ctl_cmd u32 ctx_allow; /* 8: context switch allowance */ } PACKED bvt; - struct fbvt_ctl - { - /* IN variables. */ - u32 ctx_allow; /* 8: context switch allowance */ - } PACKED fbvt; - struct rrobin_ctl { /* IN variables */ @@ -64,14 +57,6 @@ struct sched_adjdom_cmd long long warpu; /* 40: unwarp time requirement */ } PACKED bvt; - struct fbvt_adjdom - { - u32 mcu_adv; /* 16: mcu advance: inverse of weight */ - u32 warp; /* 20: time warp */ - u32 warpl; /* 24: warp limit */ - u32 warpu; /* 28: unwarp time requirement */ - } PACKED fbvt; - struct atropos_adjdom { u64 nat_period; /* 16 */ -- 2.39.5