From dfe76a61c4994fb15245d933f33e88243d9ebe21 Mon Sep 17 00:00:00 2001 From: Daeyeong Lee Date: Thu, 14 Jun 2018 10:17:52 +0900 Subject: [PATCH] sched: ems: ontime: Modify to check whether fit_cpus is empty. - 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 --- kernel/sched/ems/ontime.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kernel/sched/ems/ontime.c b/kernel/sched/ems/ontime.c index 0c0d7b2d5127..f4092692643b 100644 --- a/kernel/sched/ems/ontime.c +++ b/kernel/sched/ems/ontime.c @@ -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; -- 2.20.1