lkml.org 
[lkml]   [2019]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -mm] elf: init pt_regs pointer later
On Fri, 19 Apr 2019 23:03:43 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:

> Get "current_pt_regs" pointer right before usage.
>
> Space savings on x86_64:
>
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-180 (-180)
> Function old new delta
> load_elf_binary 5806 5626 -180 !!!

-256 bytes with my setup.

> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -704,12 +704,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
> unsigned long start_code, end_code, start_data, end_data;
> unsigned long reloc_func_desc __maybe_unused = 0;
> int executable_stack = EXSTACK_DEFAULT;
> - struct pt_regs *regs = current_pt_regs();
> struct {
> struct elfhdr elf_ex;
> struct elfhdr interp_elf_ex;
> } *loc;
> struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
> + struct pt_regs *regs;
>
> loc = kmalloc(sizeof(*loc), GFP_KERNEL);
> if (!loc) {
> @@ -1159,6 +1159,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
> MAP_FIXED | MAP_PRIVATE, 0);
> }
>
> + regs = current_pt_regs();
> #ifdef ELF_PLAT_INIT
> /*
> * The ABI may specify that certain registers be set up in special

Why the heck does this make such a difference?

\
 
 \ /
  Last update: 2019-04-19 22:09    [W:0.049 / U:3.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site