diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -6280,14 +6280,8 @@ return (anyvalid); } -/* - * Remove the given range of addresses from the specified map. - * - * It is assumed that the start and end are properly - * rounded to the page size. - */ -void -pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) +static void +pmap_remove1(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, bool swapout) { struct rwlock *lock; vm_page_t mt; @@ -6319,7 +6313,8 @@ pmap_delayed_invl_start(); PMAP_LOCK(pmap); - pmap_pkru_on_remove(pmap, sva, eva); + if (!swapout) + pmap_pkru_on_remove(pmap, sva, eva); /* * special handling of removing one page. a very @@ -6441,6 +6436,24 @@ vm_page_free_pages_toq(&free, true); } +/* + * Remove the given range of addresses from the specified map. + * + * It is assumed that the start and end are properly + * rounded to the page size. + */ +void +pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) +{ + pmap_remove1(pmap, sva, eva, false); +} + +void +pmap_remove_swapout(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) +{ + pmap_remove1(pmap, sva, eva, true); +} + /* * Routine: pmap_remove_all * Function: diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -495,6 +495,7 @@ int pmap_pkru_clear(pmap_t pmap, vm_offset_t sva, vm_offset_t eva); int pmap_pkru_set(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, u_int keyidx, int flags); +void pmap_remove_swapout(pmap_t, vm_offset_t, vm_offset_t); void pmap_thread_init_invl_gen(struct thread *td); int pmap_vmspace_copy(pmap_t dst_pmap, pmap_t src_pmap); void pmap_page_array_startup(long count); diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h --- a/sys/arm/include/pmap.h +++ b/sys/arm/include/pmap.h @@ -45,6 +45,7 @@ void *pmap_kenter_temporary(vm_paddr_t, int); #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) void pmap_page_set_memattr(vm_page_t, vm_memattr_t); +#define pmap_remove_swapout(pmap, sva, eva) pmap_remove(pmap, sva, eva) void *pmap_mapdev(vm_paddr_t, vm_size_t); void pmap_unmapdev(void *, vm_size_t); diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h --- a/sys/arm64/include/pmap.h +++ b/sys/arm64/include/pmap.h @@ -154,6 +154,7 @@ bool pmap_ps_enabled(pmap_t pmap); uint64_t pmap_to_ttbr0(pmap_t pmap); void pmap_disable_promotion(vm_offset_t sva, vm_size_t size); +#define pmap_remove_swapout(pmap, sva, eva) pmap_remove(pmap, sva, eva) void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapbios(vm_paddr_t, vm_size_t); diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -258,6 +258,7 @@ void pmap_force_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva); void *pmap_trm_alloc(size_t size, int flags); void pmap_trm_free(void *addr, size_t size); +#define pmap_remove_swapout(pmap, sva, eva) pmap_remove(pmap, sva, eva) void invltlb_glob(void); diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h --- a/sys/powerpc/include/pmap.h +++ b/sys/powerpc/include/pmap.h @@ -326,6 +326,7 @@ bool pmap_ps_enabled(pmap_t pmap); int pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t flags); boolean_t pmap_page_is_mapped(vm_page_t m); +#define pmap_remove_swapout(pmap, sva, eva) pmap_remove(pmap, sva, eva) void pmap_page_array_startup(long count); diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h --- a/sys/riscv/include/pmap.h +++ b/sys/riscv/include/pmap.h @@ -57,6 +57,7 @@ #define pmap_page_get_memattr(m) ((m)->md.pv_memattr) #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); +#define pmap_remove_swapout(pmap, sva, eva) pmap_remove(pmap, sva, eva) /* * Pmap stuff diff --git a/sys/vm/vm_swapout.c b/sys/vm/vm_swapout.c --- a/sys/vm/vm_swapout.c +++ b/sys/vm/vm_swapout.c @@ -319,7 +319,7 @@ * table pages. */ if (desired == 0 && nothingwired) { - pmap_remove(vm_map_pmap(map), vm_map_min(map), + pmap_remove_swapout(vm_map_pmap(map), vm_map_min(map), vm_map_max(map)); }