sched/tune: use a single initialisation function
authorPatrick Bellasi <patrick.bellasi@arm.com>
Fri, 29 Jul 2016 14:19:41 +0000 (15:19 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 14 Sep 2016 09:29:32 +0000 (14:59 +0530)
With the introduction of initialization function required to compute the
energy normalization constants from DTB at boot time, we have now a
late_initcall which is already used by SchedTune.

This patch consolidate within that function the other initialization
bits which was previously deferred to the first CGroup creation.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
[jstultz: fwdported to 4.4]
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/sched/tune.c

index 6d5fbde9c70e915eec7f2ed54fbbde39cd9d1931..a691b8db28881eb38e962da142f25207215a2102 100644 (file)
@@ -410,8 +410,6 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft,
            s64 boost)
 {
        struct schedtune *st = css_st(css);
-       unsigned threshold_idx;
-       int boost_pct;
 
        if (boost < -100 || boost > 100)
                return -EINVAL;
@@ -456,33 +454,14 @@ schedtune_boostgroup_init(struct schedtune *st)
        return 0;
 }
 
-static int
-schedtune_init(void)
-{
-       struct boost_groups *bg;
-       int cpu;
-
-       /* Initialize the per CPU boost groups */
-       for_each_possible_cpu(cpu) {
-               bg = &per_cpu(cpu_boost_groups, cpu);
-               memset(bg, 0, sizeof(struct boost_groups));
-       }
-
-       pr_info("  schedtune configured to support %d boost groups\n",
-               BOOSTGROUPS_COUNT);
-       return 0;
-}
-
 static struct cgroup_subsys_state *
 schedtune_css_alloc(struct cgroup_subsys_state *parent_css)
 {
        struct schedtune *st;
        int idx;
 
-       if (!parent_css) {
-               schedtune_init();
+       if (!parent_css)
                return &root_schedtune.css;
-       }
 
        /* Allow only single level hierachies */
        if (parent_css != &root_schedtune.css) {
@@ -543,6 +522,22 @@ struct cgroup_subsys schedtune_cgrp_subsys = {
        .early_init     = 1,
 };
 
+static inline void
+schedtune_init_cgroups(void)
+{
+       struct boost_groups *bg;
+       int cpu;
+
+       /* Initialize the per CPU boost groups */
+       for_each_possible_cpu(cpu) {
+               bg = &per_cpu(cpu_boost_groups, cpu);
+               memset(bg, 0, sizeof(struct boost_groups));
+       }
+
+       pr_info("schedtune: configured to support %d boost groups\n",
+               BOOSTGROUPS_COUNT);
+}
+
 #else /* CONFIG_CGROUP_SCHEDTUNE */
 
 int
@@ -690,7 +685,7 @@ schedtune_add_cluster_nrg(
  * that bind the EM to the topology information.
  */
 static int
-schedtune_init_late(void)
+schedtune_init(void)
 {
        struct target_nrg *ste = &schedtune_target_nrg;
        unsigned long delta_pwr = 0;
@@ -730,10 +725,17 @@ schedtune_init_late(void)
                ste->rdiv.m, ste->rdiv.sh1, ste->rdiv.sh2);
 
        schedtune_test_nrg(delta_pwr);
+
+#ifdef CONFIG_CGROUP_SCHEDTUNE
+       schedtune_init_cgroups();
+#else
+       pr_info("schedtune: configured to support global boosting only\n");
+#endif
+
        return 0;
 
 nodata:
        rcu_read_unlock();
        return -EINVAL;
 }
-late_initcall(schedtune_init_late);
+late_initcall(schedtune_init);