sched: ehmp: Add to select initial util type for new task.
authorlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 26 Feb 2018 11:35:49 +0000 (20:35 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:30:45 +0000 (17:30 +0900)
Change-Id: Idd792099fb636585f2d620ae7fd3f8405cec142f
Signed-off-by: lakkyung.jung <lakkyung.jung@samsung.com>
kernel/sched/ehmp.c

index 686933be46dec177e17d5e1dcdb5da19c00cd76f..b3cd7ecd512d19f30e7940f7c19e5479de278e67 100644 (file)
@@ -60,7 +60,65 @@ static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
 /**********************************************************************
  * task initialization                                                *
  **********************************************************************/
-void exynos_init_entity_util_avg(struct sched_entity *se)
+enum {
+       TYPE_BASE_CFS_RQ_UTIL = 0,
+       TYPE_BASE_INHERIT_PARENT_UTIL,
+       TYPE_MAX_NUM,
+};
+
+static unsigned long init_util_type = TYPE_BASE_CFS_RQ_UTIL;
+static unsigned long init_util_ratio = 25;                     /* 25% */
+
+static ssize_t show_initial_util_type(struct kobject *kobj,
+               struct kobj_attribute *attr, char *buf)
+{
+        return snprintf(buf, 10, "%ld\n", init_util_type);
+}
+
+static ssize_t store_initial_util_type(struct kobject *kobj,
+                struct kobj_attribute *attr, const char *buf,
+                size_t count)
+{
+        long input;
+
+        if (!sscanf(buf, "%ld", &input))
+                return -EINVAL;
+
+        input = input < 0 ? 0 : input;
+        input = input >= TYPE_MAX_NUM ? TYPE_MAX_NUM - 1 : input;
+
+        init_util_type = input;
+
+        return count;
+}
+
+static ssize_t show_initial_util_ratio(struct kobject *kobj,
+               struct kobj_attribute *attr, char *buf)
+{
+        return snprintf(buf, 10, "%ld\n", init_util_ratio);
+}
+
+static ssize_t store_initial_util_ratio(struct kobject *kobj,
+                struct kobj_attribute *attr, const char *buf,
+                size_t count)
+{
+        long input;
+
+        if (!sscanf(buf, "%ld", &input))
+                return -EINVAL;
+
+        init_util_ratio = !!input;
+
+        return count;
+}
+
+static struct kobj_attribute initial_util_type =
+__ATTR(initial_util_type, 0644, show_initial_util_type, store_initial_util_type);
+
+static struct kobj_attribute initial_util_ratio =
+__ATTR(initial_util_ratio, 0644, show_initial_util_ratio, store_initial_util_ratio);
+
+void base_cfs_rq_util(struct sched_entity *se)
 {
        struct cfs_rq *cfs_rq = se->cfs_rq;
        struct sched_avg *sa = &se->avg;
@@ -76,7 +134,7 @@ void exynos_init_entity_util_avg(struct sched_entity *se)
                        if (sa->util_avg > cap)
                                sa->util_avg = cap;
                } else {
-                       sa->util_avg = cap_org >> 2;
+                       sa->util_avg = cap_org * init_util_ratio / 100;
                }
                /*
                 * If we wish to restore tuning via setting initial util,
@@ -86,6 +144,32 @@ void exynos_init_entity_util_avg(struct sched_entity *se)
        }
 }
 
+void base_inherit_parent_util(struct sched_entity *se)
+{
+       struct sched_avg *sa = &se->avg;
+       struct task_struct *p = current;
+
+       sa->util_avg = p->se.avg.util_avg;
+       sa->util_sum = p->se.avg.util_sum;
+}
+
+void exynos_init_entity_util_avg(struct sched_entity *se)
+{
+       int type = init_util_type;
+
+       switch(type) {
+       case TYPE_BASE_CFS_RQ_UTIL:
+               base_cfs_rq_util(se);
+               break;
+       case TYPE_BASE_INHERIT_PARENT_UTIL:
+               base_inherit_parent_util(se);
+               break;
+       default:
+               pr_info("%s: Not support initial util type %ld\n",
+                               __func__, init_util_type);
+       }
+}
+
 /**********************************************************************
  * load balance                                                       *
  **********************************************************************/
@@ -1592,6 +1676,8 @@ static struct attribute *ehmp_attrs[] = {
        &top_overutil_attr.attr,
        &bot_overutil_attr.attr,
        &prefer_perf_attr.attr,
+       &initial_util_type.attr,
+       &initial_util_ratio.attr,
        NULL,
 };