@@ -393,6 +393,12 @@ void __weak arch_suspend_enable_irqs(void)
local_irq_enable();
}
+/*
+ * Intentionally not part of a header file to avoid risk of abuse by other
+ * drivers.
+ */
+void sched_set_energy_aware(unsigned int enable);
+
/**
* suspend_enter - Make the system enter the given sleep state.
* @state: System sleep state to enter.
@@ -468,6 +474,15 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
Platform_wake:
platform_resume_noirq(state);
+ /*
+ * We do this only for resume instead of suspend and resume for these
+ * reasons:
+ * - Performance is more important than power for resume.
+ * - Power spent entering suspend is more important for suspend. Also,
+ * stangely, disabling EAS was making suspent a few milliseconds
+ * slower in my testing.
+ */
+ sched_set_energy_aware(0);
dpm_resume_noirq(PMSG_RESUME);
Platform_early_resume:
@@ -520,6 +535,7 @@ int suspend_devices_and_enter(suspend_state_t state)
Resume_devices:
suspend_test_start();
dpm_resume_end(PMSG_RESUME);
+ sched_set_energy_aware(1);
suspend_test_finish("resume devices");
trace_suspend_resume(TPS("resume_console"), state, true);
resume_console();
@@ -284,6 +284,19 @@ void rebuild_sched_domains_energy(void)
mutex_unlock(&sched_energy_mutex);
}
+void sched_set_energy_aware(unsigned int enable)
+{
+ int state;
+
+ if (!sched_is_eas_possible(cpu_active_mask))
+ return;
+
+ sysctl_sched_energy_aware = enable;
+ state = static_branch_unlikely(&sched_energy_present);
+ if (state != sysctl_sched_energy_aware)
+ rebuild_sched_domains_energy();
+}
+
#ifdef CONFIG_PROC_SYSCTL
static int sched_energy_aware_handler(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
As of today, the scheduler doesn't spread out all the kworker threads across all the available CPUs during suspend/resume. This causes significant resume latency during the dpm_resume*() phases. System resume latency is a very user-visible event. Reducing the latency is more important than trying to be energy aware during that period. Since there are no userspace processes running during this time and this is a very short time window, we can simply disable EAS during resume so that the parallel resume of the devices is spread across all the CPUs. On a Pixel 6, averaging over 100 suspend/resume cycles, the new logic plus disabling EAS for resume yields significant improvements: +---------------------------+-----------+------------+------------------+ | Phase | Old full sync | New full async | % change | | | | + EAS disabled | | +---------------------------+-----------+------------+------------------+ | Total dpm_suspend*() time | 107 ms | 62 ms | -42% | +---------------------------+-----------+------------+------------------+ | Total dpm_resume*() time | 75 ms | 61 ms | -19% | +---------------------------+-----------+------------+------------------+ | Sum | 182 ms | 123 ms | -32% | +---------------------------+-----------+------------+------------------+ Signed-off-by: Saravana Kannan <saravanak@google.com> --- kernel/power/suspend.c | 16 ++++++++++++++++ kernel/sched/topology.c | 13 +++++++++++++ 2 files changed, 29 insertions(+)