Commit 9efe4f29 authored by Martin Schwidefsky's avatar Martin Schwidefsky

s390/mm: optimize randomize_et_dyn for !PF_RANDOMIZE

Skip the call to brk_rnd() if the PF_RANDOMIZE flag is not set for
the process. This avoids the costly get_random_int() call. Modify
arch_randomize_brk() as well to make it look like randomize_et_dyn().
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 61aa4884
...@@ -261,20 +261,18 @@ static inline unsigned long brk_rnd(void) ...@@ -261,20 +261,18 @@ static inline unsigned long brk_rnd(void)
unsigned long arch_randomize_brk(struct mm_struct *mm) unsigned long arch_randomize_brk(struct mm_struct *mm)
{ {
unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd()); unsigned long ret;
if (ret < mm->brk) ret = PAGE_ALIGN(mm->brk + brk_rnd());
return mm->brk; return (ret > mm->brk) ? ret : mm->brk;
return ret;
} }
unsigned long randomize_et_dyn(unsigned long base) unsigned long randomize_et_dyn(unsigned long base)
{ {
unsigned long ret = PAGE_ALIGN(base + brk_rnd()); unsigned long ret;
if (!(current->flags & PF_RANDOMIZE)) if (!(current->flags & PF_RANDOMIZE))
return base; return base;
if (ret < base) ret = PAGE_ALIGN(base + brk_rnd());
return base; return (ret > base) ? ret : base;
return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment