Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
[firefly-linux-kernel-4.4.55.git] / kernel / sched / sched.h
index f48fb371913a9bad56c4e233cfb22c26b59b6e41..2f2b959ad24485ca8eaf2907b2fc66d58e04bc33 100644 (file)
@@ -685,6 +685,9 @@ struct rq {
        u64 prev_runnable_sum;
        u64 nt_curr_runnable_sum;
        u64 nt_prev_runnable_sum;
+       u64 cur_irqload;
+       u64 avg_irqload;
+       u64 irqload_ts;
 #endif /* CONFIG_SCHED_WALT */
 
 
@@ -1574,9 +1577,10 @@ static inline unsigned long __cpu_util(int cpu, int delta)
        unsigned long capacity = capacity_orig_of(cpu);
 
 #ifdef CONFIG_SCHED_WALT
-       if (!walt_disabled && sysctl_sched_use_walt_cpu_util)
-               util = (cpu_rq(cpu)->prev_runnable_sum << SCHED_LOAD_SHIFT) /
-                       walt_ravg_window;
+       if (!walt_disabled && sysctl_sched_use_walt_cpu_util) {
+               util = cpu_rq(cpu)->prev_runnable_sum << SCHED_LOAD_SHIFT;
+               do_div(util, walt_ravg_window);
+       }
 #endif
        delta += util;
        if (delta < 0)
@@ -1608,8 +1612,27 @@ void update_cpu_capacity_request(int cpu, bool request);
 static inline void set_cfs_cpu_capacity(int cpu, bool request,
                                        unsigned long capacity)
 {
-       if (per_cpu(cpu_sched_capacity_reqs, cpu).cfs != capacity) {
-               per_cpu(cpu_sched_capacity_reqs, cpu).cfs = capacity;
+       struct sched_capacity_reqs *scr = &per_cpu(cpu_sched_capacity_reqs, cpu);
+
+#ifdef CONFIG_SCHED_WALT
+       if (!walt_disabled && sysctl_sched_use_walt_cpu_util) {
+               int rtdl = scr->rt + scr->dl;
+               /*
+                * WALT tracks the utilization of a CPU considering the load
+                * generated by all the scheduling classes.
+                * Since the following call to:
+                *    update_cpu_capacity
+                * is already adding the RT and DL utilizations let's remove
+                * these contributions from the WALT signal.
+                */
+               if (capacity > rtdl)
+                       capacity -= rtdl;
+               else
+                       capacity = 0;
+       }
+#endif
+       if (scr->cfs != capacity) {
+               scr->cfs = capacity;
                update_cpu_capacity_request(cpu, request);
        }
 }
@@ -1810,7 +1833,8 @@ static inline int double_lock_balance(struct rq *this_rq, struct rq *busiest)
 static inline void double_unlock_balance(struct rq *this_rq, struct rq *busiest)
        __releases(busiest->lock)
 {
-       raw_spin_unlock(&busiest->lock);
+       if (this_rq != busiest)
+               raw_spin_unlock(&busiest->lock);
        lock_set_subclass(&this_rq->lock.dep_map, 0, _RET_IP_);
 }