From 105c3171664c7c6f734eb0eac5958e4e5aab6434 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 14 Dec 2018 21:04:30 +0000 Subject: [PATCH] Avoid needless TLB invalidations in pmap_remove_pages(). pmap_remove_pages() is called during process termination, when it is guaranteed that no other CPU may access the mappings being torn down. In particular, it unnecessary to invalidate each mapping individually since we do a pmap_invalidate_all() at the end of the function. Also don't call pmap_invalidate_all() while holding a PV list lock, the global pvh lock is sufficient. Reviewed by: jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18562 --- sys/riscv/riscv/pmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 570a1b30317..ad13bc9f510 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -2721,9 +2721,10 @@ pmap_remove_pages(pmap_t pmap) l3 = pmap_l2_to_l3(l2, pv->pv_va); tl3 = pmap_load(l3); -/* - * We cannot remove wired pages from a process' mapping at this time - */ + /* + * We cannot remove wired pages from a + * process' mapping at this time. + */ if (tl3 & PTE_SW_WIRED) { allfree = 0; continue; @@ -2742,7 +2743,6 @@ pmap_remove_pages(pmap_t pmap) (uintmax_t)tl3)); pmap_load_clear(l3); - pmap_invalidate_page(pmap, pv->pv_va); /* * Update the vm_page_t clean/reference bits. @@ -2771,9 +2771,9 @@ pmap_remove_pages(pmap_t pmap) free_pv_chunk(pc); } } - pmap_invalidate_all(pmap); if (lock != NULL) rw_wunlock(lock); + pmap_invalidate_all(pmap); rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); vm_page_free_pages_toq(&free, false);