linux-mips
[Top] [All Lists]

[PATCH] MIPS: Optimize pgd_init and pmd_init

To: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: [PATCH] MIPS: Optimize pgd_init and pmd_init
From: David Daney <ddaney.cavm@gmail.com>
Date: Thu, 16 Aug 2012 11:15:22 -0700
Cc: David Daney <ddaney@caviumnetworks.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=w3Tokz21YM55dmrmpD/SIFo8zNpOxfwZxsxLBqx5cUI=; b=M9sUdkM7W8O5bAaTq3jN4Nzs0rKNl8Dc5MrgRBYZNl/NPMBcKVfVnxSqDpr3LPlb/I h4auET7DcdReiB9CuPZSWEy3R9xMlnfJKWCMqj/xP0KZ2xnML7RlKRnzWCTtMSEEP65z ZCjlVPwGLlj+nT+wpeZNdkEQWEYgCBmYG84gw2Byzm/vd29s0HkRc+IY7E2fNcqbtWQY LJ3rZomXC8xST8c+KO4z9h0CL9tzIDIsQ1e1lkMnUMDwUruqmioTsDilWePp+YCbQw4a 1FBzhyYDotqor54U8GvhlPs59BC3vRBvyyzPNNGt4UPjo2KbpOOvh1OztC8PbvWG3VGw j3ag==
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Sender: linux-mips-bounce@linux-mips.org
From: David Daney <ddaney@caviumnetworks.com>

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>
---
 arch/mips/mm/pgtable-64.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
index cda4e30..2540779 100644
--- a/arch/mips/mm/pgtable-64.c
+++ b/arch/mips/mm/pgtable-64.c
@@ -26,17 +26,17 @@ void pgd_init(unsigned long page)
        p = (unsigned long *) page;
        end = p + PTRS_PER_PGD;
 
-       while (p < end) {
+       do {
                p[0] = entry;
                p[1] = entry;
                p[2] = entry;
                p[3] = entry;
                p[4] = entry;
-               p[5] = entry;
-               p[6] = entry;
-               p[7] = entry;
                p += 8;
-       }
+               p[-3] = entry;
+               p[-2] = entry;
+               p[-1] = entry;
+       } while (p != end);
 }
 
 #ifndef __PAGETABLE_PMD_FOLDED
@@ -47,17 +47,17 @@ void pmd_init(unsigned long addr, unsigned long pagetable)
        p = (unsigned long *) addr;
        end = p + PTRS_PER_PMD;
 
-       while (p < end) {
+       do {
                p[0] = pagetable;
                p[1] = pagetable;
                p[2] = pagetable;
                p[3] = pagetable;
                p[4] = pagetable;
-               p[5] = pagetable;
-               p[6] = pagetable;
-               p[7] = pagetable;
                p += 8;
-       }
+               p[-3] = pagetable;
+               p[-2] = pagetable;
+               p[-1] = pagetable;
+       } while (p != end);
 }
 #endif
 
-- 
1.7.11.2


<Prev in Thread] Current Thread [Next in Thread>