Removed load balancer from CFS. Seems to work, but cannot be testet. p/jkrieg/linux-2.6.38
authorJens Krieg <jkrieg@mailbox.tu-berlin.de>
Thu, 24 Apr 2014 09:11:39 +0000 (11:11 +0200)
committerJens Krieg <jkrieg@mailbox.tu-berlin.de>
Thu, 24 Apr 2014 09:11:39 +0000 (11:11 +0200)
arch/x86/kernel/setup.c
init/main.c
kernel/sched.c
kernel/sched_debug.c
kernel/sched_fair.c
kernel/sched_idletask.c
kernel/sched_rt.c

index d3cfe26..39f88ea 100644 (file)
@@ -906,6 +906,7 @@ void __init setup_arch(char **cmdline_p)
                max_low_pfn = max_pfn;
 
        high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
+       printk("setup_arch: high_memory=%p\n", high_memory);
 #endif
 
        /*
index 33c37c3..28bc749 100644 (file)
@@ -543,6 +543,7 @@ static void __init mm_init(void)
 
 asmlinkage void __init start_kernel(void)
 {
+       long unsigned int pgd_i, pud_i, pmd_i, pte_i;
        char * command_line;
        extern const struct kernel_param __start___param[], __stop___param[];
 
@@ -597,6 +598,18 @@ asmlinkage void __init start_kernel(void)
        sort_main_extable();
        trap_init();
        mm_init();
+
+//     for (pgd_i=0; pgd_i<(_AC(1, UL) << PGDIR_SHIFT); pgd_i+=(_AC(1, UL) << PGDIR_SHIFT)) {
+//             for (pud_i=0; pud_i<(_AC(1, UL) << PGDIR_SHIFT); pud_i+=PMD_PAGE_SIZE) {
+//                     for (pmd_i=0; pmd_i<PUD_PAGE_SIZE; pmd_i+=PMD_PAGE_SIZE) {
+//                             for (pte_i=0; pte_i<PMD_PAGE_SIZE; pte_i+=PAGE_SIZE) {
+//                                     printk("start_kernel: pte_index of 0x%x is %lu\n", pmd_i+pte_i, pte_index(pmd_i+pte_i+PAGE_OFFSET));
+//                             }
+//                     }
+//             }
+//     }
+
+       printk("start_kernel: active_mm=0x%x\n", init_task.active_mm);
        /*
         * Set up the scheduler prior starting any interrupts (such as the
         * timer interrupt). Full topology setup happens at smp_init()
index 42eab5a..bbfa50a 100644 (file)
@@ -1,3 +1,26 @@
+/* * Copyright (c) 2010 - 2012 Intel Corporation.
+*
+* Disclaimer: The codes contained in these modules may be specific to the
+* Intel Software Development Platform codenamed: Knights Ferry, and the 
+* Intel product codenamed: Knights Corner, and are not backward compatible 
+* with other Intel products. Additionally, Intel will NOT support the codes 
+* or instruction set in future products.
+*
+* Intel offers no warranty of any kind regarding the code.  This code is
+* licensed on an "AS IS" basis and Intel is not obligated to provide any support,
+* assistance, installation, training, or other services of any kind.  Intel is 
+* also not obligated to provide any updates, enhancements or extensions.  Intel 
+* specifically disclaims any warranty of merchantability, non-infringement, 
+* fitness for any particular purpose, and any other warranty.
+*
+* Further, Intel disclaims all liability of any kind, including but not
+* limited to liability for infringement of any proprietary rights, relating
+* to the use of the code, even if Intel is notified of the possibility of
+* such liability.  Except as expressly stated in an Intel license agreement
+* provided with this code and agreed upon with Intel, no license, express
+* or implied, by estoppel or otherwise, to any intellectual property rights
+* is granted herein.
+*/
 /*
  *  kernel/sched.c
  *
  */
 #define NS_TO_JIFFIES(TIME)    ((unsigned long)(TIME) / (NSEC_PER_SEC / HZ))
 
-#define NICE_0_LOAD            SCHED_LOAD_SCALE
-#define NICE_0_SHIFT           SCHED_LOAD_SHIFT
+//#define NICE_0_LOAD          SCHED_LOAD_SCALE
+//#define NICE_0_SHIFT         SCHED_LOAD_SHIFT
 
 /*
  * These are the 'tuning knobs' of the scheduler:
@@ -256,7 +279,7 @@ struct task_group {
        struct cfs_rq **cfs_rq;
        unsigned long shares;
 
-       atomic_t load_weight;
+//     atomic_t load_weight;
 #endif
 
 #ifdef CONFIG_RT_GROUP_SCHED
@@ -283,7 +306,7 @@ static DEFINE_SPINLOCK(task_group_lock);
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 
-# define ROOT_TASK_GROUP_LOAD  NICE_0_LOAD
+//# define ROOT_TASK_GROUP_LOAD        NICE_0_LOAD
 
 /*
  * A weight of 0 or 1 can cause arithmetics problems.
@@ -296,7 +319,7 @@ static DEFINE_SPINLOCK(task_group_lock);
 #define MIN_SHARES     2
 #define MAX_SHARES     (1UL << 18)
 
-static int root_task_group_load = ROOT_TASK_GROUP_LOAD;
+//static int root_task_group_load = ROOT_TASK_GROUP_LOAD;
 #endif
 
 /* Default task group.
@@ -308,7 +331,7 @@ struct task_group root_task_group;
 
 /* CFS-related fields in a runqueue */
 struct cfs_rq {
-       struct load_weight load;
+//     struct load_weight load;
        unsigned long nr_running;
 
        u64 exec_clock;
@@ -318,7 +341,7 @@ struct cfs_rq {
        struct rb_node *rb_leftmost;
 
        struct list_head tasks;
-       struct list_head *balance_iterator;
+//     struct list_head *balance_iterator;
 
        /*
         * 'curr' points to currently running entity on this cfs_rq.
@@ -343,33 +366,33 @@ struct cfs_rq {
        struct list_head leaf_cfs_rq_list;
        struct task_group *tg;  /* group that "owns" this runqueue */
 
-#ifdef CONFIG_SMP
-       /*
-        * the part of load.weight contributed by tasks
-        */
-       unsigned long task_weight;
-
-       /*
-        *   h_load = weight * f(tg)
-        *
-        * Where f(tg) is the recursive weight fraction assigned to
-        * this group.
-        */
-       unsigned long h_load;
-
-       /*
-        * Maintaining per-cpu shares distribution for group scheduling
-        *
-        * load_stamp is the last time we updated the load average
-        * load_last is the last time we updated the load average and saw load
-        * load_unacc_exec_time is currently unaccounted execution time
-        */
-       u64 load_avg;
-       u64 load_period;
-       u64 load_stamp, load_last, load_unacc_exec_time;
-
-       unsigned long load_contribution;
-#endif
+//#ifdef CONFIG_SMP
+//     /*
+//      * the part of load.weight contributed by tasks
+//      */
+//     unsigned long task_weight;
+//
+//     /*
+//      *   h_load = weight * f(tg)
+//      *
+//      * Where f(tg) is the recursive weight fraction assigned to
+//      * this group.
+//      */
+//     unsigned long h_load;
+//
+//     /*
+//      * Maintaining per-cpu shares distribution for group scheduling
+//      *
+//      * load_stamp is the last time we updated the load average
+//      * load_last is the last time we updated the load average and saw load
+//      * load_unacc_exec_time is currently unaccounted execution time
+//      */
+//     u64 load_avg;
+//     u64 load_period;
+//     u64 load_stamp, load_last, load_unacc_exec_time;
+//
+//     unsigned long load_contribution;
+//#endif
 #endif
 };
 
@@ -388,7 +411,7 @@ struct rt_rq {
 #ifdef CONFIG_SMP
        unsigned long rt_nr_migratory;
        unsigned long rt_nr_total;
-       int overloaded;
+//     int overloaded;
        struct plist_head pushable_tasks;
 #endif
        int rt_throttled;
@@ -454,18 +477,18 @@ struct rq {
         * remote CPUs use both these fields when doing load calculation.
         */
        unsigned long nr_running;
-       #define CPU_LOAD_IDX_MAX 5
-       unsigned long cpu_load[CPU_LOAD_IDX_MAX];
-       unsigned long last_load_update_tick;
+//     #define CPU_LOAD_IDX_MAX 5
+//     unsigned long cpu_load[CPU_LOAD_IDX_MAX];
+//     unsigned long last_load_update_tick;
 #ifdef CONFIG_NO_HZ
        u64 nohz_stamp;
-       unsigned char nohz_balance_kick;
+//     unsigned char nohz_balance_kick;
 #endif
        unsigned int skip_clock_update;
 
        /* capture load from *all* tasks on this cpu: */
-       struct load_weight load;
-       unsigned long nr_load_updates;
+//     struct load_weight load;
+//     unsigned long nr_load_updates;
        u64 nr_switches;
 
        struct cfs_rq cfs;
@@ -488,7 +511,7 @@ struct rq {
        unsigned long nr_uninterruptible;
 
        struct task_struct *curr, *idle, *stop;
-       unsigned long next_balance;
+//     unsigned long next_balance;
        struct mm_struct *prev_mm;
 
        u64 clock;
@@ -505,14 +528,14 @@ struct rq {
        unsigned char idle_at_tick;
        /* For active balancing */
        int post_schedule;
-       int active_balance;
+//     int active_balance;
        int push_cpu;
-       struct cpu_stop_work active_balance_work;
+//     struct cpu_stop_work active_balance_work;
        /* cpu of this runqueue: */
        int cpu;
        int online;
 
-       unsigned long avg_load_per_task;
+//     unsigned long avg_load_per_task;
 
        u64 rt_avg;
        u64 age_stamp;
@@ -525,8 +548,8 @@ struct rq {
 #endif
 
        /* calc_load related fields */
-       unsigned long calc_load_update;
-       long calc_load_active;
+//     unsigned long calc_load_update;
+//     long calc_load_active;
 
 #ifdef CONFIG_SCHED_HRTICK
 #ifdef CONFIG_SMP
@@ -1172,16 +1195,16 @@ static void resched_task(struct task_struct *p)
                smp_send_reschedule(cpu);
 }
 
-static void resched_cpu(int cpu)
-{
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long flags;
-
-       if (!raw_spin_trylock_irqsave(&rq->lock, flags))
-               return;
-       resched_task(cpu_curr(cpu));
-       raw_spin_unlock_irqrestore(&rq->lock, flags);
-}
+//static void resched_cpu(int cpu)
+//{
+//     struct rq *rq = cpu_rq(cpu);
+//     unsigned long flags;
+//
+//     if (!raw_spin_trylock_irqsave(&rq->lock, flags))
+//             return;
+//     resched_task(cpu_curr(cpu));
+//     raw_spin_unlock_irqrestore(&rq->lock, flags);
+//}
 
 #ifdef CONFIG_NO_HZ
 /*
@@ -1306,50 +1329,50 @@ static void sched_avg_update(struct rq *rq)
 /*
  * delta *= weight / lw
  */
-static unsigned long
-calc_delta_mine(unsigned long delta_exec, unsigned long weight,
-               struct load_weight *lw)
-{
-       u64 tmp;
-
-       if (!lw->inv_weight) {
-               if (BITS_PER_LONG > 32 && unlikely(lw->weight >= WMULT_CONST))
-                       lw->inv_weight = 1;
-               else
-                       lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)
-                               / (lw->weight+1);
-       }
-
-       tmp = (u64)delta_exec * weight;
-       /*
-        * Check whether we'd overflow the 64-bit multiplication:
-        */
-       if (unlikely(tmp > WMULT_CONST))
-               tmp = SRR(SRR(tmp, WMULT_SHIFT/2) * lw->inv_weight,
-                       WMULT_SHIFT/2);
-       else
-               tmp = SRR(tmp * lw->inv_weight, WMULT_SHIFT);
-
-       return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX);
-}
-
-static inline void update_load_add(struct load_weight *lw, unsigned long inc)
-{
-       lw->weight += inc;
-       lw->inv_weight = 0;
-}
-
-static inline void update_load_sub(struct load_weight *lw, unsigned long dec)
-{
-       lw->weight -= dec;
-       lw->inv_weight = 0;
-}
-
-static inline void update_load_set(struct load_weight *lw, unsigned long w)
-{
-       lw->weight = w;
-       lw->inv_weight = 0;
-}
+//static unsigned long
+//calc_delta_mine(unsigned long delta_exec, unsigned long weight,
+//             struct load_weight *lw)
+//{
+//     u64 tmp;
+//
+//     if (!lw->inv_weight) {
+//             if (BITS_PER_LONG > 32 && unlikely(lw->weight >= WMULT_CONST))
+//                     lw->inv_weight = 1;
+//             else
+//                     lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)
+//                             / (lw->weight+1);
+//     }
+//
+//     tmp = (u64)delta_exec * weight;
+//     /*
+//      * Check whether we'd overflow the 64-bit multiplication:
+//      */
+//     if (unlikely(tmp > WMULT_CONST))
+//             tmp = SRR(SRR(tmp, WMULT_SHIFT/2) * lw->inv_weight,
+//                     WMULT_SHIFT/2);
+//     else
+//             tmp = SRR(tmp * lw->inv_weight, WMULT_SHIFT);
+//
+//     return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX);
+//}
+//
+//static inline void update_load_add(struct load_weight *lw, unsigned long inc)
+//{
+//     lw->weight += inc;
+//     lw->inv_weight = 0;
+//}
+//
+//static inline void update_load_sub(struct load_weight *lw, unsigned long dec)
+//{
+//     lw->weight -= dec;
+//     lw->inv_weight = 0;
+//}
+//
+//static inline void update_load_set(struct load_weight *lw, unsigned long w)
+//{
+//     lw->weight = w;
+//     lw->inv_weight = 0;
+//}
 
 /*
  * To aid in avoiding the subversion of "niceness" due to uneven distribution
@@ -1422,15 +1445,15 @@ static inline void cpuacct_update_stats(struct task_struct *tsk,
                enum cpuacct_stat_index idx, cputime_t val) {}
 #endif
 
-static inline void inc_cpu_load(struct rq *rq, unsigned long load)
-{
-       update_load_add(&rq->load, load);
-}
-
-static inline void dec_cpu_load(struct rq *rq, unsigned long load)
-{
-       update_load_sub(&rq->load, load);
-}
+//static inline void inc_cpu_load(struct rq *rq, unsigned long load)
+//{
+//     update_load_add(&rq->load, load);
+//}
+//
+//static inline void dec_cpu_load(struct rq *rq, unsigned long load)
+//{
+//     update_load_sub(&rq->load, load);
+//}
 
 #if (defined(CONFIG_SMP) && defined(CONFIG_FAIR_GROUP_SCHED)) || defined(CONFIG_RT_GROUP_SCHED)
 typedef int (*tg_visitor)(struct task_group *, void *);
@@ -1439,135 +1462,135 @@ typedef int (*tg_visitor)(struct task_group *, void *);
  * Iterate the full tree, calling @down when first entering a node and @up when
  * leaving it for the final time.
  */
-static int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
-{
-       struct task_group *parent, *child;
-       int ret;
-
-       rcu_read_lock();
-       parent = &root_task_group;
-down:
-       ret = (*down)(parent, data);
-       if (ret)
-               goto out_unlock;
-       list_for_each_entry_rcu(child, &parent->children, siblings) {
-               parent = child;
-               goto down;
-
-up:
-               continue;
-       }
-       ret = (*up)(parent, data);
-       if (ret)
-               goto out_unlock;
-
-       child = parent;
-       parent = parent->parent;
-       if (parent)
-               goto up;
-out_unlock:
-       rcu_read_unlock();
-
-       return ret;
-}
-
-static int tg_nop(struct task_group *tg, void *data)
-{
-       return 0;
-}
+//static int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
+//{
+//     struct task_group *parent, *child;
+//     int ret;
+//
+//     rcu_read_lock();
+//     parent = &root_task_group;
+//down:
+//     ret = (*down)(parent, data);
+//     if (ret)
+//             goto out_unlock;
+//     list_for_each_entry_rcu(child, &parent->children, siblings) {
+//             parent = child;
+//             goto down;
+//
+//up:
+//             continue;
+//     }
+//     ret = (*up)(parent, data);
+//     if (ret)
+//             goto out_unlock;
+//
+//     child = parent;
+//     parent = parent->parent;
+//     if (parent)
+//             goto up;
+//out_unlock:
+//     rcu_read_unlock();
+//
+//     return ret;
+//}
+
+//static int tg_nop(struct task_group *tg, void *data)
+//{
+//     return 0;
+//}
 #endif
 
 #ifdef CONFIG_SMP
 /* Used instead of source_load when we know the type == 0 */
-static unsigned long weighted_cpuload(const int cpu)
-{
-       return cpu_rq(cpu)->load.weight;
-}
-
-/*
- * Return a low guess at the load of a migration-source cpu weighted
- * according to the scheduling class and "nice" value.
- *
- * We want to under-estimate the load of migration sources, to
- * balance conservatively.
- */
-static unsigned long source_load(int cpu, int type)
-{
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long total = weighted_cpuload(cpu);
-
-       if (type == 0 || !sched_feat(LB_BIAS))
-               return total;
-
-       return min(rq->cpu_load[type-1], total);
-}
-
-/*
- * Return a high guess at the load of a migration-target cpu weighted
- * according to the scheduling class and "nice" value.
- */
-static unsigned long target_load(int cpu, int type)
-{
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long total = weighted_cpuload(cpu);
-
-       if (type == 0 || !sched_feat(LB_BIAS))
-               return total;
-
-       return max(rq->cpu_load[type-1], total);
-}
+//static unsigned long weighted_cpuload(const int cpu)
+//{
+//     return cpu_rq(cpu)->load.weight;
+//}
+//
+///*
+// * Return a low guess at the load of a migration-source cpu weighted
+// * according to the scheduling class and "nice" value.
+// *
+// * We want to under-estimate the load of migration sources, to
+// * balance conservatively.
+// */
+//static unsigned long source_load(int cpu, int type)
+//{
+//     struct rq *rq = cpu_rq(cpu);
+//     unsigned long total = weighted_cpuload(cpu);
+//
+//     if (type == 0 || !sched_feat(LB_BIAS))
+//             return total;
+//
+//     return min(rq->cpu_load[type-1], total);
+//}
+//
+///*
+// * Return a high guess at the load of a migration-target cpu weighted
+// * according to the scheduling class and "nice" value.
+// */
+//static unsigned long target_load(int cpu, int type)
+//{
+//     struct rq *rq = cpu_rq(cpu);
+//     unsigned long total = weighted_cpuload(cpu);
+//
+//     if (type == 0 || !sched_feat(LB_BIAS))
+//             return total;
+//
+//     return max(rq->cpu_load[type-1], total);
+//}
 
 static unsigned long power_of(int cpu)
 {
        return cpu_rq(cpu)->cpu_power;
 }
 
-static int task_hot(struct task_struct *p, u64 now, struct sched_domain *sd);
-
-static unsigned long cpu_avg_load_per_task(int cpu)
-{
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long nr_running = ACCESS_ONCE(rq->nr_running);
-
-       if (nr_running)
-               rq->avg_load_per_task = rq->load.weight / nr_running;
-       else
-               rq->avg_load_per_task = 0;
-
-       return rq->avg_load_per_task;
-}
-
-#ifdef CONFIG_FAIR_GROUP_SCHED
-
-/*
- * Compute the cpu's hierarchical load factor for each task group.
- * This needs to be done in a top-down fashion because the load of a child
- * group is a fraction of its parents load.
- */
-static int tg_load_down(struct task_group *tg, void *data)
-{
-       unsigned long load;
-       long cpu = (long)data;
-
-       if (!tg->parent) {
-               load = cpu_rq(cpu)->load.weight;
-       } else {
-               load = tg->parent->cfs_rq[cpu]->h_load;
-               load *= tg->se[cpu]->load.weight;
-               load /= tg->parent->cfs_rq[cpu]->load.weight + 1;
-       }
-
-       tg->cfs_rq[cpu]->h_load = load;
-
-       return 0;
-}
-
-static void update_h_load(long cpu)
-{
-       walk_tg_tree(tg_load_down, tg_nop, (void *)cpu);
-}
-
-#endif
+//static int task_hot(struct task_struct *p, u64 now, struct sched_domain *sd);
+
+//static unsigned long cpu_avg_load_per_task(int cpu)
+//{
+//     struct rq *rq = cpu_rq(cpu);
+//     unsigned long nr_running = ACCESS_ONCE(rq->nr_running);
+//
+//     if (nr_running)
+//             rq->avg_load_per_task = rq->load.weight / nr_running;
+//     else
+//             rq->avg_load_per_task = 0;
+//
+//     return rq->avg_load_per_task;
+//}
+
+//#ifdef CONFIG_FAIR_GROUP_SCHED
+//
+///*
+// * Compute the cpu's hierarchical load factor for each task group.
+// * This needs to be done in a top-down fashion because the load of a child
+// * group is a fraction of its parents load.
+// */
+//static int tg_load_down(struct task_group *tg, void *data)
+//{
+//     unsigned long load;
+//     long cpu = (long)data;
+//
+//     if (!tg->parent) {
+//             load = cpu_rq(cpu)->load.weight;
+//     } else {
+//             load = tg->parent->cfs_rq[cpu]->h_load;
+//             load *= tg->se[cpu]->load.weight;
+//             load /= tg->parent->cfs_rq[cpu]->load.weight + 1;
+//     }
+//
+//     tg->cfs_rq[cpu]->h_load = load;
+//
+//     return 0;
+//}
+//
+//static void update_h_load(long cpu)
+//{
+//     walk_tg_tree(tg_load_down, tg_nop, (void *)cpu);
+//}
+//
+//#endif
 
 #ifdef CONFIG_PREEMPT
 
@@ -1688,10 +1711,10 @@ static void double_rq_unlock(struct rq *rq1, struct rq *rq2)
 
 #endif
 
-static void calc_load_account_idle(struct rq *this_rq);
+//static void calc_load_account_idle(struct rq *this_rq);
 static void update_sysctl(void);
 static int get_update_sysctl_factor(void);
-static void update_cpu_load(struct rq *this_rq);
+//static void update_cpu_load(struct rq *this_rq);
 
 static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
 {
@@ -1725,20 +1748,20 @@ static void dec_nr_running(struct rq *rq)
        rq->nr_running--;
 }
 
-static void set_load_weight(struct task_struct *p)
-{
-       /*
-        * SCHED_IDLE tasks get minimal weight:
-        */
-       if (p->policy == SCHED_IDLE) {
-               p->se.load.weight = WEIGHT_IDLEPRIO;
-               p->se.load.inv_weight = WMULT_IDLEPRIO;
-               return;
-       }
-
-       p->se.load.weight = prio_to_weight[p->static_prio - MAX_RT_PRIO];
-       p->se.load.inv_weight = prio_to_wmult[p->static_prio - MAX_RT_PRIO];
-}
+//static void set_load_weight(struct task_struct *p)
+//{
+//     /*
+//      * SCHED_IDLE tasks get minimal weight:
+//      */
+//     if (p->policy == SCHED_IDLE) {
+//             p->se.load.weight = WEIGHT_IDLEPRIO;
+//             p->se.load.inv_weight = WMULT_IDLEPRIO;
+//             return;
+//     }
+//
+//     p->se.load.weight = prio_to_weight[p->static_prio - MAX_RT_PRIO];
+//     p->se.load.inv_weight = prio_to_wmult[p->static_prio - MAX_RT_PRIO];
+//}
 
 static void enqueue_task(struct rq *rq, struct task_struct *p, int flags)
 {
@@ -2064,34 +2087,34 @@ static void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
 /*
  * Is this task likely cache-hot:
  */
-static int
-task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
-{
-       s64 delta;
-
-       if (p->sched_class != &fair_sched_class)
-               return 0;
-
-       if (unlikely(p->policy == SCHED_IDLE))
-               return 0;
-
-       /*
-        * Buddy candidates are cache hot:
-        */
-       if (sched_feat(CACHE_HOT_BUDDY) && this_rq()->nr_running &&
-                       (&p->se == cfs_rq_of(&p->se)->next ||
-                        &p->se == cfs_rq_of(&p->se)->last))
-               return 1;
-
-       if (sysctl_sched_migration_cost == -1)
-               return 1;
-       if (sysctl_sched_migration_cost == 0)
-               return 0;
-
-       delta = now - p->se.exec_start;
-
-       return delta < (s64)sysctl_sched_migration_cost;
-}
+//static int
+//task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
+//{
+//     s64 delta;
+//
+//     if (p->sched_class != &fair_sched_class)
+//             return 0;
+//
+//     if (unlikely(p->policy == SCHED_IDLE))
+//             return 0;
+//
+//     /*
+//      * Buddy candidates are cache hot:
+//      */
+//     if (sched_feat(CACHE_HOT_BUDDY) && this_rq()->nr_running &&
+//                     (&p->se == cfs_rq_of(&p->se)->next ||
+//                      &p->se == cfs_rq_of(&p->se)->last))
+//             return 1;
+//
+//     if (sysctl_sched_migration_cost == -1)
+//             return 1;
+//     if (sysctl_sched_migration_cost == 0)
+//             return 0;
+//
+//     delta = now - p->se.exec_start;
+//
+//     return delta < (s64)sysctl_sched_migration_cost;
+//}
 
 void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 {
@@ -2545,7 +2568,8 @@ static void try_to_wake_up_local(struct task_struct *p)
  */
 int wake_up_process(struct task_struct *p)
 {
-       return try_to_wake_up(p, TASK_ALL, 0);
+       WARN_ON(task_is_stopped_or_traced(p));
+       return try_to_wake_up(p, TASK_NORMAL, 0);
 }
 EXPORT_SYMBOL(wake_up_process);
 
@@ -2607,7 +2631,7 @@ void sched_fork(struct task_struct *p, int clone_flags)
                if (PRIO_TO_NICE(p->static_prio) < 0) {
                        p->static_prio = NICE_TO_PRIO(0);
                        p->normal_prio = p->static_prio;
-                       set_load_weight(p);
+//                     set_load_weight(p);
                }
 
                /*
@@ -3017,40 +3041,41 @@ unsigned long nr_iowait_cpu(int cpu)
 
 unsigned long this_cpu_load(void)
 {
-       struct rq *this = this_rq();
-       return this->cpu_load[0];
+//     struct rq *this = this_rq();
+//     return this->cpu_load[0];
+       return 0;
 }
 
 
 /* Variables and functions for calc_load */
-static atomic_long_t calc_load_tasks;
-static unsigned long calc_load_update;
+//static atomic_long_t calc_load_tasks;
+//static unsigned long calc_load_update;
 unsigned long avenrun[3];
 EXPORT_SYMBOL(avenrun);
 
-static long calc_load_fold_active(struct rq *this_rq)
-{
-       long nr_active, delta = 0;
-
-       nr_active = this_rq->nr_running;
-       nr_active += (long) this_rq->nr_uninterruptible;
-
-       if (nr_active != this_rq->calc_load_active) {
-               delta = nr_active - this_rq->calc_load_active;
-               this_rq->calc_load_active = nr_active;
-       }
-
-       return delta;
-}
-
-static unsigned long
-calc_load(unsigned long load, unsigned long exp, unsigned long active)
-{
-       load *= exp;
-       load += active * (FIXED_1 - exp);
-       load += 1UL << (FSHIFT - 1);
-       return load >> FSHIFT;
-}
+//static long calc_load_fold_active(struct rq *this_rq)
+//{
+//     long nr_active, delta = 0;
+//
+//     nr_active = this_rq->nr_running;
+//     nr_active += (long) this_rq->nr_uninterruptible;
+//
+//     if (nr_active != this_rq->calc_load_active) {
+//             delta = nr_active - this_rq->calc_load_active;
+//             this_rq->calc_load_active = nr_active;
+//     }
+//
+//     return delta;
+//}
+
+//static unsigned long
+//calc_load(unsigned long load, unsigned long exp, unsigned long active)
+//{
+//     load *= exp;
+//     load += active * (FIXED_1 - exp);
+//     load += 1UL << (FSHIFT - 1);
+//     return load >> FSHIFT;
+//}
 
 #ifdef CONFIG_NO_HZ
 /*
@@ -3058,29 +3083,29 @@ calc_load(unsigned long load, unsigned long exp, unsigned long active)
  *
  * When making the ILB scale, we should try to pull this in as well.
  */
-static atomic_long_t calc_load_tasks_idle;
-
-static void calc_load_account_idle(struct rq *this_rq)
-{
-       long delta;
-
-       delta = calc_load_fold_active(this_rq);
-       if (delta)
-               atomic_long_add(delta, &calc_load_tasks_idle);
-}
-
-static long calc_load_fold_idle(void)
-{
-       long delta = 0;
-
-       /*
-        * Its got a race, we don't care...
-        */
-       if (atomic_long_read(&calc_load_tasks_idle))
-               delta = atomic_long_xchg(&calc_load_tasks_idle, 0);
-
-       return delta;
-}
+//static atomic_long_t calc_load_tasks_idle;
+
+//static void calc_load_account_idle(struct rq *this_rq)
+//{
+//     long delta;
+//
+//     delta = calc_load_fold_active(this_rq);
+//     if (delta)
+//             atomic_long_add(delta, &calc_load_tasks_idle);
+//}
+
+//static long calc_load_fold_idle(void)
+//{
+//     long delta = 0;
+//
+//     /*
+//      * Its got a race, we don't care...
+//      */
+//     if (atomic_long_read(&calc_load_tasks_idle))
+//             delta = atomic_long_xchg(&calc_load_tasks_idle, 0);
+//
+//     return delta;
+//}
 
 /**
  * fixed_power_int - compute: x^n, in O(log n) time
@@ -3097,27 +3122,27 @@ static long calc_load_fold_idle(void)
  * of course trivially computable in O(log_2 n), the length of our binary
  * vector.
  */
-static unsigned long
-fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)
-{
-       unsigned long result = 1UL << frac_bits;
-
-       if (n) for (;;) {
-               if (n & 1) {
-                       result *= x;
-                       result += 1UL << (frac_bits - 1);
-                       result >>= frac_bits;
-               }
-               n >>= 1;
-               if (!n)
-                       break;
-               x *= x;
-               x += 1UL << (frac_bits - 1);
-               x >>= frac_bits;
-       }
-
-       return result;
-}
+//static unsigned long
+//fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)
+//{
+//     unsigned long result = 1UL << frac_bits;
+//
+//     if (n) for (;;) {
+//             if (n & 1) {
+//                     result *= x;
+//                     result += 1UL << (frac_bits - 1);
+//                     result >>= frac_bits;
+//             }
+//             n >>= 1;
+//             if (!n)
+//                     break;
+//             x *= x;
+//             x += 1UL << (frac_bits - 1);
+//             x >>= frac_bits;
+//     }
+//
+//     return result;
+//}
 
 /*
  * a1 = a0 * e + a * (1 - e)
@@ -3142,13 +3167,13 @@ fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)
  *     S_n := \Sum x^i = -------------
  *             i=0          1 - x
  */
-static unsigned long
-calc_load_n(unsigned long load, unsigned long exp,
-           unsigned long active, unsigned int n)
-{
-
-       return calc_load(load, fixed_power_int(exp, FSHIFT, n), active);
-}
+//static unsigned long
+//calc_load_n(unsigned long load, unsigned long exp,
+//         unsigned long active, unsigned int n)
+//{
+//
+//     return calc_load(load, fixed_power_int(exp, FSHIFT, n), active);
+//}
 
 /*
  * NO_HZ can leave us missing all per-cpu ticks calling
@@ -3159,63 +3184,63 @@ calc_load_n(unsigned long load, unsigned long exp,
  * Once we've updated the global active value, we need to apply the exponential
  * weights adjusted to the number of cycles missed.
  */
-static void calc_global_nohz(unsigned long ticks)
-{
-       long delta, active, n;
-
-       if (time_before(jiffies, calc_load_update))
-               return;
-
-       /*
-        * If we crossed a calc_load_update boundary, make sure to fold
-        * any pending idle changes, the respective CPUs might have
-        * missed the tick driven calc_load_account_active() update
-        * due to NO_HZ.
-        */
-       delta = calc_load_fold_idle();
-       if (delta)
-               atomic_long_add(delta, &calc_load_tasks);
-
-       /*
-        * If we were idle for multiple load cycles, apply them.
-        */
-       if (ticks >= LOAD_FREQ) {
-               n = ticks / LOAD_FREQ;
-
-               active = atomic_long_read(&calc_load_tasks);
-               active = active > 0 ? active * FIXED_1 : 0;
-
-               avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
-               avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
-               avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
-
-               calc_load_update += n * LOAD_FREQ;
-       }
-
-       /*
-        * Its possible the remainder of the above division also crosses
-        * a LOAD_FREQ period, the regular check in calc_global_load()
-        * which comes after this will take care of that.
-        *
-        * Consider us being 11 ticks before a cycle completion, and us
-        * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
-        * age us 4 cycles, and the test in calc_global_load() will
-        * pick up the final one.
-        */
-}
+//static void calc_global_nohz(unsigned long ticks)
+//{
+//     long delta, active, n;
+//
+//     if (time_before(jiffies, calc_load_update))
+//             return;
+//
+//     /*
+//      * If we crossed a calc_load_update boundary, make sure to fold
+//      * any pending idle changes, the respective CPUs might have
+//      * missed the tick driven calc_load_account_active() update
+//      * due to NO_HZ.
+//      */
+//     delta = calc_load_fold_idle();
+//     if (delta)
+//             atomic_long_add(delta, &calc_load_tasks);
+//
+//     /*
+//      * If we were idle for multiple load cycles, apply them.
+//      */
+//     if (ticks >= LOAD_FREQ) {
+//             n = ticks / LOAD_FREQ;
+//
+//             active = atomic_long_read(&calc_load_tasks);
+//             active = active > 0 ? active * FIXED_1 : 0;
+//
+//             avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
+//             avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
+//             avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
+//
+//             calc_load_update += n * LOAD_FREQ;
+//     }
+//
+//     /*
+//      * Its possible the remainder of the above division also crosses
+//      * a LOAD_FREQ period, the regular check in calc_global_load()
+//      * which comes after this will take care of that.
+//      *
+//      * Consider us being 11 ticks before a cycle completion, and us
+//      * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
+//      * age us 4 cycles, and the test in calc_global_load() will
+//      * pick up the final one.
+//      */
+//}
 #else
-static void calc_load_account_idle(struct rq *this_rq)
-{
-}
-
-static inline long calc_load_fold_idle(void)
-{
-       return 0;
-}
-
-static void calc_global_nohz(unsigned long ticks)
-{
-}
+//static void calc_load_account_idle(struct rq *this_rq)
+//{
+//}
+//
+//static inline long calc_load_fold_idle(void)
+//{
+//     return 0;
+//}
+//
+//static void calc_global_nohz(unsigned long ticks)
+//{
+//}
 #endif
 
 /**
@@ -3228,9 +3253,10 @@ static void calc_global_nohz(unsigned long ticks)
  */
 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
 {
-       loads[0] = (avenrun[0] + offset) << shift;
-       loads[1] = (avenrun[1] + offset) << shift;
-       loads[2] = (avenrun[2] + offset) << shift;
+//     loads[0] = (avenrun[0] + offset) << shift;
+//     loads[1] = (avenrun[1] + offset) << shift;
+//     loads[2] = (avenrun[2] + offset) << shift;
+       return;
 }
 
 /*
@@ -3239,41 +3265,41 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
  */
 void calc_global_load(unsigned long ticks)
 {
-       long active;
-
-       calc_global_nohz(ticks);
-
-       if (time_before(jiffies, calc_load_update + 10))
-               return;
-
-       active = atomic_long_read(&calc_load_tasks);
-       active = active > 0 ? active * FIXED_1 : 0;
-
-       avenrun[0] = calc_load(avenrun[0], EXP_1, active);
-       avenrun[1] = calc_load(avenrun[1], EXP_5, active);
-       avenrun[2] = calc_load(avenrun[2], EXP_15, active);
-
-       calc_load_update += LOAD_FREQ;
-}
-
-/*
- * Called from update_cpu_load() to periodically update this CPU's
- * active count.
- */
-static void calc_load_account_active(struct rq *this_rq)
-{
-       long delta;
-
-       if (time_before(jiffies, this_rq->calc_load_update))
-               return;
-
-       delta  = calc_load_fold_active(this_rq);
-       delta += calc_load_fold_idle();
-       if (delta)
-               atomic_long_add(delta, &calc_load_tasks);
-
-       this_rq->calc_load_update += LOAD_FREQ;
-}
+//     long active;
+//
+//     calc_global_nohz(ticks);
+//
+//     if (time_before(jiffies, calc_load_update + 10))
+//             return;
+//
+//     active = atomic_long_read(&calc_load_tasks);
+//     active = active > 0 ? active * FIXED_1 : 0;
+//
+//     avenrun[0] = calc_load(avenrun[0], EXP_1, active);
+//     avenrun[1] = calc_load(avenrun[1], EXP_5, active);
+//     avenrun[2] = calc_load(avenrun[2], EXP_15, active);
+//
+//     calc_load_update += LOAD_FREQ;
+}
+//
+///*
+// * Called from update_cpu_load() to periodically update this CPU's
+// * active count.
+// */
+//static void calc_load_account_active(struct rq *this_rq)
+//{
+//     long delta;
+//
+//     if (time_before(jiffies, this_rq->calc_load_update))
+//             return;
+//
+//     delta  = calc_load_fold_active(this_rq);
+//     delta += calc_load_fold_idle();
+//     if (delta)
+//             atomic_long_add(delta, &calc_load_tasks);
+//
+//     this_rq->calc_load_update += LOAD_FREQ;
+//}
 
 /*
  * The exact cpuload at various idx values, calculated at every tick would be
@@ -3302,97 +3328,97 @@ static void calc_load_account_active(struct rq *this_rq)
  * by looking at 1 bits in n and doing as many mult/shift instead of
  * n mult/shifts needed by the exact degradation.
  */
-#define DEGRADE_SHIFT          7
-static const unsigned char
-               degrade_zero_ticks[CPU_LOAD_IDX_MAX] = {0, 8, 32, 64, 128};
-static const unsigned char
-               degrade_factor[CPU_LOAD_IDX_MAX][DEGRADE_SHIFT + 1] = {
-                                       {0, 0, 0, 0, 0, 0, 0, 0},
-                                       {64, 32, 8, 0, 0, 0, 0, 0},
-                                       {96, 72, 40, 12, 1, 0, 0},
-                                       {112, 98, 75, 43, 15, 1, 0},
-                                       {120, 112, 98, 76, 45, 16, 2} };
+//#define DEGRADE_SHIFT                7
+//static const unsigned char
+//             degrade_zero_ticks[CPU_LOAD_IDX_MAX] = {0, 8, 32, 64, 128};
+//static const unsigned char
+//             degrade_factor[CPU_LOAD_IDX_MAX][DEGRADE_SHIFT + 1] = {
+//                                     {0, 0, 0, 0, 0, 0, 0, 0},
+//                                     {64, 32, 8, 0, 0, 0, 0, 0},
+//                                     {96, 72, 40, 12, 1, 0, 0},
+//                                     {112, 98, 75, 43, 15, 1, 0},
+//                                     {120, 112, 98, 76, 45, 16, 2} };
 
 /*
  * Update cpu_load for any missed ticks, due to tickless idle. The backlog
  * would be when CPU is idle and so we just decay the old load without
  * adding any new load.
  */
-static unsigned long
-decay_load_missed(unsigned long load, unsigned long missed_updates, int idx)
-{
-       int j = 0;
-
-       if (!missed_updates)
-               return load;
-
-       if (missed_updates >= degrade_zero_ticks[idx])
-               return 0;
-
-       if (idx == 1)
-               return load >> missed_updates;
-
-       while (missed_updates) {
-               if (missed_updates % 2)
-                       load = (load * degrade_factor[idx][j]) >> DEGRADE_SHIFT;
-
-               missed_updates >>= 1;
-               j++;
-       }
-       return load;
-}
+//static unsigned long
+//decay_load_missed(unsigned long load, unsigned long missed_updates, int idx)
+//{
+//     int j = 0;
+//
+//     if (!missed_updates)
+//             return load;
+//
+//     if (missed_updates >= degrade_zero_ticks[idx])
+//             return 0;
+//
+//     if (idx == 1)
+//             return load >> missed_updates;
+//
+//     while (missed_updates) {
+//             if (missed_updates % 2)
+//                     load = (load * degrade_factor[idx][j]) >> DEGRADE_SHIFT;
+//
+//             missed_updates >>= 1;
+//             j++;
+//     }
+//     return load;
+//}
 
 /*
  * Update rq->cpu_load[] statistics. This function is usually called every
  * scheduler tick (TICK_NSEC). With tickless idle this will not be called
  * every tick. We fix it up based on jiffies.
  */
-static void update_cpu_load(struct rq *this_rq)
-{
-       unsigned long this_load = this_rq->load.weight;
-       unsigned long curr_jiffies = jiffies;
-       unsigned long pending_updates;
-       int i, scale;
-
-       this_rq->nr_load_updates++;
-
-       /* Avoid repeated calls on same jiffy, when moving in and out of idle */
-       if (curr_jiffies == this_rq->last_load_update_tick)
-               return;
-
-       pending_updates = curr_jiffies - this_rq->last_load_update_tick;
-       this_rq->last_load_update_tick = curr_jiffies;
-
-       /* Update our load: */
-       this_rq->cpu_load[0] = this_load; /* Fasttrack for idx 0 */
-       for (i = 1, scale = 2; i < CPU_LOAD_IDX_MAX; i++, scale += scale) {
-               unsigned long old_load, new_load;
-
-               /* scale is effectively 1 << i now, and >> i divides by scale */
-
-               old_load = this_rq->cpu_load[i];
-               old_load = decay_load_missed(old_load, pending_updates - 1, i);
-               new_load = this_load;
-               /*
-                * Round up the averaging division if load is increasing. This
-                * prevents us from getting stuck on 9 if the load is 10, for
-                * example.
-                */
-               if (new_load > old_load)
-                       new_load += scale - 1;
-
-               this_rq->cpu_load[i] = (old_load * (scale - 1) + new_load) >> i;
-       }
-
-       sched_avg_update(this_rq);
-}
-
-static void update_cpu_load_active(struct rq *this_rq)
-{
-       update_cpu_load(this_rq);
-
-       calc_load_account_active(this_rq);
-}
+//static void update_cpu_load(struct rq *this_rq)
+//{
+//     unsigned long this_load = this_rq->load.weight;
+//     unsigned long curr_jiffies = jiffies;
+//     unsigned long pending_updates;
+//     int i, scale;
+//
+//     this_rq->nr_load_updates++;
+//
+//     /* Avoid repeated calls on same jiffy, when moving in and out of idle */
+//     if (curr_jiffies == this_rq->last_load_update_tick)
+//             return;
+//
+//     pending_updates = curr_jiffies - this_rq->last_load_update_tick;
+//     this_rq->last_load_update_tick = curr_jiffies;
+//
+//     /* Update our load: */
+//     this_rq->cpu_load[0] = this_load; /* Fasttrack for idx 0 */
+//     for (i = 1, scale = 2; i < CPU_LOAD_IDX_MAX; i++, scale += scale) {
+//             unsigned long old_load, new_load;
+//
+//             /* scale is effectively 1 << i now, and >> i divides by scale */
+//
+//             old_load = this_rq->cpu_load[i];
+//             old_load = decay_load_missed(old_load, pending_updates - 1, i);
+//             new_load = this_load;
+//             /*
+//              * Round up the averaging division if load is increasing. This
+//              * prevents us from getting stuck on 9 if the load is 10, for
+//              * example.
+//              */
+//             if (new_load > old_load)
+//                     new_load += scale - 1;
+//
+//             this_rq->cpu_load[i] = (old_load * (scale - 1) + new_load) >> i;
+//     }
+//
+//     sched_avg_update(this_rq);
+//}
+//
+//static void update_cpu_load_active(struct rq *this_rq)
+//{
+//     update_cpu_load(this_rq);
+//
+//     calc_load_account_active(this_rq);
+//}
 
 #ifdef CONFIG_SMP
 
@@ -3777,7 +3803,7 @@ void scheduler_tick(void)
 
        raw_spin_lock(&rq->lock);
        update_rq_clock(rq);
-       update_cpu_load_active(rq);
+//     update_cpu_load_active(rq);
        curr->sched_class->task_tick(rq, curr, 0);
        raw_spin_unlock(&rq->lock);
 
@@ -3785,7 +3811,7 @@ void scheduler_tick(void)
 
 #ifdef CONFIG_SMP
        rq->idle_at_tick = idle_cpu(cpu);
-       trigger_load_balance(rq, cpu);
+//     trigger_load_balance(rq, cpu);
 #endif
 }
 
@@ -3980,8 +4006,8 @@ need_resched_nonpreemptible:
 
        pre_schedule(rq, prev);
 
-       if (unlikely(!rq->nr_running))
-               idle_balance(cpu, rq);
+//     if (unlikely(!rq->nr_running))
+//             idle_balance(cpu, rq);
 
        put_prev_task(rq, prev);
        next = pick_next_task(rq);
@@ -4609,7 +4635,7 @@ void set_user_nice(struct task_struct *p, long nice)
                dequeue_task(rq, p, 0);
 
        p->static_prio = NICE_TO_PRIO(nice);
-       set_load_weight(p);
+//     set_load_weight(p);
        old_prio = p->prio;
        p->prio = effective_prio(p);
        delta = p->prio - old_prio;
@@ -4749,7 +4775,7 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio)
                p->sched_class = &rt_sched_class;
        else
                p->sched_class = &fair_sched_class;
-       set_load_weight(p);
+//     set_load_weight(p);
 }
 
 /*
@@ -5572,7 +5598,7 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu)
         * The idle tasks have their own, simple scheduling class:
         */
        idle->sched_class = &idle_sched_class;
-       ftrace_graph_init_task(idle);
+//     ftrace_graph_init_idle_task(idle, cpu);
 }
 
 /*
@@ -5814,11 +5840,11 @@ static void migrate_nr_uninterruptible(struct rq *rq_src)
 /*
  * remove the tasks which were accounted by rq from calc_load_tasks.
  */
-static void calc_global_load_remove(struct rq *rq)
-{
-       atomic_long_sub(rq->calc_load_active, &calc_load_tasks);
-       rq->calc_load_active = 0;
-}
+//static void calc_global_load_remove(struct rq *rq)
+//{
+//     atomic_long_sub(rq->calc_load_active, &calc_load_tasks);
+//     rq->calc_load_active = 0;
+//}
 
 /*
  * Migrate all tasks from the rq, sleeping tasks will be migrated by
@@ -6081,7 +6107,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
        switch (action & ~CPU_TASKS_FROZEN) {
 
        case CPU_UP_PREPARE:
-               rq->calc_load_update = calc_load_update;
+//             rq->calc_load_update = calc_load_update;
                break;
 
        case CPU_ONLINE:
@@ -6108,7 +6134,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
                raw_spin_unlock_irqrestore(&rq->lock, flags);
 
                migrate_nr_uninterruptible(rq);
-               calc_global_load_remove(rq);
+//             calc_global_load_remove(rq);
                break;
 #endif
        }
@@ -6935,51 +6961,51 @@ static void free_sched_groups(const struct cpumask *cpu_map,
  * having more cpu_power will pickup more load compared to the group having
  * less cpu_power.
  */
-static void init_sched_groups_power(int cpu, struct sched_domain *sd)
-{
-       struct sched_domain *child;
-       struct sched_group *group;
-       long power;
-       int weight;
-
-       WARN_ON(!sd || !sd->groups);
-
-       if (cpu != group_first_cpu(sd->groups))
-               return;
-
-       sd->groups->group_weight = cpumask_weight(sched_group_cpus(sd->groups));
-
-       child = sd->child;
-
-       sd->groups->cpu_power = 0;
-
-       if (!child) {
-               power = SCHED_LOAD_SCALE;
-               weight = cpumask_weight(sched_domain_span(sd));
-               /*
-                * SMT siblings share the power of a single core.
-                * Usually multiple threads get a better yield out of
-                * that one core than a single thread would have,
-                * reflect that in sd->smt_gain.
-                */
-               if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
-                       power *= sd->smt_gain;
-                       power /= weight;
-                       power >>= SCHED_LOAD_SHIFT;
-               }
-               sd->groups->cpu_power += power;
-               return;
-       }
-
-       /*
-        * Add cpu_power of each child group to this groups cpu_power.
-        */
-       group = child->groups;
-       do {
-               sd->groups->cpu_power += group->cpu_power;
-               group = group->next;
-       } while (group != child->groups);
-}
+//static void init_sched_groups_power(int cpu, struct sched_domain *sd)
+//{
+//     struct sched_domain *child;
+//     struct sched_group *group;
+//     long power;
+//     int weight;
+//
+//     WARN_ON(!sd || !sd->groups);
+//
+//     if (cpu != group_first_cpu(sd->groups))
+//             return;
+//
+//     sd->groups->group_weight = cpumask_weight(sched_group_cpus(sd->groups));
+//
+//     child = sd->child;
+//
+//     sd->groups->cpu_power = 0;
+//
+//     if (!child) {
+//             power = SCHED_LOAD_SCALE;
+//             weight = cpumask_weight(sched_domain_span(sd));
+//             /*
+//              * SMT siblings share the power of a single core.
+//              * Usually multiple threads get a better yield out of
+//              * that one core than a single thread would have,
+//              * reflect that in sd->smt_gain.
+//              */
+//             if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
+//                     power *= sd->smt_gain;
+//                     power /= weight;
+//                     power >>= SCHED_LOAD_SHIFT;
+//             }
+//             sd->groups->cpu_power += power;
+//             return;
+//     }
+//
+//     /*
+//      * Add cpu_power of each child group to this groups cpu_power.
+//      */
+//     group = child->groups;
+//     do {
+//             sd->groups->cpu_power += group->cpu_power;
+//             group = group->next;
+//     } while (group != child->groups);
+//}
 
 /*
  * Initializers for schedule domains
@@ -7334,25 +7360,25 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
 #ifdef CONFIG_SCHED_SMT
        for_each_cpu(i, cpu_map) {
                sd = &per_cpu(cpu_domains, i).sd;
-               init_sched_groups_power(i, sd);
+//             init_sched_groups_power(i, sd);
        }
 #endif
 #ifdef CONFIG_SCHED_MC
        for_each_cpu(i, cpu_map) {
                sd = &per_cpu(core_domains, i).sd;
-               init_sched_groups_power(i, sd);
+//             init_sched_groups_power(i, sd);
        }
 #endif
 #ifdef CONFIG_SCHED_BOOK
        for_each_cpu(i, cpu_map) {
                sd = &per_cpu(book_domains, i).sd;
-               init_sched_groups_power(i, sd);
+//             init_sched_groups_power(i, sd);
        }
 #endif
 
        for_each_cpu(i, cpu_map) {
                sd = &per_cpu(phys_domains, i).sd;
-               init_sched_groups_power(i, sd);
+//             init_sched_groups_power(i, sd);
        }
 
 #ifdef CONFIG_NUMA
@@ -7822,7 +7848,7 @@ static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq)
 #endif
 #ifdef CONFIG_SMP
        rt_rq->rt_nr_migratory = 0;
-       rt_rq->overloaded = 0;
+//     rt_rq->overloaded = 0;
        plist_head_init_raw(&rt_rq->pushable_tasks, &rq->lock);
 #endif
 
@@ -7858,7 +7884,7 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
                se->cfs_rq = parent->my_q;
 
        se->my_q = cfs_rq;
-       update_load_set(&se->load, 0);
+//     update_load_set(&se->load, 0);
        se->parent = parent;
 }
 #endif
@@ -7892,7 +7918,7 @@ static void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
 
 void __init sched_init(void)
 {
-       int i, j;
+       int i/*, j*/;
        unsigned long alloc_size = 0, ptr;
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
@@ -7955,12 +7981,12 @@ void __init sched_init(void)
                rq = cpu_rq(i);
                raw_spin_lock_init(&rq->lock);
                rq->nr_running = 0;
-               rq->calc_load_active = 0;
-               rq->calc_load_update = jiffies + LOAD_FREQ;
+//             rq->calc_load_active = 0;
+//             rq->calc_load_update = jiffies + LOAD_FREQ;
                init_cfs_rq(&rq->cfs, rq);
                init_rt_rq(&rq->rt, rq);
 #ifdef CONFIG_FAIR_GROUP_SCHED
-               root_task_group.shares = root_task_group_load;
+//             root_task_group.shares = root_task_group_load;
                INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
                /*
                 * How much cpu bandwidth does root_task_group get?
@@ -7990,18 +8016,18 @@ void __init sched_init(void)
                init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, NULL);
 #endif
 
-               for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
-                       rq->cpu_load[j] = 0;
+//             for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
+//                     rq->cpu_load[j] = 0;
 
-               rq->last_load_update_tick = jiffies;
+//             rq->last_load_update_tick = jiffies;
 
 #ifdef CONFIG_SMP
                rq->sd = NULL;
                rq->rd = NULL;
-               rq->cpu_power = SCHED_LOAD_SCALE;
+//             rq->cpu_power = SCHED_LOAD_SCALE;
                rq->post_schedule = 0;
-               rq->active_balance = 0;
-               rq->next_balance = jiffies;
+//             rq->active_balance = 0;
+//             rq->next_balance = jiffies;
                rq->push_cpu = 0;
                rq->cpu = i;
                rq->online = 0;
@@ -8009,7 +8035,7 @@ void __init sched_init(void)
                rq->avg_idle = 2*sysctl_sched_migration_cost;
                rq_attach_root(rq, &def_root_domain);
 #ifdef CONFIG_NO_HZ
-               rq->nohz_balance_kick = 0;
+//             rq->nohz_balance_kick = 0;
                init_sched_softirq_csd(&per_cpu(remote_sched_softirq_cb, i));
 #endif
 #endif
@@ -8017,14 +8043,14 @@ void __init sched_init(void)
                atomic_set(&rq->nr_iowait, 0);
        }
 
-       set_load_weight(&init_task);
+//     set_load_weight(&init_task);
 
 #ifdef CONFIG_PREEMPT_NOTIFIERS
        INIT_HLIST_HEAD(&init_task.preempt_notifiers);
 #endif
 
 #ifdef CONFIG_SMP
-       open_softirq(SCHED_SOFTIRQ, run_rebalance_domains);
+//     open_softirq(SCHED_SOFTIRQ, run_rebalance_domains);
 #endif
 
 #ifdef CONFIG_RT_MUTEXES
@@ -8045,7 +8071,7 @@ void __init sched_init(void)
         */
        init_idle(current, smp_processor_id());
 
-       calc_load_update = jiffies + LOAD_FREQ;
+//     calc_load_update = jiffies + LOAD_FREQ;
 
        /*
         * During early bootup we pretend to be a normal task:
@@ -8058,7 +8084,7 @@ void __init sched_init(void)
 #ifdef CONFIG_NO_HZ
        zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT);
        alloc_cpumask_var(&nohz.grp_idle_mask, GFP_NOWAIT);
-       atomic_set(&nohz.load_balancer, nr_cpu_ids);
+//     atomic_set(&nohz.load_balancer, nr_cpu_ids);
        atomic_set(&nohz.first_pick_cpu, nr_cpu_ids);
        atomic_set(&nohz.second_pick_cpu, nr_cpu_ids);
 #endif
@@ -8167,7 +8193,7 @@ void normalize_rt_tasks(void)
 
 #endif /* CONFIG_MAGIC_SYSRQ */
 
-#if defined(CONFIG_IA64) || defined(CONFIG_KGDB_KDB)
+#if defined(CONFIG_IA64) || defined(CONFIG_KGDB_KDB) || defined(CONFIG_KDB)
 /*
  * These functions are only useful for the IA64 MCA handling, or kdb.
  *
@@ -8235,7 +8261,7 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
 {
        struct cfs_rq *cfs_rq;
        struct sched_entity *se;
-       struct rq *rq;
+//     struct rq *rq;
        int i;
 
        tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL);
@@ -8245,10 +8271,10 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
        if (!tg->se)
                goto err;
 
-       tg->shares = NICE_0_LOAD;
+//     tg->shares = NICE_0_LOAD;
 
        for_each_possible_cpu(i) {
-               rq = cpu_rq(i);
+//             rq = cpu_rq(i);
 
                cfs_rq = kzalloc_node(sizeof(struct cfs_rq),
                                      GFP_KERNEL, cpu_to_node(i));
@@ -8484,8 +8510,8 @@ static DEFINE_MUTEX(shares_mutex);
 
 int sched_group_set_shares(struct task_group *tg, unsigned long shares)
 {
-       int i;
-       unsigned long flags;
+//     int i;
+//     unsigned long flags;
 
        /*
         * We can't change the weight of the root cgroup.
@@ -8503,17 +8529,17 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
                goto done;
 
        tg->shares = shares;
-       for_each_possible_cpu(i) {
-               struct rq *rq = cpu_rq(i);
-               struct sched_entity *se;
-
-               se = tg->se[i];
-               /* Propagate contribution to hierarchy */
-               raw_spin_lock_irqsave(&rq->lock, flags);
-               for_each_sched_entity(se)
-                       update_cfs_shares(group_cfs_rq(se), 0);
-               raw_spin_unlock_irqrestore(&rq->lock, flags);
-       }
+//     for_each_possible_cpu(i) {
+//             struct rq *rq = cpu_rq(i);
+//             struct sched_entity *se;
+//
+//             se = tg->se[i];
+//             /* Propagate contribution to hierarchy */
+//             raw_spin_lock_irqsave(&rq->lock, flags);
+//             for_each_sched_entity(se)
+//                     update_cfs_shares(group_cfs_rq(se), 0);
+//             raw_spin_unlock_irqrestore(&rq->lock, flags);
+//     }
 
 done:
        mutex_unlock(&shares_mutex);
@@ -9255,3 +9281,108 @@ struct cgroup_subsys cpuacct_subsys = {
 };
 #endif /* CONFIG_CGROUP_CPUACCT */
 
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+
+static void
+kdb_prio(char *name, struct rt_prio_array *array, kdb_printf_t xxx_printf,
+       unsigned int cpu)
+{
+       int pri, printed_header = 0;
+       struct task_struct *p;
+
+       xxx_printf(" %s rt bitmap: 0x%lx 0x%lx 0x%lx\n",
+               name,
+               array->bitmap[0], array->bitmap[1], array->bitmap[2]);
+
+       pri = sched_find_first_bit(array->bitmap);
+       if (pri < MAX_RT_PRIO) {
+               xxx_printf("   rt bitmap priorities:");
+               while (pri < MAX_RT_PRIO) {
+                       xxx_printf(" %d", pri);
+                       pri++;
+                       pri = find_next_bit(array->bitmap, MAX_RT_PRIO, pri);
+               }
+               xxx_printf("\n");
+       }
+
+       for (pri = 0; pri < MAX_RT_PRIO; pri++) {
+               int printed_hdr = 0;
+               struct list_head *head, *curr;
+
+               head = array->queue + pri;
+               curr = head->next;
+               while(curr != head) {
+                       struct task_struct *task;
+                       if (!printed_hdr) {
+                               xxx_printf("   queue at priority=%d\n", pri);
+                               printed_hdr = 1;
+                       }
+                       task = list_entry(curr, struct task_struct, rt.run_list);
+                       if (task)
+                               xxx_printf("    0x%p %d %s  time_slice:%d\n",
+                                  task, task->pid, task->comm,
+                                  task->rt.time_slice);
+                       curr = curr->next;
+               }
+       }
+       for_each_process(p) {
+               if (p->se.on_rq && (task_cpu(p) == cpu) &&
+                  (p->policy == SCHED_NORMAL)) {
+                       if (!printed_header) {
+                               xxx_printf("  sched_normal queue:\n");
+                               printed_header = 1;
+                       }
+                       xxx_printf("    0x%p %d %s pri:%d spri:%d npri:%d\n",
+                               p, p->pid, p->comm, p->prio,
+                               p->static_prio, p->normal_prio);
+               }
+       }
+}
+
+/* This code must be in sched.c because struct rq is only defined in this
+ * source.  To allow most of kdb to be modular, this code cannot call any kdb
+ * functions directly, any external functions that it needs must be passed in
+ * as parameters.
+ */
+
+void
+kdb_runqueue(unsigned long cpu, kdb_printf_t xxx_printf)
+{
+       int i;
+       struct rq *rq;
+
+       rq = cpu_rq(cpu);
+
+       xxx_printf("CPU%ld lock:%s curr:0x%p(%d)(%s)",
+                  cpu, (spin_is_locked(&rq->lock))?"LOCKED":"free",
+                  rq->curr, rq->curr->pid, rq->curr->comm);
+       if (rq->curr == rq->idle)
+               xxx_printf(" is idle");
+       xxx_printf("\n");
+
+       xxx_printf(" nr_running:%ld ", rq->nr_running);
+       xxx_printf(" nr_uninterruptible:%ld ", rq->nr_uninterruptible);
+
+       xxx_printf(" nr_switches:%llu ", (long long)rq->nr_switches);
+       xxx_printf(" nr_iowait:%u ", atomic_read(&rq->nr_iowait));
+//     xxx_printf(" next_balance:%lu\n", rq->next_balance);
+
+#ifdef CONFIG_SMP
+//     xxx_printf(" active_balance:%u ", rq->active_balance);
+       xxx_printf(" idle_at_tick:%u\n", rq->idle_at_tick);
+
+       xxx_printf(" push_cpu:%u ", rq->push_cpu);
+       xxx_printf(" cpu:%u ", rq->cpu);
+       xxx_printf(" online:%u\n", rq->online);
+#endif
+
+       xxx_printf(" cpu_load:");
+       for (i=0; i<CPU_LOAD_IDX_MAX; i++)
+               xxx_printf(" %lu", rq->cpu_load[i]);
+       xxx_printf("\n");
+       kdb_prio("active", &rq->rt.active, xxx_printf, (unsigned int)cpu);
+}
+EXPORT_SYMBOL(kdb_runqueue);
+
+#endif /* CONFIG_KDB */
index eb6cb8e..c6ddd91 100644 (file)
@@ -203,16 +203,16 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
        SEQ_printf(m, "  .%-30s: %ld\n", "nr_running", cfs_rq->nr_running);
        SEQ_printf(m, "  .%-30s: %ld\n", "load", cfs_rq->load.weight);
 #ifdef CONFIG_FAIR_GROUP_SCHED
-#ifdef CONFIG_SMP
-       SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "load_avg",
-                       SPLIT_NS(cfs_rq->load_avg));
-       SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "load_period",
-                       SPLIT_NS(cfs_rq->load_period));
-       SEQ_printf(m, "  .%-30s: %ld\n", "load_contrib",
-                       cfs_rq->load_contribution);
-       SEQ_printf(m, "  .%-30s: %d\n", "load_tg",
-                       atomic_read(&cfs_rq->tg->load_weight));
-#endif
+//#ifdef CONFIG_SMP
+//     SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "load_avg",
+//                     SPLIT_NS(cfs_rq->load_avg));
+//     SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "load_period",
+//                     SPLIT_NS(cfs_rq->load_period));
+//     SEQ_printf(m, "  .%-30s: %ld\n", "load_contrib",
+//                     cfs_rq->load_contribution);
+//     SEQ_printf(m, "  .%-30s: %d\n", "load_tg",
+//                     atomic_read(&cfs_rq->tg->load_weight));
+//#endif
 
        print_cfs_group_stats(m, cpu, cfs_rq->tg);
 #endif
@@ -264,19 +264,19 @@ static void print_cpu(struct seq_file *m, int cpu)
        SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
 
        P(nr_running);
-       SEQ_printf(m, "  .%-30s: %lu\n", "load",
-                  rq->load.weight);
+//     SEQ_printf(m, "  .%-30s: %lu\n", "load",
+//                rq->load.weight);
        P(nr_switches);
-       P(nr_load_updates);
+//     P(nr_load_updates);
        P(nr_uninterruptible);
        PN(next_balance);
        P(curr->pid);
        PN(clock);
-       P(cpu_load[0]);
-       P(cpu_load[1]);
-       P(cpu_load[2]);
-       P(cpu_load[3]);
-       P(cpu_load[4]);
+//     P(cpu_load[0]);
+//     P(cpu_load[1]);
+//     P(cpu_load[2]);
+//     P(cpu_load[3]);
+//     P(cpu_load[4]);
 #undef P
 #undef PN
 
index 0c26e2d..4e89cda 100644 (file)
@@ -471,14 +471,14 @@ int sched_proc_update_handler(struct ctl_table *table, int write,
 /*
  * delta /= w
  */
-static inline unsigned long
-calc_delta_fair(unsigned long delta, struct sched_entity *se)
-{
-       if (unlikely(se->load.weight != NICE_0_LOAD))
-               delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load);
-
-       return delta;
-}
+//static inline unsigned long
+//calc_delta_fair(unsigned long delta, struct sched_entity *se)
+//{
+//     if (unlikely(se->load.weight != NICE_0_LOAD))
+//             delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load);
+//
+//     return delta;
+//}
 
 /*
  * The idea is to set a period in which each task runs once.
@@ -488,18 +488,18 @@ calc_delta_fair(unsigned long delta, struct sched_entity *se)
  *
  * p = (nr <= nl) ? l : l*nr/nl
  */
-static u64 __sched_period(unsigned long nr_running)
-{
-       u64 period = sysctl_sched_latency;
-       unsigned long nr_latency = sched_nr_latency;
-
-       if (unlikely(nr_running > nr_latency)) {
-               period = sysctl_sched_min_granularity;
-               period *= nr_running;
-       }
-
-       return period;
-}
+//static u64 __sched_period(unsigned long nr_running)
+//{
+//     u64 period = sysctl_sched_latency;
+//     unsigned long nr_latency = sched_nr_latency;
+//
+//     if (unlikely(nr_running > nr_latency)) {
+//             period = sysctl_sched_min_granularity;
+//             period *= nr_running;
+//     }
+//
+//     return period;
+//}
 
 /*
  * We calculate the wall-time slice from the period by taking a part
@@ -507,40 +507,40 @@ static u64 __sched_period(unsigned long nr_running)
  *
  * s = p*P[w/rw]
  */
-static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
-{
-       u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq);
-
-       for_each_sched_entity(se) {
-               struct load_weight *load;
-               struct load_weight lw;
-
-               cfs_rq = cfs_rq_of(se);
-               load = &cfs_rq->load;
-
-               if (unlikely(!se->on_rq)) {
-                       lw = cfs_rq->load;
-
-                       update_load_add(&lw, se->load.weight);
-                       load = &lw;
-               }
-               slice = calc_delta_mine(slice, se->load.weight, load);
-       }
-       return slice;
-}
+//static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
+//{
+//     u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq);
+//
+//     for_each_sched_entity(se) {
+//             struct load_weight *load;
+//             struct load_weight lw;
+//
+//             cfs_rq = cfs_rq_of(se);
+//             load = &cfs_rq->load;
+//
+//             if (unlikely(!se->on_rq)) {
+//                     lw = cfs_rq->load;
+//
+//                     update_load_add(&lw, se->load.weight);
+//                     load = &lw;
+//             }
+//             slice = calc_delta_mine(slice, se->load.weight, load);
+//     }
+//     return slice;
+//}
 
 /*
  * We calculate the vruntime slice of a to be inserted task
  *
  * vs = s/w
  */
-static u64 sched_vslice(struct cfs_rq *cfs_rq, struct sched_entity *se)
-{
-       return calc_delta_fair(sched_slice(cfs_rq, se), se);
-}
+//static u64 sched_vslice(struct cfs_rq *cfs_rq, struct sched_entity *se)
+//{
+//     return calc_delta_fair(sched_slice(cfs_rq, se), se);
+//}
 
-static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update);
-static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta);
+//static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update);
+//static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta);
 
 /*
  * Update the current task's runtime statistics. Skip current tasks that
@@ -550,21 +550,21 @@ static inline void
 __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,
              unsigned long delta_exec)
 {
-       unsigned long delta_exec_weighted;
+       unsigned long delta_exec_weighted = 0;
 
        schedstat_set(curr->statistics.exec_max,
                      max((u64)delta_exec, curr->statistics.exec_max));
 
        curr->sum_exec_runtime += delta_exec;
        schedstat_add(cfs_rq, exec_clock, delta_exec);
-       delta_exec_weighted = calc_delta_fair(delta_exec, curr);
+//     delta_exec_weighted = calc_delta_fair(delta_exec, curr);
 
        curr->vruntime += delta_exec_weighted;
        update_min_vruntime(cfs_rq);
 
-#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED
-       cfs_rq->load_unacc_exec_time += delta_exec;
-#endif
+//#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED
+//     cfs_rq->load_unacc_exec_time += delta_exec;
+//#endif
 }
 
 static void update_curr(struct cfs_rq *cfs_rq)
@@ -660,27 +660,27 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
  * Scheduling class queueing methods:
  */
 
-#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED
-static void
-add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
-{
-       cfs_rq->task_weight += weight;
-}
-#else
-static inline void
-add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
-{
-}
-#endif
+//#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED
+//static void
+//add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
+//{
+//     cfs_rq->task_weight += weight;
+//}
+//#else
+//static inline void
+//add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
+//{
+//}
+//#endif
 
 static void
 account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-       update_load_add(&cfs_rq->load, se->load.weight);
+//     update_load_add(&cfs_rq->load, se->load.weight);
        if (!parent_entity(se))
-               inc_cpu_load(rq_of(cfs_rq), se->load.weight);
+//             inc_cpu_load(rq_of(cfs_rq), se->load.weight);
        if (entity_is_task(se)) {
-               add_cfs_task_weight(cfs_rq, se->load.weight);
+//             add_cfs_task_weight(cfs_rq, se->load.weight);
                list_add(&se->group_node, &cfs_rq->tasks);
        }
        cfs_rq->nr_running++;
@@ -689,11 +689,11 @@ account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
 static void
 account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-       update_load_sub(&cfs_rq->load, se->load.weight);
+//     update_load_sub(&cfs_rq->load, se->load.weight);
        if (!parent_entity(se))
-               dec_cpu_load(rq_of(cfs_rq), se->load.weight);
+//             dec_cpu_load(rq_of(cfs_rq), se->load.weight);
        if (entity_is_task(se)) {
-               add_cfs_task_weight(cfs_rq, -se->load.weight);
+//             add_cfs_task_weight(cfs_rq, -se->load.weight);
                list_del_init(&se->group_node);
        }
        cfs_rq->nr_running--;
@@ -701,159 +701,159 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 # ifdef CONFIG_SMP
-static void update_cfs_rq_load_contribution(struct cfs_rq *cfs_rq,
-                                           int global_update)
-{
-       struct task_group *tg = cfs_rq->tg;
-       long load_avg;
-
-       load_avg = div64_u64(cfs_rq->load_avg, cfs_rq->load_period+1);
-       load_avg -= cfs_rq->load_contribution;
-
-       if (global_update || abs(load_avg) > cfs_rq->load_contribution / 8) {
-               atomic_add(load_avg, &tg->load_weight);
-               cfs_rq->load_contribution += load_avg;
-       }
-}
-
-static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
-{
-       u64 period = sysctl_sched_shares_window;
-       u64 now, delta;
-       unsigned long load = cfs_rq->load.weight;
-
-       if (cfs_rq->tg == &root_task_group)
-               return;
-
-       now = rq_of(cfs_rq)->clock_task;
-       delta = now - cfs_rq->load_stamp;
-
-       /* truncate load history at 4 idle periods */
-       if (cfs_rq->load_stamp > cfs_rq->load_last &&
-           now - cfs_rq->load_last > 4 * period) {
-               cfs_rq->load_period = 0;
-               cfs_rq->load_avg = 0;
-       }
-
-       cfs_rq->load_stamp = now;
-       cfs_rq->load_unacc_exec_time = 0;
-       cfs_rq->load_period += delta;
-       if (load) {
-               cfs_rq->load_last = now;
-               cfs_rq->load_avg += delta * load;
-       }
-
-       /* consider updating load contribution on each fold or truncate */
-       if (global_update || cfs_rq->load_period > period
-           || !cfs_rq->load_period)
-               update_cfs_rq_load_contribution(cfs_rq, global_update);
-
-       while (cfs_rq->load_period > period) {
-               /*
-                * Inline assembly required to prevent the compiler
-                * optimising this loop into a divmod call.
-                * See __iter_div_u64_rem() for another example of this.
-                */
-               asm("" : "+rm" (cfs_rq->load_period));
-               cfs_rq->load_period /= 2;
-               cfs_rq->load_avg /= 2;
-       }
-
-       if (!cfs_rq->curr && !cfs_rq->nr_running && !cfs_rq->load_avg)
-               list_del_leaf_cfs_rq(cfs_rq);
-}
-
-static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
-                               long weight_delta)
-{
-       long load_weight, load, shares;
-
-       load = cfs_rq->load.weight + weight_delta;
-
-       load_weight = atomic_read(&tg->load_weight);
-       load_weight -= cfs_rq->load_contribution;
-       load_weight += load;
-
-       shares = (tg->shares * load);
-       if (load_weight)
-               shares /= load_weight;
-
-       if (shares < MIN_SHARES)
-               shares = MIN_SHARES;
-       if (shares > tg->shares)
-               shares = tg->shares;
-
-       return shares;
-}
-
-static void update_entity_shares_tick(struct cfs_rq *cfs_rq)
-{
-       if (cfs_rq->load_unacc_exec_time > sysctl_sched_shares_window) {
-               update_cfs_load(cfs_rq, 0);
-               update_cfs_shares(cfs_rq, 0);
-       }
-}
+//static void update_cfs_rq_load_contribution(struct cfs_rq *cfs_rq,
+//                                         int global_update)
+//{
+//     struct task_group *tg = cfs_rq->tg;
+//     long load_avg;
+//
+//     load_avg = div64_u64(cfs_rq->load_avg, cfs_rq->load_period+1);
+//     load_avg -= cfs_rq->load_contribution;
+//
+//     if (global_update || abs(load_avg) > cfs_rq->load_contribution / 8) {
+//             atomic_add(load_avg, &tg->load_weight);
+//             cfs_rq->load_contribution += load_avg;
+//     }
+//}
+//
+//static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
+//{
+//     u64 period = sysctl_sched_shares_window;
+//     u64 now, delta;
+//     unsigned long load = cfs_rq->load.weight;
+//
+//     if (cfs_rq->tg == &root_task_group)
+//             return;
+//
+//     now = rq_of(cfs_rq)->clock_task;
+//     delta = now - cfs_rq->load_stamp;
+//
+//     /* truncate load history at 4 idle periods */
+//     if (cfs_rq->load_stamp > cfs_rq->load_last &&
+//         now - cfs_rq->load_last > 4 * period) {
+//             cfs_rq->load_period = 0;
+//             cfs_rq->load_avg = 0;
+//     }
+//
+//     cfs_rq->load_stamp = now;
+//     cfs_rq->load_unacc_exec_time = 0;
+//     cfs_rq->load_period += delta;
+//     if (load) {
+//             cfs_rq->load_last = now;
+//             cfs_rq->load_avg += delta * load;
+//     }
+//
+//     /* consider updating load contribution on each fold or truncate */
+//     if (global_update || cfs_rq->load_period > period
+//         || !cfs_rq->load_period)
+//             update_cfs_rq_load_contribution(cfs_rq, global_update);
+//
+//     while (cfs_rq->load_period > period) {
+//             /*
+//              * Inline assembly required to prevent the compiler
+//              * optimising this loop into a divmod call.
+//              * See __iter_div_u64_rem() for another example of this.
+//              */
+//             asm("" : "+rm" (cfs_rq->load_period));
+//             cfs_rq->load_period /= 2;
+//             cfs_rq->load_avg /= 2;
+//     }
+//
+//     if (!cfs_rq->curr && !cfs_rq->nr_running && !cfs_rq->load_avg)
+//             list_del_leaf_cfs_rq(cfs_rq);
+//}
+
+//static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
+//                             long weight_delta)
+//{
+//     long load_weight, load, shares;
+//
+//     load = cfs_rq->load.weight + weight_delta;
+//
+//     load_weight = atomic_read(&tg->load_weight);
+//     load_weight -= cfs_rq->load_contribution;
+//     load_weight += load;
+//
+//     shares = (tg->shares * load);
+//     if (load_weight)
+//             shares /= load_weight;
+//
+//     if (shares < MIN_SHARES)
+//             shares = MIN_SHARES;
+//     if (shares > tg->shares)
+//             shares = tg->shares;
+//
+//     return shares;
+//}
+
+//static void update_entity_shares_tick(struct cfs_rq *cfs_rq)
+//{
+//     if (cfs_rq->load_unacc_exec_time > sysctl_sched_shares_window) {
+//             update_cfs_load(cfs_rq, 0);
+//             update_cfs_shares(cfs_rq, 0);
+//     }
+//}
 # else /* CONFIG_SMP */
-static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
+//static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
 {
 }
 
-static inline long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
-                               long weight_delta)
-{
-       return tg->shares;
-}
+//static inline long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
+//                             long weight_delta)
+//{
+//     return tg->shares;
+//}
 
-static inline void update_entity_shares_tick(struct cfs_rq *cfs_rq)
-{
-}
+//static inline void update_entity_shares_tick(struct cfs_rq *cfs_rq)
+//{
+//}
 # endif /* CONFIG_SMP */
-static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
-                           unsigned long weight)
-{
-       if (se->on_rq) {
-               /* commit outstanding execution time */
-               if (cfs_rq->curr == se)
-                       update_curr(cfs_rq);
-               account_entity_dequeue(cfs_rq, se);
-       }
-
-       update_load_set(&se->load, weight);
-
-       if (se->on_rq)
-               account_entity_enqueue(cfs_rq, se);
-}
-
-static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
-{
-       struct task_group *tg;
-       struct sched_entity *se;
-       long shares;
-
-       tg = cfs_rq->tg;
-       se = tg->se[cpu_of(rq_of(cfs_rq))];
-       if (!se)
-               return;
-#ifndef CONFIG_SMP
-       if (likely(se->load.weight == tg->shares))
-               return;
-#endif
-       shares = calc_cfs_shares(cfs_rq, tg, weight_delta);
-
-       reweight_entity(cfs_rq_of(se), se, shares);
-}
+//static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
+//                         unsigned long weight)
+//{
+//     if (se->on_rq) {
+//             /* commit outstanding execution time */
+//             if (cfs_rq->curr == se)
+//                     update_curr(cfs_rq);
+//             account_entity_dequeue(cfs_rq, se);
+//     }
+//
+////   update_load_set(&se->load, weight);
+//
+//     if (se->on_rq)
+//             account_entity_enqueue(cfs_rq, se);
+//}
+
+//static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
+//{
+//     struct task_group *tg;
+//     struct sched_entity *se;
+//     long shares;
+//
+//     tg = cfs_rq->tg;
+//     se = tg->se[cpu_of(rq_of(cfs_rq))];
+//     if (!se)
+//             return;
+//#ifndef CONFIG_SMP
+//     if (likely(se->load.weight == tg->shares))
+//             return;
+//#endif
+//     shares = calc_cfs_shares(cfs_rq, tg, weight_delta);
+//
+//     reweight_entity(cfs_rq_of(se), se, shares);
+//}
 #else /* CONFIG_FAIR_GROUP_SCHED */
-static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
-{
-}
+//static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
+//{
+//}
 
-static inline void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
-{
-}
+//static inline void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
+//{
+//}
 
-static inline void update_entity_shares_tick(struct cfs_rq *cfs_rq)
-{
-}
+//static inline void update_entity_shares_tick(struct cfs_rq *cfs_rq)
+//{
+//}
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
 static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -940,8 +940,8 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
         * little, place the new task so that it fits in the slot that
         * stays open at the end.
         */
-       if (initial && sched_feat(START_DEBIT))
-               vruntime += sched_vslice(cfs_rq, se);
+//     if (initial && sched_feat(START_DEBIT))
+//             vruntime += sched_vslice(cfs_rq, se);
 
        /* sleeps up to a single latency don't count. */
        if (!initial) {
@@ -977,8 +977,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
         * Update run-time statistics of the 'current'.
         */
        update_curr(cfs_rq);
-       update_cfs_load(cfs_rq, 0);
-       update_cfs_shares(cfs_rq, se->load.weight);
+//     update_cfs_load(cfs_rq, 0);
+//     update_cfs_shares(cfs_rq, se->load.weight);
        account_entity_enqueue(cfs_rq, se);
 
        if (flags & ENQUEUE_WAKEUP) {
@@ -1038,10 +1038,10 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
        if (se != cfs_rq->curr)
                __dequeue_entity(cfs_rq, se);
        se->on_rq = 0;
-       update_cfs_load(cfs_rq, 0);
+//     update_cfs_load(cfs_rq, 0);
        account_entity_dequeue(cfs_rq, se);
        update_min_vruntime(cfs_rq);
-       update_cfs_shares(cfs_rq, 0);
+//     update_cfs_shares(cfs_rq, 0);
 
        /*
         * Normalize the entity after updating the min_vruntime because the
@@ -1058,9 +1058,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 static void
 check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 {
-       unsigned long ideal_runtime, delta_exec;
+       unsigned long ideal_runtime = 0, delta_exec = 0;
 
-       ideal_runtime = sched_slice(cfs_rq, curr);
+//     ideal_runtime = sched_slice(cfs_rq, curr);
        delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
        if (delta_exec > ideal_runtime) {
                resched_task(rq_of(cfs_rq)->curr);
@@ -1111,17 +1111,17 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
 
        update_stats_curr_start(cfs_rq, se);
        cfs_rq->curr = se;
-#ifdef CONFIG_SCHEDSTATS
-       /*
-        * Track our maximum slice length, if the CPU's load is at
-        * least twice that of our own weight (i.e. dont track it
-        * when there are only lesser-weight tasks around):
-        */
-       if (rq_of(cfs_rq)->load.weight >= 2*se->load.weight) {
-               se->statistics.slice_max = max(se->statistics.slice_max,
-                       se->sum_exec_runtime - se->prev_sum_exec_runtime);
-       }
-#endif
+//#ifdef CONFIG_SCHEDSTATS
+//     /*
+//      * Track our maximum slice length, if the CPU's load is at
+//      * least twice that of our own weight (i.e. dont track it
+//      * when there are only lesser-weight tasks around):
+//      */
+//     if (rq_of(cfs_rq)->load.weight >= 2*se->load.weight) {
+//             se->statistics.slice_max = max(se->statistics.slice_max,
+//                     se->sum_exec_runtime - se->prev_sum_exec_runtime);
+//     }
+//#endif
        se->prev_sum_exec_runtime = se->sum_exec_runtime;
 }
 
@@ -1176,7 +1176,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
        /*
         * Update share accounting for long-running entities.
         */
-       update_entity_shares_tick(cfs_rq);
+//     update_entity_shares_tick(cfs_rq);
 
 #ifdef CONFIG_SCHED_HRTICK
        /*
@@ -1212,7 +1212,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
        WARN_ON(task_rq(p) != rq);
 
        if (hrtick_enabled(rq) && cfs_rq->nr_running > 1) {
-               u64 slice = sched_slice(cfs_rq, se);
+               u64 slice = 0;//sched_slice(cfs_rq, se);
                u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime;
                s64 delta = slice - ran;
 
@@ -1278,12 +1278,12 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
                flags = ENQUEUE_WAKEUP;
        }
 
-       for_each_sched_entity(se) {
-               struct cfs_rq *cfs_rq = cfs_rq_of(se);
-
-               update_cfs_load(cfs_rq, 0);
-               update_cfs_shares(cfs_rq, 0);
-       }
+//     for_each_sched_entity(se) {
+//             struct cfs_rq *cfs_rq = cfs_rq_of(se);
+//
+//             update_cfs_load(cfs_rq, 0);
+//             update_cfs_shares(cfs_rq, 0);
+//     }
 
        hrtick_update(rq);
 }
@@ -1303,17 +1303,17 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
                dequeue_entity(cfs_rq, se, flags);
 
                /* Don't dequeue parent if it has other entities besides us */
-               if (cfs_rq->load.weight)
-                       break;
+//             if (cfs_rq->load.weight)
+//                     break;
                flags |= DEQUEUE_SLEEP;
        }
 
-       for_each_sched_entity(se) {
-               struct cfs_rq *cfs_rq = cfs_rq_of(se);
-
-               update_cfs_load(cfs_rq, 0);
-               update_cfs_shares(cfs_rq, 0);
-       }
+//     for_each_sched_entity(se) {
+//             struct cfs_rq *cfs_rq = cfs_rq_of(se);
+//
+//             update_cfs_load(cfs_rq, 0);
+//             update_cfs_shares(cfs_rq, 0);
+//     }
 
        hrtick_update(rq);
 }
@@ -1382,212 +1382,211 @@ static void task_waking_fair(struct rq *rq, struct task_struct *p)
  * of group shares between cpus. Assuming the shares were perfectly aligned one
  * can calculate the shift in shares.
  */
-static long effective_load(struct task_group *tg, int cpu, long wl, long wg)
-{
-       struct sched_entity *se = tg->se[cpu];
-
-       if (!tg->parent)
-               return wl;
-
-       for_each_sched_entity(se) {
-               long lw, w;
-
-               tg = se->my_q->tg;
-               w = se->my_q->load.weight;
-
-               /* use this cpu's instantaneous contribution */
-               lw = atomic_read(&tg->load_weight);
-               lw -= se->my_q->load_contribution;
-               lw += w + wg;
-
-               wl += w;
-
-               if (lw > 0 && wl < lw)
-                       wl = (wl * tg->shares) / lw;
-               else
-                       wl = tg->shares;
-
-               /* zero point is MIN_SHARES */
-               if (wl < MIN_SHARES)
-                       wl = MIN_SHARES;
-               wl -= se->load.weight;
-               wg = 0;
-       }
-
-       return wl;
-}
+//static long effective_load(struct task_group *tg, int cpu, long wl, long wg)
+//{
+//     struct sched_entity *se = tg->se[cpu];
+//
+//     if (!tg->parent)
+//             return wl;
+//
+//     for_each_sched_entity(se) {
+//             long lw = 0, w = 0;
+//
+//             tg = se->my_q->tg;
+//             w = se->my_q->load.weight;
+//
+//             /* use this cpu's instantaneous contribution */
+////           lw = atomic_read(&tg->load_weight);
+////           lw -= se->my_q->load_contribution;
+//             lw += w + wg;
+//
+//             wl += w;
+//
+//             if (lw > 0 && wl < lw)
+//                     wl = (wl * tg->shares) / lw;
+//             else
+//                     wl = tg->shares;
+//
+//             /* zero point is MIN_SHARES */
+//             if (wl < MIN_SHARES)
+//                     wl = MIN_SHARES;
+//             wl -= se->load.weight;
+//             wg = 0;
+//     }
+//
+//     return wl;
+//}
 
 #else
 
-static inline unsigned long effective_load(struct task_group *tg, int cpu,
-               unsigned long wl, unsigned long wg)
-{
-       return wl;
-}
+//static inline unsigned long effective_load(struct task_group *tg, int cpu,
+//             unsigned long wl, unsigned long wg)
+//{
+//     return wl;
+//}
 
 #endif
 
-static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
-{
-       s64 this_load, load;
-       int idx, this_cpu, prev_cpu;
-       unsigned long tl_per_task;
-       struct task_group *tg;
-       unsigned long weight;
-       int balanced;
-
-       idx       = sd->wake_idx;
-       this_cpu  = smp_processor_id();
-       prev_cpu  = task_cpu(p);
-       load      = source_load(prev_cpu, idx);
-       this_load = target_load(this_cpu, idx);
-
-       /*
-        * If sync wakeup then subtract the (maximum possible)
-        * effect of the currently running task from the load
-        * of the current CPU:
-        */
-       rcu_read_lock();
-       if (sync) {
-               tg = task_group(current);
-               weight = current->se.load.weight;
-
-               this_load += effective_load(tg, this_cpu, -weight, -weight);
-               load += effective_load(tg, prev_cpu, 0, -weight);
-       }
-
-       tg = task_group(p);
-       weight = p->se.load.weight;
-
-       /*
-        * In low-load situations, where prev_cpu is idle and this_cpu is idle
-        * due to the sync cause above having dropped this_load to 0, we'll
-        * always have an imbalance, but there's really nothing you can do
-        * about that, so that's good too.
-        *
-        * Otherwise check if either cpus are near enough in load to allow this
-        * task to be woken on this_cpu.
-        */
-       if (this_load > 0) {
-               s64 this_eff_load, prev_eff_load;
-
-               this_eff_load = 100;
-               this_eff_load *= power_of(prev_cpu);
-               this_eff_load *= this_load +
-                       effective_load(tg, this_cpu, weight, weight);
-
-               prev_eff_load = 100 + (sd->imbalance_pct - 100) / 2;
-               prev_eff_load *= power_of(this_cpu);
-               prev_eff_load *= load + effective_load(tg, prev_cpu, 0, weight);
-
-               balanced = this_eff_load <= prev_eff_load;
-       } else
-               balanced = true;
-       rcu_read_unlock();
-
-       /*
-        * If the currently running task will sleep within
-        * a reasonable amount of time then attract this newly
-        * woken task:
-        */
-       if (sync && balanced)
-               return 1;
-
-       schedstat_inc(p, se.statistics.nr_wakeups_affine_attempts);
-       tl_per_task = cpu_avg_load_per_task(this_cpu);
-
-       if (balanced ||
-           (this_load <= load &&
-            this_load + target_load(prev_cpu, idx) <= tl_per_task)) {
-               /*
-                * This domain has SD_WAKE_AFFINE and
-                * p is cache cold in this domain, and
-                * there is no bad imbalance.
-                */
-               schedstat_inc(sd, ttwu_move_affine);
-               schedstat_inc(p, se.statistics.nr_wakeups_affine);
-
-               return 1;
-       }
-       return 0;
-}
+//static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
+//{
+//     s64 this_load, load;
+//     int idx, this_cpu, prev_cpu;
+//     unsigned long tl_per_task;
+//     struct task_group *tg;
+//     unsigned long weight;
+//     int balanced;
+//
+//     idx       = sd->wake_idx;
+//     this_cpu  = smp_processor_id();
+//     prev_cpu  = task_cpu(p);
+//     load      = source_load(prev_cpu, idx);
+//     this_load = target_load(this_cpu, idx);
+//
+//     /*
+//      * If sync wakeup then subtract the (maximum possible)
+//      * effect of the currently running task from the load
+//      * of the current CPU:
+//      */
+//     rcu_read_lock();
+//     if (sync) {
+//             tg = task_group(current);
+////           weight = current->se.load.weight;
+//
+////           this_load += effective_load(tg, this_cpu, -weight, -weight);
+////           load += effective_load(tg, prev_cpu, 0, -weight);
+//     }
+//
+//     tg = task_group(p);
+//     weight = p->se.load.weight;
+//
+//     /*
+//      * In low-load situations, where prev_cpu is idle and this_cpu is idle
+//      * due to the sync cause above having dropped this_load to 0, we'll
+//      * always have an imbalance, but there's really nothing you can do
+//      * about that, so that's good too.
+//      *
+//      * Otherwise check if either cpus are near enough in load to allow this
+//      * task to be woken on this_cpu.
+//      */
+//     if (this_load > 0) {
+//             s64 this_eff_load, prev_eff_load;
+//
+//             this_eff_load = 100;
+//             this_eff_load *= power_of(prev_cpu);
+//             this_eff_load *= this_load +
+//                     effective_load(tg, this_cpu, weight, weight);
+//
+//             prev_eff_load = 100 + (sd->imbalance_pct - 100) / 2;
+//             prev_eff_load *= power_of(this_cpu);
+//             prev_eff_load *= load + effective_load(tg, prev_cpu, 0, weight);
+//
+//             balanced = this_eff_load <= prev_eff_load;
+//     } else
+//             balanced = true;
+//     rcu_read_unlock();
+//
+//     /*
+//      * If the currently running task will sleep within
+//      * a reasonable amount of time then attract this newly
+//      * woken task:
+//      */
+//     if (sync && balanced)
+//             return 1;
+//
+//     schedstat_inc(p, se.statistics.nr_wakeups_affine_attempts);
+////   tl_per_task = cpu_avg_load_per_task(this_cpu);
+//
+//     if (balanced ||
+//         (this_load <= load /*&&
+//          this_load + target_load(prev_cpu, idx) <= tl_per_task*/)) {
+//             /*
+//              * This domain has SD_WAKE_AFFINE and
+//              * p is cache cold in this domain, and
+//              * there is no bad imbalance.
+//              */
+//             schedstat_inc(sd, ttwu_move_affine);
+//             schedstat_inc(p, se.statistics.nr_wakeups_affine);
+//
+//             return 1;
+//     }
+//}
 
 /*
  * find_idlest_group finds and returns the least busy CPU group within the
  * domain.
  */
-static struct sched_group *
-find_idlest_group(struct sched_domain *sd, struct task_struct *p,
-                 int this_cpu, int load_idx)
-{
-       struct sched_group *idlest = NULL, *group = sd->groups;
-       unsigned long min_load = ULONG_MAX, this_load = 0;
-       int imbalance = 100 + (sd->imbalance_pct-100)/2;
-
-       do {
-               unsigned long load, avg_load;
-               int local_group;
-               int i;
-
-               /* Skip over this group if it has no CPUs allowed */
-               if (!cpumask_intersects(sched_group_cpus(group),
-                                       &p->cpus_allowed))
-                       continue;
-
-               local_group = cpumask_test_cpu(this_cpu,
-                                              sched_group_cpus(group));
-
-               /* Tally up the load of all CPUs in the group */
-               avg_load = 0;
-
-               for_each_cpu(i, sched_group_cpus(group)) {
-                       /* Bias balancing toward cpus of our domain */
-                       if (local_group)
-                               load = source_load(i, load_idx);
-                       else
-                               load = target_load(i, load_idx);
-
-                       avg_load += load;
-               }
-
-               /* Adjust by relative CPU power of the group */
-               avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power;
-
-               if (local_group) {
-                       this_load = avg_load;
-               } else if (avg_load < min_load) {
-                       min_load = avg_load;
-                       idlest = group;
-               }
-       } while (group = group->next, group != sd->groups);
-
-       if (!idlest || 100*this_load < imbalance*min_load)
-               return NULL;
-       return idlest;
-}
+//static struct sched_group *
+//find_idlest_group(struct sched_domain *sd, struct task_struct *p,
+//               int this_cpu, int load_idx)
+//{
+//     struct sched_group *idlest = NULL, *group = sd->groups;
+//     unsigned long min_load = ULONG_MAX, this_load = 0;
+//     int imbalance = 100 + (sd->imbalance_pct-100)/2;
+//
+//     do {
+//             unsigned long load, avg_load;
+//             int local_group;
+//             int i;
+//
+//             /* Skip over this group if it has no CPUs allowed */
+//             if (!cpumask_intersects(sched_group_cpus(group),
+//                                     &p->cpus_allowed))
+//                     continue;
+//
+//             local_group = cpumask_test_cpu(this_cpu,
+//                                            sched_group_cpus(group));
+//
+//             /* Tally up the load of all CPUs in the group */
+//             avg_load = 0;
+//
+////           for_each_cpu(i, sched_group_cpus(group)) {
+////                   /* Bias balancing toward cpus of our domain */
+////                   if (local_group)
+////                           load = source_load(i, load_idx);
+////                   else
+////                           load = target_load(i, load_idx);
+////
+////                   avg_load += load;
+////           }
+//
+//             /* Adjust by relative CPU power of the group */
+//             avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power;
+//
+//             if (local_group) {
+//                     this_load = avg_load;
+//             } else if (avg_load < min_load) {
+//                     min_load = avg_load;
+//                     idlest = group;
+//             }
+//     } while (group = group->next, group != sd->groups);
+//
+//     if (!idlest || 100*this_load < imbalance*min_load)
+//             return NULL;
+//     return idlest;
+//}
 
 /*
  * find_idlest_cpu - find the idlest cpu among the cpus in group.
  */
-static int
-find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
-{
-       unsigned long load, min_load = ULONG_MAX;
-       int idlest = -1;
-       int i;
-
-       /* Traverse only the allowed CPUs */
-       for_each_cpu_and(i, sched_group_cpus(group), &p->cpus_allowed) {
-               load = weighted_cpuload(i);
-
-               if (load < min_load || (load == min_load && i == this_cpu)) {
-                       min_load = load;
-                       idlest = i;
-               }
-       }
-
-       return idlest;
-}
+//static int
+//find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
+//{
+//     unsigned long load = 0, min_load = ULONG_MAX;
+//     int idlest = -1;
+//     int i;
+//
+//     /* Traverse only the allowed CPUs */
+//     for_each_cpu_and(i, sched_group_cpus(group), &p->cpus_allowed) {
+////           load = weighted_cpuload(i);
+//
+//             if (load < min_load || (load == min_load && i == this_cpu)) {
+//                     min_load = load;
+//                     idlest = i;
+//             }
+//     }
+//
+//     return idlest;
+//}
 
 /*
  * Try and locate an idle CPU in the sched_domain.
@@ -1659,7 +1658,7 @@ select_task_rq_fair(struct rq *rq, struct task_struct *p, int sd_flag, int wake_
        int new_cpu = cpu;
        int want_affine = 0;
        int want_sd = 1;
-       int sync = wake_flags & WF_SYNC;
+//     int sync = wake_flags & WF_SYNC;
 
        if (sd_flag & SD_BALANCE_WAKE) {
                if (cpumask_test_cpu(cpu, &p->cpus_allowed))
@@ -1716,15 +1715,15 @@ select_task_rq_fair(struct rq *rq, struct task_struct *p, int sd_flag, int wake_
        }
 
        if (affine_sd) {
-               if (cpu == prev_cpu || wake_affine(affine_sd, p, sync))
+               if (cpu == prev_cpu /*|| wake_affine(affine_sd, p, sync)*/)
                        return select_idle_sibling(p, cpu);
                else
                        return select_idle_sibling(p, prev_cpu);
        }
 
        while (sd) {
-               int load_idx = sd->forkexec_idx;
-               struct sched_group *group;
+//             int load_idx = sd->forkexec_idx;
+//             struct sched_group *group;
                int weight;
 
                if (!(sd->flags & sd_flag)) {
@@ -1732,16 +1731,16 @@ select_task_rq_fair(struct rq *rq, struct task_struct *p, int sd_flag, int wake_
                        continue;
                }
 
-               if (sd_flag & SD_BALANCE_WAKE)
-                       load_idx = sd->wake_idx;
+//             if (sd_flag & SD_BALANCE_WAKE)
+//                     load_idx = sd->wake_idx;
 
-               group = find_idlest_group(sd, p, cpu, load_idx);
-               if (!group) {
-                       sd = sd->child;
-                       continue;
-               }
+//             group = find_idlest_group(sd, p, cpu, load_idx);
+//             if (!group) {
+//                     sd = sd->child;
+//                     continue;
+//             }
 
-               new_cpu = find_idlest_cpu(group, p, cpu);
+//             new_cpu = find_idlest_cpu(group, p, cpu);
                if (new_cpu == -1 || new_cpu == cpu) {
                        /* Now try balancing at a lower domain level of cpu */
                        sd = sd->child;
@@ -1783,8 +1782,8 @@ wakeup_gran(struct sched_entity *curr, struct sched_entity *se)
         * This is especially important for buddies when the leftmost
         * task is higher priority than the buddy.
         */
-       if (unlikely(se->load.weight != NICE_0_LOAD))
-               gran = calc_delta_fair(gran, se);
+//     if (unlikely(se->load.weight != NICE_0_LOAD))
+//             gran = calc_delta_fair(gran, se);
 
        return gran;
 }
@@ -1941,65 +1940,65 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev)
  * pull_task - move a task from a remote runqueue to the local runqueue.
  * Both runqueues must be locked.
  */
-static void pull_task(struct rq *src_rq, struct task_struct *p,
-                     struct rq *this_rq, int this_cpu)
-{
-       deactivate_task(src_rq, p, 0);
-       set_task_cpu(p, this_cpu);
-       activate_task(this_rq, p, 0);
-       check_preempt_curr(this_rq, p, 0);
-}
+//static void pull_task(struct rq *src_rq, struct task_struct *p,
+//                   struct rq *this_rq, int this_cpu)
+//{
+//     deactivate_task(src_rq, p, 0);
+//     set_task_cpu(p, this_cpu);
+//     activate_task(this_rq, p, 0);
+//     check_preempt_curr(this_rq, p, 0);
+//}
 
 /*
  * can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
  */
-static
-int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
-                    struct sched_domain *sd, enum cpu_idle_type idle,
-                    int *all_pinned)
-{
-       int tsk_cache_hot = 0;
-       /*
-        * We do not migrate tasks that are:
-        * 1) running (obviously), or
-        * 2) cannot be migrated to this CPU due to cpus_allowed, or
-        * 3) are cache-hot on their current CPU.
-        */
-       if (!cpumask_test_cpu(this_cpu, &p->cpus_allowed)) {
-               schedstat_inc(p, se.statistics.nr_failed_migrations_affine);
-               return 0;
-       }
-       *all_pinned = 0;
-
-       if (task_running(rq, p)) {
-               schedstat_inc(p, se.statistics.nr_failed_migrations_running);
-               return 0;
-       }
-
-       /*
-        * Aggressive migration if:
-        * 1) task is cache cold, or
-        * 2) too many balance attempts have failed.
-        */
-
-       tsk_cache_hot = task_hot(p, rq->clock_task, sd);
-       if (!tsk_cache_hot ||
-               sd->nr_balance_failed > sd->cache_nice_tries) {
-#ifdef CONFIG_SCHEDSTATS
-               if (tsk_cache_hot) {
-                       schedstat_inc(sd, lb_hot_gained[idle]);
-                       schedstat_inc(p, se.statistics.nr_forced_migrations);
-               }
-#endif
-               return 1;
-       }
-
-       if (tsk_cache_hot) {
-               schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
-               return 0;
-       }
-       return 1;
-}
+//static
+//int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
+//                  struct sched_domain *sd, enum cpu_idle_type idle,
+//                  int *all_pinned)
+//{
+//     int tsk_cache_hot = 0;
+//     /*
+//      * We do not migrate tasks that are:
+//      * 1) running (obviously), or
+//      * 2) cannot be migrated to this CPU due to cpus_allowed, or
+//      * 3) are cache-hot on their current CPU.
+//      */
+//     if (!cpumask_test_cpu(this_cpu, &p->cpus_allowed)) {
+//             schedstat_inc(p, se.statistics.nr_failed_migrations_affine);
+//             return 0;
+//     }
+//     *all_pinned = 0;
+//
+//     if (task_running(rq, p)) {
+//             schedstat_inc(p, se.statistics.nr_failed_migrations_running);
+//             return 0;
+//     }
+//
+//     /*
+//      * Aggressive migration if:
+//      * 1) task is cache cold, or
+//      * 2) too many balance attempts have failed.
+//      */
+//
+//     tsk_cache_hot = task_hot(p, rq->clock_task, sd);
+//     if (!tsk_cache_hot ||
+//             sd->nr_balance_failed > sd->cache_nice_tries) {
+//#ifdef CONFIG_SCHEDSTATS
+//             if (tsk_cache_hot) {
+//                     schedstat_inc(sd, lb_hot_gained[idle]);
+//                     schedstat_inc(p, se.statistics.nr_forced_migrations);
+//             }
+//#endif
+//             return 1;
+//     }
+//
+//     if (tsk_cache_hot) {
+//             schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
+//             return 0;
+//     }
+//     return 1;
+//}
 
 /*
  * move_one_task tries to move exactly one task from busiest to this_rq, as
@@ -2008,330 +2007,326 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
  *
  * Called with both runqueues locked.
  */
-static int
-move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest,
-             struct sched_domain *sd, enum cpu_idle_type idle)
-{
-       struct task_struct *p, *n;
-       struct cfs_rq *cfs_rq;
-       int pinned = 0;
+//static int
+//move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest,
+//           struct sched_domain *sd, enum cpu_idle_type idle)
+//{
+//     struct task_struct *p, *n;
+//     struct cfs_rq *cfs_rq;
+//     int pinned = 0;
+//
+//     for_each_leaf_cfs_rq(busiest, cfs_rq) {
+//             list_for_each_entry_safe(p, n, &cfs_rq->tasks, se.group_node) {
+//
+//                     if (!can_migrate_task(p, busiest, this_cpu,
+//                                             sd, idle, &pinned))
+//                             continue;
+//
+//                     pull_task(busiest, p, this_rq, this_cpu);
+//                     /*
+//                      * Right now, this is only the second place pull_task()
+//                      * is called, so we can safely collect pull_task()
+//                      * stats here rather than inside pull_task().
+//                      */
+//                     schedstat_inc(sd, lb_gained[idle]);
+//                     return 1;
+//             }
+//     }
+//
+//     return 0;
+//}
+
+//static unsigned long
+//balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
+//           unsigned long max_load_move, struct sched_domain *sd,
+//           enum cpu_idle_type idle, int *all_pinned,
+//           int *this_best_prio, struct cfs_rq *busiest_cfs_rq)
+//{
+//     int loops = 0, pulled = 0;
+//     long rem_load_move = max_load_move;
+//     struct task_struct *p, *n;
+//
+//     if (max_load_move == 0)
+//             goto out;
+//
+//     list_for_each_entry_safe(p, n, &busiest_cfs_rq->tasks, se.group_node) {
+//             if (loops++ > sysctl_sched_nr_migrate)
+//                     break;
+//
+//             if ((p->se.load.weight >> 1) > rem_load_move ||
+//                 !can_migrate_task(p, busiest, this_cpu, sd, idle,
+//                                   all_pinned))
+//                     continue;
+//
+//             pull_task(busiest, p, this_rq, this_cpu);
+//             pulled++;
+//             rem_load_move -= p->se.load.weight;
+//
+//#ifdef CONFIG_PREEMPT
+//             /*
+//              * NEWIDLE balancing is a source of latency, so preemptible
+//              * kernels will stop after the first task is pulled to minimize
+//              * the critical section.
+//              */
+//             if (idle == CPU_NEWLY_IDLE)
+//                     break;
+//#endif
+//
+//             /*
+//              * We only want to steal up to the prescribed amount of
+//              * weighted load.
+//              */
+//             if (rem_load_move <= 0)
+//                     break;
+//
+//             if (p->prio < *this_best_prio)
+//                     *this_best_prio = p->prio;
+//     }
+//out:
+//     /*
+//      * Right now, this is one of only two places pull_task() is called,
+//      * so we can safely collect pull_task() stats here rather than
+//      * inside pull_task().
+//      */
+//     schedstat_add(sd, lb_gained[idle], pulled);
+//
+//     return max_load_move - rem_load_move;
+//}
 
-       for_each_leaf_cfs_rq(busiest, cfs_rq) {
-               list_for_each_entry_safe(p, n, &cfs_rq->tasks, se.group_node) {
+#ifdef CONFIG_FAIR_GROUP_SCHED
+/*
+ * update tg->load_weight by folding this cpu's load_avg
+ */
+//static int update_shares_cpu(struct task_group *tg, int cpu)
+//{
+//     struct cfs_rq *cfs_rq;
+//     unsigned long flags;
+//     struct rq *rq;
+//
+//     if (!tg->se[cpu])
+//             return 0;
+//
+//     rq = cpu_rq(cpu);
+//     cfs_rq = tg->cfs_rq[cpu];
+//
+//     raw_spin_lock_irqsave(&rq->lock, flags);
+//
+//     update_rq_clock(rq);
+////   update_cfs_load(cfs_rq, 1);
+//
+//     /*
+//      * We need to update shares after updating tg->load_weight in
+//      * order to adjust the weight of groups with long running tasks.
+//      */
+////   update_cfs_shares(cfs_rq, 0);
+//
+//     raw_spin_unlock_irqrestore(&rq->lock, flags);
+//
+//     return 0;
+//}
+
+//static void update_shares(int cpu)
+//{
+//     struct cfs_rq *cfs_rq;
+//     struct rq *rq = cpu_rq(cpu);
+//
+//     rcu_read_lock();
+//     for_each_leaf_cfs_rq(rq, cfs_rq)
+//             update_shares_cpu(cfs_rq->tg, cpu);
+//     rcu_read_unlock();
+//}
+
+//static unsigned long
+//load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
+//               unsigned long max_load_move,
+//               struct sched_domain *sd, enum cpu_idle_type idle,
+//               int *all_pinned, int *this_best_prio)
+//{
+//     long rem_load_move = max_load_move;
+//     int busiest_cpu = cpu_of(busiest);
+//     struct task_group *tg;
+//
+//     rcu_read_lock();
+////   update_h_load(busiest_cpu);
+//
+//     list_for_each_entry_rcu(tg, &task_groups, list) {
+//             struct cfs_rq *busiest_cfs_rq = tg->cfs_rq[busiest_cpu];
+//             unsigned long busiest_h_load = busiest_cfs_rq->h_load;
+//             unsigned long busiest_weight = busiest_cfs_rq->load.weight;
+//             u64 rem_load, moved_load;
+//
+//             /*
+//              * empty group
+//              */
+//             if (!busiest_cfs_rq->task_weight)
+//                     continue;
+//
+//             rem_load = (u64)rem_load_move * busiest_weight;
+//             rem_load = div_u64(rem_load, busiest_h_load + 1);
+//
+//             moved_load = balance_tasks(this_rq, this_cpu, busiest,
+//                             rem_load, sd, idle, all_pinned, this_best_prio,
+//                             busiest_cfs_rq);
+//
+//             if (!moved_load)
+//                     continue;
+//
+//             moved_load *= busiest_h_load;
+//             moved_load = div_u64(moved_load, busiest_weight + 1);
+//
+//             rem_load_move -= moved_load;
+//             if (rem_load_move < 0)
+//                     break;
+//     }
+//     rcu_read_unlock();
+//
+//     return max_load_move - rem_load_move;
+//}
+#else
+//static inline void update_shares(int cpu)
+//{
+//}
+
+//static unsigned long
+//load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
+//               unsigned long max_load_move,
+//               struct sched_domain *sd, enum cpu_idle_type idle,
+//               int *all_pinned, int *this_best_prio)
+//{
+//     return balance_tasks(this_rq, this_cpu, busiest,
+//                     max_load_move, sd, idle, all_pinned,
+//                     this_best_prio, &busiest->cfs);
+//}
+#endif
 
-                       if (!can_migrate_task(p, busiest, this_cpu,
-                                               sd, idle, &pinned))
-                               continue;
+/*
+ * move_tasks tries to move up to max_load_move weighted load from busiest to
+ * this_rq, as part of a balancing operation within domain "sd".
+ * Returns 1 if successful and 0 otherwise.
+ *
+ * Called with both runqueues locked.
+ */
+//static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
+//                   unsigned long max_load_move,
+//                   struct sched_domain *sd, enum cpu_idle_type idle,
+//                   int *all_pinned)
+//{
+//     unsigned long total_load_moved = 0, load_moved;
+//     int this_best_prio = this_rq->curr->prio;
+//
+//     do {
+//             load_moved = load_balance_fair(this_rq, this_cpu, busiest,
+//                             max_load_move - total_load_moved,
+//                             sd, idle, all_pinned, &this_best_prio);
+//
+//             total_load_moved += load_moved;
+//
+//#ifdef CONFIG_PREEMPT
+//             /*
+//              * NEWIDLE balancing is a source of latency, so preemptible
+//              * kernels will stop after the first task is pulled to minimize
+//              * the critical section.
+//              */
+//             if (idle == CPU_NEWLY_IDLE && this_rq->nr_running)
+//                     break;
+//
+//             if (raw_spin_is_contended(&this_rq->lock) ||
+//                             raw_spin_is_contended(&busiest->lock))
+//                     break;
+//#endif
+//     } while (load_moved && max_load_move > total_load_moved);
+//
+//     return total_load_moved > 0;
+//}
 
-                       pull_task(busiest, p, this_rq, this_cpu);
-                       /*
-                        * Right now, this is only the second place pull_task()
-                        * is called, so we can safely collect pull_task()
-                        * stats here rather than inside pull_task().
-                        */
-                       schedstat_inc(sd, lb_gained[idle]);
-                       return 1;
-               }
-       }
+/********** Helpers for find_busiest_group ************************/
+/*
+ * sd_lb_stats - Structure to store the statistics of a sched_domain
+ *             during load balancing.
+ */
+//struct sd_lb_stats {
+//     struct sched_group *busiest; /* Busiest group in this sd */
+//     struct sched_group *this;  /* Local group in this sd */
+////   unsigned long total_load;  /* Total load of all groups in sd */
+////   unsigned long total_pwr;   /*   Total power of all groups in sd */
+////   unsigned long avg_load;    /* Average load across all groups in sd */
+//
+//     /** Statistics of this group */
+////   unsigned long this_load;
+////   unsigned long this_load_per_task;
+//     unsigned long this_nr_running;
+////   unsigned long this_has_capacity;
+//     unsigned int  this_idle_cpus;
+//
+//     /* Statistics of the busiest group */
+//     unsigned int  busiest_idle_cpus;
+//     unsigned long max_load;
+//     unsigned long busiest_load_per_task;
+//     unsigned long busiest_nr_running;
+//     unsigned long busiest_group_capacity;
+//     unsigned long busiest_has_capacity;
+//     unsigned int  busiest_group_weight;
+//
+//     int group_imb; /* Is there imbalance in this sd */
+//#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
+////   int power_savings_balance; /* Is powersave balance needed for this sd */
+//     struct sched_group *group_min; /* Least loaded group in sd */
+//     struct sched_group *group_leader; /* Group which relieves group_min */
+////   unsigned long min_load_per_task; /* load_per_task in group_min */
+//     unsigned long leader_nr_running; /* Nr running of group_leader */
+//     unsigned long min_nr_running; /* Nr running of group_min */
+//#endif
+//};
 
-       return 0;
+/*
+ * sg_lb_stats - stats of a sched_group required for load_balancing
+ */
+//struct sg_lb_stats {
+////   unsigned long avg_load; /*Avg load across the CPUs of the group */
+////   unsigned long group_load; /* Total load over the CPUs of the group */
+//     unsigned long sum_nr_running; /* Nr tasks running in the group */
+////   unsigned long sum_weighted_load; /* Weighted load of group's tasks */
+////   unsigned long group_capacity;
+//     unsigned long idle_cpus;
+////   unsigned long group_weight;
+////   int group_imb; /* Is there an imbalance in the group ? */
+////   int group_has_capacity; /* Is there extra capacity in the group? */
+//};
+
+/**
+ * group_first_cpu - Returns the first cpu in the cpumask of a sched_group.
+ * @group: The group whose first cpu is to be returned.
+ */
+static inline unsigned int group_first_cpu(struct sched_group *group)
+{
+       return cpumask_first(sched_group_cpus(group));
 }
 
-static unsigned long
-balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
-             unsigned long max_load_move, struct sched_domain *sd,
-             enum cpu_idle_type idle, int *all_pinned,
-             int *this_best_prio, struct cfs_rq *busiest_cfs_rq)
+/**
+ * get_sd_load_idx - Obtain the load index for a given sched domain.
+ * @sd: The sched_domain whose load_idx is to be obtained.
+ * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
+ */
+static inline int get_sd_load_idx(struct sched_domain *sd,
+                                       enum cpu_idle_type idle)
 {
-       int loops = 0, pulled = 0, pinned = 0;
-       long rem_load_move = max_load_move;
-       struct task_struct *p, *n;
+       int load_idx;
 
-       if (max_load_move == 0)
-               goto out;
+       switch (idle) {
+       case CPU_NOT_IDLE:
+               load_idx = sd->busy_idx;
+               break;
 
-       pinned = 1;
+       case CPU_NEWLY_IDLE:
+               load_idx = sd->newidle_idx;
+               break;
+       default:
+               load_idx = sd->idle_idx;
+               break;
+       }
 
-       list_for_each_entry_safe(p, n, &busiest_cfs_rq->tasks, se.group_node) {
-               if (loops++ > sysctl_sched_nr_migrate)
-                       break;
-
-               if ((p->se.load.weight >> 1) > rem_load_move ||
-                   !can_migrate_task(p, busiest, this_cpu, sd, idle, &pinned))
-                       continue;
-
-               pull_task(busiest, p, this_rq, this_cpu);
-               pulled++;
-               rem_load_move -= p->se.load.weight;
-
-#ifdef CONFIG_PREEMPT
-               /*
-                * NEWIDLE balancing is a source of latency, so preemptible
-                * kernels will stop after the first task is pulled to minimize
-                * the critical section.
-                */
-               if (idle == CPU_NEWLY_IDLE)
-                       break;
-#endif
-
-               /*
-                * We only want to steal up to the prescribed amount of
-                * weighted load.
-                */
-               if (rem_load_move <= 0)
-                       break;
-
-               if (p->prio < *this_best_prio)
-                       *this_best_prio = p->prio;
-       }
-out:
-       /*
-        * Right now, this is one of only two places pull_task() is called,
-        * so we can safely collect pull_task() stats here rather than
-        * inside pull_task().
-        */
-       schedstat_add(sd, lb_gained[idle], pulled);
-
-       if (all_pinned)
-               *all_pinned = pinned;
-
-       return max_load_move - rem_load_move;
-}
-
-#ifdef CONFIG_FAIR_GROUP_SCHED
-/*
- * update tg->load_weight by folding this cpu's load_avg
- */
-static int update_shares_cpu(struct task_group *tg, int cpu)
-{
-       struct cfs_rq *cfs_rq;
-       unsigned long flags;
-       struct rq *rq;
-
-       if (!tg->se[cpu])
-               return 0;
-
-       rq = cpu_rq(cpu);
-       cfs_rq = tg->cfs_rq[cpu];
-
-       raw_spin_lock_irqsave(&rq->lock, flags);
-
-       update_rq_clock(rq);
-       update_cfs_load(cfs_rq, 1);
-
-       /*
-        * We need to update shares after updating tg->load_weight in
-        * order to adjust the weight of groups with long running tasks.
-        */
-       update_cfs_shares(cfs_rq, 0);
-
-       raw_spin_unlock_irqrestore(&rq->lock, flags);
-
-       return 0;
-}
-
-static void update_shares(int cpu)
-{
-       struct cfs_rq *cfs_rq;
-       struct rq *rq = cpu_rq(cpu);
-
-       rcu_read_lock();
-       for_each_leaf_cfs_rq(rq, cfs_rq)
-               update_shares_cpu(cfs_rq->tg, cpu);
-       rcu_read_unlock();
-}
-
-static unsigned long
-load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
-                 unsigned long max_load_move,
-                 struct sched_domain *sd, enum cpu_idle_type idle,
-                 int *all_pinned, int *this_best_prio)
-{
-       long rem_load_move = max_load_move;
-       int busiest_cpu = cpu_of(busiest);
-       struct task_group *tg;
-
-       rcu_read_lock();
-       update_h_load(busiest_cpu);
-
-       list_for_each_entry_rcu(tg, &task_groups, list) {
-               struct cfs_rq *busiest_cfs_rq = tg->cfs_rq[busiest_cpu];
-               unsigned long busiest_h_load = busiest_cfs_rq->h_load;
-               unsigned long busiest_weight = busiest_cfs_rq->load.weight;
-               u64 rem_load, moved_load;
-
-               /*
-                * empty group
-                */
-               if (!busiest_cfs_rq->task_weight)
-                       continue;
-
-               rem_load = (u64)rem_load_move * busiest_weight;
-               rem_load = div_u64(rem_load, busiest_h_load + 1);
-
-               moved_load = balance_tasks(this_rq, this_cpu, busiest,
-                               rem_load, sd, idle, all_pinned, this_best_prio,
-                               busiest_cfs_rq);
-
-               if (!moved_load)
-                       continue;
-
-               moved_load *= busiest_h_load;
-               moved_load = div_u64(moved_load, busiest_weight + 1);
-
-               rem_load_move -= moved_load;
-               if (rem_load_move < 0)
-                       break;
-       }
-       rcu_read_unlock();
-
-       return max_load_move - rem_load_move;
-}
-#else
-static inline void update_shares(int cpu)
-{
-}
-
-static unsigned long
-load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
-                 unsigned long max_load_move,
-                 struct sched_domain *sd, enum cpu_idle_type idle,
-                 int *all_pinned, int *this_best_prio)
-{
-       return balance_tasks(this_rq, this_cpu, busiest,
-                       max_load_move, sd, idle, all_pinned,
-                       this_best_prio, &busiest->cfs);
-}
-#endif
-
-/*
- * move_tasks tries to move up to max_load_move weighted load from busiest to
- * this_rq, as part of a balancing operation within domain "sd".
- * Returns 1 if successful and 0 otherwise.
- *
- * Called with both runqueues locked.
- */
-static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
-                     unsigned long max_load_move,
-                     struct sched_domain *sd, enum cpu_idle_type idle,
-                     int *all_pinned)
-{
-       unsigned long total_load_moved = 0, load_moved;
-       int this_best_prio = this_rq->curr->prio;
-
-       do {
-               load_moved = load_balance_fair(this_rq, this_cpu, busiest,
-                               max_load_move - total_load_moved,
-                               sd, idle, all_pinned, &this_best_prio);
-
-               total_load_moved += load_moved;
-
-#ifdef CONFIG_PREEMPT
-               /*
-                * NEWIDLE balancing is a source of latency, so preemptible
-                * kernels will stop after the first task is pulled to minimize
-                * the critical section.
-                */
-               if (idle == CPU_NEWLY_IDLE && this_rq->nr_running)
-                       break;
-
-               if (raw_spin_is_contended(&this_rq->lock) ||
-                               raw_spin_is_contended(&busiest->lock))
-                       break;
-#endif
-       } while (load_moved && max_load_move > total_load_moved);
-
-       return total_load_moved > 0;
-}
-
-/********** Helpers for find_busiest_group ************************/
-/*
- * sd_lb_stats - Structure to store the statistics of a sched_domain
- *             during load balancing.
- */
-struct sd_lb_stats {
-       struct sched_group *busiest; /* Busiest group in this sd */
-       struct sched_group *this;  /* Local group in this sd */
-       unsigned long total_load;  /* Total load of all groups in sd */
-       unsigned long total_pwr;   /*   Total power of all groups in sd */
-       unsigned long avg_load;    /* Average load across all groups in sd */
-
-       /** Statistics of this group */
-       unsigned long this_load;
-       unsigned long this_load_per_task;
-       unsigned long this_nr_running;
-       unsigned long this_has_capacity;
-       unsigned int  this_idle_cpus;
-
-       /* Statistics of the busiest group */
-       unsigned int  busiest_idle_cpus;
-       unsigned long max_load;
-       unsigned long busiest_load_per_task;
-       unsigned long busiest_nr_running;
-       unsigned long busiest_group_capacity;
-       unsigned long busiest_has_capacity;
-       unsigned int  busiest_group_weight;
-
-       int group_imb; /* Is there imbalance in this sd */
-#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
-       int power_savings_balance; /* Is powersave balance needed for this sd */
-       struct sched_group *group_min; /* Least loaded group in sd */
-       struct sched_group *group_leader; /* Group which relieves group_min */
-       unsigned long min_load_per_task; /* load_per_task in group_min */
-       unsigned long leader_nr_running; /* Nr running of group_leader */
-       unsigned long min_nr_running; /* Nr running of group_min */
-#endif
-};
-
-/*
- * sg_lb_stats - stats of a sched_group required for load_balancing
- */
-struct sg_lb_stats {
-       unsigned long avg_load; /*Avg load across the CPUs of the group */
-       unsigned long group_load; /* Total load over the CPUs of the group */
-       unsigned long sum_nr_running; /* Nr tasks running in the group */
-       unsigned long sum_weighted_load; /* Weighted load of group's tasks */
-       unsigned long group_capacity;
-       unsigned long idle_cpus;
-       unsigned long group_weight;
-       int group_imb; /* Is there an imbalance in the group ? */
-       int group_has_capacity; /* Is there extra capacity in the group? */
-};
-
-/**
- * group_first_cpu - Returns the first cpu in the cpumask of a sched_group.
- * @group: The group whose first cpu is to be returned.
- */
-static inline unsigned int group_first_cpu(struct sched_group *group)
-{
-       return cpumask_first(sched_group_cpus(group));
-}
-
-/**
- * get_sd_load_idx - Obtain the load index for a given sched domain.
- * @sd: The sched_domain whose load_idx is to be obtained.
- * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
- */
-static inline int get_sd_load_idx(struct sched_domain *sd,
-                                       enum cpu_idle_type idle)
-{
-       int load_idx;
-
-       switch (idle) {
-       case CPU_NOT_IDLE:
-               load_idx = sd->busy_idx;
-               break;
-
-       case CPU_NEWLY_IDLE:
-               load_idx = sd->newidle_idx;
-               break;
-       default:
-               load_idx = sd->idle_idx;
-               break;
-       }
-
-       return load_idx;
-}
+       return load_idx;
+}
 
 
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -2343,21 +2338,21 @@ static inline int get_sd_load_idx(struct sched_domain *sd,
  * @sds: Variable containing the statistics for sd.
  * @idle: Idle status of the CPU at which we're performing load-balancing.
  */
-static inline void init_sd_power_savings_stats(struct sched_domain *sd,
-       struct sd_lb_stats *sds, enum cpu_idle_type idle)
-{
-       /*
-        * Busy processors will not participate in power savings
-        * balance.
-        */
-       if (idle == CPU_NOT_IDLE || !(sd->flags & SD_POWERSAVINGS_BALANCE))
-               sds->power_savings_balance = 0;
-       else {
-               sds->power_savings_balance = 1;
-               sds->min_nr_running = ULONG_MAX;
-               sds->leader_nr_running = 0;
-       }
-}
+//static inline void init_sd_power_savings_stats(struct sched_domain *sd,
+//     struct sd_lb_stats *sds, enum cpu_idle_type idle)
+//{
+//     /*
+//      * Busy processors will not participate in power savings
+//      * balance.
+//      */
+//     if (idle == CPU_NOT_IDLE || !(sd->flags & SD_POWERSAVINGS_BALANCE))
+//             sds->power_savings_balance = 0;
+//     else {
+//             sds->power_savings_balance = 1;
+//             sds->min_nr_running = ULONG_MAX;
+//             sds->leader_nr_running = 0;
+//     }
+//}
 
 /**
  * update_sd_power_savings_stats - Update the power saving stats for a
@@ -2369,59 +2364,59 @@ static inline void init_sd_power_savings_stats(struct sched_domain *sd,
  *             load balancing ?
  * @sgs: Variable containing the statistics of the group.
  */
-static inline void update_sd_power_savings_stats(struct sched_group *group,
-       struct sd_lb_stats *sds, int local_group, struct sg_lb_stats *sgs)
-{
-
-       if (!sds->power_savings_balance)
-               return;
-
-       /*
-        * If the local group is idle or completely loaded
-        * no need to do power savings balance at this domain
-        */
-       if (local_group && (sds->this_nr_running >= sgs->group_capacity ||
-                               !sds->this_nr_running))
-               sds->power_savings_balance = 0;
-
-       /*
-        * If a group is already running at full capacity or idle,
-        * don't include that group in power savings calculations
-        */
-       if (!sds->power_savings_balance ||
-               sgs->sum_nr_running >= sgs->group_capacity ||
-               !sgs->sum_nr_running)
-               return;
-
-       /*
-        * Calculate the group which has the least non-idle load.
-        * This is the group from where we need to pick up the load
-        * for saving power
-        */
-       if ((sgs->sum_nr_running < sds->min_nr_running) ||
-           (sgs->sum_nr_running == sds->min_nr_running &&
-            group_first_cpu(group) > group_first_cpu(sds->group_min))) {
-               sds->group_min = group;
-               sds->min_nr_running = sgs->sum_nr_running;
-               sds->min_load_per_task = sgs->sum_weighted_load /
-                                               sgs->sum_nr_running;
-       }
-
-       /*
-        * Calculate the group which is almost near its
-        * capacity but still has some space to pick up some load
-        * from other group and save more power
-        */
-       if (sgs->sum_nr_running + 1 > sgs->group_capacity)
-               return;
-
-       if (sgs->sum_nr_running > sds->leader_nr_running ||
-           (sgs->sum_nr_running == sds->leader_nr_running &&
-            group_first_cpu(group) < group_first_cpu(sds->group_leader))) {
-               sds->group_leader = group;
-               sds->leader_nr_running = sgs->sum_nr_running;
-       }
-}
+//static inline void update_sd_power_savings_stats(struct sched_group *group,
+//     struct sd_lb_stats *sds, int local_group, struct sg_lb_stats *sgs)
+//{
+//
+//     if (!sds->power_savings_balance)
+//             return;
+//
+//     /*
+//      * If the local group is idle or completely loaded
+//      * no need to do power savings balance at this domain
+//      */
+//     if (local_group && (sds->this_nr_running >= sgs->group_capacity ||
+//                             !sds->this_nr_running))
+//             sds->power_savings_balance = 0;
+//
+//     /*
+//      * If a group is already running at full capacity or idle,
+//      * don't include that group in power savings calculations
+//      */
+//     if (!sds->power_savings_balance ||
+//             sgs->sum_nr_running >= sgs->group_capacity ||
+//             !sgs->sum_nr_running)
+//             return;
+//
+//     /*
+//      * Calculate the group which has the least non-idle load.
+//      * This is the group from where we need to pick up the load
+//      * for saving power
+//      */
+//     if ((sgs->sum_nr_running < sds->min_nr_running) ||
+//         (sgs->sum_nr_running == sds->min_nr_running &&
+//          group_first_cpu(group) > group_first_cpu(sds->group_min))) {
+//             sds->group_min = group;
+//             sds->min_nr_running = sgs->sum_nr_running;
+////           sds->min_load_per_task = sgs->sum_weighted_load /
+////                                           sgs->sum_nr_running;
+//     }
+//
+//     /*
+//      * Calculate the group which is almost near its
+//      * capacity but still has some space to pick up some load
+//      * from other group and save more power
+//      */
+//     if (sgs->sum_nr_running + 1 > sgs->group_capacity)
+//             return;
+//
+//     if (sgs->sum_nr_running > sds->leader_nr_running ||
+//         (sgs->sum_nr_running == sds->leader_nr_running &&
+//          group_first_cpu(group) < group_first_cpu(sds->group_leader))) {
+//             sds->group_leader = group;
+//             sds->leader_nr_running = sgs->sum_nr_running;
+//     }
+//}
 
 /**
  * check_power_save_busiest_group - see if there is potential for some power-savings balance
@@ -2438,40 +2433,40 @@ static inline void update_sd_power_savings_stats(struct sched_group *group,
  * Returns 1 if there is potential to perform power-savings balance.
  * Else returns 0.
  */
-static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
-                                       int this_cpu, unsigned long *imbalance)
-{
-       if (!sds->power_savings_balance)
-               return 0;
-
-       if (sds->this != sds->group_leader ||
-                       sds->group_leader == sds->group_min)
-               return 0;
-
-       *imbalance = sds->min_load_per_task;
-       sds->busiest = sds->group_min;
-
-       return 1;
-
-}
+//static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
+//                                     int this_cpu, unsigned long *imbalance)
+//{
+//     if (!sds->power_savings_balance)
+//             return 0;
+//
+//     if (sds->this != sds->group_leader ||
+//                     sds->group_leader == sds->group_min)
+//             return 0;
+//
+//     *imbalance = sds->min_load_per_task;
+//     sds->busiest = sds->group_min;
+//
+//     return 1;
+//
+//}
 #else /* CONFIG_SCHED_MC || CONFIG_SCHED_SMT */
-static inline void init_sd_power_savings_stats(struct sched_domain *sd,
-       struct sd_lb_stats *sds, enum cpu_idle_type idle)
-{
-       return;
-}
-
-static inline void update_sd_power_savings_stats(struct sched_group *group,
-       struct sd_lb_stats *sds, int local_group, struct sg_lb_stats *sgs)
-{
-       return;
-}
-
-static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
-                                       int this_cpu, unsigned long *imbalance)
-{
-       return 0;
-}
+//static inline void init_sd_power_savings_stats(struct sched_domain *sd,
+//     struct sd_lb_stats *sds, enum cpu_idle_type idle)
+//{
+//     return;
+//}
+//
+//static inline void update_sd_power_savings_stats(struct sched_group *group,
+//     struct sd_lb_stats *sds, int local_group, struct sg_lb_stats *sgs)
+//{
+//     return;
+//}
+//
+//static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
+//                                     int this_cpu, unsigned long *imbalance)
+//{
+//     return 0;
+//}
 #endif /* CONFIG_SCHED_MC || CONFIG_SCHED_SMT */
 
 
@@ -2522,61 +2517,61 @@ unsigned long scale_rt_power(int cpu)
        return div_u64(available, total);
 }
 
-static void update_cpu_power(struct sched_domain *sd, int cpu)
-{
-       unsigned long weight = sd->span_weight;
-       unsigned long power = SCHED_LOAD_SCALE;
-       struct sched_group *sdg = sd->groups;
-
-       if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
-               if (sched_feat(ARCH_POWER))
-                       power *= arch_scale_smt_power(sd, cpu);
-               else
-                       power *= default_scale_smt_power(sd, cpu);
-
-               power >>= SCHED_LOAD_SHIFT;
-       }
-
-       sdg->cpu_power_orig = power;
-
-       if (sched_feat(ARCH_POWER))
-               power *= arch_scale_freq_power(sd, cpu);
-       else
-               power *= default_scale_freq_power(sd, cpu);
-
-       power >>= SCHED_LOAD_SHIFT;
-
-       power *= scale_rt_power(cpu);
-       power >>= SCHED_LOAD_SHIFT;
-
-       if (!power)
-               power = 1;
-
-       cpu_rq(cpu)->cpu_power = power;
-       sdg->cpu_power = power;
-}
-
-static void update_group_power(struct sched_domain *sd, int cpu)
-{
-       struct sched_domain *child = sd->child;
-       struct sched_group *group, *sdg = sd->groups;
-       unsigned long power;
-
-       if (!child) {
-               update_cpu_power(sd, cpu);
-               return;
-       }
-
-       power = 0;
-
-       group = child->groups;
-       do {
-               power += group->cpu_power;
-               group = group->next;
-       } while (group != child->groups);
-
-       sdg->cpu_power = power;
-}
+//static void update_cpu_power(struct sched_domain *sd, int cpu)
+//{
+//     unsigned long weight = sd->span_weight;
+//     unsigned long power = SCHED_LOAD_SCALE;
+//     struct sched_group *sdg = sd->groups;
+//
+//     if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
+//             if (sched_feat(ARCH_POWER))
+//                     power *= arch_scale_smt_power(sd, cpu);
+//             else
+//                     power *= default_scale_smt_power(sd, cpu);
+//
+//             power >>= SCHED_LOAD_SHIFT;
+//     }
+//
+//     sdg->cpu_power_orig = power;
+//
+//     if (sched_feat(ARCH_POWER))
+//             power *= arch_scale_freq_power(sd, cpu);
+//     else
+//             power *= default_scale_freq_power(sd, cpu);
+//
+//     power >>= SCHED_LOAD_SHIFT;
+//
+//     power *= scale_rt_power(cpu);
+//     power >>= SCHED_LOAD_SHIFT;
+//
+//     if (!power)
+//             power = 1;
+//
+//     cpu_rq(cpu)->cpu_power = power;
+//     sdg->cpu_power = power;
+//}
+
+//static void update_group_power(struct sched_domain *sd, int cpu)
+//{
+//     struct sched_domain *child = sd->child;
+//     struct sched_group *group, *sdg = sd->groups;
+//     unsigned long power;
+//
+//     if (!child) {
+//             update_cpu_power(sd, cpu);
+//             return;
+//     }
+//
+//     power = 0;
+//
+//     group = child->groups;
+//     do {
+//             power += group->cpu_power;
+//             group = group->next;
+//     } while (group != child->groups);
+//
+//     sdg->cpu_power = power;
+//}
 
 /*
  * Try and fix up capacity for tiny siblings, this is needed when
@@ -2598,931 +2593,932 @@ fix_small_capacity(struct sched_domain *sd, struct sched_group *group)
         * If ~90% of the cpu_power is still there, we're good.
         */
        if (group->cpu_power * 32 > group->cpu_power_orig * 29)
-               return 1;
-
-       return 0;
-}
-
-/**
- * update_sg_lb_stats - Update sched_group's statistics for load balancing.
- * @sd: The sched_domain whose statistics are to be updated.
- * @group: sched_group whose statistics are to be updated.
- * @this_cpu: Cpu for which load balance is currently performed.
- * @idle: Idle status of this_cpu
- * @load_idx: Load index of sched_domain of this_cpu for load calc.
- * @sd_idle: Idle status of the sched_domain containing group.
- * @local_group: Does group contain this_cpu.
- * @cpus: Set of cpus considered for load balancing.
- * @balance: Should we balance.
- * @sgs: variable to hold the statistics for this group.
- */
-static inline void update_sg_lb_stats(struct sched_domain *sd,
-                       struct sched_group *group, int this_cpu,
-                       enum cpu_idle_type idle, int load_idx, int *sd_idle,
-                       int local_group, const struct cpumask *cpus,
-                       int *balance, struct sg_lb_stats *sgs)
-{
-       unsigned long load, max_cpu_load, min_cpu_load, max_nr_running;
-       int i;
-       unsigned int balance_cpu = -1, first_idle_cpu = 0;
-       unsigned long avg_load_per_task = 0;
-
-       if (local_group)
-               balance_cpu = group_first_cpu(group);
-
-       /* Tally up the load of all CPUs in the group */
-       max_cpu_load = 0;
-       min_cpu_load = ~0UL;
-       max_nr_running = 0;
-
-       for_each_cpu_and(i, sched_group_cpus(group), cpus) {
-               struct rq *rq = cpu_rq(i);
-
-               if (*sd_idle && rq->nr_running)
-                       *sd_idle = 0;
-
-               /* Bias balancing toward cpus of our domain */
-               if (local_group) {
-                       if (idle_cpu(i) && !first_idle_cpu) {
-                               first_idle_cpu = 1;
-                               balance_cpu = i;
-                       }
-
-                       load = target_load(i, load_idx);
-               } else {
-                       load = source_load(i, load_idx);
-                       if (load > max_cpu_load) {
-                               max_cpu_load = load;
-                               max_nr_running = rq->nr_running;
-                       }
-                       if (min_cpu_load > load)
-                               min_cpu_load = load;
-               }
-
-               sgs->group_load += load;
-               sgs->sum_nr_running += rq->nr_running;
-               sgs->sum_weighted_load += weighted_cpuload(i);
-               if (idle_cpu(i))
-                       sgs->idle_cpus++;
-       }
-
-       /*
-        * First idle cpu or the first cpu(busiest) in this sched group
-        * is eligible for doing load balancing at this and above
-        * domains. In the newly idle case, we will allow all the cpu's
-        * to do the newly idle load balance.
-        */
-       if (idle != CPU_NEWLY_IDLE && local_group) {
-               if (balance_cpu != this_cpu) {
-                       *balance = 0;
-                       return;
-               }
-               update_group_power(sd, this_cpu);
-       }
-
-       /* Adjust by relative CPU power of the group */
-       sgs->avg_load = (sgs->group_load * SCHED_LOAD_SCALE) / group->cpu_power;
-
-       /*
-        * Consider the group unbalanced when the imbalance is larger
-        * than the average weight of two tasks.
-        *
-        * APZ: with cgroup the avg task weight can vary wildly and
-        *      might not be a suitable number - should we keep a
-        *      normalized nr_running number somewhere that negates
-        *      the hierarchy?
-        */
-       if (sgs->sum_nr_running)
-               avg_load_per_task = sgs->sum_weighted_load / sgs->sum_nr_running;
-
-       if ((max_cpu_load - min_cpu_load) > 2*avg_load_per_task && max_nr_running > 1)
-               sgs->group_imb = 1;
-
-       sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE);
-       if (!sgs->group_capacity)
-               sgs->group_capacity = fix_small_capacity(sd, group);
-       sgs->group_weight = group->group_weight;
-
-       if (sgs->group_capacity > sgs->sum_nr_running)
-               sgs->group_has_capacity = 1;
-}
-
-/**
- * update_sd_pick_busiest - return 1 on busiest group
- * @sd: sched_domain whose statistics are to be checked
- * @sds: sched_domain statistics
- * @sg: sched_group candidate to be checked for being the busiest
- * @sgs: sched_group statistics
- * @this_cpu: the current cpu
- *
- * Determine if @sg is a busier group than the previously selected
- * busiest group.
- */
-static bool update_sd_pick_busiest(struct sched_domain *sd,
-                                  struct sd_lb_stats *sds,
-                                  struct sched_group *sg,
-                                  struct sg_lb_stats *sgs,
-                                  int this_cpu)
-{
-       if (sgs->avg_load <= sds->max_load)
-               return false;
-
-       if (sgs->sum_nr_running > sgs->group_capacity)
-               return true;
-
-       if (sgs->group_imb)
-               return true;
-
-       /*
-        * ASYM_PACKING needs to move all the work to the lowest
-        * numbered CPUs in the group, therefore mark all groups
-        * higher than ourself as busy.
-        */
-       if ((sd->flags & SD_ASYM_PACKING) && sgs->sum_nr_running &&
-           this_cpu < group_first_cpu(sg)) {
-               if (!sds->busiest)
-                       return true;
-
-               if (group_first_cpu(sds->busiest) > group_first_cpu(sg))
-                       return true;
-       }
-
-       return false;
-}
-
-/**
- * update_sd_lb_stats - Update sched_group's statistics for load balancing.
- * @sd: sched_domain whose statistics are to be updated.
- * @this_cpu: Cpu for which load balance is currently performed.
- * @idle: Idle status of this_cpu
- * @sd_idle: Idle status of the sched_domain containing sg.
- * @cpus: Set of cpus considered for load balancing.
- * @balance: Should we balance.
- * @sds: variable to hold the statistics for this sched_domain.
- */
-static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
-                       enum cpu_idle_type idle, int *sd_idle,
-                       const struct cpumask *cpus, int *balance,
-                       struct sd_lb_stats *sds)
-{
-       struct sched_domain *child = sd->child;
-       struct sched_group *sg = sd->groups;
-       struct sg_lb_stats sgs;
-       int load_idx, prefer_sibling = 0;
-
-       if (child && child->flags & SD_PREFER_SIBLING)
-               prefer_sibling = 1;
-
-       init_sd_power_savings_stats(sd, sds, idle);
-       load_idx = get_sd_load_idx(sd, idle);
-
-       do {
-               int local_group;
-
-               local_group = cpumask_test_cpu(this_cpu, sched_group_cpus(sg));
-               memset(&sgs, 0, sizeof(sgs));
-               update_sg_lb_stats(sd, sg, this_cpu, idle, load_idx, sd_idle,
-                               local_group, cpus, balance, &sgs);
-
-               if (local_group && !(*balance))
-                       return;
-
-               sds->total_load += sgs.group_load;
-               sds->total_pwr += sg->cpu_power;
-
-               /*
-                * In case the child domain prefers tasks go to siblings
-                * first, lower the sg capacity to one so that we'll try
-                * and move all the excess tasks away. We lower the capacity
-                * of a group only if the local group has the capacity to fit
-                * these excess tasks, i.e. nr_running < group_capacity. The
-                * extra check prevents the case where you always pull from the
-                * heaviest group when it is already under-utilized (possible
-                * with a large weight task outweighs the tasks on the system).
-                */
-               if (prefer_sibling && !local_group && sds->this_has_capacity)
-                       sgs.group_capacity = min(sgs.group_capacity, 1UL);
-
-               if (local_group) {
-                       sds->this_load = sgs.avg_load;
-                       sds->this = sg;
-                       sds->this_nr_running = sgs.sum_nr_running;
-                       sds->this_load_per_task = sgs.sum_weighted_load;
-                       sds->this_has_capacity = sgs.group_has_capacity;
-                       sds->this_idle_cpus = sgs.idle_cpus;
-               } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) {
-                       sds->max_load = sgs.avg_load;
-                       sds->busiest = sg;
-                       sds->busiest_nr_running = sgs.sum_nr_running;
-                       sds->busiest_idle_cpus = sgs.idle_cpus;
-                       sds->busiest_group_capacity = sgs.group_capacity;
-                       sds->busiest_load_per_task = sgs.sum_weighted_load;
-                       sds->busiest_has_capacity = sgs.group_has_capacity;
-                       sds->busiest_group_weight = sgs.group_weight;
-                       sds->group_imb = sgs.group_imb;
-               }
-
-               update_sd_power_savings_stats(sg, sds, local_group, &sgs);
-               sg = sg->next;
-       } while (sg != sd->groups);
-}
-
-int __weak arch_sd_sibling_asym_packing(void)
-{
-       return 0*SD_ASYM_PACKING;
-}
-
-/**
- * check_asym_packing - Check to see if the group is packed into the
- *                     sched doman.
- *
- * This is primarily intended to used at the sibling level.  Some
- * cores like POWER7 prefer to use lower numbered SMT threads.  In the
- * case of POWER7, it can move to lower SMT modes only when higher
- * threads are idle.  When in lower SMT modes, the threads will
- * perform better since they share less core resources.  Hence when we
- * have idle threads, we want them to be the higher ones.
- *
- * This packing function is run on idle threads.  It checks to see if
- * the busiest CPU in this domain (core in the P7 case) has a higher
- * CPU number than the packing function is being run on.  Here we are
- * assuming lower CPU number will be equivalent to lower a SMT thread
- * number.
- *
- * Returns 1 when packing is required and a task should be moved to
- * this CPU.  The amount of the imbalance is returned in *imbalance.
- *
- * @sd: The sched_domain whose packing is to be checked.
- * @sds: Statistics of the sched_domain which is to be packed
- * @this_cpu: The cpu at whose sched_domain we're performing load-balance.
- * @imbalance: returns amount of imbalanced due to packing.
- */
-static int check_asym_packing(struct sched_domain *sd,
-                             struct sd_lb_stats *sds,
-                             int this_cpu, unsigned long *imbalance)
-{
-       int busiest_cpu;
-
-       if (!(sd->flags & SD_ASYM_PACKING))
-               return 0;
-
-       if (!sds->busiest)
-               return 0;
-
-       busiest_cpu = group_first_cpu(sds->busiest);
-       if (this_cpu > busiest_cpu)
-               return 0;
-
-       *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->cpu_power,
-                                      SCHED_LOAD_SCALE);
-       return 1;
-}
-
-/**
- * fix_small_imbalance - Calculate the minor imbalance that exists
- *                     amongst the groups of a sched_domain, during
- *                     load balancing.
- * @sds: Statistics of the sched_domain whose imbalance is to be calculated.
- * @this_cpu: The cpu at whose sched_domain we're performing load-balance.
- * @imbalance: Variable to store the imbalance.
- */
-static inline void fix_small_imbalance(struct sd_lb_stats *sds,
-                               int this_cpu, unsigned long *imbalance)
-{
-       unsigned long tmp, pwr_now = 0, pwr_move = 0;
-       unsigned int imbn = 2;
-       unsigned long scaled_busy_load_per_task;
-
-       if (sds->this_nr_running) {
-               sds->this_load_per_task /= sds->this_nr_running;
-               if (sds->busiest_load_per_task >
-                               sds->this_load_per_task)
-                       imbn = 1;
-       } else
-               sds->this_load_per_task =
-                       cpu_avg_load_per_task(this_cpu);
-
-       scaled_busy_load_per_task = sds->busiest_load_per_task
-                                                * SCHED_LOAD_SCALE;
-       scaled_busy_load_per_task /= sds->busiest->cpu_power;
-
-       if (sds->max_load - sds->this_load + scaled_busy_load_per_task >=
-                       (scaled_busy_load_per_task * imbn)) {
-               *imbalance = sds->busiest_load_per_task;
-               return;
-       }
-
-       /*
-        * OK, we don't have enough imbalance to justify moving tasks,
-        * however we may be able to increase total CPU power used by
-        * moving them.
-        */
-
-       pwr_now += sds->busiest->cpu_power *
-                       min(sds->busiest_load_per_task, sds->max_load);
-       pwr_now += sds->this->cpu_power *
-                       min(sds->this_load_per_task, sds->this_load);
-       pwr_now /= SCHED_LOAD_SCALE;
-
-       /* Amount of load we'd subtract */
-       tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
-               sds->busiest->cpu_power;
-       if (sds->max_load > tmp)
-               pwr_move += sds->busiest->cpu_power *
-                       min(sds->busiest_load_per_task, sds->max_load - tmp);
-
-       /* Amount of load we'd add */
-       if (sds->max_load * sds->busiest->cpu_power <
-               sds->busiest_load_per_task * SCHED_LOAD_SCALE)
-               tmp = (sds->max_load * sds->busiest->cpu_power) /
-                       sds->this->cpu_power;
-       else
-               tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
-                       sds->this->cpu_power;
-       pwr_move += sds->this->cpu_power *
-                       min(sds->this_load_per_task, sds->this_load + tmp);
-       pwr_move /= SCHED_LOAD_SCALE;
-
-       /* Move if we gain throughput */
-       if (pwr_move > pwr_now)
-               *imbalance = sds->busiest_load_per_task;
-}
-
-/**
- * calculate_imbalance - Calculate the amount of imbalance present within the
- *                      groups of a given sched_domain during load balance.
- * @sds: statistics of the sched_domain whose imbalance is to be calculated.
- * @this_cpu: Cpu for which currently load balance is being performed.
- * @imbalance: The variable to store the imbalance.
- */
-static inline void calculate_imbalance(struct sd_lb_stats *sds, int this_cpu,
-               unsigned long *imbalance)
-{
-       unsigned long max_pull, load_above_capacity = ~0UL;
-
-       sds->busiest_load_per_task /= sds->busiest_nr_running;
-       if (sds->group_imb) {
-               sds->busiest_load_per_task =
-                       min(sds->busiest_load_per_task, sds->avg_load);
-       }
-
-       /*
-        * In the presence of smp nice balancing, certain scenarios can have
-        * max load less than avg load(as we skip the groups at or below
-        * its cpu_power, while calculating max_load..)
-        */
-       if (sds->max_load < sds->avg_load) {
-               *imbalance = 0;
-               return fix_small_imbalance(sds, this_cpu, imbalance);
-       }
-
-       if (!sds->group_imb) {
-               /*
-                * Don't want to pull so many tasks that a group would go idle.
-                */
-               load_above_capacity = (sds->busiest_nr_running -
-                                               sds->busiest_group_capacity);
-
-               load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_LOAD_SCALE);
-
-               load_above_capacity /= sds->busiest->cpu_power;
-       }
-
-       /*
-        * We're trying to get all the cpus to the average_load, so we don't
-        * want to push ourselves above the average load, nor do we wish to
-        * reduce the max loaded cpu below the average load. At the same time,
-        * we also don't want to reduce the group load below the group capacity
-        * (so that we can implement power-savings policies etc). Thus we look
-        * for the minimum possible imbalance.
-        * Be careful of negative numbers as they'll appear as very large values
-        * with unsigned longs.
-        */
-       max_pull = min(sds->max_load - sds->avg_load, load_above_capacity);
-
-       /* How much load to actually move to equalise the imbalance */
-       *imbalance = min(max_pull * sds->busiest->cpu_power,
-               (sds->avg_load - sds->this_load) * sds->this->cpu_power)
-                       / SCHED_LOAD_SCALE;
-
-       /*
-        * if *imbalance is less than the average load per runnable task
-        * there is no gaurantee that any tasks will be moved so we'll have
-        * a think about bumping its value to force at least one task to be
-        * moved
-        */
-       if (*imbalance < sds->busiest_load_per_task)
-               return fix_small_imbalance(sds, this_cpu, imbalance);
-
-}
-
-/******* find_busiest_group() helpers end here *********************/
-
-/**
- * find_busiest_group - Returns the busiest group within the sched_domain
- * if there is an imbalance. If there isn't an imbalance, and
- * the user has opted for power-savings, it returns a group whose
- * CPUs can be put to idle by rebalancing those tasks elsewhere, if
- * such a group exists.
- *
- * Also calculates the amount of weighted load which should be moved
- * to restore balance.
- *
- * @sd: The sched_domain whose busiest group is to be returned.
- * @this_cpu: The cpu for which load balancing is currently being performed.
- * @imbalance: Variable which stores amount of weighted load which should
- *             be moved to restore balance/put a group to idle.
- * @idle: The idle status of this_cpu.
- * @sd_idle: The idleness of sd
- * @cpus: The set of CPUs under consideration for load-balancing.
- * @balance: Pointer to a variable indicating if this_cpu
- *     is the appropriate cpu to perform load balancing at this_level.
- *
- * Returns:    - the busiest group if imbalance exists.
- *             - If no imbalance and user has opted for power-savings balance,
- *                return the least loaded group whose CPUs can be
- *                put to idle by rebalancing its tasks onto our group.
- */
-static struct sched_group *
-find_busiest_group(struct sched_domain *sd, int this_cpu,
-                  unsigned long *imbalance, enum cpu_idle_type idle,
-                  int *sd_idle, const struct cpumask *cpus, int *balance)
-{
-       struct sd_lb_stats sds;
-
-       memset(&sds, 0, sizeof(sds));
-
-       /*
-        * Compute the various statistics relavent for load balancing at
-        * this level.
-        */
-       update_sd_lb_stats(sd, this_cpu, idle, sd_idle, cpus,
-                                       balance, &sds);
-
-       /* Cases where imbalance does not exist from POV of this_cpu */
-       /* 1) this_cpu is not the appropriate cpu to perform load balancing
-        *    at this level.
-        * 2) There is no busy sibling group to pull from.
-        * 3) This group is the busiest group.
-        * 4) This group is more busy than the avg busieness at this
-        *    sched_domain.
-        * 5) The imbalance is within the specified limit.
-        *
-        * Note: when doing newidle balance, if the local group has excess
-        * capacity (i.e. nr_running < group_capacity) and the busiest group
-        * does not have any capacity, we force a load balance to pull tasks
-        * to the local group. In this case, we skip past checks 3, 4 and 5.
-        */
-       if (!(*balance))
-               goto ret;
-
-       if ((idle == CPU_IDLE || idle == CPU_NEWLY_IDLE) &&
-           check_asym_packing(sd, &sds, this_cpu, imbalance))
-               return sds.busiest;
-
-       if (!sds.busiest || sds.busiest_nr_running == 0)
-               goto out_balanced;
-
-       /*  SD_BALANCE_NEWIDLE trumps SMP nice when underutilized */
-       if (idle == CPU_NEWLY_IDLE && sds.this_has_capacity &&
-                       !sds.busiest_has_capacity)
-               goto force_balance;
-
-       if (sds.this_load >= sds.max_load)
-               goto out_balanced;
-
-       sds.avg_load = (SCHED_LOAD_SCALE * sds.total_load) / sds.total_pwr;
-
-       if (sds.this_load >= sds.avg_load)
-               goto out_balanced;
-
-       /*
-        * In the CPU_NEWLY_IDLE, use imbalance_pct to be conservative.
-        * And to check for busy balance use !idle_cpu instead of
-        * CPU_NOT_IDLE. This is because HT siblings will use CPU_NOT_IDLE
-        * even when they are idle.
-        */
-       if (idle == CPU_NEWLY_IDLE || !idle_cpu(this_cpu)) {
-               if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load)
-                       goto out_balanced;
-       } else {
-               /*
-                * This cpu is idle. If the busiest group load doesn't
-                * have more tasks than the number of available cpu's and
-                * there is no imbalance between this and busiest group
-                * wrt to idle cpu's, it is balanced.
-                */
-               if ((sds.this_idle_cpus  <= sds.busiest_idle_cpus + 1) &&
-                   sds.busiest_nr_running <= sds.busiest_group_weight)
-                       goto out_balanced;
-       }
-
-force_balance:
-       /* Looks like there is an imbalance. Compute it */
-       calculate_imbalance(&sds, this_cpu, imbalance);
-       return sds.busiest;
-
-out_balanced:
-       /*
-        * There is no obvious imbalance. But check if we can do some balancing
-        * to save power.
-        */
-       if (check_power_save_busiest_group(&sds, this_cpu, imbalance))
-               return sds.busiest;
-ret:
-       *imbalance = 0;
-       return NULL;
-}
-
-/*
- * find_busiest_queue - find the busiest runqueue among the cpus in group.
- */
-static struct rq *
-find_busiest_queue(struct sched_domain *sd, struct sched_group *group,
-                  enum cpu_idle_type idle, unsigned long imbalance,
-                  const struct cpumask *cpus)
-{
-       struct rq *busiest = NULL, *rq;
-       unsigned long max_load = 0;
-       int i;
-
-       for_each_cpu(i, sched_group_cpus(group)) {
-               unsigned long power = power_of(i);
-               unsigned long capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE);
-               unsigned long wl;
-
-               if (!capacity)
-                       capacity = fix_small_capacity(sd, group);
-
-               if (!cpumask_test_cpu(i, cpus))
-                       continue;
-
-               rq = cpu_rq(i);
-               wl = weighted_cpuload(i);
-
-               /*
-                * When comparing with imbalance, use weighted_cpuload()
-                * which is not scaled with the cpu power.
-                */
-               if (capacity && rq->nr_running == 1 && wl > imbalance)
-                       continue;
-
-               /*
-                * For the load comparisons with the other cpu's, consider
-                * the weighted_cpuload() scaled with the cpu power, so that
-                * the load can be moved away from the cpu that is potentially
-                * running at a lower capacity.
-                */
-               wl = (wl * SCHED_LOAD_SCALE) / power;
-
-               if (wl > max_load) {
-                       max_load = wl;
-                       busiest = rq;
-               }
-       }
-
-       return busiest;
-}
-
-/*
- * Max backoff if we encounter pinned tasks. Pretty arbitrary value, but
- * so long as it is large enough.
- */
-#define MAX_PINNED_INTERVAL    512
-
-/* Working cpumask for load_balance and load_balance_newidle. */
-static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask);
-
-static int need_active_balance(struct sched_domain *sd, int sd_idle, int idle,
-                              int busiest_cpu, int this_cpu)
-{
-       if (idle == CPU_NEWLY_IDLE) {
-
-               /*
-                * ASYM_PACKING needs to force migrate tasks from busy but
-                * higher numbered CPUs in order to pack all tasks in the
-                * lowest numbered CPUs.
-                */
-               if ((sd->flags & SD_ASYM_PACKING) && busiest_cpu > this_cpu)
-                       return 1;
-
-               /*
-                * The only task running in a non-idle cpu can be moved to this
-                * cpu in an attempt to completely freeup the other CPU
-                * package.
-                *
-                * The package power saving logic comes from
-                * find_busiest_group(). If there are no imbalance, then
-                * f_b_g() will return NULL. However when sched_mc={1,2} then
-                * f_b_g() will select a group from which a running task may be
-                * pulled to this cpu in order to make the other package idle.
-                * If there is no opportunity to make a package idle and if
-                * there are no imbalance, then f_b_g() will return NULL and no
-                * action will be taken in load_balance_newidle().
-                *
-                * Under normal task pull operation due to imbalance, there
-                * will be more than one task in the source run queue and
-                * move_tasks() will succeed.  ld_moved will be true and this
-                * active balance code will not be triggered.
-                */
-               if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
-                   !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
-                       return 0;
-
-               if (sched_mc_power_savings < POWERSAVINGS_BALANCE_WAKEUP)
-                       return 0;
-       }
-
-       return unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2);
-}
-
-static int active_load_balance_cpu_stop(void *data);
-
-/*
- * Check this_cpu to ensure it is balanced within domain. Attempt to move
- * tasks if there is an imbalance.
- */
-static int load_balance(int this_cpu, struct rq *this_rq,
-                       struct sched_domain *sd, enum cpu_idle_type idle,
-                       int *balance)
-{
-       int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0;
-       struct sched_group *group;
-       unsigned long imbalance;
-       struct rq *busiest;
-       unsigned long flags;
-       struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
-
-       cpumask_copy(cpus, cpu_active_mask);
-
-       /*
-        * When power savings policy is enabled for the parent domain, idle
-        * sibling can pick up load irrespective of busy siblings. In this case,
-        * let the state of idle sibling percolate up as CPU_IDLE, instead of
-        * portraying it as CPU_NOT_IDLE.
-        */
-       if (idle != CPU_NOT_IDLE && sd->flags & SD_SHARE_CPUPOWER &&
-           !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
-               sd_idle = 1;
-
-       schedstat_inc(sd, lb_count[idle]);
-
-redo:
-       group = find_busiest_group(sd, this_cpu, &imbalance, idle, &sd_idle,
-                                  cpus, balance);
-
-       if (*balance == 0)
-               goto out_balanced;
-
-       if (!group) {
-               schedstat_inc(sd, lb_nobusyg[idle]);
-               goto out_balanced;
-       }
-
-       busiest = find_busiest_queue(sd, group, idle, imbalance, cpus);
-       if (!busiest) {
-               schedstat_inc(sd, lb_nobusyq[idle]);
-               goto out_balanced;
-       }
-
-       BUG_ON(busiest == this_rq);
-
-       schedstat_add(sd, lb_imbalance[idle], imbalance);
-
-       ld_moved = 0;
-       if (busiest->nr_running > 1) {
-               /*
-                * Attempt to move tasks. If find_busiest_group has found
-                * an imbalance but busiest->nr_running <= 1, the group is
-                * still unbalanced. ld_moved simply stays zero, so it is
-                * correctly treated as an imbalance.
-                */
-               local_irq_save(flags);
-               double_rq_lock(this_rq, busiest);
-               ld_moved = move_tasks(this_rq, this_cpu, busiest,
-                                     imbalance, sd, idle, &all_pinned);
-               double_rq_unlock(this_rq, busiest);
-               local_irq_restore(flags);
-
-               /*
-                * some other cpu did the load balance for us.
-                */
-               if (ld_moved && this_cpu != smp_processor_id())
-                       resched_cpu(this_cpu);
-
-               /* All tasks on this runqueue were pinned by CPU affinity */
-               if (unlikely(all_pinned)) {
-                       cpumask_clear_cpu(cpu_of(busiest), cpus);
-                       if (!cpumask_empty(cpus))
-                               goto redo;
-                       goto out_balanced;
-               }
-       }
-
-       if (!ld_moved) {
-               schedstat_inc(sd, lb_failed[idle]);
-               /*
-                * Increment the failure counter only on periodic balance.
-                * We do not want newidle balance, which can be very
-                * frequent, pollute the failure counter causing
-                * excessive cache_hot migrations and active balances.
-                */
-               if (idle != CPU_NEWLY_IDLE)
-                       sd->nr_balance_failed++;
-
-               if (need_active_balance(sd, sd_idle, idle, cpu_of(busiest),
-                                       this_cpu)) {
-                       raw_spin_lock_irqsave(&busiest->lock, flags);
-
-                       /* don't kick the active_load_balance_cpu_stop,
-                        * if the curr task on busiest cpu can't be
-                        * moved to this_cpu
-                        */
-                       if (!cpumask_test_cpu(this_cpu,
-                                             &busiest->curr->cpus_allowed)) {
-                               raw_spin_unlock_irqrestore(&busiest->lock,
-                                                           flags);
-                               all_pinned = 1;
-                               goto out_one_pinned;
-                       }
-
-                       /*
-                        * ->active_balance synchronizes accesses to
-                        * ->active_balance_work.  Once set, it's cleared
-                        * only after active load balance is finished.
-                        */
-                       if (!busiest->active_balance) {
-                               busiest->active_balance = 1;
-                               busiest->push_cpu = this_cpu;
-                               active_balance = 1;
-                       }
-                       raw_spin_unlock_irqrestore(&busiest->lock, flags);
-
-                       if (active_balance)
-                               stop_one_cpu_nowait(cpu_of(busiest),
-                                       active_load_balance_cpu_stop, busiest,
-                                       &busiest->active_balance_work);
-
-                       /*
-                        * We've kicked active balancing, reset the failure
-                        * counter.
-                        */
-                       sd->nr_balance_failed = sd->cache_nice_tries+1;
-               }
-       } else
-               sd->nr_balance_failed = 0;
-
-       if (likely(!active_balance)) {
-               /* We were unbalanced, so reset the balancing interval */
-               sd->balance_interval = sd->min_interval;
-       } else {
-               /*
-                * If we've begun active balancing, start to back off. This
-                * case may not be covered by the all_pinned logic if there
-                * is only 1 task on the busy runqueue (because we don't call
-                * move_tasks).
-                */
-               if (sd->balance_interval < sd->max_interval)
-                       sd->balance_interval *= 2;
-       }
-
-       if (!ld_moved && !sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
-           !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
-               ld_moved = -1;
-
-       goto out;
-
-out_balanced:
-       schedstat_inc(sd, lb_balanced[idle]);
-
-       sd->nr_balance_failed = 0;
-
-out_one_pinned:
-       /* tune up the balancing interval */
-       if ((all_pinned && sd->balance_interval < MAX_PINNED_INTERVAL) ||
-                       (sd->balance_interval < sd->max_interval))
-               sd->balance_interval *= 2;
-
-       if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
-           !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
-               ld_moved = -1;
-       else
-               ld_moved = 0;
-out:
-       return ld_moved;
-}
-
-/*
- * idle_balance is called by schedule() if this_cpu is about to become
- * idle. Attempts to pull tasks from other CPUs.
- */
-static void idle_balance(int this_cpu, struct rq *this_rq)
-{
-       struct sched_domain *sd;
-       int pulled_task = 0;
-       unsigned long next_balance = jiffies + HZ;
-
-       this_rq->idle_stamp = this_rq->clock;
-
-       if (this_rq->avg_idle < sysctl_sched_migration_cost)
-               return;
-
-       /*
-        * Drop the rq->lock, but keep IRQ/preempt disabled.
-        */
-       raw_spin_unlock(&this_rq->lock);
-
-       update_shares(this_cpu);
-       for_each_domain(this_cpu, sd) {
-               unsigned long interval;
-               int balance = 1;
-
-               if (!(sd->flags & SD_LOAD_BALANCE))
-                       continue;
-
-               if (sd->flags & SD_BALANCE_NEWIDLE) {
-                       /* If we've pulled tasks over stop searching: */
-                       pulled_task = load_balance(this_cpu, this_rq,
-                                                  sd, CPU_NEWLY_IDLE, &balance);
-               }
+               return 1;
 
-               interval = msecs_to_jiffies(sd->balance_interval);
-               if (time_after(next_balance, sd->last_balance + interval))
-                       next_balance = sd->last_balance + interval;
-               if (pulled_task) {
-                       this_rq->idle_stamp = 0;
-                       break;
-               }
-       }
+       return 0;
+}
 
-       raw_spin_lock(&this_rq->lock);
+/**
+ * update_sg_lb_stats - Update sched_group's statistics for load balancing.
+ * @sd: The sched_domain whose statistics are to be updated.
+ * @group: sched_group whose statistics are to be updated.
+ * @this_cpu: Cpu for which load balance is currently performed.
+ * @idle: Idle status of this_cpu
+ * @load_idx: Load index of sched_domain of this_cpu for load calc.
+ * @sd_idle: Idle status of the sched_domain containing group.
+ * @local_group: Does group contain this_cpu.
+ * @cpus: Set of cpus considered for load balancing.
+ * @balance: Should we balance.
+ * @sgs: variable to hold the statistics for this group.
+ */
+//static inline void update_sg_lb_stats(struct sched_domain *sd,
+//                     struct sched_group *group, int this_cpu,
+//                     enum cpu_idle_type idle, int load_idx, int *sd_idle,
+//                     int local_group, const struct cpumask *cpus,
+//                     int *balance, struct sg_lb_stats *sgs)
+//{
+//     unsigned long load, max_cpu_load, min_cpu_load, max_nr_running;
+//     int i;
+//     unsigned int balance_cpu = -1, first_idle_cpu = 0;
+//     unsigned long avg_load_per_task = 0;
+//
+//     if (local_group)
+//             balance_cpu = group_first_cpu(group);
+//
+//     /* Tally up the load of all CPUs in the group */
+//     max_cpu_load = 0;
+//     min_cpu_load = ~0UL;
+//     max_nr_running = 0;
+//
+//     for_each_cpu_and(i, sched_group_cpus(group), cpus) {
+//             struct rq *rq = cpu_rq(i);
+//
+//             if (*sd_idle && rq->nr_running)
+//                     *sd_idle = 0;
+//
+//             /* Bias balancing toward cpus of our domain */
+//             if (local_group) {
+//                     if (idle_cpu(i) && !first_idle_cpu) {
+//                             first_idle_cpu = 1;
+//                             balance_cpu = i;
+//                     }
+//
+////                   load = target_load(i, load_idx);
+//             } else {
+////                   load = source_load(i, load_idx);
+////                   if (load > max_cpu_load) {
+////                           max_cpu_load = load;
+////                           max_nr_running = rq->nr_running;
+////                   }
+////                   if (min_cpu_load > load)
+////                           min_cpu_load = load;
+//             }
+//
+//             sgs->group_load += load;
+//             sgs->sum_nr_running += rq->nr_running;
+////           sgs->sum_weighted_load += weighted_cpuload(i);
+//             if (idle_cpu(i))
+//                     sgs->idle_cpus++;
+//     }
+//
+//     /*
+//      * First idle cpu or the first cpu(busiest) in this sched group
+//      * is eligible for doing load balancing at this and above
+//      * domains. In the newly idle case, we will allow all the cpu's
+//      * to do the newly idle load balance.
+//      */
+//     if (idle != CPU_NEWLY_IDLE && local_group) {
+//             if (balance_cpu != this_cpu) {
+//                     *balance = 0;
+//                     return;
+//             }
+//             update_group_power(sd, this_cpu);
+//     }
+//
+//     /* Adjust by relative CPU power of the group */
+//     sgs->avg_load = (sgs->group_load * SCHED_LOAD_SCALE) / group->cpu_power;
+//
+//     /*
+//      * Consider the group unbalanced when the imbalance is larger
+//      * than the average weight of two tasks.
+//      *
+//      * APZ: with cgroup the avg task weight can vary wildly and
+//      *      might not be a suitable number - should we keep a
+//      *      normalized nr_running number somewhere that negates
+//      *      the hierarchy?
+//      */
+//     if (sgs->sum_nr_running)
+//             avg_load_per_task = sgs->sum_weighted_load / sgs->sum_nr_running;
+//
+//     if ((max_cpu_load - min_cpu_load) > 2*avg_load_per_task && max_nr_running > 1)
+//             sgs->group_imb = 1;
+//
+//     sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE);
+//     if (!sgs->group_capacity)
+//             sgs->group_capacity = fix_small_capacity(sd, group);
+//     sgs->group_weight = group->group_weight;
+//
+//     if (sgs->group_capacity > sgs->sum_nr_running)
+//             sgs->group_has_capacity = 1;
+//}
 
-       if (pulled_task || time_after(jiffies, this_rq->next_balance)) {
-               /*
-                * We are going idle. next_balance may be set based on
-                * a busy processor. So reset next_balance.
-                */
-               this_rq->next_balance = next_balance;
-       }
-}
+/**
+ * update_sd_pick_busiest - return 1 on busiest group
+ * @sd: sched_domain whose statistics are to be checked
+ * @sds: sched_domain statistics
+ * @sg: sched_group candidate to be checked for being the busiest
+ * @sgs: sched_group statistics
+ * @this_cpu: the current cpu
+ *
+ * Determine if @sg is a busier group than the previously selected
+ * busiest group.
+ */
+//static bool update_sd_pick_busiest(struct sched_domain *sd,
+//                                struct sd_lb_stats *sds,
+//                                struct sched_group *sg,
+//                                struct sg_lb_stats *sgs,
+//                                int this_cpu)
+//{
+////   if (sgs->avg_load <= sds->max_load)
+////           return false;
+//
+//     if (sgs->sum_nr_running > sgs->group_capacity)
+//             return true;
+//
+//     if (sgs->group_imb)
+//             return true;
+//
+//     /*
+//      * ASYM_PACKING needs to move all the work to the lowest
+//      * numbered CPUs in the group, therefore mark all groups
+//      * higher than ourself as busy.
+//      */
+//     if ((sd->flags & SD_ASYM_PACKING) && sgs->sum_nr_running &&
+//         this_cpu < group_first_cpu(sg)) {
+//             if (!sds->busiest)
+//                     return true;
+//
+//             if (group_first_cpu(sds->busiest) > group_first_cpu(sg))
+//                     return true;
+//     }
+//
+//     return false;
+//}
 
-/*
- * active_load_balance_cpu_stop is run by cpu stopper. It pushes
- * running tasks off the busiest CPU onto idle CPUs. It requires at
- * least 1 task to be running on each physical CPU where possible, and
- * avoids physical / logical imbalances.
+/**
+ * update_sd_lb_stats - Update sched_group's statistics for load balancing.
+ * @sd: sched_domain whose statistics are to be updated.
+ * @this_cpu: Cpu for which load balance is currently performed.
+ * @idle: Idle status of this_cpu
+ * @sd_idle: Idle status of the sched_domain containing sg.
+ * @cpus: Set of cpus considered for load balancing.
+ * @balance: Should we balance.
+ * @sds: variable to hold the statistics for this sched_domain.
  */
-static int active_load_balance_cpu_stop(void *data)
+//static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
+//                     enum cpu_idle_type idle, int *sd_idle,
+//                     const struct cpumask *cpus, int *balance,
+//                     struct sd_lb_stats *sds)
+//{
+//     struct sched_domain *child = sd->child;
+//     struct sched_group *sg = sd->groups;
+//     struct sg_lb_stats sgs;
+//     int load_idx, prefer_sibling = 0;
+//
+//     if (child && child->flags & SD_PREFER_SIBLING)
+//             prefer_sibling = 1;
+//
+//     init_sd_power_savings_stats(sd, sds, idle);
+//     load_idx = get_sd_load_idx(sd, idle);
+//
+//     do {
+//             int local_group;
+//
+//             local_group = cpumask_test_cpu(this_cpu, sched_group_cpus(sg));
+//             memset(&sgs, 0, sizeof(sgs));
+////           update_sg_lb_stats(sd, sg, this_cpu, idle, load_idx, sd_idle,
+////                           local_group, cpus, balance, &sgs);
+//
+//             if (local_group && !(*balance))
+//                     return;
+//
+////           sds->total_load += sgs.group_load;
+//             sds->total_pwr += sg->cpu_power;
+//
+//             /*
+//              * In case the child domain prefers tasks go to siblings
+//              * first, lower the sg capacity to one so that we'll try
+//              * and move all the excess tasks away. We lower the capacity
+//              * of a group only if the local group has the capacity to fit
+//              * these excess tasks, i.e. nr_running < group_capacity. The
+//              * extra check prevents the case where you always pull from the
+//              * heaviest group when it is already under-utilized (possible
+//              * with a large weight task outweighs the tasks on the system).
+//              */
+//             if (prefer_sibling && !local_group && sds->this_has_capacity)
+//                     sgs.group_capacity = min(sgs.group_capacity, 1UL);
+//
+//             if (local_group) {
+//                     sds->this_load = sgs.avg_load;
+//                     sds->this = sg;
+//                     sds->this_nr_running = sgs.sum_nr_running;
+//                     sds->this_load_per_task = sgs.sum_weighted_load;
+//                     sds->this_has_capacity = sgs.group_has_capacity;
+//                     sds->this_idle_cpus = sgs.idle_cpus;
+//             } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) {
+//                     sds->max_load = sgs.avg_load;
+//                     sds->busiest = sg;
+//                     sds->busiest_nr_running = sgs.sum_nr_running;
+//                     sds->busiest_idle_cpus = sgs.idle_cpus;
+//                     sds->busiest_group_capacity = sgs.group_capacity;
+//                     sds->busiest_load_per_task = sgs.sum_weighted_load;
+//                     sds->busiest_has_capacity = sgs.group_has_capacity;
+//                     sds->busiest_group_weight = sgs.group_weight;
+//                     sds->group_imb = sgs.group_imb;
+//             }
+//
+//             update_sd_power_savings_stats(sg, sds, local_group, &sgs);
+//             sg = sg->next;
+//     } while (sg != sd->groups);
+//}
+
+int __weak arch_sd_sibling_asym_packing(void)
 {
-       struct rq *busiest_rq = data;
-       int busiest_cpu = cpu_of(busiest_rq);
-       int target_cpu = busiest_rq->push_cpu;
-       struct rq *target_rq = cpu_rq(target_cpu);
-       struct sched_domain *sd;
+       return 0*SD_ASYM_PACKING;
+}
 
-       raw_spin_lock_irq(&busiest_rq->lock);
+/**
+ * check_asym_packing - Check to see if the group is packed into the
+ *                     sched doman.
+ *
+ * This is primarily intended to used at the sibling level.  Some
+ * cores like POWER7 prefer to use lower numbered SMT threads.  In the
+ * case of POWER7, it can move to lower SMT modes only when higher
+ * threads are idle.  When in lower SMT modes, the threads will
+ * perform better since they share less core resources.  Hence when we
+ * have idle threads, we want them to be the higher ones.
+ *
+ * This packing function is run on idle threads.  It checks to see if
+ * the busiest CPU in this domain (core in the P7 case) has a higher
+ * CPU number than the packing function is being run on.  Here we are
+ * assuming lower CPU number will be equivalent to lower a SMT thread
+ * number.
+ *
+ * Returns 1 when packing is required and a task should be moved to
+ * this CPU.  The amount of the imbalance is returned in *imbalance.
+ *
+ * @sd: The sched_domain whose packing is to be checked.
+ * @sds: Statistics of the sched_domain which is to be packed
+ * @this_cpu: The cpu at whose sched_domain we're performing load-balance.
+ * @imbalance: returns amount of imbalanced due to packing.
+ */
+//static int check_asym_packing(struct sched_domain *sd,
+//                           struct sd_lb_stats *sds,
+//                           int this_cpu, unsigned long *imbalance)
+//{
+//     int busiest_cpu;
+//
+//     if (!(sd->flags & SD_ASYM_PACKING))
+//             return 0;
+//
+//     if (!sds->busiest)
+//             return 0;
+//
+//     busiest_cpu = group_first_cpu(sds->busiest);
+//     if (this_cpu > busiest_cpu)
+//             return 0;
+//
+//     *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->cpu_power,
+//                                    SCHED_LOAD_SCALE);
+//     return 1;
+//}
 
-       /* make sure the requested cpu hasn't gone down in the meantime */
-       if (unlikely(busiest_cpu != smp_processor_id() ||
-                    !busiest_rq->active_balance))
-               goto out_unlock;
+/**
+ * fix_small_imbalance - Calculate the minor imbalance that exists
+ *                     amongst the groups of a sched_domain, during
+ *                     load balancing.
+ * @sds: Statistics of the sched_domain whose imbalance is to be calculated.
+ * @this_cpu: The cpu at whose sched_domain we're performing load-balance.
+ * @imbalance: Variable to store the imbalance.
+ */
+//static inline void fix_small_imbalance(struct sd_lb_stats *sds,
+//                             int this_cpu, unsigned long *imbalance)
+//{
+//     unsigned long tmp, pwr_now = 0, pwr_move = 0;
+//     unsigned int imbn = 2;
+//     unsigned long scaled_busy_load_per_task;
+//
+//     if (sds->this_nr_running) {
+//             sds->this_load_per_task /= sds->this_nr_running;
+//             if (sds->busiest_load_per_task >
+//                             sds->this_load_per_task)
+//                     imbn = 1;
+//     } else
+//             sds->this_load_per_task =
+//                     cpu_avg_load_per_task(this_cpu);
+//
+//     scaled_busy_load_per_task = sds->busiest_load_per_task
+//                                              * SCHED_LOAD_SCALE;
+//     scaled_busy_load_per_task /= sds->busiest->cpu_power;
+//
+//     if (sds->max_load - sds->this_load + scaled_busy_load_per_task >=
+//                     (scaled_busy_load_per_task * imbn)) {
+//             *imbalance = sds->busiest_load_per_task;
+//             return;
+//     }
+//
+//     /*
+//      * OK, we don't have enough imbalance to justify moving tasks,
+//      * however we may be able to increase total CPU power used by
+//      * moving them.
+//      */
+//
+//     pwr_now += sds->busiest->cpu_power *
+//                     min(sds->busiest_load_per_task, sds->max_load);
+//     pwr_now += sds->this->cpu_power *
+//                     min(sds->this_load_per_task, sds->this_load);
+//     pwr_now /= SCHED_LOAD_SCALE;
+//
+//     /* Amount of load we'd subtract */
+//     tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
+//             sds->busiest->cpu_power;
+//     if (sds->max_load > tmp)
+//             pwr_move += sds->busiest->cpu_power *
+//                     min(sds->busiest_load_per_task, sds->max_load - tmp);
+//
+//     /* Amount of load we'd add */
+//     if (sds->max_load * sds->busiest->cpu_power <
+//             sds->busiest_load_per_task * SCHED_LOAD_SCALE)
+//             tmp = (sds->max_load * sds->busiest->cpu_power) /
+//                     sds->this->cpu_power;
+//     else
+//             tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
+//                     sds->this->cpu_power;
+//     pwr_move += sds->this->cpu_power *
+//                     min(sds->this_load_per_task, sds->this_load + tmp);
+//     pwr_move /= SCHED_LOAD_SCALE;
+//
+//     /* Move if we gain throughput */
+//     if (pwr_move > pwr_now)
+//             *imbalance = sds->busiest_load_per_task;
+//}
 
-       /* Is there any task to move? */
-       if (busiest_rq->nr_running <= 1)
-               goto out_unlock;
+/**
+ * calculate_imbalance - Calculate the amount of imbalance present within the
+ *                      groups of a given sched_domain during load balance.
+ * @sds: statistics of the sched_domain whose imbalance is to be calculated.
+ * @this_cpu: Cpu for which currently load balance is being performed.
+ * @imbalance: The variable to store the imbalance.
+ */
+//static inline void calculate_imbalance(struct sd_lb_stats *sds, int this_cpu,
+//             unsigned long *imbalance)
+//{
+//     unsigned long max_pull, load_above_capacity = ~0UL;
+//
+//     sds->busiest_load_per_task /= sds->busiest_nr_running;
+//     if (sds->group_imb) {
+//             sds->busiest_load_per_task =
+//                     min(sds->busiest_load_per_task, sds->avg_load);
+//     }
+//
+//     /*
+//      * In the presence of smp nice balancing, certain scenarios can have
+//      * max load less than avg load(as we skip the groups at or below
+//      * its cpu_power, while calculating max_load..)
+//      */
+//     if (sds->max_load < sds->avg_load) {
+//             *imbalance = 0;
+//             return fix_small_imbalance(sds, this_cpu, imbalance);
+//     }
+//
+//     if (!sds->group_imb) {
+//             /*
+//              * Don't want to pull so many tasks that a group would go idle.
+//              */
+//             load_above_capacity = (sds->busiest_nr_running -
+//                                             sds->busiest_group_capacity);
+//
+//             load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_LOAD_SCALE);
+//
+//             load_above_capacity /= sds->busiest->cpu_power;
+//     }
+//
+//     /*
+//      * We're trying to get all the cpus to the average_load, so we don't
+//      * want to push ourselves above the average load, nor do we wish to
+//      * reduce the max loaded cpu below the average load. At the same time,
+//      * we also don't want to reduce the group load below the group capacity
+//      * (so that we can implement power-savings policies etc). Thus we look
+//      * for the minimum possible imbalance.
+//      * Be careful of negative numbers as they'll appear as very large values
+//      * with unsigned longs.
+//      */
+//     max_pull = min(sds->max_load - sds->avg_load, load_above_capacity);
+//
+//     /* How much load to actually move to equalise the imbalance */
+//     *imbalance = min(max_pull * sds->busiest->cpu_power,
+//             (sds->avg_load - sds->this_load) * sds->this->cpu_power)
+//                     / SCHED_LOAD_SCALE;
+//
+//     /*
+//      * if *imbalance is less than the average load per runnable task
+//      * there is no gaurantee that any tasks will be moved so we'll have
+//      * a think about bumping its value to force at least one task to be
+//      * moved
+//      */
+//     if (*imbalance < sds->busiest_load_per_task)
+//             return fix_small_imbalance(sds, this_cpu, imbalance);
+//
+//}
 
-       /*
-        * This condition is "impossible", if it occurs
-        * we need to fix it. Originally reported by
-        * Bjorn Helgaas on a 128-cpu setup.
-        */
-       BUG_ON(busiest_rq == target_rq);
+/******* find_busiest_group() helpers end here *********************/
 
-       /* move a task from busiest_rq to target_rq */
-       double_lock_balance(busiest_rq, target_rq);
+/**
+ * find_busiest_group - Returns the busiest group within the sched_domain
+ * if there is an imbalance. If there isn't an imbalance, and
+ * the user has opted for power-savings, it returns a group whose
+ * CPUs can be put to idle by rebalancing those tasks elsewhere, if
+ * such a group exists.
+ *
+ * Also calculates the amount of weighted load which should be moved
+ * to restore balance.
+ *
+ * @sd: The sched_domain whose busiest group is to be returned.
+ * @this_cpu: The cpu for which load balancing is currently being performed.
+ * @imbalance: Variable which stores amount of weighted load which should
+ *             be moved to restore balance/put a group to idle.
+ * @idle: The idle status of this_cpu.
+ * @sd_idle: The idleness of sd
+ * @cpus: The set of CPUs under consideration for load-balancing.
+ * @balance: Pointer to a variable indicating if this_cpu
+ *     is the appropriate cpu to perform load balancing at this_level.
+ *
+ * Returns:    - the busiest group if imbalance exists.
+ *             - If no imbalance and user has opted for power-savings balance,
+ *                return the least loaded group whose CPUs can be
+ *                put to idle by rebalancing its tasks onto our group.
+ */
+//static struct sched_group *
+//find_busiest_group(struct sched_domain *sd, int this_cpu,
+//                unsigned long *imbalance, enum cpu_idle_type idle,
+//                int *sd_idle, const struct cpumask *cpus, int *balance)
+//{
+//     struct sd_lb_stats sds;
+//
+//     memset(&sds, 0, sizeof(sds));
+//
+//     /*
+//      * Compute the various statistics relavent for load balancing at
+//      * this level.
+//      */
+//     update_sd_lb_stats(sd, this_cpu, idle, sd_idle, cpus,
+//                                     balance, &sds);
+//
+//     /* Cases where imbalance does not exist from POV of this_cpu */
+//     /* 1) this_cpu is not the appropriate cpu to perform load balancing
+//      *    at this level.
+//      * 2) There is no busy sibling group to pull from.
+//      * 3) This group is the busiest group.
+//      * 4) This group is more busy than the avg busieness at this
+//      *    sched_domain.
+//      * 5) The imbalance is within the specified limit.
+//      *
+//      * Note: when doing newidle balance, if the local group has excess
+//      * capacity (i.e. nr_running < group_capacity) and the busiest group
+//      * does not have any capacity, we force a load balance to pull tasks
+//      * to the local group. In this case, we skip past checks 3, 4 and 5.
+//      */
+//     if (!(*balance))
+//             goto ret;
+//
+//     if ((idle == CPU_IDLE || idle == CPU_NEWLY_IDLE) &&
+//         check_asym_packing(sd, &sds, this_cpu, imbalance))
+//             return sds.busiest;
+//
+//     if (!sds.busiest || sds.busiest_nr_running == 0)
+//             goto out_balanced;
+//
+//     /*  SD_BALANCE_NEWIDLE trumps SMP nice when underutilized */
+//     if (idle == CPU_NEWLY_IDLE && sds.this_has_capacity &&
+//                     !sds.busiest_has_capacity)
+//             goto force_balance;
+//
+//     if (sds.this_load >= sds.max_load)
+//             goto out_balanced;
+//
+//     sds.avg_load = (SCHED_LOAD_SCALE * sds.total_load) / sds.total_pwr;
+//
+//     if (sds.this_load >= sds.avg_load)
+//             goto out_balanced;
+//
+//     /*
+//      * In the CPU_NEWLY_IDLE, use imbalance_pct to be conservative.
+//      * And to check for busy balance use !idle_cpu instead of
+//      * CPU_NOT_IDLE. This is because HT siblings will use CPU_NOT_IDLE
+//      * even when they are idle.
+//      */
+//     if (idle == CPU_NEWLY_IDLE || !idle_cpu(this_cpu)) {
+//             if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load)
+//                     goto out_balanced;
+//     } else {
+//             /*
+//              * This cpu is idle. If the busiest group load doesn't
+//              * have more tasks than the number of available cpu's and
+//              * there is no imbalance between this and busiest group
+//              * wrt to idle cpu's, it is balanced.
+//              */
+//             if ((sds.this_idle_cpus  <= sds.busiest_idle_cpus + 1) &&
+//                 sds.busiest_nr_running <= sds.busiest_group_weight)
+//                     goto out_balanced;
+//     }
+//
+//force_balance:
+//     /* Looks like there is an imbalance. Compute it */
+//     calculate_imbalance(&sds, this_cpu, imbalance);
+//     return sds.busiest;
+//
+//out_balanced:
+//     /*
+//      * There is no obvious imbalance. But check if we can do some balancing
+//      * to save power.
+//      */
+//     if (check_power_save_busiest_group(&sds, this_cpu, imbalance))
+//             return sds.busiest;
+//ret:
+//     *imbalance = 0;
+//     return NULL;
+//}
 
-       /* Search for an sd spanning us and the target CPU. */
-       for_each_domain(target_cpu, sd) {
-               if ((sd->flags & SD_LOAD_BALANCE) &&
-                   cpumask_test_cpu(busiest_cpu, sched_domain_span(sd)))
-                               break;
-       }
+/*
+ * find_busiest_queue - find the busiest runqueue among the cpus in group.
+ */
+//static struct rq *
+//find_busiest_queue(struct sched_domain *sd, struct sched_group *group,
+//                enum cpu_idle_type idle, unsigned long imbalance,
+//                const struct cpumask *cpus)
+//{
+//     struct rq *busiest = NULL, *rq;
+//     unsigned long max_load = 0;
+//     int i;
+//
+//     for_each_cpu(i, sched_group_cpus(group)) {
+//             unsigned long power = power_of(i);
+//             unsigned long capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE);
+//             unsigned long wl;
+//
+//             if (!capacity)
+//                     capacity = fix_small_capacity(sd, group);
+//
+//             if (!cpumask_test_cpu(i, cpus))
+//                     continue;
+//
+//             rq = cpu_rq(i);
+//             wl = weighted_cpuload(i);
+//
+//             /*
+//              * When comparing with imbalance, use weighted_cpuload()
+//              * which is not scaled with the cpu power.
+//              */
+//             if (capacity && rq->nr_running == 1 && wl > imbalance)
+//                     continue;
+//
+//             /*
+//              * For the load comparisons with the other cpu's, consider
+//              * the weighted_cpuload() scaled with the cpu power, so that
+//              * the load can be moved away from the cpu that is potentially
+//              * running at a lower capacity.
+//              */
+//             wl = (wl * SCHED_LOAD_SCALE) / power;
+//
+//             if (wl > max_load) {
+//                     max_load = wl;
+//                     busiest = rq;
+//             }
+//     }
+//
+//     return busiest;
+//}
 
-       if (likely(sd)) {
-               schedstat_inc(sd, alb_count);
+/*
+ * Max backoff if we encounter pinned tasks. Pretty arbitrary value, but
+ * so long as it is large enough.
+ */
+#define MAX_PINNED_INTERVAL    512
 
-               if (move_one_task(target_rq, target_cpu, busiest_rq,
-                                 sd, CPU_IDLE))
-                       schedstat_inc(sd, alb_pushed);
-               else
-                       schedstat_inc(sd, alb_failed);
-       }
-       double_unlock_balance(busiest_rq, target_rq);
-out_unlock:
-       busiest_rq->active_balance = 0;
-       raw_spin_unlock_irq(&busiest_rq->lock);
-       return 0;
-}
+///* Working cpumask for load_balance and load_balance_newidle. */
+//static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask);
+//
+//static int need_active_balance(struct sched_domain *sd, int sd_idle, int idle,
+//                            int busiest_cpu, int this_cpu)
+//{
+//     if (idle == CPU_NEWLY_IDLE) {
+//
+//             /*
+//              * ASYM_PACKING needs to force migrate tasks from busy but
+//              * higher numbered CPUs in order to pack all tasks in the
+//              * lowest numbered CPUs.
+//              */
+//             if ((sd->flags & SD_ASYM_PACKING) && busiest_cpu > this_cpu)
+//                     return 1;
+//
+//             /*
+//              * The only task running in a non-idle cpu can be moved to this
+//              * cpu in an attempt to completely freeup the other CPU
+//              * package.
+//              *
+//              * The package power saving logic comes from
+//              * find_busiest_group(). If there are no imbalance, then
+//              * f_b_g() will return NULL. However when sched_mc={1,2} then
+//              * f_b_g() will select a group from which a running task may be
+//              * pulled to this cpu in order to make the other package idle.
+//              * If there is no opportunity to make a package idle and if
+//              * there are no imbalance, then f_b_g() will return NULL and no
+//              * action will be taken in load_balance_newidle().
+//              *
+//              * Under normal task pull operation due to imbalance, there
+//              * will be more than one task in the source run queue and
+//              * move_tasks() will succeed.  ld_moved will be true and this
+//              * active balance code will not be triggered.
+//              */
+//             if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
+//                 !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
+//                     return 0;
+//
+//             if (sched_mc_power_savings < POWERSAVINGS_BALANCE_WAKEUP)
+//                     return 0;
+//     }
+//
+//     return unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2);
+//}
+//
+//static int active_load_balance_cpu_stop(void *data);
+//
+///*
+// * Check this_cpu to ensure it is balanced within domain. Attempt to move
+// * tasks if there is an imbalance.
+// */
+//static int load_balance(int this_cpu, struct rq *this_rq,
+//                     struct sched_domain *sd, enum cpu_idle_type idle,
+//                     int *balance)
+//{
+//     int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0;
+//     struct sched_group *group;
+//     unsigned long imbalance;
+//     struct rq *busiest;
+//     unsigned long flags;
+//     struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
+//
+//     cpumask_copy(cpus, cpu_active_mask);
+//
+//     /*
+//      * When power savings policy is enabled for the parent domain, idle
+//      * sibling can pick up load irrespective of busy siblings. In this case,
+//      * let the state of idle sibling percolate up as CPU_IDLE, instead of
+//      * portraying it as CPU_NOT_IDLE.
+//      */
+//     if (idle != CPU_NOT_IDLE && sd->flags & SD_SHARE_CPUPOWER &&
+//         !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
+//             sd_idle = 1;
+//
+//     schedstat_inc(sd, lb_count[idle]);
+//
+//redo:
+//     group = find_busiest_group(sd, this_cpu, &imbalance, idle, &sd_idle,
+//                                cpus, balance);
+//
+//     if (*balance == 0)
+//             goto out_balanced;
+//
+//     if (!group) {
+//             schedstat_inc(sd, lb_nobusyg[idle]);
+//             goto out_balanced;
+//     }
+//
+//     busiest = find_busiest_queue(sd, group, idle, imbalance, cpus);
+//     if (!busiest) {
+//             schedstat_inc(sd, lb_nobusyq[idle]);
+//             goto out_balanced;
+//     }
+//
+//     BUG_ON(busiest == this_rq);
+//
+//     schedstat_add(sd, lb_imbalance[idle], imbalance);
+//
+//     ld_moved = 0;
+//     if (busiest->nr_running > 1) {
+//             /*
+//              * Attempt to move tasks. If find_busiest_group has found
+//              * an imbalance but busiest->nr_running <= 1, the group is
+//              * still unbalanced. ld_moved simply stays zero, so it is
+//              * correctly treated as an imbalance.
+//              */
+//             all_pinned = 1;
+//             local_irq_save(flags);
+//             double_rq_lock(this_rq, busiest);
+//             ld_moved = move_tasks(this_rq, this_cpu, busiest,
+//                                   imbalance, sd, idle, &all_pinned);
+//             double_rq_unlock(this_rq, busiest);
+//             local_irq_restore(flags);
+//
+//             /*
+//              * some other cpu did the load balance for us.
+//              */
+//             if (ld_moved && this_cpu != smp_processor_id())
+//                     resched_cpu(this_cpu);
+//
+//             /* All tasks on this runqueue were pinned by CPU affinity */
+//             if (unlikely(all_pinned)) {
+//                     cpumask_clear_cpu(cpu_of(busiest), cpus);
+//                     if (!cpumask_empty(cpus))
+//                             goto redo;
+//                     goto out_balanced;
+//             }
+//     }
+//
+//     if (!ld_moved) {
+//             schedstat_inc(sd, lb_failed[idle]);
+//             /*
+//              * Increment the failure counter only on periodic balance.
+//              * We do not want newidle balance, which can be very
+//              * frequent, pollute the failure counter causing
+//              * excessive cache_hot migrations and active balances.
+//              */
+//             if (idle != CPU_NEWLY_IDLE)
+//                     sd->nr_balance_failed++;
+//
+//             if (need_active_balance(sd, sd_idle, idle, cpu_of(busiest),
+//                                     this_cpu)) {
+//                     raw_spin_lock_irqsave(&busiest->lock, flags);
+//
+//                     /* don't kick the active_load_balance_cpu_stop,
+//                      * if the curr task on busiest cpu can't be
+//                      * moved to this_cpu
+//                      */
+//                     if (!cpumask_test_cpu(this_cpu,
+//                                           &busiest->curr->cpus_allowed)) {
+//                             raw_spin_unlock_irqrestore(&busiest->lock,
+//                                                         flags);
+//                             all_pinned = 1;
+//                             goto out_one_pinned;
+//                     }
+//
+//                     /*
+//                      * ->active_balance synchronizes accesses to
+//                      * ->active_balance_work.  Once set, it's cleared
+//                      * only after active load balance is finished.
+//                      */
+//                     if (!busiest->active_balance) {
+//                             busiest->active_balance = 1;
+//                             busiest->push_cpu = this_cpu;
+//                             active_balance = 1;
+//                     }
+//                     raw_spin_unlock_irqrestore(&busiest->lock, flags);
+//
+//                     if (active_balance)
+//                             stop_one_cpu_nowait(cpu_of(busiest),
+//                                     active_load_balance_cpu_stop, busiest,
+//                                     &busiest->active_balance_work);
+//
+//                     /*
+//                      * We've kicked active balancing, reset the failure
+//                      * counter.
+//                      */
+//                     sd->nr_balance_failed = sd->cache_nice_tries+1;
+//             }
+//     } else
+//             sd->nr_balance_failed = 0;
+//
+//     if (likely(!active_balance)) {
+//             /* We were unbalanced, so reset the balancing interval */
+//             sd->balance_interval = sd->min_interval;
+//     } else {
+//             /*
+//              * If we've begun active balancing, start to back off. This
+//              * case may not be covered by the all_pinned logic if there
+//              * is only 1 task on the busy runqueue (because we don't call
+//              * move_tasks).
+//              */
+//             if (sd->balance_interval < sd->max_interval)
+//                     sd->balance_interval *= 2;
+//     }
+//
+//     if (!ld_moved && !sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
+//         !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
+//             ld_moved = -1;
+//
+//     goto out;
+//
+//out_balanced:
+//     schedstat_inc(sd, lb_balanced[idle]);
+//
+//     sd->nr_balance_failed = 0;
+//
+//out_one_pinned:
+//     /* tune up the balancing interval */
+//     if ((all_pinned && sd->balance_interval < MAX_PINNED_INTERVAL) ||
+//                     (sd->balance_interval < sd->max_interval))
+//             sd->balance_interval *= 2;
+//
+//     if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
+//         !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
+//             ld_moved = -1;
+//     else
+//             ld_moved = 0;
+//out:
+//     return ld_moved;
+//}
+//
+///*
+// * idle_balance is called by schedule() if this_cpu is about to become
+// * idle. Attempts to pull tasks from other CPUs.
+// */
+//static void idle_balance(int this_cpu, struct rq *this_rq)
+//{
+//     struct sched_domain *sd;
+//     int pulled_task = 0;
+//     unsigned long next_balance = jiffies + HZ;
+//
+//     this_rq->idle_stamp = this_rq->clock;
+//
+//     if (this_rq->avg_idle < sysctl_sched_migration_cost)
+//             return;
+//
+//     /*
+//      * Drop the rq->lock, but keep IRQ/preempt disabled.
+//      */
+//     raw_spin_unlock(&this_rq->lock);
+//
+//     update_shares(this_cpu);
+//     for_each_domain(this_cpu, sd) {
+//             unsigned long interval;
+//             int balance = 1;
+//
+//             if (!(sd->flags & SD_LOAD_BALANCE))
+//                     continue;
+//
+//             if (sd->flags & SD_BALANCE_NEWIDLE) {
+//                     /* If we've pulled tasks over stop searching: */
+//                     pulled_task = load_balance(this_cpu, this_rq,
+//                                                sd, CPU_NEWLY_IDLE, &balance);
+//             }
+//
+//             interval = msecs_to_jiffies(sd->balance_interval);
+//             if (time_after(next_balance, sd->last_balance + interval))
+//                     next_balance = sd->last_balance + interval;
+//             if (pulled_task) {
+//                     this_rq->idle_stamp = 0;
+//                     break;
+//             }
+//     }
+//
+//     raw_spin_lock(&this_rq->lock);
+//
+//     if (pulled_task || time_after(jiffies, this_rq->next_balance)) {
+//             /*
+//              * We are going idle. next_balance may be set based on
+//              * a busy processor. So reset next_balance.
+//              */
+//             this_rq->next_balance = next_balance;
+//     }
+//}
+//
+///*
+// * active_load_balance_cpu_stop is run by cpu stopper. It pushes
+// * running tasks off the busiest CPU onto idle CPUs. It requires at
+// * least 1 task to be running on each physical CPU where possible, and
+// * avoids physical / logical imbalances.
+// */
+//static int active_load_balance_cpu_stop(void *data)
+//{
+//     struct rq *busiest_rq = data;
+//     int busiest_cpu = cpu_of(busiest_rq);
+//     int target_cpu = busiest_rq->push_cpu;
+//     struct rq *target_rq = cpu_rq(target_cpu);
+//     struct sched_domain *sd;
+//
+//     raw_spin_lock_irq(&busiest_rq->lock);
+//
+//     /* make sure the requested cpu hasn't gone down in the meantime */
+//     if (unlikely(busiest_cpu != smp_processor_id() ||
+//                  !busiest_rq->active_balance))
+//             goto out_unlock;
+//
+//     /* Is there any task to move? */
+//     if (busiest_rq->nr_running <= 1)
+//             goto out_unlock;
+//
+//     /*
+//      * This condition is "impossible", if it occurs
+//      * we need to fix it. Originally reported by
+//      * Bjorn Helgaas on a 128-cpu setup.
+//      */
+//     BUG_ON(busiest_rq == target_rq);
+//
+//     /* move a task from busiest_rq to target_rq */
+//     double_lock_balance(busiest_rq, target_rq);
+//
+//     /* Search for an sd spanning us and the target CPU. */
+//     for_each_domain(target_cpu, sd) {
+//             if ((sd->flags & SD_LOAD_BALANCE) &&
+//                 cpumask_test_cpu(busiest_cpu, sched_domain_span(sd)))
+//                             break;
+//     }
+//
+//     if (likely(sd)) {
+//             schedstat_inc(sd, alb_count);
+//
+//             if (move_one_task(target_rq, target_cpu, busiest_rq,
+//                               sd, CPU_IDLE))
+//                     schedstat_inc(sd, alb_pushed);
+//             else
+//                     schedstat_inc(sd, alb_failed);
+//     }
+//     double_unlock_balance(busiest_rq, target_rq);
+//out_unlock:
+//     busiest_rq->active_balance = 0;
+//     raw_spin_unlock_irq(&busiest_rq->lock);
+//     return 0;
+//}
 
 #ifdef CONFIG_NO_HZ
 
@@ -3552,18 +3548,18 @@ static inline void init_sched_softirq_csd(struct call_single_data *csd)
  *   load balancing for all the idle CPUs.
  */
 static struct {
-       atomic_t load_balancer;
+//     atomic_t load_balancer;
        atomic_t first_pick_cpu;
        atomic_t second_pick_cpu;
        cpumask_var_t idle_cpus_mask;
        cpumask_var_t grp_idle_mask;
-       unsigned long next_balance;     /* in jiffy units */
+//     unsigned long next_balance;     /* in jiffy units */
 } nohz ____cacheline_aligned;
 
-int get_nohz_load_balancer(void)
-{
-       return atomic_read(&nohz.load_balancer);
-}
+//int get_nohz_load_balancer(void)
+//{
+//     return atomic_read(&nohz.load_balancer);
+//}
 
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
 /**
@@ -3639,45 +3635,45 @@ static inline int is_semi_idle_group(struct sched_group *ilb_group)
  * completely idle packages/cores just for the purpose of idle load balancing
  * when there are other idle cpu's which are better suited for that job.
  */
-static int find_new_ilb(int cpu)
-{
-       struct sched_domain *sd;
-       struct sched_group *ilb_group;
-
-       /*
-        * Have idle load balancer selection from semi-idle packages only
-        * when power-aware load balancing is enabled
-        */
-       if (!(sched_smt_power_savings || sched_mc_power_savings))
-               goto out_done;
-
-       /*
-        * Optimize for the case when we have no idle CPUs or only one
-        * idle CPU. Don't walk the sched_domain hierarchy in such cases
-        */
-       if (cpumask_weight(nohz.idle_cpus_mask) < 2)
-               goto out_done;
-
-       for_each_flag_domain(cpu, sd, SD_POWERSAVINGS_BALANCE) {
-               ilb_group = sd->groups;
-
-               do {
-                       if (is_semi_idle_group(ilb_group))
-                               return cpumask_first(nohz.grp_idle_mask);
-
-                       ilb_group = ilb_group->next;
-
-               } while (ilb_group != sd->groups);
-       }
-
-out_done:
-       return nr_cpu_ids;
-}
+//static int find_new_ilb(int cpu)
+//{
+//     struct sched_domain *sd;
+//     struct sched_group *ilb_group;
+//
+//     /*
+//      * Have idle load balancer selection from semi-idle packages only
+//      * when power-aware load balancing is enabled
+//      */
+//     if (!(sched_smt_power_savings || sched_mc_power_savings))
+//             goto out_done;
+//
+//     /*
+//      * Optimize for the case when we have no idle CPUs or only one
+//      * idle CPU. Don't walk the sched_domain hierarchy in such cases
+//      */
+//     if (cpumask_weight(nohz.idle_cpus_mask) < 2)
+//             goto out_done;
+//
+//     for_each_flag_domain(cpu, sd, SD_POWERSAVINGS_BALANCE) {
+//             ilb_group = sd->groups;
+//
+//             do {
+//                     if (is_semi_idle_group(ilb_group))
+//                             return cpumask_first(nohz.grp_idle_mask);
+//
+//                     ilb_group = ilb_group->next;
+//
+//             } while (ilb_group != sd->groups);
+//     }
+//
+//out_done:
+//     return nr_cpu_ids;
+//}
 #else /*  (CONFIG_SCHED_MC || CONFIG_SCHED_SMT) */
-static inline int find_new_ilb(int call_cpu)
-{
-       return nr_cpu_ids;
-}
+//static inline int find_new_ilb(int call_cpu)
+//{
+//     return nr_cpu_ids;
+//}
 #endif
 
 /*
@@ -3685,29 +3681,29 @@ static inline int find_new_ilb(int call_cpu)
  * nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
  * CPU (if there is one).
  */
-static void nohz_balancer_kick(int cpu)
-{
-       int ilb_cpu;
-
-       nohz.next_balance++;
-
-       ilb_cpu = get_nohz_load_balancer();
-
-       if (ilb_cpu >= nr_cpu_ids) {
-               ilb_cpu = cpumask_first(nohz.idle_cpus_mask);
-               if (ilb_cpu >= nr_cpu_ids)
-                       return;
-       }
-
-       if (!cpu_rq(ilb_cpu)->nohz_balance_kick) {
-               struct call_single_data *cp;
-
-               cpu_rq(ilb_cpu)->nohz_balance_kick = 1;
-               cp = &per_cpu(remote_sched_softirq_cb, cpu);
-               __smp_call_function_single(ilb_cpu, cp, 0);
-       }
-       return;
-}
+//static void nohz_balancer_kick(int cpu)
+//{
+//     int ilb_cpu;
+//
+//     nohz.next_balance++;
+//
+//     ilb_cpu = get_nohz_load_balancer();
+//
+//     if (ilb_cpu >= nr_cpu_ids) {
+//             ilb_cpu = cpumask_first(nohz.idle_cpus_mask);
+//             if (ilb_cpu >= nr_cpu_ids)
+//                     return;
+//     }
+//
+//     if (!cpu_rq(ilb_cpu)->nohz_balance_kick) {
+//             struct call_single_data *cp;
+//
+//             cpu_rq(ilb_cpu)->nohz_balance_kick = 1;
+//             cp = &per_cpu(remote_sched_softirq_cb, cpu);
+//             __smp_call_function_single(ilb_cpu, cp, 0);
+//     }
+//     return;
+//}
 
 /*
  * This routine will try to nominate the ilb (idle load balancing)
@@ -3724,67 +3720,67 @@ static void nohz_balancer_kick(int cpu)
  */
 void select_nohz_load_balancer(int stop_tick)
 {
-       int cpu = smp_processor_id();
-
-       if (stop_tick) {
-               if (!cpu_active(cpu)) {
-                       if (atomic_read(&nohz.load_balancer) != cpu)
-                               return;
-
-                       /*
-                        * If we are going offline and still the leader,
-                        * give up!
-                        */
-                       if (atomic_cmpxchg(&nohz.load_balancer, cpu,
-                                          nr_cpu_ids) != cpu)
-                               BUG();
-
-                       return;
-               }
-
-               cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
-
-               if (atomic_read(&nohz.first_pick_cpu) == cpu)
-                       atomic_cmpxchg(&nohz.first_pick_cpu, cpu, nr_cpu_ids);
-               if (atomic_read(&nohz.second_pick_cpu) == cpu)
-                       atomic_cmpxchg(&nohz.second_pick_cpu, cpu, nr_cpu_ids);
-
-               if (atomic_read(&nohz.load_balancer) >= nr_cpu_ids) {
-                       int new_ilb;
-
-                       /* make me the ilb owner */
-                       if (atomic_cmpxchg(&nohz.load_balancer, nr_cpu_ids,
-                                          cpu) != nr_cpu_ids)
-                               return;
-
-                       /*
-                        * Check to see if there is a more power-efficient
-                        * ilb.
-                        */
-                       new_ilb = find_new_ilb(cpu);
-                       if (new_ilb < nr_cpu_ids && new_ilb != cpu) {
-                               atomic_set(&nohz.load_balancer, nr_cpu_ids);
-                               resched_cpu(new_ilb);
-                               return;
-                       }
-                       return;
-               }
-       } else {
-               if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
-                       return;
-
-               cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
-
-               if (atomic_read(&nohz.load_balancer) == cpu)
-                       if (atomic_cmpxchg(&nohz.load_balancer, cpu,
-                                          nr_cpu_ids) != cpu)
-                               BUG();
-       }
-       return;
+//     int cpu = smp_processor_id();
+//
+//     if (stop_tick) {
+//             if (!cpu_active(cpu)) {
+//                     if (atomic_read(&nohz.load_balancer) != cpu)
+//                             return;
+//
+//                     /*
+//                      * If we are going offline and still the leader,
+//                      * give up!
+//                      */
+//                     if (atomic_cmpxchg(&nohz.load_balancer, cpu,
+//                                        nr_cpu_ids) != cpu)
+//                             BUG();
+//
+//                     return;
+//             }
+//
+//             cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
+//
+//             if (atomic_read(&nohz.first_pick_cpu) == cpu)
+//                     atomic_cmpxchg(&nohz.first_pick_cpu, cpu, nr_cpu_ids);
+//             if (atomic_read(&nohz.second_pick_cpu) == cpu)
+//                     atomic_cmpxchg(&nohz.second_pick_cpu, cpu, nr_cpu_ids);
+//
+//             if (atomic_read(&nohz.load_balancer) >= nr_cpu_ids) {
+//                     int new_ilb;
+//
+//                     /* make me the ilb owner */
+//                     if (atomic_cmpxchg(&nohz.load_balancer, nr_cpu_ids,
+//                                        cpu) != nr_cpu_ids)
+//                             return;
+//
+//                     /*
+//                      * Check to see if there is a more power-efficient
+//                      * ilb.
+//                      */
+//                     new_ilb = find_new_ilb(cpu);
+//                     if (new_ilb < nr_cpu_ids && new_ilb != cpu) {
+//                             atomic_set(&nohz.load_balancer, nr_cpu_ids);
+//                             resched_cpu(new_ilb);
+//                             return;
+//                     }
+//                     return;
+//             }
+//     } else {
+//             if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
+//                     return;
+//
+//             cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
+//
+//             if (atomic_read(&nohz.load_balancer) == cpu)
+//                     if (atomic_cmpxchg(&nohz.load_balancer, cpu,
+//                                        nr_cpu_ids) != cpu)
+//                             BUG();
+//     }
+//     return;
 }
 #endif
 
-static DEFINE_SPINLOCK(balancing);
+//static DEFINE_SPINLOCK(balancing);
 
 /*
  * It checks each scheduling domain to see if it is due to be balanced,
@@ -3792,120 +3788,120 @@ static DEFINE_SPINLOCK(balancing);
  *
  * Balancing parameters are set up in arch_init_sched_domains.
  */
-static void rebalance_domains(int cpu, enum cpu_idle_type idle)
-{
-       int balance = 1;
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long interval;
-       struct sched_domain *sd;
-       /* Earliest time when we have to do rebalance again */
-       unsigned long next_balance = jiffies + 60*HZ;
-       int update_next_balance = 0;
-       int need_serialize;
-
-       update_shares(cpu);
-
-       for_each_domain(cpu, sd) {
-               if (!(sd->flags & SD_LOAD_BALANCE))
-                       continue;
-
-               interval = sd->balance_interval;
-               if (idle != CPU_IDLE)
-                       interval *= sd->busy_factor;
-
-               /* scale ms to jiffies */
-               interval = msecs_to_jiffies(interval);
-               if (unlikely(!interval))
-                       interval = 1;
-               if (interval > HZ*NR_CPUS/10)
-                       interval = HZ*NR_CPUS/10;
-
-               need_serialize = sd->flags & SD_SERIALIZE;
-
-               if (need_serialize) {
-                       if (!spin_trylock(&balancing))
-                               goto out;
-               }
-
-               if (time_after_eq(jiffies, sd->last_balance + interval)) {
-                       if (load_balance(cpu, rq, sd, idle, &balance)) {
-                               /*
-                                * We've pulled tasks over so either we're no
-                                * longer idle, or one of our SMT siblings is
-                                * not idle.
-                                */
-                               idle = CPU_NOT_IDLE;
-                       }
-                       sd->last_balance = jiffies;
-               }
-               if (need_serialize)
-                       spin_unlock(&balancing);
-out:
-               if (time_after(next_balance, sd->last_balance + interval)) {
-                       next_balance = sd->last_balance + interval;
-                       update_next_balance = 1;
-               }
-
-               /*
-                * Stop the load balance at this level. There is another
-                * CPU in our sched group which is doing load balancing more
-                * actively.
-                */
-               if (!balance)
-                       break;
-       }
-
-       /*
-        * next_balance will be updated only when there is a need.
-        * When the cpu is attached to null domain for ex, it will not be
-        * updated.
-        */
-       if (likely(update_next_balance))
-               rq->next_balance = next_balance;
-}
+//static void rebalance_domains(int cpu, enum cpu_idle_type idle)
+//{
+//     int balance = 1;
+//     struct rq *rq = cpu_rq(cpu);
+//     unsigned long interval;
+//     struct sched_domain *sd;
+//     /* Earliest time when we have to do rebalance again */
+//     unsigned long next_balance = jiffies + 60*HZ;
+//     int update_next_balance = 0;
+//     int need_serialize;
+//
+//     update_shares(cpu);
+//
+//     for_each_domain(cpu, sd) {
+//             if (!(sd->flags & SD_LOAD_BALANCE))
+//                     continue;
+//
+//             interval = sd->balance_interval;
+//             if (idle != CPU_IDLE)
+//                     interval *= sd->busy_factor;
+//
+//             /* scale ms to jiffies */
+//             interval = msecs_to_jiffies(interval);
+//             if (unlikely(!interval))
+//                     interval = 1;
+//             if (interval > HZ*NR_CPUS/10)
+//                     interval = HZ*NR_CPUS/10;
+//
+//             need_serialize = sd->flags & SD_SERIALIZE;
+//
+//             if (need_serialize) {
+//                     if (!spin_trylock(&balancing))
+//                             goto out;
+//             }
+//
+//             if (time_after_eq(jiffies, sd->last_balance + interval)) {
+//                     if (load_balance(cpu, rq, sd, idle, &balance)) {
+//                             /*
+//                              * We've pulled tasks over so either we're no
+//                              * longer idle, or one of our SMT siblings is
+//                              * not idle.
+//                              */
+//                             idle = CPU_NOT_IDLE;
+//                     }
+//                     sd->last_balance = jiffies;
+//             }
+//             if (need_serialize)
+//                     spin_unlock(&balancing);
+//out:
+//             if (time_after(next_balance, sd->last_balance + interval)) {
+//                     next_balance = sd->last_balance + interval;
+//                     update_next_balance = 1;
+//             }
+//
+//             /*
+//              * Stop the load balance at this level. There is another
+//              * CPU in our sched group which is doing load balancing more
+//              * actively.
+//              */
+//             if (!balance)
+//                     break;
+//     }
+//
+//     /*
+//      * next_balance will be updated only when there is a need.
+//      * When the cpu is attached to null domain for ex, it will not be
+//      * updated.
+//      */
+//     if (likely(update_next_balance))
+//             rq->next_balance = next_balance;
+//}
 
 #ifdef CONFIG_NO_HZ
 /*
  * In CONFIG_NO_HZ case, the idle balance kickee will do the
  * rebalancing for all the cpus for whom scheduler ticks are stopped.
  */
-static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle)
-{
-       struct rq *this_rq = cpu_rq(this_cpu);
-       struct rq *rq;
-       int balance_cpu;
-
-       if (idle != CPU_IDLE || !this_rq->nohz_balance_kick)
-               return;
-
-       for_each_cpu(balance_cpu, nohz.idle_cpus_mask) {
-               if (balance_cpu == this_cpu)
-                       continue;
-
-               /*
-                * If this cpu gets work to do, stop the load balancing
-                * work being done for other cpus. Next load
-                * balancing owner will pick it up.
-                */
-               if (need_resched()) {
-                       this_rq->nohz_balance_kick = 0;
-                       break;
-               }
-
-               raw_spin_lock_irq(&this_rq->lock);
-               update_rq_clock(this_rq);
-               update_cpu_load(this_rq);
-               raw_spin_unlock_irq(&this_rq->lock);
-
-               rebalance_domains(balance_cpu, CPU_IDLE);
-
-               rq = cpu_rq(balance_cpu);
-               if (time_after(this_rq->next_balance, rq->next_balance))
-                       this_rq->next_balance = rq->next_balance;
-       }
-       nohz.next_balance = this_rq->next_balance;
-       this_rq->nohz_balance_kick = 0;
-}
+//static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle)
+//{
+//     struct rq *this_rq = cpu_rq(this_cpu);
+//     struct rq *rq;
+//     int balance_cpu;
+//
+//     if (idle != CPU_IDLE || !this_rq->nohz_balance_kick)
+//             return;
+//
+//     for_each_cpu(balance_cpu, nohz.idle_cpus_mask) {
+//             if (balance_cpu == this_cpu)
+//                     continue;
+//
+//             /*
+//              * If this cpu gets work to do, stop the load balancing
+//              * work being done for other cpus. Next load
+//              * balancing owner will pick it up.
+//              */
+//             if (need_resched()) {
+//                     this_rq->nohz_balance_kick = 0;
+//                     break;
+//             }
+//
+//             raw_spin_lock_irq(&this_rq->lock);
+//             update_rq_clock(this_rq);
+////           update_cpu_load(this_rq);
+//             raw_spin_unlock_irq(&this_rq->lock);
+//
+////           rebalance_domains(balance_cpu, CPU_IDLE);
+//
+//             rq = cpu_rq(balance_cpu);
+//             if (time_after(this_rq->next_balance, rq->next_balance))
+//                     this_rq->next_balance = rq->next_balance;
+//     }
+//     nohz.next_balance = this_rq->next_balance;
+//     this_rq->nohz_balance_kick = 0;
+//}
 
 /*
  * Current heuristic for kicking the idle load balancer
@@ -3919,63 +3915,63 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle)
  *   physical CPUs). So, second_pick_cpu is the second of the busy CPUs
  *   which will kick idle load balancer as soon as it has any load.
  */
-static inline int nohz_kick_needed(struct rq *rq, int cpu)
-{
-       unsigned long now = jiffies;
-       int ret;
-       int first_pick_cpu, second_pick_cpu;
-
-       if (time_before(now, nohz.next_balance))
-               return 0;
-
-       if (rq->idle_at_tick)
-               return 0;
-
-       first_pick_cpu = atomic_read(&nohz.first_pick_cpu);
-       second_pick_cpu = atomic_read(&nohz.second_pick_cpu);
-
-       if (first_pick_cpu < nr_cpu_ids && first_pick_cpu != cpu &&
-           second_pick_cpu < nr_cpu_ids && second_pick_cpu != cpu)
-               return 0;
-
-       ret = atomic_cmpxchg(&nohz.first_pick_cpu, nr_cpu_ids, cpu);
-       if (ret == nr_cpu_ids || ret == cpu) {
-               atomic_cmpxchg(&nohz.second_pick_cpu, cpu, nr_cpu_ids);
-               if (rq->nr_running > 1)
-                       return 1;
-       } else {
-               ret = atomic_cmpxchg(&nohz.second_pick_cpu, nr_cpu_ids, cpu);
-               if (ret == nr_cpu_ids || ret == cpu) {
-                       if (rq->nr_running)
-                               return 1;
-               }
-       }
-       return 0;
-}
+//static inline int nohz_kick_needed(struct rq *rq, int cpu)
+//{
+//     unsigned long now = jiffies;
+//     int ret;
+//     int first_pick_cpu, second_pick_cpu;
+//
+//     if (time_before(now, nohz.next_balance))
+//             return 0;
+//
+//     if (rq->idle_at_tick)
+//             return 0;
+//
+//     first_pick_cpu = atomic_read(&nohz.first_pick_cpu);
+//     second_pick_cpu = atomic_read(&nohz.second_pick_cpu);
+//
+//     if (first_pick_cpu < nr_cpu_ids && first_pick_cpu != cpu &&
+//         second_pick_cpu < nr_cpu_ids && second_pick_cpu != cpu)
+//             return 0;
+//
+//     ret = atomic_cmpxchg(&nohz.first_pick_cpu, nr_cpu_ids, cpu);
+//     if (ret == nr_cpu_ids || ret == cpu) {
+//             atomic_cmpxchg(&nohz.second_pick_cpu, cpu, nr_cpu_ids);
+//             if (rq->nr_running > 1)
+//                     return 1;
+//     } else {
+//             ret = atomic_cmpxchg(&nohz.second_pick_cpu, nr_cpu_ids, cpu);
+//             if (ret == nr_cpu_ids || ret == cpu) {
+//                     if (rq->nr_running)
+//                             return 1;
+//             }
+//     }
+//     return 0;
+//}
 #else
-static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
+//static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
 #endif
 
 /*
  * run_rebalance_domains is triggered when needed from the scheduler tick.
  * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
  */
-static void run_rebalance_domains(struct softirq_action *h)
-{
-       int this_cpu = smp_processor_id();
-       struct rq *this_rq = cpu_rq(this_cpu);
-       enum cpu_idle_type idle = this_rq->idle_at_tick ?
-                                               CPU_IDLE : CPU_NOT_IDLE;
-
-       rebalance_domains(this_cpu, idle);
-
-       /*
-        * If this cpu has a pending nohz_balance_kick, then do the
-        * balancing on behalf of the other idle cpus whose ticks are
-        * stopped.
-        */
-       nohz_idle_balance(this_cpu, idle);
-}
+//static void run_rebalance_domains(struct softirq_action *h)
+//{
+//     int this_cpu = smp_processor_id();
+//     struct rq *this_rq = cpu_rq(this_cpu);
+//     enum cpu_idle_type idle = this_rq->idle_at_tick ?
+//                                             CPU_IDLE : CPU_NOT_IDLE;
+//
+//     rebalance_domains(this_cpu, idle);
+//
+//     /*
+//      * If this cpu has a pending nohz_balance_kick, then do the
+//      * balancing on behalf of the other idle cpus whose ticks are
+//      * stopped.
+//      */
+//     nohz_idle_balance(this_cpu, idle);
+//}
 
 static inline int on_null_domain(int cpu)
 {
@@ -3985,17 +3981,17 @@ static inline int on_null_domain(int cpu)
 /*
  * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing.
  */
-static inline void trigger_load_balance(struct rq *rq, int cpu)
-{
-       /* Don't need to rebalance while attached to NULL domain */
-       if (time_after_eq(jiffies, rq->next_balance) &&
-           likely(!on_null_domain(cpu)))
-               raise_softirq(SCHED_SOFTIRQ);
-#ifdef CONFIG_NO_HZ
-       else if (nohz_kick_needed(rq, cpu) && likely(!on_null_domain(cpu)))
-               nohz_balancer_kick(cpu);
-#endif
-}
+//static inline void trigger_load_balance(struct rq *rq, int cpu)
+//{
+//     /* Don't need to rebalance while attached to NULL domain */
+//     if (time_after_eq(jiffies, rq->next_balance) &&
+//         likely(!on_null_domain(cpu)))
+//             raise_softirq(SCHED_SOFTIRQ);
+//#ifdef CONFIG_NO_HZ
+//     else if (nohz_kick_needed(rq, cpu) && likely(!on_null_domain(cpu)))
+//             nohz_balancer_kick(cpu);
+//#endif
+//}
 
 static void rq_online_fair(struct rq *rq)
 {
@@ -4012,9 +4008,9 @@ static void rq_offline_fair(struct rq *rq)
 /*
  * on UP we do not need to balance between CPUs:
  */
-static inline void idle_balance(int cpu, struct rq *rq)
-{
-}
+//static inline void idle_balance(int cpu, struct rq *rq)
+//{
+//}
 
 #endif /* CONFIG_SMP */
 
@@ -4150,17 +4146,18 @@ static void task_move_group_fair(struct task_struct *p, int on_rq)
 
 static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task)
 {
-       struct sched_entity *se = &task->se;
-       unsigned int rr_interval = 0;
-
-       /*
-        * Time slice is 0 for SCHED_OTHER tasks that are on an otherwise
-        * idle runqueue:
-        */
-       if (rq->cfs.load.weight)
-               rr_interval = NS_TO_JIFFIES(sched_slice(&rq->cfs, se));
-
-       return rr_interval;
+//     struct sched_entity *se = &task->se;
+//     unsigned int rr_interval = 0;
+//
+//     /*
+//      * Time slice is 0 for SCHED_OTHER tasks that are on an otherwise
+//      * idle runqueue:
+//      */
+//     if (rq->cfs.load.weight)
+//             rr_interval = NS_TO_JIFFIES(sched_slice(&rq->cfs, se));
+//
+//     return rr_interval;
+       return 0;
 }
 
 /*
index 9fa0f40..bf01e8b 100644 (file)
@@ -23,7 +23,7 @@ static void check_preempt_curr_idle(struct rq *rq, struct task_struct *p, int fl
 static struct task_struct *pick_next_task_idle(struct rq *rq)
 {
        schedstat_inc(rq, sched_goidle);
-       calc_load_account_idle(rq);
+//     calc_load_account_idle(rq);
        return rq->idle;
 }
 
index 01f75a5..4246607 100644 (file)
@@ -83,18 +83,18 @@ static inline void rt_clear_overload(struct rq *rq)
        cpumask_clear_cpu(rq->cpu, rq->rd->rto_mask);
 }
 
-static void update_rt_migration(struct rt_rq *rt_rq)
-{
-       if (rt_rq->rt_nr_migratory && rt_rq->rt_nr_total > 1) {
-               if (!rt_rq->overloaded) {
-                       rt_set_overload(rq_of_rt_rq(rt_rq));
-                       rt_rq->overloaded = 1;
-               }
-       } else if (rt_rq->overloaded) {
-               rt_clear_overload(rq_of_rt_rq(rt_rq));
-               rt_rq->overloaded = 0;
-       }
-}
+//static void update_rt_migration(struct rt_rq *rt_rq)
+//{
+//     if (rt_rq->rt_nr_migratory && rt_rq->rt_nr_total > 1) {
+//             if (!rt_rq->overloaded) {
+//                     rt_set_overload(rq_of_rt_rq(rt_rq));
+//                     rt_rq->overloaded = 1;
+//             }
+//     } else if (rt_rq->overloaded) {
+//             rt_clear_overload(rq_of_rt_rq(rt_rq));
+//             rt_rq->overloaded = 0;
+//     }
+//}
 
 static void inc_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
 {
@@ -107,7 +107,7 @@ static void inc_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
        if (rt_se->nr_cpus_allowed > 1)
                rt_rq->rt_nr_migratory++;
 
-       update_rt_migration(rt_rq);
+//     update_rt_migration(rt_rq);
 }
 
 static void dec_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
@@ -121,7 +121,7 @@ static void dec_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
        if (rt_se->nr_cpus_allowed > 1)
                rt_rq->rt_nr_migratory--;
 
-       update_rt_migration(rt_rq);
+//     update_rt_migration(rt_rq);
 }
 
 static void enqueue_pushable_task(struct rq *rq, struct task_struct *p)
@@ -1261,163 +1261,163 @@ static int find_lowest_rq(struct task_struct *task)
 }
 
 /* Will lock the rq it finds */
-static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
-{
-       struct rq *lowest_rq = NULL;
-       int tries;
-       int cpu;
-
-       for (tries = 0; tries < RT_MAX_TRIES; tries++) {
-               cpu = find_lowest_rq(task);
-
-               if ((cpu == -1) || (cpu == rq->cpu))
-                       break;
-
-               lowest_rq = cpu_rq(cpu);
-
-               /* if the prio of this runqueue changed, try again */
-               if (double_lock_balance(rq, lowest_rq)) {
-                       /*
-                        * We had to unlock the run queue. In
-                        * the mean time, task could have
-                        * migrated already or had its affinity changed.
-                        * Also make sure that it wasn't scheduled on its rq.
-                        */
-                       if (unlikely(task_rq(task) != rq ||
-                                    !cpumask_test_cpu(lowest_rq->cpu,
-                                                      &task->cpus_allowed) ||
-                                    task_running(rq, task) ||
-                                    !task->se.on_rq)) {
-
-                               raw_spin_unlock(&lowest_rq->lock);
-                               lowest_rq = NULL;
-                               break;
-                       }
-               }
-
-               /* If this rq is still suitable use it. */
-               if (lowest_rq->rt.highest_prio.curr > task->prio)
-                       break;
-
-               /* try again */
-               double_unlock_balance(rq, lowest_rq);
-               lowest_rq = NULL;
-       }
-
-       return lowest_rq;
-}
-
-static struct task_struct *pick_next_pushable_task(struct rq *rq)
-{
-       struct task_struct *p;
-
-       if (!has_pushable_tasks(rq))
-               return NULL;
-
-       p = plist_first_entry(&rq->rt.pushable_tasks,
-                             struct task_struct, pushable_tasks);
-
-       BUG_ON(rq->cpu != task_cpu(p));
-       BUG_ON(task_current(rq, p));
-       BUG_ON(p->rt.nr_cpus_allowed <= 1);
-
-       BUG_ON(!p->se.on_rq);
-       BUG_ON(!rt_task(p));
-
-       return p;
-}
+//static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
+//{
+//     struct rq *lowest_rq = NULL;
+//     int tries;
+//     int cpu;
+//
+//     for (tries = 0; tries < RT_MAX_TRIES; tries++) {
+//             cpu = find_lowest_rq(task);
+//
+//             if ((cpu == -1) || (cpu == rq->cpu))
+//                     break;
+//
+//             lowest_rq = cpu_rq(cpu);
+//
+//             /* if the prio of this runqueue changed, try again */
+//             if (double_lock_balance(rq, lowest_rq)) {
+//                     /*
+//                      * We had to unlock the run queue. In
+//                      * the mean time, task could have
+//                      * migrated already or had its affinity changed.
+//                      * Also make sure that it wasn't scheduled on its rq.
+//                      */
+//                     if (unlikely(task_rq(task) != rq ||
+//                                  !cpumask_test_cpu(lowest_rq->cpu,
+//                                                    &task->cpus_allowed) ||
+//                                  task_running(rq, task) ||
+//                                  !task->se.on_rq)) {
+//
+//                             raw_spin_unlock(&lowest_rq->lock);
+//                             lowest_rq = NULL;
+//                             break;
+//                     }
+//             }
+//
+//             /* If this rq is still suitable use it. */
+//             if (lowest_rq->rt.highest_prio.curr > task->prio)
+//                     break;
+//
+//             /* try again */
+//             double_unlock_balance(rq, lowest_rq);
+//             lowest_rq = NULL;
+//     }
+//
+//     return lowest_rq;
+//}
+
+//static struct task_struct *pick_next_pushable_task(struct rq *rq)
+//{
+//     struct task_struct *p;
+//
+//     if (!has_pushable_tasks(rq))
+//             return NULL;
+//
+//     p = plist_first_entry(&rq->rt.pushable_tasks,
+//                           struct task_struct, pushable_tasks);
+//
+//     BUG_ON(rq->cpu != task_cpu(p));
+//     BUG_ON(task_current(rq, p));
+//     BUG_ON(p->rt.nr_cpus_allowed <= 1);
+//
+//     BUG_ON(!p->se.on_rq);
+//     BUG_ON(!rt_task(p));
+//
+//     return p;
+//}
 
 /*
  * If the current CPU has more than one RT task, see if the non
  * running task can migrate over to a CPU that is running a task
  * of lesser priority.
  */
-static int push_rt_task(struct rq *rq)
-{
-       struct task_struct *next_task;
-       struct rq *lowest_rq;
-
-       if (!rq->rt.overloaded)
-               return 0;
-
-       next_task = pick_next_pushable_task(rq);
-       if (!next_task)
-               return 0;
-
-retry:
-       if (unlikely(next_task == rq->curr)) {
-               WARN_ON(1);
-               return 0;
-       }
-
-       /*
-        * It's possible that the next_task slipped in of
-        * higher priority than current. If that's the case
-        * just reschedule current.
-        */
-       if (unlikely(next_task->prio < rq->curr->prio)) {
-               resched_task(rq->curr);
-               return 0;
-       }
-
-       /* We might release rq lock */
-       get_task_struct(next_task);
-
-       /* find_lock_lowest_rq locks the rq if found */
-       lowest_rq = find_lock_lowest_rq(next_task, rq);
-       if (!lowest_rq) {
-               struct task_struct *task;
-               /*
-                * find lock_lowest_rq releases rq->lock
-                * so it is possible that next_task has migrated.
-                *
-                * We need to make sure that the task is still on the same
-                * run-queue and is also still the next task eligible for
-                * pushing.
-                */
-               task = pick_next_pushable_task(rq);
-               if (task_cpu(next_task) == rq->cpu && task == next_task) {
-                       /*
-                        * If we get here, the task hasnt moved at all, but
-                        * it has failed to push.  We will not try again,
-                        * since the other cpus will pull from us when they
-                        * are ready.
-                        */
-                       dequeue_pushable_task(rq, next_task);
-                       goto out;
-               }
-
-               if (!task)
-                       /* No more tasks, just exit */
-                       goto out;
-
-               /*
-                * Something has shifted, try again.
-                */
-               put_task_struct(next_task);
-               next_task = task;
-               goto retry;
-       }
-
-       deactivate_task(rq, next_task, 0);
-       set_task_cpu(next_task, lowest_rq->cpu);
-       activate_task(lowest_rq, next_task, 0);
-
-       resched_task(lowest_rq->curr);
-
-       double_unlock_balance(rq, lowest_rq);
-
-out:
-       put_task_struct(next_task);
-
-       return 1;
-}
+//static int push_rt_task(struct rq *rq)
+//{
+//     struct task_struct *next_task;
+//     struct rq *lowest_rq;
+//
+//     if (!rq->rt.overloaded)
+//             return 0;
+//
+//     next_task = pick_next_pushable_task(rq);
+//     if (!next_task)
+//             return 0;
+//
+//retry:
+//     if (unlikely(next_task == rq->curr)) {
+//             WARN_ON(1);
+//             return 0;
+//     }
+//
+//     /*
+//      * It's possible that the next_task slipped in of
+//      * higher priority than current. If that's the case
+//      * just reschedule current.
+//      */
+//     if (unlikely(next_task->prio < rq->curr->prio)) {
+//             resched_task(rq->curr);
+//             return 0;
+//     }
+//
+//     /* We might release rq lock */
+//     get_task_struct(next_task);
+//
+//     /* find_lock_lowest_rq locks the rq if found */
+//     lowest_rq = find_lock_lowest_rq(next_task, rq);
+//     if (!lowest_rq) {
+//             struct task_struct *task;
+//             /*
+//              * find lock_lowest_rq releases rq->lock
+//              * so it is possible that next_task has migrated.
+//              *
+//              * We need to make sure that the task is still on the same
+//              * run-queue and is also still the next task eligible for
+//              * pushing.
+//              */
+//             task = pick_next_pushable_task(rq);
+//             if (task_cpu(next_task) == rq->cpu && task == next_task) {
+//                     /*
+//                      * If we get here, the task hasnt moved at all, but
+//                      * it has failed to push.  We will not try again,
+//                      * since the other cpus will pull from us when they
+//                      * are ready.
+//                      */
+//                     dequeue_pushable_task(rq, next_task);
+//                     goto out;
+//             }
+//
+//             if (!task)
+//                     /* No more tasks, just exit */
+//                     goto out;
+//
+//             /*
+//              * Something has shifted, try again.
+//              */
+//             put_task_struct(next_task);
+//             next_task = task;
+//             goto retry;
+//     }
+//
+//     deactivate_task(rq, next_task, 0);
+//     set_task_cpu(next_task, lowest_rq->cpu);
+//     activate_task(lowest_rq, next_task, 0);
+//
+//     resched_task(lowest_rq->curr);
+//
+//     double_unlock_balance(rq, lowest_rq);
+//
+//out:
+//     put_task_struct(next_task);
+//
+//     return 1;
+//}
 
 static void push_rt_tasks(struct rq *rq)
 {
        /* push_rt_task will return true if it moved an RT */
-       while (push_rt_task(rq))
-               ;
+//     while (push_rt_task(rq))
+//             ;
 }
 
 static int pull_rt_task(struct rq *this_rq)
@@ -1566,7 +1566,7 @@ static void set_cpus_allowed_rt(struct task_struct *p,
                        rq->rt.rt_nr_migratory--;
                }
 
-               update_rt_migration(&rq->rt);
+//             update_rt_migration(&rq->rt);
        }
 
        cpumask_copy(&p->cpus_allowed, new_mask);
@@ -1576,8 +1576,8 @@ static void set_cpus_allowed_rt(struct task_struct *p,
 /* Assumes rq->lock is held */
 static void rq_online_rt(struct rq *rq)
 {
-       if (rq->rt.overloaded)
-               rt_set_overload(rq);
+//     if (rq->rt.overloaded)
+//             rt_set_overload(rq);
 
        __enable_runtime(rq);
 
@@ -1587,8 +1587,8 @@ static void rq_online_rt(struct rq *rq)
 /* Assumes rq->lock is held */
 static void rq_offline_rt(struct rq *rq)
 {
-       if (rq->rt.overloaded)
-               rt_clear_overload(rq);
+//     if (rq->rt.overloaded)
+//             rt_clear_overload(rq);
 
        __disable_runtime(rq);
 
@@ -1642,10 +1642,10 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p,
         */
        if (!running) {
 #ifdef CONFIG_SMP
-               if (rq->rt.overloaded && push_rt_task(rq) &&
-                   /* Don't resched if we changed runqueues */
-                   rq != task_rq(p))
-                       check_resched = 0;
+//             if (rq->rt.overloaded && push_rt_task(rq) &&
+//                 /* Don't resched if we changed runqueues */
+//                 rq != task_rq(p))
+//                     check_resched = 0;
 #endif /* CONFIG_SMP */
                if (check_resched && p->prio < rq->curr->prio)
                        resched_task(rq->curr);