Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Optimize pgd_init and pmd_init

On a dual issue processor GCC generates code that saves a couple of
clock cycles per loop if we rearrange things slightly. Checking for
p != end saves a SLTU per loop, moving the increment to the middle can
let it dual issue on multi-issue processors.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/4249/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

David Daney and committed by
Ralf Baechle
f59a2d22 a7911a8f

+10 -10
+10 -10
arch/mips/mm/pgtable-64.c
··· 26 26 p = (unsigned long *) page; 27 27 end = p + PTRS_PER_PGD; 28 28 29 - while (p < end) { 29 + do { 30 30 p[0] = entry; 31 31 p[1] = entry; 32 32 p[2] = entry; 33 33 p[3] = entry; 34 34 p[4] = entry; 35 - p[5] = entry; 36 - p[6] = entry; 37 - p[7] = entry; 38 35 p += 8; 39 - } 36 + p[-3] = entry; 37 + p[-2] = entry; 38 + p[-1] = entry; 39 + } while (p != end); 40 40 } 41 41 42 42 #ifndef __PAGETABLE_PMD_FOLDED ··· 47 47 p = (unsigned long *) addr; 48 48 end = p + PTRS_PER_PMD; 49 49 50 - while (p < end) { 50 + do { 51 51 p[0] = pagetable; 52 52 p[1] = pagetable; 53 53 p[2] = pagetable; 54 54 p[3] = pagetable; 55 55 p[4] = pagetable; 56 - p[5] = pagetable; 57 - p[6] = pagetable; 58 - p[7] = pagetable; 59 56 p += 8; 60 - } 57 + p[-3] = pagetable; 58 + p[-2] = pagetable; 59 + p[-1] = pagetable; 60 + } while (p != end); 61 61 } 62 62 #endif 63 63