summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/pmap.c
diff options
context:
space:
mode:
authorcem <cem@FreeBSD.org>2015-12-06 17:39:13 +0000
committercem <cem@FreeBSD.org>2015-12-06 17:39:13 +0000
commita15dada94bf633f34d63b4206062a0168ffd6e1b (patch)
tree8c6569774b0f23c7f3ee51bf35fe90dea88f0c9f /sys/amd64/amd64/pmap.c
parent23770ab9427614306517b5c1475be90157731cef (diff)
downloadFreeBSD-src-a15dada94bf633f34d63b4206062a0168ffd6e1b.zip
FreeBSD-src-a15dada94bf633f34d63b4206062a0168ffd6e1b.tar.gz
pmap_invalidate_range: For very large ranges, flush the whole TLB
Typical TLBs have 40-512 entries available. At some point, iterating every single page in a requested invalidation range and issuing invlpg on it is more expensive than flushing the TLB and allowing it to reload on demand. Broadwell CPUs have 1536 L2 TLB entries, so I've picked the arbitrary number 4096 entries as a hueristic at which point we flush TLB rather than invalidating every single potential page. Reviewed by: alc Feedback from: jhb, kib MFC notes: Depends on r291688 Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D4280
Diffstat (limited to 'sys/amd64/amd64/pmap.c')
-rw-r--r--sys/amd64/amd64/pmap.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 9f9654a..8b04eab 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -1421,6 +1421,9 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
sched_unpin();
}
+/* 4k PTEs -- Chosen to exceed the total size of Broadwell L2 TLB */
+#define PMAP_INVLPG_THRESHOLD (4 * 1024 * PAGE_SIZE)
+
void
pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
{
@@ -1428,6 +1431,11 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
vm_offset_t addr;
u_int cpuid, i;
+ if (eva - sva >= PMAP_INVLPG_THRESHOLD) {
+ pmap_invalidate_all(pmap);
+ return;
+ }
+
if (pmap_type_guest(pmap)) {
pmap_invalidate_ept(pmap);
return;
OpenPOWER on IntegriCloud