aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2015-12-06 17:39:13 +0000
committerConrad Meyer <cem@FreeBSD.org>2015-12-06 17:39:13 +0000
commit10386b56ad93296e683ac4569da8dfb513ba331f (patch)
tree8c6569774b0f23c7f3ee51bf35fe90dea88f0c9f /sys/i386
parentc979034b18da66c6f65818748754d5fbe2901707 (diff)
downloadsrc-10386b56ad93296e683ac4569da8dfb513ba331f.tar.gz
src-10386b56ad93296e683ac4569da8dfb513ba331f.zip
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
Notes
Notes: svn path=/head/; revision=291906
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/pmap.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 5ae41a316deb..5bdc98875ca7 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -1032,6 +1032,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)
{
@@ -1039,6 +1042,11 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
vm_offset_t addr;
u_int cpuid;
+ if (eva - sva >= PMAP_INVLPG_THRESHOLD) {
+ pmap_invalidate_all(pmap);
+ return;
+ }
+
sched_pin();
if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
for (addr = sva; addr < eva; addr += PAGE_SIZE)