hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZBSR CVE: NA
----------------------------------------
Considering for inheritance of the pre-verion code.
We make all task to the highest qos_level (grid_qos_level = 0),when smart_grid strategy was disabled.
Otherwise, When smart_grid strategy was enabled, we use the task's actually grid_qos_level.
Default smart_grid strategy was disable (=0).
Signed-off-by: Yipeng Zou zouyipeng@huawei.com --- include/linux/sched/grid_qos.h | 1 + include/linux/sched/sysctl.h | 1 + kernel/sched/fair.c | 5 +---- kernel/sched/grid/qos.c | 27 +++++++++++++++++++++++++++ kernel/sysctl.c | 9 +++++++++ 5 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/include/linux/sched/grid_qos.h b/include/linux/sched/grid_qos.h index 89a492707d1d..cc0742290fe8 100644 --- a/include/linux/sched/grid_qos.h +++ b/include/linux/sched/grid_qos.h @@ -112,6 +112,7 @@ int sched_grid_zone_update(bool is_locked); int sched_grid_zone_add_af(struct auto_affinity *af); int sched_grid_zone_del_af(struct auto_affinity *af); struct cpumask* sched_grid_zone_cpumask(enum sgq_zone zone); +struct cpumask* sched_grid_prefer_cpus(struct task_struct *p); #else static inline int sched_grid_preferred_interleave_nid(struct mempolicy *policy) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 31c4a84ce3df..5cd5b3c579d3 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -36,6 +36,7 @@ extern int sysctl_sched_util_low_pct; #endif
#ifdef CONFIG_QOS_SCHED_SMART_GRID +extern unsigned int sysctl_smart_grid_strategy_ctrl; extern int sysctl_affinity_adjust_delay_ms; #endif
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index cef9d5422b66..3f08ab3eae99 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5839,16 +5839,13 @@ static void smart_grid_usage_dec(void)
static inline struct cpumask *task_prefer_cpus(struct task_struct *p) { - struct affinity_domain *ad; - if (!smart_grid_used()) return p->prefer_cpus;
if (task_group(p)->auto_affinity->mode == 0) return p->cpus_ptr;
- ad = &task_group(p)->auto_affinity->ad; - return ad->domains[ad->curr_level]; + return sched_grid_prefer_cpus(p); }
static inline int dynamic_affinity_mode(struct task_struct *p) diff --git a/kernel/sched/grid/qos.c b/kernel/sched/grid/qos.c index 733645db15b5..6f9dae6a6f42 100644 --- a/kernel/sched/grid/qos.c +++ b/kernel/sched/grid/qos.c @@ -233,3 +233,30 @@ struct cpumask* sched_grid_zone_cpumask(enum sgq_zone zone)
return &sg_zone.cpus[zone][0]; } + +/* + * Default smart_grid strategy was disable (=0). + * But, considering for inheritance of the pre-verion code. + * We make all the task to the highest qos_level (class_lvl = 0), + * when smart_grid strategy was disabled. + * Otherwise, When smart_grid strategy was enabled, we use the task's + * actually class_lvl. + */ +unsigned int sysctl_smart_grid_strategy_ctrl = 0; + +struct cpumask* sched_grid_prefer_cpus(struct task_struct *p) +{ + enum sgq_zone current_zone; + + /* when smart_grid strategy was disabled, + We make all the task to the highest qos_level (class_lvl = 0) */ + if (sysctl_smart_grid_strategy_ctrl == 0) { + current_zone = SMART_GRID_ZONE_HOT; + } else { + /* Only place highest level task into hot zone */ + current_zone = p->grid_qos->stat.class_lvl == SCHED_GRID_QOS_TASK_LEVEL_HIGHEST ? + SMART_GRID_ZONE_HOT : SMART_GRID_ZONE_WARM; + } + + return &sg_zone.cpus[current_zone][0]; +} diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 58eeca0db3d0..f3f43b2def7f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2804,6 +2804,15 @@ static struct ctl_table kern_table[] = { }, #endif #ifdef CONFIG_QOS_SCHED_SMART_GRID + { + .procname = "smart_grid_strategy_ctrl", + .data = &sysctl_smart_grid_strategy_ctrl, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, { .procname = "affinity_adjust_delay_ms", .data = &sysctl_affinity_adjust_delay_ms,