1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-28 16:43:09 +00:00
freebsd/sys/amd64
Konstantin Belousov ca1f624517 Fix the pv_chunks pc_lru tailq handling in reclaim_pv_chunk().
For processing, reclaim_pv_chunk() removes the pv_chunk from the lru
list, which makes pc_lru linkage invalid.  Then the pmap lock is
released, which allows for other thread to free the last pv entry
allocated from the chunk and call free_pv_chunk(), which tries to
modify the invalid linkage.

Similarly, the chunk is inserted into the private tailq new_tail
temporary.  Again, free_pv_chunk() might be run and corrupt the
linkage for the new_tail after the pmap lock is dropped.

This is a consequence of r299788 elimination of pvh_global_lock, which
allowed for reclaim to run in parallel with other pmap calls which
free pv chunks.

As a fix, do not remove the chunk from pc_lru queue, use a marker to
remember the position in the queue iteration.  We can safely operate
on the chunks after the chunk's pmap is locked, we fetched the chunk
after the marker, and we checked that chunk pmap is same as we have
locked, because chunk removal from pc_lru requires both pv_chunk_mutex
and the pmap mutex owned.

Note that the fix lost an optimization which was present in the
previous algorithm.  Namely, new_tail requeueing rotated the pv chunks
list so that reclaim didn't scan the same pv chunks that couldn't be
freed (because they contained a wired and/or superpage mapping) on
every invocation.  An additional change is planned which would improve
this.

Reported and tested by:	pho
Reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-10-16 15:16:24 +00:00
..
acpica Ensure that resume path on amd64 only accesses page tables for normal 2017-05-15 20:52:43 +00:00
amd64 Fix the pv_chunks pc_lru tailq handling in reclaim_pv_chunk(). 2017-10-16 15:16:24 +00:00
cloudabi32 Move struct syscall_args syscall arguments parameters container into 2017-06-12 21:03:23 +00:00
cloudabi64 Keep top page on CloudABI to work around AMD Ryzen stability issues. 2017-08-02 13:08:10 +00:00
conf Add MMCCAM-enabled kernel config for IMX6, reduce debug noice in MMCCAM kernels 2017-09-13 10:56:02 +00:00
ia32 Translate between abridged and full x87 tags for compat32 2017-06-24 11:38:31 +00:00
include Fix the pv_chunks pc_lru tailq handling in reclaim_pv_chunk(). 2017-10-16 15:16:24 +00:00
linux Lower the amd64 shared page, which contains the signal trampoline, 2017-08-02 01:43:35 +00:00
linux32 Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code. 2017-07-30 21:24:20 +00:00
pci pcicfg: Fix direct calls of pci_cfg{read,write} on systems w/o PCI host bridge. 2017-05-04 05:28:46 +00:00
sgx Fix module unload when SGX support is not present in CPU. 2017-08-18 14:47:06 +00:00
vmm Save KGSBASE in pcb before overriding it with the guest value. 2017-08-24 10:49:53 +00:00
Makefile Bring the tags and links entries for amd64 up to date. 2015-10-27 22:59:24 +00:00