kernel: Boost whenever a zygote-forked process becomes a top app

Boost the CPU to the max for 1000 ms whenever the top app changes, which
improves app launch speeds and addresses jitter when switching between
apps. A check to make sure that the top-app's parent is zygote ensures
that a user-facing app is indeed what's added to the top app task group,
since app processes are forked from zygote.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Sultan Alsawaf
2019-04-19 12:44:52 -07:00
committed by UtsavBalar1231
parent ab25cbf8fb
commit 1237497eba
3 changed files with 25 additions and 0 deletions

View File

@@ -77,6 +77,16 @@ int suid_dumpable = 0;
static LIST_HEAD(formats);
static DEFINE_RWLOCK(binfmt_lock);
#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);
@@ -1799,6 +1809,13 @@ static int do_execveat_common(int fd, struct filename *filename,
if (retval < 0)
goto out;
if (is_global_init(current->parent)) {
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 */
current->fs->in_exec = 0;
current->in_execve = 0;

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

@@ -13,6 +13,8 @@
#include <linux/delayacct.h>
#include <linux/pid_namespace.h>
#include <linux/cgroupstats.h>
#include <linux/binfmts.h>
#include <linux/cpu_input_boost.h>
#include <trace/events/cgroup.h>
@@ -551,6 +553,11 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of,
ret = cgroup_attach_task(cgrp, task, threadgroup);
/* This covers boosting for app launches and app transitions */
if (!ret && !threadgroup && !strcmp(of->kn->parent->name, "top-app") &&
task_is_zygote(task->parent))
cpu_input_boost_kick_max(1000);
out_finish:
cgroup_procs_write_finish(task);
out_unlock: