kernel: Boost DDR bus for a short period when zygote forks

There is a gap from when a new app is forked to the time that the
devfreq governor managing the DDR bus can pick up the increased load and
ramp up appropriately. Since the polling interval for this governor is
typically 50 ms, that means it may take up to 50 ms before the governor
ramps up, which hurts cold launch app performance. Boosting the DDR bus
for 50 ms upon a fork from zygote covers that gap, speeding up cold app
launches.

[ghostrider-reborn]
- add input timeout of 1.5s since we don't want to boost DDR for
zygote forks not initiated by user input, such as services
spawning in background

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
This commit is contained in:
Sultan Alsawaf 2020-12-31 20:44:08 -08:00 committed by Adithya R
parent 5a908d2a0c
commit eb045e3b8f
3 changed files with 22 additions and 0 deletions

View File

@ -79,6 +79,16 @@ static DEFINE_RWLOCK(binfmt_lock);
#define HWCOMPOSER_BIN_PREFIX "/vendor/bin/hw/android.hardware.graphics.composer"
#define ZYGOTE32_BIN "/system/bin/app_process32"
#define ZYGOTE64_BIN "/system/bin/app_process64"
static struct signal_struct *zygote32_sig;
static struct signal_struct *zygote64_sig;
bool task_is_zygote(struct task_struct *p)
{
return p->signal == zygote32_sig || p->signal == zygote64_sig;
}
void __register_binfmt(struct linux_binfmt * fmt, int insert)
{
BUG_ON(!fmt);
@ -1811,6 +1821,10 @@ static int do_execveat_common(int fd, struct filename *filename,
strlen(HWCOMPOSER_BIN_PREFIX)))) {
current->flags |= PF_PERF_CRITICAL;
set_cpus_allowed_ptr(current, cpu_perf_mask);
} else if (unlikely(!strcmp(filename->name, ZYGOTE32_BIN))) {
zygote32_sig = current->signal;
} else if (unlikely(!strcmp(filename->name, ZYGOTE64_BIN))) {
zygote64_sig = current->signal;
}
}

View File

@ -139,6 +139,7 @@ extern int prepare_bprm_creds(struct linux_binprm *bprm);
extern void install_exec_creds(struct linux_binprm *bprm);
extern void set_binfmt(struct linux_binfmt *new);
extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);
extern bool task_is_zygote(struct task_struct *p);
extern int do_execve(struct filename *,
const char __user * const __user *,

View File

@ -94,6 +94,7 @@
#include <linux/thread_info.h>
#include <linux/cpufreq_times.h>
#include <linux/scs.h>
#include <linux/devfreq_boost.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@ -2208,6 +2209,12 @@ long _do_fork(unsigned long clone_flags,
int trace = 0;
long nr;
/* Boost DDR bus to the max for 50 ms when userspace launches an app */
if (task_is_zygote(current) && df_boost_within_input(1500)) {
devfreq_boost_kick_max(DEVFREQ_MSM_LLCCBW, 50);
devfreq_boost_kick_max(DEVFREQ_MSM_CPUBW, 50);
}
/*
* Determine whether and which event to report to ptracer. When
* called from kernel_thread or CLONE_UNTRACED is explicitly