diff --git a/include/linux/xsched.h b/include/linux/xsched.h index a277c70b605b0f52ad2cf5e30cff4ca4635556eb..d21393ac82d690f97019a0dfde0373ccc1a5575d 100644 --- a/include/linux/xsched.h +++ b/include/linux/xsched.h @@ -7,6 +7,7 @@ #include #include #include +#include #ifndef pr_fmt #define pr_fmt(fmt) fmt @@ -39,7 +40,7 @@ #define RUNTIME_INF ((u64)~0ULL) #define XSCHED_TIME_INF RUNTIME_INF -#define XSCHED_CFS_WEIGHT_DFLT 1 +#define XSCHED_CFS_WEIGHT_DFLT 1024 #define XSCHED_CFS_QUOTA_PERIOD_MS (100 * NSEC_PER_MSEC) #define XSCHED_CFG_SHARE_DFLT 1024 @@ -268,8 +269,7 @@ struct xsched_group { int prio; /* Bandwidth setting: shares value set by user */ - u64 shares_cfg; - u64 shares_cfg_red; + u32 shares_cfg; u32 weight; u64 children_shares_sum; @@ -296,6 +296,8 @@ struct xsched_group { /* to control the xcu.{period, quota, shares} files shown or not */ struct cgroup_file xcu_file[NR_XCU_FILE_TYPES]; struct work_struct file_show_work; + + bool is_offline; }; #endif /* CONFIG_CGROUP_XCU */ @@ -326,7 +328,7 @@ xse_this_grp(struct xsched_entity_cfs *xse_cfs) } #endif /* CONFIG_CGROUP_XCU */ -static inline int xse_integrity_check(const struct xsched_entity *xse) +static inline int xse_integrity_check(struct xsched_entity *xse) { if (!xse) { XSCHED_ERR("xse is null @ %s\n", __func__); @@ -338,6 +340,15 @@ static inline int xse_integrity_check(const struct xsched_entity *xse) return -EINVAL; } +#ifdef CONFIG_CGROUP_XCU + if (xse->is_group && !xse_this_grp_xcu(&xse->cfs)->cfs_rq) { + // Can only be in the free process + XSCHED_ERR("the sub_rq this cgroup-type xse [%d] owned cannot be NULL @ %s\n", + xse->tgid, __func__); + return -EINVAL; + } +#endif /* CONFIG_CGROUP_XCU */ + return 0; } @@ -454,7 +465,10 @@ int delete_ctx(struct xsched_context *ctx); void xsched_group_inherit(struct task_struct *tsk, struct xsched_entity *xse); void xcu_cg_subsys_init(void); void xcu_cfs_root_cg_init(struct xsched_cu *xcu); -void xcu_grp_shares_update(struct xsched_group *parent); +void xcu_grp_shares_update(struct xsched_group *parent, + struct xsched_group *child, u32 shares_cfg); +void xcu_grp_shares_add(struct xsched_group *parent, struct xsched_group *child); +void xcu_grp_shares_sub(struct xsched_group *parent, struct xsched_group *child); void xsched_group_xse_detach(struct xsched_entity *xse); void xsched_quota_init(void); @@ -475,4 +489,20 @@ void xsched_quota_refill(struct work_struct *work); #endif +static inline u64 xs_calc_delta(u64 delta_exec, u32 base_weight, u32 weight) +{ + if (unlikely(weight == 0)) + weight = 1; + + if (weight == base_weight) + return delta_exec; + + return mul_u64_u32_div(delta_exec, base_weight, weight); +} + +static inline u64 xs_calc_delta_fair(u64 delta_exec, u32 weight) +{ + return xs_calc_delta(delta_exec, XSCHED_CFG_SHARE_DFLT, weight); +} + #endif /* !__LINUX_XSCHED_H__ */ diff --git a/kernel/xsched/cfs.c b/kernel/xsched/cfs.c index 883ba69744506c0a8d63512a42e288a02c5364f3..2c8319f7f18da7e4b0b83d25accffbffcbd1855a 100644 --- a/kernel/xsched/cfs.c +++ b/kernel/xsched/cfs.c @@ -62,14 +62,19 @@ static void xs_cfs_rq_update(struct xsched_entity_cfs *xse_cfs, u64 new_xrt) static inline struct xsched_entity_cfs * xs_pick_first(struct xsched_rq_cfs *cfs_rq) { - struct xsched_entity_cfs *xse_cfs; - struct rb_node *left = rb_first_cached(&cfs_rq->ctx_timeline); + struct rb_node *left; + + if (!cfs_rq) { + XSCHED_WARN("the rq cannot be NULL @ %s\n", __func__); + return NULL; + } + + left = rb_first_cached(&cfs_rq->ctx_timeline); if (!left) return NULL; - xse_cfs = rb_entry(left, struct xsched_entity_cfs, run_node); - return xse_cfs; + return rb_entry(left, struct xsched_entity_cfs, run_node); } /** @@ -82,7 +87,7 @@ static void xs_update(struct xsched_entity_cfs *xse_cfs, u64 delta) struct xsched_group_xcu_priv *xg = xse_parent_grp_xcu(xse_cfs); for (; xg; xse_cfs = &xg->xse.cfs, xg = &xcg_parent_grp_xcu(xg)) { - u64 new_xrt = xse_cfs->xruntime + delta * xse_cfs->weight; + u64 new_xrt = xse_cfs->xruntime + xs_calc_delta_fair(delta, xse_cfs->weight); xs_cfs_rq_update(xse_cfs, new_xrt); xse_cfs->sum_exec_runtime += delta; @@ -107,10 +112,8 @@ static void xg_update(struct xsched_group_xcu_priv *xg, int task_delta) for (; xg; xg = &xcg_parent_grp_xcu(xg)) { xg->cfs_rq->nr_running += task_delta; entry = xs_pick_first(xg->cfs_rq); - if (entry) - new_xrt = xg->xse.cfs.sum_exec_runtime * xg->xse.cfs.weight; - else - new_xrt = XSCHED_TIME_INF; + new_xrt = entry ? xs_calc_delta_fair(entry->xruntime, xg->xse.cfs.weight) + : XSCHED_TIME_INF; xg->cfs_rq->min_xruntime = new_xrt; xg->xse.cfs.xruntime = new_xrt; @@ -159,12 +162,25 @@ static void enqueue_ctx_fair(struct xsched_entity *xse, struct xsched_cu *xcu) { int task_delta; struct xsched_entity_cfs *first; - struct xsched_rq_cfs *rq; + struct xsched_rq_cfs *rq, *sub_rq; struct xsched_entity_cfs *xse_cfs = &xse->cfs; rq = xse_cfs->cfs_rq = xse_parent_grp_xcu(xse_cfs)->cfs_rq; + if (!rq) { + XSCHED_WARN("the parent rq this xse [%d] attached cannot be NULL @ %s\n", + xse->tgid, __func__); + return; + } + + sub_rq = xse_this_grp_xcu(xse_cfs)->cfs_rq; + if (xse->is_group && !sub_rq) { + XSCHED_WARN("the sub_rq this cgroup-type xse [%d] owned cannot be NULL @ %s\n", + xse->tgid, __func__); + return; + } + task_delta = - (xse->is_group) ? xse_this_grp_xcu(xse_cfs)->cfs_rq->nr_running : 1; + (xse->is_group) ? sub_rq->nr_running : 1; /* If no XSE or only empty groups */ if (xs_pick_first(rq) == NULL || rq->min_xruntime == XSCHED_TIME_INF) @@ -188,10 +204,13 @@ static struct xsched_entity *pick_next_ctx_fair(struct xsched_cu *xcu) if (!xse) return NULL; - for (; XSCHED_SE_OF(xse)->is_group; xse = xs_pick_first(rq)) { - if (!xse || CFS_INNER_RQ_EMPTY(xse)) - return NULL; + for (; xse && XSCHED_SE_OF(xse)->is_group; xse = xs_pick_first(rq)) rq = xse_this_grp_xcu(xse)->cfs_rq; + + if (!xse) { + XSCHED_DEBUG("the xse this xcu [%d] is trying to pick is NULL @ %s\n", + xcu->id, __func__); + return NULL; } return container_of(xse, struct xsched_entity, cfs); diff --git a/kernel/xsched/cfs_quota.c b/kernel/xsched/cfs_quota.c index 2e17a48c071bd232c98e82fde0a4c9a91bb7a5ee..70316dab682adfb388564fd4bcde11ec93a446b0 100644 --- a/kernel/xsched/cfs_quota.c +++ b/kernel/xsched/cfs_quota.c @@ -26,6 +26,11 @@ static void xsched_group_unthrottle(struct xsched_group *xg) for_each_active_xcu(xcu, id) { mutex_lock(&xcu->xcu_lock); + if (!xg || READ_ONCE(xg->is_offline) || + READ_ONCE(xg->sched_class) != XSCHED_TYPE_CFS) { + mutex_unlock(&xcu->xcu_lock); + return; + } if (!READ_ONCE(xg->perxcu_priv[id].xse.on_rq)) { enqueue_ctx(&xg->perxcu_priv[id].xse, xcu); wake_up_interruptible(&xcu->wq_xcu_idle); @@ -107,6 +112,10 @@ void xsched_quota_timeout_update(struct xsched_group *xg) hrtimer_cancel(t); + if (!xg || READ_ONCE(xg->is_offline) || + READ_ONCE(xg->sched_class) != XSCHED_TYPE_CFS) + return; + if (xg->quota > 0 && xg->period > 0) hrtimer_start(t, ns_to_ktime(xg->period), HRTIMER_MODE_REL_SOFT); else diff --git a/kernel/xsched/cgroup.c b/kernel/xsched/cgroup.c index 02957b33340a64030361e588752e09482539e8d3..8f3e2d9e9e12c5ab4d944729b548df93f574994e 100644 --- a/kernel/xsched/cgroup.c +++ b/kernel/xsched/cgroup.c @@ -31,27 +31,33 @@ struct xsched_group *root_xcg = &root_xsched_group; static struct kmem_cache *xsched_group_cache __read_mostly; static struct kmem_cache *xcg_attach_entry_cache __read_mostly; static LIST_HEAD(xcg_attach_list); +static DEFINE_MUTEX(xcg_mutex); +static DEFINE_MUTEX(xcu_file_show_mutex); static const char xcu_sched_name[XSCHED_TYPE_NUM][4] = { [XSCHED_TYPE_RT] = "rt", [XSCHED_TYPE_CFS] = "cfs" }; -static int xcu_cg_set_file_show(struct xsched_group *xg) +static int xcu_cg_set_file_show(struct xsched_group *xg, int sched_class) { if (!xg) { XSCHED_ERR("xsched_group is NULL.\n"); return -EINVAL; } + mutex_lock(&xcu_file_show_mutex); /* Update visibility of related files based on sched_class */ for (int type_name = XCU_FILE_PERIOD_MS; type_name < NR_XCU_FILE_TYPES; type_name++) { - if (unlikely(!xg->xcu_file[type_name].kn)) + if (unlikely(!xg->xcu_file[type_name].kn)) { + mutex_unlock(&xcu_file_show_mutex); return -EBUSY; + } - cgroup_file_show(&xg->xcu_file[type_name], xg->sched_class == XSCHED_TYPE_CFS); + cgroup_file_show(&xg->xcu_file[type_name], sched_class == XSCHED_TYPE_CFS); } + mutex_unlock(&xcu_file_show_mutex); return 0; } @@ -72,6 +78,7 @@ static void xcu_cg_initialize_components(struct xsched_group *xcg) INIT_LIST_HEAD(&xcg->children_groups); xsched_quota_timeout_init(xcg); INIT_WORK(&xcg->refill_work, xsched_quota_refill); + WRITE_ONCE(xcg->is_offline, false); } void xcu_cg_subsys_init(void) @@ -98,6 +105,21 @@ void xcu_cfs_root_cg_init(struct xsched_cu *xcu) root_xcg->perxcu_priv[id].xse.cfs.weight = XSCHED_CFS_WEIGHT_DFLT; } +static void xcg_perxcu_cfs_rq_deinit(struct xsched_group *xcg, int max_id) +{ + struct xsched_cu *xcu; + int i; + + for (i = 0; i < max_id; i++) { + xcu = xsched_cu_mgr[i]; + mutex_lock(&xcu->xcu_lock); + dequeue_ctx(&xcg->perxcu_priv[i].xse, xcu); + kfree(xcg->perxcu_priv[i].cfs_rq); + xcg->perxcu_priv[i].cfs_rq = NULL; + mutex_unlock(&xcu->xcu_lock); + } +} + /** * xcu_cfs_cg_init() - Initialize xsched_group cfs runqueues and bw control. * @xcg: new xsched_cgroup @@ -110,7 +132,7 @@ void xcu_cfs_root_cg_init(struct xsched_cu *xcu) static int xcu_cfs_cg_init(struct xsched_group *xcg, struct xsched_group *parent_xg) { - int id = 0, err, i; + int id = 0; struct xsched_cu *xcu; struct xsched_rq_cfs *sub_cfs_rq; @@ -118,11 +140,11 @@ static int xcu_cfs_cg_init(struct xsched_group *xcg, xcg->perxcu_priv[id].xcu_id = id; xcg->perxcu_priv[id].self = xcg; - sub_cfs_rq = kzalloc(sizeof(struct xsched_rq_cfs), GFP_KERNEL); + sub_cfs_rq = kzalloc(sizeof(*sub_cfs_rq), GFP_KERNEL); if (!sub_cfs_rq) { XSCHED_ERR("Fail to alloc cfs runqueue on xcu %d\n", id); - err = -ENOMEM; - goto alloc_error; + xcg_perxcu_cfs_rq_deinit(xcg, id); + return -ENOMEM; } xcg->perxcu_priv[id].cfs_rq = sub_cfs_rq; xcg->perxcu_priv[id].cfs_rq->ctx_timeline = RB_ROOT_CACHED; @@ -142,38 +164,18 @@ static int xcu_cfs_cg_init(struct xsched_group *xcg, } xcg->shares_cfg = XSCHED_CFG_SHARE_DFLT; - xcu_grp_shares_update(parent_xg); + xcu_grp_shares_add(parent_xg, xcg); xcg->period = XSCHED_CFS_QUOTA_PERIOD_MS; xcg->quota = XSCHED_TIME_INF; xcg->runtime = 0; return 0; - -alloc_error: - for (i = 0; i < id; i++) { - xcu = xsched_cu_mgr[i]; - mutex_lock(&xcu->xcu_lock); - dequeue_ctx(&xcg->perxcu_priv[i].xse, xcu); - mutex_unlock(&xcu->xcu_lock); - - kfree(xcg->perxcu_priv[i].cfs_rq); - } - - return err; } static void xcu_cfs_cg_deinit(struct xsched_group *xcg) { - uint32_t id; - struct xsched_cu *xcu; - - for_each_active_xcu(xcu, id) { - mutex_lock(&xcu->xcu_lock); - dequeue_ctx(&xcg->perxcu_priv[id].xse, xcu); - mutex_unlock(&xcu->xcu_lock); - kfree(xcg->perxcu_priv[id].cfs_rq); - } - xcu_grp_shares_update(xcg->parent); + xcg_perxcu_cfs_rq_deinit(xcg, num_active_xcu); + xcu_grp_shares_sub(xcg->parent, xcg); } /** @@ -230,7 +232,7 @@ xcu_css_alloc(struct cgroup_subsys_state *parent_css) if (!parent_css) return &root_xsched_group.css; - xg = kmem_cache_alloc(xsched_group_cache, GFP_KERNEL | __GFP_ZERO); + xg = kmem_cache_zalloc(xsched_group_cache, GFP_KERNEL); if (!xg) return ERR_PTR(-ENOMEM); @@ -241,18 +243,36 @@ static void xcu_css_free(struct cgroup_subsys_state *css) { struct xsched_group *xcg = xcu_cg_from_css(css); + if (!xsched_group_is_root(xcg)) { + switch (xcg->sched_class) { + case XSCHED_TYPE_CFS: + xcu_cfs_cg_deinit(xcg); + break; + default: + XSCHED_INFO("xcu_cgroup: deinit RT group css=0x%lx\n", + (uintptr_t)&xcg->css); + break; + } + } + + list_del(&xcg->group_node); + kmem_cache_free(xsched_group_cache, xcg); } - static void delay_xcu_cg_set_file_show_workfn(struct work_struct *work) { struct xsched_group *xg; xg = container_of(work, struct xsched_group, file_show_work); + if (!xg) { + XSCHED_ERR("xsched_group cannot be null @ %s", __func__); + return; + } + for (int i = 0; i < XCUCG_SET_FILE_RETRY_COUNT; i++) { - if (!xcu_cg_set_file_show(xg)) + if (!xcu_cg_set_file_show(xg, xg->sched_class)) return; mdelay(XCUCG_SET_FILE_DELAY_MS); @@ -292,20 +312,12 @@ static void xcu_css_offline(struct cgroup_subsys_state *css) struct xsched_group *xcg; xcg = xcu_cg_from_css(css); - if (!xsched_group_is_root(xcg)) { - switch (xcg->sched_class) { - case XSCHED_TYPE_CFS: - xcu_cfs_cg_deinit(xcg); - break; - default: - XSCHED_INFO("xcu_cgroup: deinit RT group css=0x%lx\n", - (uintptr_t)&xcg->css); - break; - } - } + + WRITE_ONCE(xcg->is_offline, true); + hrtimer_cancel(&xcg->quota_timeout); cancel_work_sync(&xcg->refill_work); - list_del(&xcg->group_node); + cancel_work_sync(&xcg->file_show_work); } static void xsched_group_xse_attach(struct xsched_group *xg, @@ -360,18 +372,20 @@ static int xcu_can_attach(struct cgroup_taskset *tset) old_xcg = xcu_cg_from_css(old_css); ret = xcu_task_can_attach(task, old_xcg); - if (ret) - break; + if (ret < 0) + return ret; /* record entry for this task */ - entry = kmem_cache_alloc(xcg_attach_entry_cache, GFP_KERNEL | __GFP_ZERO); + entry = kmem_cache_zalloc(xcg_attach_entry_cache, GFP_KERNEL); + if (!entry) + return -ENOMEM; entry->task = task; entry->old_xcg = old_xcg; entry->new_xcg = dst_xcg; list_add_tail(&entry->node, &xcg_attach_list); } - return ret; + return 0; } static void xcu_cancel_attach(struct cgroup_taskset *tset) @@ -496,22 +510,17 @@ static int xcu_cg_set_sched_class(struct xsched_group *xg, int type) xcu_cfs_cg_deinit(xg); break; default: - XSCHED_INFO("xcu_cgroup: the original sched_class is RT, css=0x%lx\n", - (uintptr_t)&xg->css); break; } /* update type */ xg->sched_class = type; - xcu_cg_set_file_show(xg); /* init new type if necessary */ switch (type) { case XSCHED_TYPE_CFS: return xcu_cfs_cg_init(xg, xg->parent); default: - XSCHED_INFO("xcu_cgroup: the target sched_class is RT, css=0x%lx\n", - (uintptr_t)&xg->css); return 0; } } @@ -520,7 +529,7 @@ static ssize_t xcu_sched_class_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { struct cgroup_subsys_state *css = of_css(of); - struct xsched_group *xg = xcu_cg_from_css(css); + struct xsched_group *xg; char type_name[SCHED_CLASS_MAX_LENGTH]; int type; @@ -533,20 +542,31 @@ static ssize_t xcu_sched_class_write(struct kernfs_open_file *of, char *buf, if (!strcmp(type_name, xcu_sched_name[type])) break; } - if (type == XSCHED_TYPE_NUM) return -EINVAL; if (!list_empty(&css->children)) return -EBUSY; + css_get(css); + xg = xcu_cg_from_css(css); + /* only the first level of root can switch scheduler type */ - if (!xsched_group_is_root(xg->parent)) + if (!xsched_group_is_root(xg->parent)) { + css_put(css); return -EINVAL; + } + mutex_lock(&xcg_mutex); ret = xcu_cg_set_sched_class(xg, type); + mutex_unlock(&xcg_mutex); + + if (!ret) + xcu_cg_set_file_show(xg, type); - return (ret) ? ret : nbytes; + css_put(css); + + return ret ? ret : nbytes; } static s64 xcu_read_s64(struct cgroup_subsys_state *css, struct cftype *cft) @@ -573,58 +593,69 @@ static s64 xcu_read_s64(struct cgroup_subsys_state *css, struct cftype *cft) return ret; } -void xcu_grp_shares_update(struct xsched_group *parent) +void xcu_grp_shares_update(struct xsched_group *parent, struct xsched_group *child, u32 shares_cfg) { int id; struct xsched_cu *xcu; - struct xsched_group *children; - u64 rem, sh_sum = 0, sh_gcd = 0, w_gcd = 0, sh_prod_red = 1; - lockdep_assert_held(&cgroup_mutex); + if (child->sched_class != XSCHED_TYPE_CFS) + return; - list_for_each_entry(children, &parent->children_groups, group_node) { - if (children->sched_class == XSCHED_TYPE_CFS) - sh_gcd = gcd(sh_gcd, children->shares_cfg); - } + parent->children_shares_sum -= child->shares_cfg; - list_for_each_entry(children, &parent->children_groups, group_node) { - if (children->sched_class == XSCHED_TYPE_CFS) { - sh_sum += children->shares_cfg; - children->shares_cfg_red = div64_u64(children->shares_cfg, sh_gcd); - div64_u64_rem(sh_prod_red, children->shares_cfg_red, &rem); - if (rem) - sh_prod_red *= children->shares_cfg_red; - } + child->shares_cfg = shares_cfg; + child->weight = child->shares_cfg; + + for_each_active_xcu(xcu, id) { + mutex_lock(&xcu->xcu_lock); + child->perxcu_priv[id].xse.cfs.weight = child->weight; + mutex_unlock(&xcu->xcu_lock); } - parent->children_shares_sum = sh_sum; + parent->children_shares_sum += child->shares_cfg; +} - list_for_each_entry(children, &parent->children_groups, group_node) { - if (children->sched_class == XSCHED_TYPE_CFS) { - children->weight = div64_u64(sh_prod_red, children->shares_cfg_red); - w_gcd = gcd(w_gcd, children->weight); - } - } +void xcu_grp_shares_add(struct xsched_group *parent, struct xsched_group *child) +{ + int id; + struct xsched_cu *xcu; - list_for_each_entry(children, &parent->children_groups, group_node) { - if (children->sched_class == XSCHED_TYPE_CFS) { - children->weight = div64_u64(children->weight, w_gcd); - for_each_active_xcu(xcu, id) { - mutex_lock(&xcu->xcu_lock); - children->perxcu_priv[id].xse.cfs.weight = children->weight; - mutex_unlock(&xcu->xcu_lock); - } - } + if (child->sched_class != XSCHED_TYPE_CFS) + return; + + child->weight = child->shares_cfg; + for_each_active_xcu(xcu, id) { + mutex_lock(&xcu->xcu_lock); + child->perxcu_priv[id].xse.cfs.weight = child->weight; + mutex_unlock(&xcu->xcu_lock); } + + parent->children_shares_sum += child->shares_cfg; +} + +void xcu_grp_shares_sub(struct xsched_group *parent, struct xsched_group *child) +{ + if (child->sched_class != XSCHED_TYPE_CFS) + return; + + parent->children_shares_sum -= child->shares_cfg; } static int xcu_write_s64(struct cgroup_subsys_state *css, struct cftype *cft, s64 val) { int ret = 0; - struct xsched_group *xcucg = xcu_cg_from_css(css); + struct xsched_group *xcucg; s64 quota_ns; + css_get(css); + xcucg = xcu_cg_from_css(css); + + if (xcucg->sched_class == XSCHED_TYPE_RT) { + css_put(css); + return -EINVAL; + } + switch (cft->private) { case XCU_FILE_PERIOD_MS: if (val < XCU_PERIOD_MIN_MS || val > (S64_MAX / NSEC_PER_MSEC)) { @@ -649,14 +680,11 @@ static int xcu_write_s64(struct cgroup_subsys_state *css, struct cftype *cft, xsched_quota_timeout_update(xcucg); break; case XCU_FILE_SHARES: - if (val < XCU_SHARES_MIN || val > U64_MAX) { + if (val < XCU_SHARES_MIN || val > U32_MAX) { ret = -EINVAL; break; } - cgroup_lock(); - xcucg->shares_cfg = val; - xcu_grp_shares_update(xcucg->parent); - cgroup_unlock(); + xcu_grp_shares_update(xcucg->parent, xcucg, val); break; default: XSCHED_ERR("invalid operation %lu @ %s\n", cft->private, __func__); @@ -664,6 +692,8 @@ static int xcu_write_s64(struct cgroup_subsys_state *css, struct cftype *cft, break; } + css_put(css); + return ret; } @@ -690,7 +720,7 @@ static int xcu_stat(struct seq_file *sf, void *v) } seq_printf(sf, "exec_runtime: %llu\n", exec_runtime); - seq_printf(sf, "shares cfg: %llu/%llu x%u\n", xcucg->shares_cfg, + seq_printf(sf, "shares cfg: %u/%llu x%u\n", xcucg->shares_cfg, xcucg->parent->children_shares_sum, xcucg->weight); seq_printf(sf, "quota: %lld\n", xcucg->quota); seq_printf(sf, "used: %lld\n", xcucg->runtime); diff --git a/kernel/xsched/core.c b/kernel/xsched/core.c index 57479fe800c9b0fe2c9999c541d92e5a9cfd8ae1..5e6c5eec2dc9e7f30418c483f1b5bd3fbf558e8c 100644 --- a/kernel/xsched/core.c +++ b/kernel/xsched/core.c @@ -110,8 +110,6 @@ static struct xsched_entity *__raw_pick_next_ctx(struct xsched_cu *xcu) return NULL; } - XSCHED_DEBUG("xse %d scheduled=%zu total=%zu @ %s\n", - next->tgid, scheduled, next->total_scheduled, __func__); break; } } @@ -230,8 +228,6 @@ static void submit_kick(struct vstream_metadata *vsm) XSCHED_ERR( "Fail to send Vstream id %u tasks to a device for processing.\n", vs->id); - - XSCHED_DEBUG("Vstream id %u submit vsm: sq_tail %u\n", vs->id, vsm->sq_tail); } static void submit_wait(struct vstream_metadata *vsm) @@ -347,11 +343,8 @@ struct vstream_metadata *xsched_vsm_fetch_first(struct vstream_info *vs) { struct vstream_metadata *vsm; - if (!vs || list_empty(&vs->metadata_list)) { - XSCHED_DEBUG("No metadata to fetch from vs %u @ %s\n", - vs->id, __func__); + if (!vs || list_empty(&vs->metadata_list)) return NULL; - } spin_lock(&vs->stream_lock); vsm = list_first_entry(&vs->metadata_list, struct vstream_metadata, node); diff --git a/kernel/xsched/rt.c b/kernel/xsched/rt.c index e2ce1ebb8a7a062d91ba2370ec8782dcc85e51d5..498d5ac618a1314c680e875e38d46fc51e8e7049 100644 --- a/kernel/xsched/rt.c +++ b/kernel/xsched/rt.c @@ -95,36 +95,21 @@ static inline uint32_t get_next_prio_rt(struct xsched_rq *xrq) static struct xsched_entity *pick_next_ctx_rt(struct xsched_cu *xcu) { - struct xsched_entity *result; int next_prio; next_prio = get_next_prio_rt(&xcu->xrq); - if (next_prio >= NR_XSE_PRIO) { - XSCHED_DEBUG("No pending kicks in RT class @ %s\n", __func__); + if (next_prio >= NR_XSE_PRIO) return NULL; - } - - result = xrq_next_xse(xcu, next_prio); - if (!result) - XSCHED_ERR("Next XSE not found @ %s\n", __func__); - else - XSCHED_DEBUG("Next XSE %u at prio %u @ %s\n", result->tgid, next_prio, __func__); - return result; + return xrq_next_xse(xcu, next_prio); } static void put_prev_ctx_rt(struct xsched_entity *xse) { xse->rt.timeslice -= xse->last_exec_runtime; - XSCHED_DEBUG( - "Update XSE=%d timeslice=%lld, XSE submitted=%lld in RT class @ %s\n", - xse->tgid, xse->rt.timeslice, - xse->last_exec_runtime, __func__); if (xse->rt.timeslice <= 0) { xse->rt.timeslice = XSCHED_RT_TIMESLICE; - XSCHED_DEBUG("Refill XSE=%d kick_slice=%lld in RT class @ %s\n", - xse->tgid, xse->rt.timeslice, __func__); xse_rt_move_tail(xse); } } diff --git a/kernel/xsched/vstream.c b/kernel/xsched/vstream.c index b9c4715c106157fc1dee8d39480728e93c8c0f8e..ebde50cbb8c6450ecaf2e7b496e2c788b9b651a4 100644 --- a/kernel/xsched/vstream.c +++ b/kernel/xsched/vstream.c @@ -89,7 +89,10 @@ static void xsched_task_free(struct kref *kref) list_del(&ctx->ctx_node); mutex_unlock(&xcu->ctx_list_lock); + mutex_lock(&xcu->xcu_lock); + dequeue_ctx(&ctx->xse, xcu); kfree(ctx); + mutex_unlock(&xcu->xcu_lock); } struct xsched_cu *xcu_find(uint32_t type,