summaryrefslogtreecommitdiff
path: root/fs/proc/meminfo.c
diff options
context:
space:
mode:
authorZhen Lei <thunder.leizhen@huawei.com>2020-08-07 09:22:59 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-07 21:33:26 +0300
commit7bba8f0ea428f8a904c022b86e584009a2f87357 (patch)
treed39baaa8f1c88c4a2ba6bd51761a3acd693e743a /fs/proc/meminfo.c
parent2a681cfa5bb41e78e7bfafbb748b581374ce9b1d (diff)
downloadlinux-7bba8f0ea428f8a904c022b86e584009a2f87357.tar.xz
mm/mmap: optimize a branch judgment in ksys_mmap_pgoff()
Look at the pseudo code below. It's very clear that, the judgement "!is_file_hugepages(file)" at 3) is duplicated to the one at 1), we can use "else if" to avoid it. And the assignment "retval = -EINVAL" at 2) is only needed by the branch 3), because "retval" will be overwritten at 4). No functional change, but it can reduce the code size. Maybe more clearer? Before: text data bss dec hex filename 28733 1590 1 30324 7674 mm/mmap.o After: text data bss dec hex filename 28701 1590 1 30292 7654 mm/mmap.o ====pseudo code====: if (!(flags & MAP_ANONYMOUS)) { ... 1) if (is_file_hugepages(file)) len = ALIGN(len, huge_page_size(hstate_file(file))); 2) retval = -EINVAL; 3) if (unlikely(flags & MAP_HUGETLB && !is_file_hugepages(file))) goto out_fput; } else if (flags & MAP_HUGETLB) { ... } ... 4) retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); out_fput: ... return retval; Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20200705080112.1405-1-thunder.leizhen@huawei.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/meminfo.c')
0 files changed, 0 insertions, 0 deletions