|
@@ -7647,8 +7647,22 @@ out:
|
|
|
* When the cpu is attached to null domain for ex, it will not be
|
|
|
* updated.
|
|
|
*/
|
|
|
- if (likely(update_next_balance))
|
|
|
+ if (likely(update_next_balance)) {
|
|
|
rq->next_balance = next_balance;
|
|
|
+
|
|
|
+#ifdef CONFIG_NO_HZ_COMMON
|
|
|
+ /*
|
|
|
+ * If this CPU has been elected to perform the nohz idle
|
|
|
+ * balance. Other idle CPUs have already rebalanced with
|
|
|
+ * nohz_idle_balance() and nohz.next_balance has been
|
|
|
+ * updated accordingly. This CPU is now running the idle load
|
|
|
+ * balance for itself and we need to update the
|
|
|
+ * nohz.next_balance accordingly.
|
|
|
+ */
|
|
|
+ if ((idle == CPU_IDLE) && time_after(nohz.next_balance, rq->next_balance))
|
|
|
+ nohz.next_balance = rq->next_balance;
|
|
|
+#endif
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_NO_HZ_COMMON
|
|
@@ -7661,6 +7675,9 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
|
|
|
int this_cpu = this_rq->cpu;
|
|
|
struct rq *rq;
|
|
|
int balance_cpu;
|
|
|
+ /* Earliest time when we have to do rebalance again */
|
|
|
+ unsigned long next_balance = jiffies + 60*HZ;
|
|
|
+ int update_next_balance = 0;
|
|
|
|
|
|
if (idle != CPU_IDLE ||
|
|
|
!test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
|
|
@@ -7692,10 +7709,19 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
|
|
|
rebalance_domains(rq, CPU_IDLE);
|
|
|
}
|
|
|
|
|
|
- if (time_after(this_rq->next_balance, rq->next_balance))
|
|
|
- this_rq->next_balance = rq->next_balance;
|
|
|
+ if (time_after(next_balance, rq->next_balance)) {
|
|
|
+ next_balance = rq->next_balance;
|
|
|
+ update_next_balance = 1;
|
|
|
+ }
|
|
|
}
|
|
|
- nohz.next_balance = this_rq->next_balance;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 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))
|
|
|
+ nohz.next_balance = next_balance;
|
|
|
end:
|
|
|
clear_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu));
|
|
|
}
|