From fa8053e9a9d69799e2b5b8c0ad7e715818a07272 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 21 Mar 2006 18:07:42 +0000 Subject: [PATCH] Eliminate unnecessary invalidations of the entire TLB by pmap_remove(). Specifically, on mappings with PG_G set pmap_remove() not only performs the necessary per-page invlpg invalidations but also performs an unnecessary invalidation of the entire set of non-PG_G entries. Reviewed by: tegge --- sys/amd64/amd64/pmap.c | 8 +++++++- sys/i386/i386/pmap.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 9434ce50bd7d..760539d6515d 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1731,7 +1731,13 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) sva += PAGE_SIZE) { if (*pte == 0) continue; - anyvalid = 1; + + /* + * The TLB entry for a PG_G mapping is invalidated + * by pmap_remove_pte(). + */ + if ((*pte & PG_G) == 0) + anyvalid = 1; if (pmap_remove_pte(pmap, pte, sva, ptpaddr)) break; } diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 143881c5c9e7..b4c9027b391f 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1719,7 +1719,13 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) sva += PAGE_SIZE) { if (*pte == 0) continue; - anyvalid = 1; + + /* + * The TLB entry for a PG_G mapping is invalidated + * by pmap_remove_pte(). + */ + if ((*pte & PG_G) == 0) + anyvalid = 1; if (pmap_remove_pte(pmap, pte, sva)) break; }