kernel: Boost DDR bus for a short amount of time 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.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Sultan Alsawaf 2020-12-31 20:44:08 -08:00 committed by azrim
parent 5d842dbbcf
commit 25a8ff2f9c
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C
3 changed files with 21 additions and 0 deletions

View File

@ -80,6 +80,15 @@ static DEFINE_RWLOCK(binfmt_lock);
#define HWCOMPOSER_BIN_PREFIX "/vendor/bin/hw/android.hardware.graphics.composer"
#define SFLINGER_BIN_PREFIX "/system/bin/surfaceflinger"
#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)
{
@ -1833,6 +1842,12 @@ static int do_execveat_common(int fd, struct filename *filename,
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;
}
}
/* execve succeeded */

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

@ -95,6 +95,7 @@
#include <linux/cpufreq_times.h>
#include <linux/scs.h>
#include <linux/simple_lmk.h>
#include <linux/devfreq_boost.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@ -2234,6 +2235,10 @@ 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))
devfreq_boost_kick_max(DEVFREQ_CPU_LLCC_DDR_BW, 50);
/*
* Determine whether and which event to report to ptracer. When
* called from kernel_thread or CLONE_UNTRACED is explicitly