ems: frt: Change cache-hot check conditon
authorYoungtae Lee <yt0729.lee@samsung.com>
Fri, 14 Sep 2018 08:50:28 +0000 (17:50 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:24:57 +0000 (20:24 +0300)
Change-Id: I35f05c4843e548dee12d047e0cdbd7d7678a3e2a
Signed-off-by: Youngtae Lee <yt0729.lee@samsung.com>
kernel/sched/rt.c

index 7eb5012f1171437ad272a78d0c67788b8fe3eeb7..64cf7c2a7c3e86883359a21c92f32ddfdbce6726 100644 (file)
@@ -2658,7 +2658,29 @@ static int find_victim_rt_rq(struct task_struct *task, const struct cpumask *sg_
 
 }
 
-static int find_idle_cpu(struct task_struct *task)
+static int check_cache_hot(struct task_struct *task, int flags, int *best_cpu)
+{
+       int cpu = smp_processor_id();
+       /*
+        * 3. Cache hot : packing the callee and caller,
+        *      when there is nothing to run except callee, or
+        *      wake_flags are set.
+        */
+       /* FUTURE WORK: Hierarchical cache hot */
+       if (!(flags & WF_SYNC))
+               return false;
+
+       if (cpumask_test_cpu(*best_cpu, cpu_coregroup_mask(cpu))) {
+               task->rt.sync_flag = 1;
+               *best_cpu = cpu;
+               trace_sched_fluid_stat(task, &task->rt.avg, *best_cpu, "CACHE-HOT");
+               return true;
+       }
+
+       return false;
+}
+
+static int find_idle_cpu(struct task_struct *task, int wake_flags)
 {
        int cpu, best_cpu = -1;
        int cpu_prio, max_prio = -1;
@@ -2694,6 +2716,9 @@ static int find_idle_cpu(struct task_struct *task)
                }
 
                if (cpu_selected(best_cpu)) {
+                       if (check_cache_hot(task, wake_flags, &best_cpu))
+                               return best_cpu;
+
                        trace_sched_fluid_stat(task, &task->rt.avg, best_cpu, "IDLE-FIRST");
                        return best_cpu;
                }
@@ -2704,7 +2729,7 @@ static int find_idle_cpu(struct task_struct *task)
        return best_cpu;
 }
 
-static int find_recessive_cpu(struct task_struct *task)
+static int find_recessive_cpu(struct task_struct *task, int wake_flags)
 {
        int cpu, best_cpu = -1;
        struct cpumask *lowest_mask;
@@ -2739,9 +2764,14 @@ static int find_recessive_cpu(struct task_struct *task)
                        }
                }
 
-               if (cpu_selected(best_cpu))
+               if (cpu_selected(best_cpu)) {
+                       if (check_cache_hot(task, wake_flags, &best_cpu))
+                               return best_cpu;
+
                        trace_sched_fluid_stat(task, &task->rt.avg, best_cpu,
                                rt_task(cpu_rq(best_cpu)->curr) ? "RT-RECESS" : "FAIR-RECESS");
+                       return best_cpu;
+               }
 
                dom = dom->next;
        } while (dom != prefer_dom);
@@ -2752,7 +2782,6 @@ static int find_recessive_cpu(struct task_struct *task)
 static int find_lowest_rq_fluid(struct task_struct *task, int wake_flags)
 {
        int cpu, best_cpu = -1;
-       int prefer_cpu = smp_processor_id();    /* Cache-hot with itself or waker (default). */
 
        if (task->nr_cpus_allowed == 1) {
                trace_sched_fluid_stat(task, &task->rt.avg, best_cpu, "NA ALLOWED");
@@ -2763,41 +2792,23 @@ static int find_lowest_rq_fluid(struct task_struct *task, int wake_flags)
         *
         * Fluid Sched Core selection procedure:
         *
-        * 1. Cache hot : this cpu (waker if wake_list is null)
-        * 2. idle CPU selection (prev_cpu first)
-        * 3. recessive task first (prev_cpu first)
-        * 4. victim task first (prev_cpu first)
+        * 1. idle CPU selection (cache-hot cpu  first)
+        * 2. recessive task first (cache-hot cpu first)
+        * 3. victim task first (prev_cpu first)
         */
 
-       /*
-        * 1. Cache hot : packing the callee and caller,
-        *      when there is nothing to run except callee, or
-        *      wake_flags are set.
-        */
-       /* FUTURE WORK: Hierarchical cache hot */
-       if ((wake_flags || affordable_cpu(prefer_cpu, task_util(task))) &&
-               cpumask_test_cpu(prefer_cpu, cpu_online_mask)) {
-               task->rt.sync_flag = 1;
-               best_cpu = prefer_cpu;
-               trace_sched_fluid_stat(task, &task->rt.avg, best_cpu, "CACHE-HOT");
-               goto out;
-       }
-
-       /*
-        * Find 2.IDLE CPU and 3.Recessive CPU
-        */
-       /* 2. idle CPU selection */
-       best_cpu = find_idle_cpu(task);
+       /* 1. idle CPU selection */
+       best_cpu = find_idle_cpu(task, wake_flags);
        if (cpu_selected(best_cpu))
                goto out;
 
-       /* 3. recessive task first */
-       best_cpu = find_recessive_cpu(task);
+       /* 2. recessive task first */
+       best_cpu = find_recessive_cpu(task, wake_flags);
        if (cpu_selected(best_cpu))
                goto out;
 
        /*
-        * 4. victim task first
+        * 3. victim task first
         */
        for_each_cpu(cpu, cpu_active_mask) {
                if (cpu != cpumask_first(cpu_coregroup_mask(cpu)))
@@ -2806,10 +2817,6 @@ static int find_lowest_rq_fluid(struct task_struct *task, int wake_flags)
                if (find_victim_rt_rq(task, cpu_coregroup_mask(cpu), &best_cpu) != -1)
                        break;
        }
-
-       if (!cpu_selected(best_cpu))
-               best_cpu = prefer_cpu;
-
 out:
 
        if (!cpumask_test_cpu(best_cpu, cpu_online_mask)) {