From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Linux Kernel Mailing List <Linux-Kernel@vger.kernel.org>
Subject: [patch 2/14] mm: pte prefetch
Date: Sun, 06 Nov 2005 19:20:50 +1100 [thread overview]
Message-ID: <436DBCE2.4050502@yahoo.com.au> (raw)
In-Reply-To: <436DBCBC.5000906@yahoo.com.au>
[-- Attachment #1: Type: text/plain, Size: 34 bytes --]
2/14
--
SUSE Labs, Novell Inc.
[-- Attachment #2: mm-pte-prefetch.patch --]
[-- Type: text/plain, Size: 2648 bytes --]
Prefetch ptes a line ahead. Worth 25% on ia64 when doing big forks.
Index: linux-2.6/include/asm-generic/pgtable.h
===================================================================
--- linux-2.6.orig/include/asm-generic/pgtable.h
+++ linux-2.6/include/asm-generic/pgtable.h
@@ -196,6 +196,33 @@ static inline void ptep_set_wrprotect(st
})
#endif
+#ifndef __HAVE_ARCH_PTE_PREFETCH
+#define PTES_PER_LINE (L1_CACHE_BYTES / sizeof(pte_t))
+#define PTE_LINE_MASK (~(PTES_PER_LINE - 1))
+#define ADDR_PER_LINE (PTES_PER_LINE << PAGE_SHIFT)
+#define ADDR_LINE_MASK (~(ADDR_PER_LINE - 1))
+
+#define pte_prefetch(pte, addr, end) \
+({ \
+ unsigned long __nextline = ((addr) + ADDR_PER_LINE) & ADDR_LINE_MASK; \
+ if (__nextline < (end)) \
+ prefetch(pte + PTES_PER_LINE); \
+})
+
+#define pte_prefetch_start(pte, addr, end) \
+({ \
+ prefetch(pte); \
+ pte_prefetch(pte, addr, end); \
+})
+
+#define pte_prefetch_next(pte, addr, end) \
+({ \
+ unsigned long __addr = (addr); \
+ if (!(__addr & ~ADDR_LINE_MASK)) /* We hit a new cacheline */ \
+ pte_prefetch(pte, __addr, end); \
+})
+#endif
+
#ifndef __ASSEMBLY__
/*
* When walking page tables, we usually want to skip any p?d_none entries;
Index: linux-2.6/mm/memory.c
===================================================================
--- linux-2.6.orig/mm/memory.c
+++ linux-2.6/mm/memory.c
@@ -437,6 +437,8 @@ again:
if (!dst_pte)
return -ENOMEM;
src_pte = pte_offset_map_nested(src_pmd, addr);
+ pte_prefetch_start(src_pte, addr, end);
+
src_ptl = pte_lockptr(src_mm, src_pmd);
spin_lock(src_ptl);
@@ -458,7 +460,8 @@ again:
}
copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vma, addr, rss);
progress += 8;
- } while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end);
+ } while (dst_pte++, src_pte++, addr += PAGE_SIZE,
+ pte_prefetch_next(src_pte, addr, end), addr != end);
spin_unlock(src_ptl);
pte_unmap_nested(src_pte - 1);
@@ -561,6 +564,7 @@ static unsigned long zap_pte_range(struc
int anon_rss = 0;
pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
+ pte_prefetch_start(pte, addr, end);
do {
pte_t ptent = *pte;
if (pte_none(ptent)) {
@@ -629,7 +633,8 @@ static unsigned long zap_pte_range(struc
if (!pte_file(ptent))
free_swap_and_cache(pte_to_swp_entry(ptent));
pte_clear_full(mm, addr, pte, tlb->fullmm);
- } while (pte++, addr += PAGE_SIZE, (addr != end && *zap_work > 0));
+ } while (pte++, addr += PAGE_SIZE, pte_prefetch_next(pte, addr, end),
+ (addr != end && *zap_work > 0));
add_mm_rss(mm, file_rss, anon_rss);
pte_unmap_unlock(pte - 1, ptl);
next prev parent reply other threads:[~2005-11-06 8:18 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-06 8:11 [rfc][patch 0/14] mm: performance improvements Nick Piggin
2005-11-06 8:20 ` [patch 1/14] mm: opt rmqueue Nick Piggin
2005-11-06 8:20 ` [patch 2/14] mm: Nick Piggin
2005-11-06 8:20 ` Nick Piggin [this message]
2005-11-06 8:21 ` [patch 3/14] mm: release opt Nick Piggin
2005-11-06 8:22 ` [patch 4/14] mm: rmap opt Nick Piggin
2005-11-06 8:23 ` [patch 5/14] mm: set_page_refs opt Nick Piggin
2005-11-06 8:24 ` [patch 6/14] mm: microopt conditions Nick Piggin
2005-11-06 8:24 ` [patch 7/14] mm: remove bad_range Nick Piggin
2005-11-06 8:25 ` [patch 8/14] mm: remove pcp_low Nick Piggin
2005-11-06 8:25 ` [patch 9/14] mm: page_state opt Nick Piggin
2005-11-06 8:26 ` [patch 10/14] mm: single pcp list Nick Piggin
2005-11-06 8:26 ` [patch 11/14] mm: increase pcp size Nick Piggin
2005-11-06 8:27 ` [patch 12/14] mm: variable " Nick Piggin
2005-11-06 8:27 ` [patch 13/14] mm: cleanup zone_pcp Nick Piggin
2005-11-06 8:28 ` [patch 14/14] mm: page_alloc cleanups Nick Piggin
2005-11-13 2:38 ` [patch 9/14] mm: page_state opt Andi Kleen
2005-11-06 17:37 ` [patch 7/14] mm: remove bad_range Bob Picco
2005-11-07 0:58 ` Nick Piggin
2005-11-07 3:00 ` Bob Picco
2005-11-07 3:05 ` Nick Piggin
2005-11-07 1:40 ` [patch 5/14] mm: set_page_refs opt Christoph Hellwig
2005-11-07 1:45 ` Nick Piggin
2005-11-06 8:35 ` [patch 2/14] mm: pte prefetch Arjan van de Ven
2005-11-06 8:51 ` Nick Piggin
2005-11-06 17:37 ` [patch 1/14] mm: opt rmqueue Andi Kleen
2005-11-07 1:06 ` Nick Piggin
2005-11-07 3:23 ` Andi Kleen
2005-11-07 3:43 ` Nick Piggin
2005-11-07 1:39 ` [rfc][patch 0/14] mm: performance improvements Christoph Hellwig
2005-11-07 1:51 ` Nick Piggin
2005-11-07 3:57 ` Paul Jackson
2005-11-07 4:51 ` Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=436DBCE2.4050502@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=Linux-Kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox