hulk inclusion category: cleanup bugzilla: https://atomgit.com/openeuler/kernel/issues/8710 ---------------------------------------- Simplify and clarify the function xse_this_grp_xcu by renaming it to xse_this_cfs_rq and adjusting its implementation to directly return the xsched_rq_cfs structure. This change ensures that only group scheduling entities can call this function, making the code more intuitive and reducing unnecessary indirection. Signed-off-by: Liu Kai <liukai284@huawei.com> --- include/linux/xsched.h | 29 ++++++++++++++--------------- kernel/xsched/cfs.c | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/linux/xsched.h b/include/linux/xsched.h index e4b08066c676..ff314f88169f 100644 --- a/include/linux/xsched.h +++ b/include/linux/xsched.h @@ -313,27 +313,26 @@ struct xsched_group { #define for_each_xsched_group(__xg) \ for (; (__xg) != root_xcg; (__xg) = (__xg)->parent) -static inline struct xsched_group_xcu_priv * -xse_this_grp_xcu(struct xsched_entity_cfs *xse_cfs) +/** + * Only group xsched entities are permitted to call. + * + * These function assumes the caller represents a scheduling group and + * accesses group-level cfs_rq structures. + */ +static inline struct xsched_rq_cfs * +xse_this_cfs_rq(struct xsched_entity *xse) { - struct xsched_entity *xse; - - xse = xse_cfs ? container_of(xse_cfs, struct xsched_entity, cfs) : NULL; - return xse ? container_of(xse, struct xsched_group_xcu_priv, xse) : NULL; -} + struct xsched_group_xcu_priv *xg_xcu = + container_of(xse, struct xsched_group_xcu_priv, xse); -static inline struct xsched_group * -xse_this_grp(struct xsched_entity_cfs *xse_cfs) -{ - return xse_cfs ? xse_this_grp_xcu(xse_cfs)->self : NULL; + return xg_xcu->cfs_rq; } static inline bool xsched_entity_throttled(struct xsched_entity *xse) { - struct xsched_group_xcu_priv *grp_xcu = - container_of(xse, struct xsched_group_xcu_priv, xse); + struct xsched_rq_cfs *cfs_rq = xse_this_cfs_rq(xse); - return grp_xcu->cfs_rq->throttled; + return cfs_rq->throttled; } #else @@ -356,7 +355,7 @@ static inline int xse_integrity_check(struct xsched_entity *xse) } #ifdef CONFIG_CGROUP_XCU - if (xse->is_group && !xse_this_grp_xcu(&xse->cfs)->cfs_rq) { + if (xse->is_group && !xse_this_cfs_rq(xse)) { // 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__); diff --git a/kernel/xsched/cfs.c b/kernel/xsched/cfs.c index 6b74f96a6860..1b2a5bcb9fbf 100644 --- a/kernel/xsched/cfs.c +++ b/kernel/xsched/cfs.c @@ -182,7 +182,7 @@ next_cfs_rq_of(struct xsched_entity_cfs *xse) struct xsched_entity *se = container_of(xse, struct xsched_entity, cfs); if (se->is_group) - return xse_this_grp_xcu(xse)->cfs_rq; + return xse_this_cfs_rq(se); #endif return NULL; } -- 2.34.1