Commit d4042ec3 authored by Elliot Berman's avatar Elliot Berman
Browse files

FROMGIT: freezer,sched: Use saved_state to reduce some spurious wakeups



After commit f5d39b02 ("freezer,sched: Rewrite core freezer logic"),
tasks that transition directly from TASK_FREEZABLE to TASK_FROZEN  are
always woken up on the thaw path. Prior to that commit, tasks could ask
freezer to consider them "frozen enough" via freezer_do_not_count(). The
commit replaced freezer_do_not_count() with a TASK_FREEZABLE state which
allows freezer to immediately mark the task as TASK_FROZEN without
waking up the task.  This is efficient for the suspend path, but on the
thaw path, the task is always woken up even if the task didn't need to
wake up and goes back to its TASK_(UN)INTERRUPTIBLE state. Although
these tasks are capable of handling of the wakeup, we can observe a
power/perf impact from the extra wakeup.

We observed on Android many tasks wait in the TASK_FREEZABLE state
(particularly due to many of them being binder clients). We observed
nearly 4x the number of tasks and a corresponding linear increase in
latency and power consumption when thawing the system. The latency
increased from ~15ms to ~50ms.

Avoid the spurious wakeups by saving the state of TASK_FREEZABLE tasks.
If the task was running before entering TASK_FROZEN state
(__refrigerator()) or if the task received a wake up for the saved
state, then the task is woken on thaw. saved_state from PREEMPT_RT locks
can be re-used because freezer would not stomp on the rtlock wait flow:
TASK_RTLOCK_WAIT isn't considered freezable.

Reported-by: default avatarPrakash Viswalingam <quic_prakashv@quicinc.com>
Signed-off-by: default avatarElliot Berman <quic_eberman@quicinc.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
(cherry picked from commit 8f0eed4a)

(cherry picked from commit e4d93065a5085dbb862aa4bd06fb3e51b02e8857
 https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git

 sched/core)
Bug: 292064955
Bug: 304294320
Change-Id: I121cfff46536a13e59b5eb60842984aed0d73faa
Signed-off-by: default avatarElliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 22cd8e0d)
parent 8095efce
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment