Skip to content

Commit

Permalink
kernel: Boost all CPUs to the max when userspace launches an app
Browse files Browse the repository at this point in the history
Zygote is Android's application process, and it only forks when launching
a new app for the first time. To accelerate app launches, boost all CPUs
to the max for 1250 ms when zygote decides to fork.

Signed-off-by: Sultan Alsawaf <[email protected]>
Signed-off-by: Francisco Franco <[email protected]>
  • Loading branch information
kerneltoast authored and franciscofranco committed Nov 2, 2018
1 parent 76b60e2 commit dc67377
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ static atomic_t call_count = ATOMIC_INIT(1);
static LIST_HEAD(formats);
static DEFINE_RWLOCK(binfmt_lock);

#define ZYGOTE32_BIN "/system/bin/app_process32"
#define ZYGOTE64_BIN "/system/bin/app_process64"
static atomic_t zygote32_pid;
static atomic_t zygote64_pid;
bool is_zygote_pid(pid_t pid)
{
return atomic_read(&zygote32_pid) == pid ||
atomic_read(&zygote64_pid) == pid;
}

void __register_binfmt(struct linux_binfmt * fmt, int insert)
{
BUG_ON(!fmt);
Expand Down Expand Up @@ -1606,6 +1616,13 @@ static int do_execve_common(const char *filename,
su_exec();
}

if (capable(CAP_SYS_ADMIN)) {
if (unlikely(!strcmp(filename->name, ZYGOTE32_BIN)))
atomic_set(&zygote32_pid, current->pid);
else if (unlikely(!strcmp(filename->name, ZYGOTE64_BIN)))
atomic_set(&zygote64_pid, current->pid);
}

/* execve succeeded */
current->fs->in_exec = 0;
current->in_execve = 0;
Expand Down
1 change: 1 addition & 0 deletions include/linux/binfmts.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ extern void install_exec_creds(struct linux_binprm *bprm);
extern void do_coredump(long signr, int exit_code, struct pt_regs *regs);
extern void set_binfmt(struct linux_binfmt *new);
extern void free_bprm(struct linux_binprm *);
extern bool is_zygote_pid(pid_t pid);

#endif /* __KERNEL__ */
#endif /* _LINUX_BINFMTS_H */

0 comments on commit dc67377

Please sign in to comment.