hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID8IIO ----------------------------------------- The XCU scheduler only supports two valid configuration combinations: 1) CONFIG_XCU_SCHEDULER + XCU_SCHED_RT 2) CONFIG_XCU_SCHEDULER + XCU_SCHED_RT + XCU_SCHED_CFS + CGROUP_XCU XCU_SCHED_RT is required whenever CONFIG_XCU_SCHEDULER is enabled, as RT is the default scheduling mode and the current implementation cannot initialize a root cgroup in CFS-only mode. XCU_SCHED_CFS requires CGROUP_XCU because all CFS configurations are managed through cgroups. Other options selected by CONFIG_XCU_SCHEDULER (e.g., XCU_VSTREAM and XSCHED_NR_CUS) remain implicitly enabled and do not affect the valid combinations above. Fixes: 43bbefc53356 ("xsched: Add XCU control group implementation and its backend in xsched CFS") Signed-off-by: Zicheng Qu <quzicheng@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 3 ++- arch/x86/configs/openeuler_defconfig | 3 ++- drivers/xcu/xcu_group.c | 2 ++ include/linux/xsched.h | 17 ++++++++++------- kernel/xsched/Kconfig | 5 ++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index a2ae0fbd7c15..b6afc4e9a31d 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -97,7 +97,8 @@ CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set # CONFIG_PREEMPT is not set # CONFIG_PREEMPT_DYNAMIC is not set -CONFIG_XCU_SCHEDULER=n +CONFIG_XCU_SCHEDULER=y +CONFIG_XSCHED_NR_CUS=128 # # CPU/Task time and stats accounting diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index 11bbad302d26..268ab3c32d3f 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -117,7 +117,8 @@ CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set # CONFIG_PREEMPT is not set # CONFIG_PREEMPT_DYNAMIC is not set -CONFIG_XCU_SCHEDULER=n +CONFIG_XCU_SCHEDULER=y +CONFIG_XSCHED_NR_CUS=128 # # CPU/Task time and stats accounting diff --git a/drivers/xcu/xcu_group.c b/drivers/xcu/xcu_group.c index 0cd8f535fb2b..1cf159b8f57d 100644 --- a/drivers/xcu/xcu_group.c +++ b/drivers/xcu/xcu_group.c @@ -327,7 +327,9 @@ int xsched_xcu_register(struct xcu_group *group, uint32_t phys_id) return ret; } +#ifdef CONFIG_CGROUP_XCU xcu_cfs_root_cg_init(xcu); +#endif /* CONFIG_CGROUP_XCU */ return 0; } diff --git a/include/linux/xsched.h b/include/linux/xsched.h index 4ec8fdc64408..bd2e32980cac 100644 --- a/include/linux/xsched.h +++ b/include/linux/xsched.h @@ -226,10 +226,12 @@ struct xsched_entity { */ struct xsched_cu *xcu; +#ifdef CONFIG_CGROUP_XCU /* Link to list of xsched_group items */ struct list_head group_node; struct xsched_group *parent_grp; bool is_group; +#endif /* CONFIG_CGROUP_XCU */ /* General purpose xse lock. */ spinlock_t xse_lock; @@ -243,6 +245,7 @@ struct xcg_attach_entry { struct list_head node; }; +#ifdef CONFIG_CGROUP_XCU /* xsched_group's xcu related stuff */ struct xsched_group_xcu_priv { /* Owner of this group */ @@ -306,22 +309,18 @@ struct xsched_group { struct cgroup_file xcu_file[NR_XCU_FILE_TYPES]; struct work_struct file_show_work; }; - -#define XSCHED_RQ_OF(xse) \ - (container_of(((xse)->cfs.cfs_rq), struct xsched_rq, cfs)) - -#define XSCHED_RQ_OF_CFS_XSE(cfs_xse) \ - (container_of(((cfs_xse)->cfs_rq), struct xsched_rq, cfs)) +#endif /* CONFIG_CGROUP_XCU */ #define XSCHED_SE_OF(cfs_xse) \ (container_of((cfs_xse), struct xsched_entity, cfs)) +#ifdef CONFIG_CGROUP_XCU #define xcg_parent_grp_xcu(xcg) \ ((xcg)->self->parent->perxcu_priv[(xcg)->xcu_id]) #define xse_parent_grp_xcu(xse_cfs) \ (&((XSCHED_SE_OF(xse_cfs) \ - ->parent_grp->perxcu_priv[(XSCHED_SE_OF(xse_cfs))->xcu->id]))) + ->parent_grp->perxcu_priv[(XSCHED_SE_OF(xse_cfs))->xcu->id]))) static inline struct xsched_group_xcu_priv * xse_this_grp_xcu(struct xsched_entity_cfs *xse_cfs) @@ -337,6 +336,7 @@ xse_this_grp(struct xsched_entity_cfs *xse_cfs) { return xse_cfs ? xse_this_grp_xcu(xse_cfs)->self : NULL; } +#endif /* CONFIG_CGROUP_XCU */ /* Increments pending kicks counter for an XCU that the given * xsched entity is attached to and for xsched entity's xsched @@ -495,6 +495,7 @@ void enqueue_ctx(struct xsched_entity *xse, struct xsched_cu *xcu); void dequeue_ctx(struct xsched_entity *xse, struct xsched_cu *xcu); int delete_ctx(struct xsched_context *ctx); +#ifdef CONFIG_CGROUP_XCU /* Xsched group manage functions */ void xsched_group_inherit(struct task_struct *tsk, struct xsched_entity *xse); void xcu_cg_subsys_init(void); @@ -508,4 +509,6 @@ void xsched_quota_timeout_update(struct xsched_group *xg); void xsched_quota_account(struct xsched_group *xg, s64 exec_time); bool xsched_quota_exceed(struct xsched_group *xg); void xsched_quota_refill(struct work_struct *work); +#endif + #endif /* !__LINUX_XSCHED_H__ */ diff --git a/kernel/xsched/Kconfig b/kernel/xsched/Kconfig index b7e7b222c949..dd170ea6df30 100644 --- a/kernel/xsched/Kconfig +++ b/kernel/xsched/Kconfig @@ -5,8 +5,6 @@ config XCU_SCHEDULER default n select XCU_VSTREAM select XCU_SCHED_RT - select XCU_SCHED_CFS - select CGROUP_XCU help This option enables the XSched scheduler, a custom scheduling mechanism designed for heterogeneous compute units (e.g., XPUs). It provides: @@ -56,6 +54,7 @@ config XCU_SCHED_CFS bool "XCU CFS scheduling class" default n depends on XCU_SCHEDULER + select CGROUP_XCU help Enable support for the CFS scheduling class in the XCU scheduler. @@ -72,7 +71,7 @@ config XCU_SCHED_CFS config CGROUP_XCU bool "XCU bandwidth control and group scheduling for xsched_cfs" default n - depends on XCU_SCHEDULER + depends on XCU_SCHEDULER && XCU_SCHED_CFS help This option enables the extended Compute Unit (XCU) resource controller for CFS task groups, providing hierarchical scheduling and fine-grained bandwidth -- 2.34.1