3873static void rebalance_domains(int cpu, enum cpu_idle_type idle)
3874{
3875 int balance = 1;
3876 struct rq *rq = cpu_rq(cpu);
3877 unsigned long interval;
3878 struct sched_domain *sd;
3879
3880 unsigned long next_balance = jiffies + 60*HZ;
3881 int update_next_balance = 0;
3882 int need_serialize;
3883 cpumask_t tmp;
3884
3885 for_each_domain(cpu, sd) {
3886 if (!(sd->flags & SD_LOAD_BALANCE))
3887 continue;
3888
3889 interval = sd->balance_interval;
3890 if (idle != CPU_IDLE)
3891 interval *= sd->busy_factor;
3892
3893
3894 interval = msecs_to_jiffies(interval);
3895 if (unlikely(!interval))
3896 interval = 1;
3897 if (interval > HZ*NR_CPUS/10)
3898 interval = HZ*NR_CPUS/10;
3899
3900 need_serialize = sd->flags & SD_SERIALIZE;
3901
3902 if (need_serialize) {
3903 if (!spin_trylock(&balancing))
3904 goto out;
3905 }
3906
3907 if (time_after_eq(jiffies, sd->last_balance + interval)) {
3908 if (load_balance(cpu, rq, sd, idle, &balance, &tmp)) {
3909
3910
3911
3912
3913