Skip to content

Commit

Permalink
mm/mlock.c: reorganize mlockall() return values and remove goto-out l…
Browse files Browse the repository at this point in the history
…abel

In mlockall syscall wrapper after out-label for goto code just doing
return.  Remove goto out statements and return error values directly.

Also instead of rewriting ret variable before every if-check move returns
to 'error'-like path under if-check.

Objdump asm listing showed me reducing by few asm lines.  Object file size
descreased from 220592 bytes to 220528 bytes for me (for aarch64).

Signed-off-by: Alexey Klimov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
trashsee authored and torvalds committed Nov 6, 2015
1 parent 9fbed25 commit 86d2adc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mm/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,13 @@ static int do_mlockall(int flags)
SYSCALL_DEFINE1(mlockall, int, flags)
{
unsigned long lock_limit;
int ret = -EINVAL;
int ret;

if (!flags || (flags & ~(MCL_CURRENT | MCL_FUTURE)))
goto out;
return -EINVAL;

ret = -EPERM;
if (!can_do_mlock())
goto out;
return -EPERM;

if (flags & MCL_CURRENT)
lru_add_drain_all(); /* flush pagevec */
Expand All @@ -708,7 +707,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
up_write(&current->mm->mmap_sem);
if (!ret && (flags & MCL_CURRENT))
mm_populate(0, TASK_SIZE);
out:

return ret;
}

Expand Down

0 comments on commit 86d2adc

Please sign in to comment.