freebsd-dev/sys/vm
Mark Johnston 20f02659d6 vm_map: Handle kernel map entry allocator recursion
On platforms without a direct map[*], vm_map_insert() may in rare
situations need to allocate a kernel map entry in order to allocate
kernel map entries.  This poses a problem similar to the one solved for
vmem boundary tags by vmem_bt_alloc().  In fact the kernel map case is a
bit more complicated since we must allocate entries with the kernel map
locked, whereas vmem can recurse into itself because boundary tags are
allocated up-front.

The solution is to add a custom slab allocator for kmapentzone which
allocates KVA directly from kernel_map, bypassing the kmem_* layer.
This avoids mutual recursion with the vmem btag allocator.  Then, when
vm_map_insert() allocates a new kernel map entry, it avoids triggering
allocation of a new slab with M_NOVM until after the insertion is
complete.  Instead, vm_map_insert() allocates from the reserve and sets
a flag in kernel_map to trigger re-population of the reserve just before
the map is unlocked.  This places an implicit upper bound on the number
of kernel map entries that may be allocated before the kernel map lock
is released, but in general a bound of 1 suffices.

[*] This also comes up on amd64 with UMA_MD_SMALL_ALLOC undefined, a
configuration required by some kernel sanitizers.

Discussed with:	kib, rlibby
Reported by:	andrew
Tested by:	pho (i386 and amd64 with !UMA_MD_SMALL_ALLOC)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26851
2020-11-11 17:16:39 +00:00
..
_vm_radix.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
default_pager.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
device_pager.c Don't hold the object lock while calling getpages. 2020-01-19 23:47:32 +00:00
memguard.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
memguard.h LinuxKPI: Implement ksize() function. 2020-08-29 19:26:31 +00:00
phys_pager.c Allow consumer to customize physical pager. 2020-09-09 00:00:43 +00:00
pmap.h Add pmap_enter(9) PMAP_ENTER_LARGEPAGE flag and implement it on amd64. 2020-09-09 21:50:24 +00:00
redzone.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
redzone.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
sg_pager.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
swap_pager.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
swap_pager.h Remove swblk_t. 2020-02-17 15:11:07 +00:00
uma_core.c When destroying a UMA zone which has a reserve (set with 2020-11-10 18:12:09 +00:00
uma_dbg.c Fix compilation failures on different arches that have vm_machdep.c not 2019-01-15 19:33:47 +00:00
uma_dbg.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
uma_int.h vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
uma.h Add more per-cpu zones. 2020-11-09 00:34:23 +00:00
vm_domainset.c Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_domainset.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_dumpset.h Avoid dump_avail[] redefinition. 2020-10-14 22:51:40 +00:00
vm_extern.h Remove the VM map zone. 2020-08-17 13:02:01 +00:00
vm_fault.c Implement superpages for PowerPC64 (HPT) 2020-11-06 14:12:45 +00:00
vm_glue.c vmspace: Convert to refcount(9) 2020-11-04 16:30:56 +00:00
vm_init.c Remove the VM map zone. 2020-08-17 13:02:01 +00:00
vm_kern.c Use a large kmem arena import size on NUMA systems. 2020-08-26 14:31:48 +00:00
vm_kern.h Remove the VM map zone. 2020-08-17 13:02:01 +00:00
vm_map.c vm_map: Handle kernel map entry allocator recursion 2020-11-11 17:16:39 +00:00
vm_map.h vm_map: Handle kernel map entry allocator recursion 2020-11-11 17:16:39 +00:00
vm_meter.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
vm_mmap.c Support for userspace non-transparent superpages (largepages). 2020-09-09 22:12:51 +00:00
vm_object.c Allow consumer to customize physical pager. 2020-09-09 00:00:43 +00:00
vm_object.h Allow consumer to customize physical pager. 2020-09-09 00:00:43 +00:00
vm_page.c Avoid dump_avail[] redefinition. 2020-10-14 22:51:40 +00:00
vm_page.h Avoid dump_avail[] redefinition. 2020-10-14 22:51:40 +00:00
vm_pageout.c vm_pageout: Avoid rounding down the inactive scan target 2020-10-02 19:16:06 +00:00
vm_pageout.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_pagequeue.h Add support for multithreading the inactive queue pageout within a domain. 2020-08-11 20:37:45 +00:00
vm_pager.c sys/vm: quiet -Wwrite-strings 2020-02-23 03:32:04 +00:00
vm_pager.h Allow consumer to customize physical pager. 2020-09-09 00:00:43 +00:00
vm_param.h (fault 3/9) Move map relookup into a dedicated function. 2020-01-23 05:07:01 +00:00
vm_phys.c Flag vm_reserv and vm_phys sysctls as MPSAFE. 2020-09-23 19:36:07 +00:00
vm_phys.h Conditionally compile struct vm_phys_seg's md_first field. This field is 2020-10-23 06:24:38 +00:00
vm_radix.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
vm_radix.h Use SMR to provide a safe unlocked lookup for vm_radix. 2020-02-19 19:58:31 +00:00
vm_reserv.c Flag vm_reserv and vm_phys sysctls as MPSAFE. 2020-09-23 19:36:07 +00:00
vm_reserv.h Fix locking in vm_reserv_reclaim_contig(). 2019-11-22 16:28:52 +00:00
vm_swapout_dummy.c SPDX: Consider code from Carnegie-Mellon University. 2017-11-30 15:48:35 +00:00
vm_swapout.c Use a single VM object for kernel stacks. 2020-04-26 20:08:57 +00:00
vm_unix.c Prepare to handle non-trivial errors from vm_map_delete(). 2020-09-09 21:34:31 +00:00
vm.h vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
vnode_pager.c vm_ooffset_t is now unsigned 2020-09-18 16:48:08 +00:00
vnode_pager.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00