sched: ems: ontime: Modify to check whether fit_cpus is empty.
authorDaeyeong Lee <daeyeong.lee@samsung.com>
Thu, 14 Jun 2018 01:17:52 +0000 (10:17 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:59:30 +0000 (14:59 +0900)
- There is a possibility of trouble, when fit_cpus is return with empty.
  To prevent this situation, ontime_select_fit_cpus fucntion return
  whether fit_cpus is empty or not.

Change-Id: Ibcadee7f1c7dd54e074509712ddb3ea05bfc82ef
Signed-off-by: Daeyeong Lee <daeyeong.lee@samsung.com>
kernel/sched/ems/ontime.c

index 0c0d7b2d5127ee28a2224151ff49c0969502b3d9..f4092692643bc095c3a8e350e7c4b7ff58254f4a 100644 (file)
@@ -113,7 +113,7 @@ static unsigned long get_coverage_ratio(int cpu)
                return 0;
 }
 
-static void
+static int
 ontime_select_fit_cpus(struct task_struct *p, struct cpumask *fit_cpus)
 {
        struct ontime_cond *curr;
@@ -121,10 +121,12 @@ ontime_select_fit_cpus(struct task_struct *p, struct cpumask *fit_cpus)
        int cpu = task_cpu(p);
 
        cpumask_and(fit_cpus, cpu_coregroup_mask(cpu), tsk_cpus_allowed(p));
+       if (cpumask_empty(fit_cpus))
+               return -ENODEV;
 
        curr = get_current_cond(cpu);
        if (!curr)
-               return;
+               return -EINVAL;
 
        if (ontime_load_avg(p) >= curr->upper_boundary) {
                /*
@@ -157,6 +159,8 @@ ontime_select_fit_cpus(struct task_struct *p, struct cpumask *fit_cpus)
                                break;
                }
        }
+
+       return 0;
 }
 
 static int
@@ -463,11 +467,16 @@ void ontime_migration(void)
                        continue;
                }
 
+               /* If fit_cpus is not searched, don't need to select dst_cpu */
+               if (ontime_select_fit_cpus(p, &fit_cpus)) {
+                       raw_spin_unlock_irqrestore(&rq->lock, flags);
+                       continue;
+               }
+
                /*
                 * If fit_cpus is smaller than current coregroup,
                 * don't need to ontime migration.
                 */
-               ontime_select_fit_cpus(p, &fit_cpus);
                if (get_cpu_mips(cpu) >= get_cpu_mips(cpumask_first(&fit_cpus))) {
                        raw_spin_unlock_irqrestore(&rq->lock, flags);
                        continue;
@@ -516,8 +525,11 @@ int ontime_task_wakeup(struct task_struct *p)
        if (ontime_of(p)->migrating == 1)
                return -1;
 
+       /* If fit_cpus is not searched, don't need to select dst_cpu */
+       if (ontime_select_fit_cpus(p, &fit_cpus))
+               return -1;
+
        /* If fit_cpus is little coregroup, don't need to select dst_cpu */
-       ontime_select_fit_cpus(p, &fit_cpus);
        if (cpumask_test_cpu(MIN_CAPACITY_CPU, &fit_cpus))
                return -1;