From 847c2761d5991c7b2a194d4254ac61f0e4aafbc4 Mon Sep 17 00:00:00 2001 From: gauravjindal Date: Tue, 2 Jun 2015 15:08:00 +0530 Subject: [PATCH 1/1] handling the error while getting slower/faster cpu domain if caller does not check for slowest/fastest cpu domain before getting the next slower/faster CPU domain, error may occur if CPU is already in slowest/fastest domain. If the CPU is already in fastest domain, it will return the head pointer of the list instead of previous faster domain. In such case ,it should return the current CPU domain only. Similarly, if the CPU is already in slowest domain, it will return the head pointer of the list instead of next slower domain. In such case , it should return the current CPU domain only. Signed-off-by: gauravjindal --- kernel/sched/fair.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1baf641..f9deb7a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3878,6 +3878,8 @@ static inline struct hmp_domain *hmp_slower_domain(int cpu) struct list_head *pos; pos = &hmp_cpu_domain(cpu)->hmp_domains; + if(list_is_last(pos, &hmp_domains)) + return hmp_cpu_domain(cpu); return list_entry(pos->next, struct hmp_domain, hmp_domains); } @@ -3887,6 +3889,8 @@ static inline struct hmp_domain *hmp_faster_domain(int cpu) struct list_head *pos; pos = &hmp_cpu_domain(cpu)->hmp_domains; + if( pos == hmp_domains.next) + return hmp_cpu_domain(cpu); return list_entry(pos->prev, struct hmp_domain, hmp_domains); } -- 1.7.9.5