Skip to content

Commit

Permalink
ANDROID: sched: Exempt paused CPU from nohz idle balance
Browse files Browse the repository at this point in the history
Subsequent to commit 4d7f8d7 ("Revert "sched: Prevent raising SCHED_SOFTIRQ when CPU is !active"")

A CPU can be paused while it is idle with it's tick stopped.
nohz_balance_exit_idle() should be called from the local CPU,
so it can't be called during pause which can happen remotely.
This results in paused CPU participating in the nohz idle balance,
which should be avoided. This can be done by calling

Fix this issue by calling nohz_balance_exit_idle() from the paused
CPU when it exits and enters idle again. This lazy approach avoids
waking the CPU from idle during pause.

[@0ctobot: This is an attempt to silence the following dmesg WARN_ON:
[    6.081902] ------------[ cut here ]------------
[    6.081909] (flags & NOHZ_KICK_MASK) == NOHZ_BALANCE_KICK
[    6.081922] WARNING: CPU: 6 PID: 0 at _nohz_idle_balance+0x408/0x410
[    6.081926] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G S                4.19.202-NeutrinoKernel-lothal-EXP xiaomi-sm8250-devs#1
[    6.081928] Hardware name: Qualcomm Technologies, Inc. kona MTP 19805 20809 (DT)
[    6.081931] pstate: 60400005 (nZCv daif +PAN -UAO)
[    6.081933] pc : _nohz_idle_balance+0x408/0x410
[    6.081935] lr : _nohz_idle_balance+0x400/0x410
[    6.081937] sp : ffffff8010033df0
[    6.081938] x29: ffffff8010033e30 x28: ffffff9d37e75040
[    6.081940] x27: ffffff9d37e572c0 x26: ffffff9d35c96050
[    6.081942] x25: 0000000000000007 x24: 0000000000000001
[    6.081944] x23: ffffff9d37e76000 x22: fffffffcb39e2a00
[    6.081946] x21: 0000000000000006 x20: 00000000ffff8d30
[    6.081947] x19: 0000000000000000 x18: ffffff8010035038
[    6.081949] x17: 0000000000000008 x16: 0000000000000000
[    6.081951] x15: 0000000000000008 x14: ffffff9d37f6dc18
[    6.081953] x13: 0000000000000004 x12: ffffff9d37e76000
[    6.081954] x11: 0000000000000000 x10: 0000000000000000
[    6.081956] x9 : a2d84b4c1c6fa900 x8 : a2d84b4c1c6fa900
[    6.081957] x7 : 000000000000002d x6 : ffffff9d38115e65
[    6.081959] x5 : ffffff9d38113500 x4 : 0000000000000000
[    6.081961] x3 : 000000000000004b x2 : 0000000000000000
[    6.081962] x1 : ffffff9d3811352d x0 : 000000000000002d
[    6.081964] Call trace:
[    6.081966] _nohz_idle_balance+0x408/0x410
[    6.081968] run_rebalance_domains+0x78/0xa8
[    6.081971] __do_softirq+0x144/0x2f4
[    6.081975] irq_exit+0x170/0x184
[    6.081978] scheduler_ipi+0x160/0x1d4
[    6.081980] handle_IPI+0x94/0x3e0
[    6.081982] gic_handle_irq.17896+0x100/0x180
[    6.081984] el1_irq+0xc4/0x140
[    6.081988] lpm_cpuidle_enter+0x61c/0x6d0
[    6.081991] cpuidle_enter_state+0x1dc/0x368
[    6.081993] do_idle+0x67c/0x74c
[    6.081995] cpu_startup_entry+0x58/0x5c
[    6.081997] secondary_start_kernel+0x13c/0x140
[    6.081999] ---[ end trace 6de171506e562a81 ]---]

Bug: 180530906
Change-Id: Ia2dfd9c9cac9b0f37c55a9256b9d5f3141ca0421
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
Pavankumar Kondeti authored and NotZeetaa committed Dec 14, 2021
1 parent 6e05b7a commit 10eeb27
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -11590,9 +11590,20 @@ void nohz_balance_enter_idle(int cpu)

SCHED_WARN_ON(cpu != smp_processor_id());

/* If this CPU is going down, then nothing needs to be done: */
if (!cpu_active(cpu))
if (!cpu_active(cpu)) {
/*
* A CPU can be paused while it is idle with it's tick
* stopped. nohz_balance_exit_idle() should be called
* from the local CPU, so it can't be called during
* pause. This results in paused CPU participating in
* the nohz idle balance, which should be avoided.
*
* When the paused CPU exits idle and enters again,
* exempt the paused CPU from nohz_balance_exit_idle.
*/
nohz_balance_exit_idle(rq);
return;
}

/* Spare idle load balancing on CPUs that don't want to be disturbed: */
if (!housekeeping_cpu(cpu, HK_FLAG_SCHED))
Expand Down

0 comments on commit 10eeb27

Please sign in to comment.