[PATCH 2/2] sched/deadline: Initialize cp->elements[].cpu to an invalid value

From: Byungchul Park
Date: Tue Jun 06 2017 - 20:05:34 EST


Currently, when the heap tree is empty, cpudl_maximum_cpu() returns 0,
which causes unnecessary migration. It has to return an invalid value
e.g. -1 to prevent that.

Signed-off-by: Byungchul Park <byungchul.park@xxxxxxx>
---
kernel/sched/cpudeadline.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index d4a6963..0f67cea 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -266,8 +266,10 @@ int cpudl_init(struct cpudl *cp)
return -ENOMEM;
}

- for_each_possible_cpu(i)
+ for_each_possible_cpu(i) {
+ cp->elements[i].cpu = -1;
cp->elements[i].idx = IDX_INVALID;
+ }

return 0;
}
--
1.9.1