]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] optimise copy page range
authorNick Piggin <nickpiggin@yahoo.com.au>
Wed, 16 Feb 2005 23:57:40 +0000 (15:57 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 16 Feb 2005 23:57:40 +0000 (15:57 -0800)
Suggested by Linus: optimise a condition in the clear_p?d_range functions.
Results in one less conditional branch on i386 with gcc-3.4.4

Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/memory.c

index e3fa88c4f6a38c7be954367ce99529efb9f37fc5..48cbd6b7b98b648a6c5b40cfe805c1a01b2a917a 100644 (file)
@@ -98,7 +98,8 @@ static inline void clear_pmd_range(struct mmu_gather *tlb, pmd_t *pmd, unsigned
                pmd_clear(pmd);
                return;
        }
-       if (!(start & ~PMD_MASK) && !(end & ~PMD_MASK)) {
+       if (!((start | end) & ~PMD_MASK)) {
+               /* Only clear full, aligned ranges */
                page = pmd_page(*pmd);
                pmd_clear(pmd);
                dec_page_state(nr_page_table_pages);
@@ -131,7 +132,8 @@ static inline void clear_pud_range(struct mmu_gather *tlb, pud_t *pud, unsigned
                addr = next;
        } while (addr && (addr < end));
 
-       if (!(start & ~PUD_MASK) && !(end & ~PUD_MASK)) {
+       if (!((start | end) & ~PUD_MASK)) {
+               /* Only clear full, aligned ranges */
                pud_clear(pud);
                pmd_free_tlb(tlb, __pmd);
        }
@@ -162,7 +164,8 @@ static inline void clear_pgd_range(struct mmu_gather *tlb, pgd_t *pgd, unsigned
                addr = next;
        } while (addr && (addr < end));
 
-       if (!(start & ~PGDIR_MASK) && !(end & ~PGDIR_MASK)) {
+       if (!((start | end) & ~PGDIR_MASK)) {
+               /* Only clear full, aligned ranges */
                pgd_clear(pgd);
                pud_free_tlb(tlb, __pud);
        }