freebsd-skq/sys/x86
Konstantin Belousov a546448b8d Rewrite amd64 PCID implementation to follow an algorithm described in
the Vahalia' "Unix Internals" section 15.12 "Other TLB Consistency
Algorithms".  The same algorithm is already utilized by the MIPS pmap
to handle ASIDs.

The PCID for the address space is now allocated per-cpu during context
switch to the thread using pmap, when no PCID on the cpu was ever
allocated, or the current PCID is invalidated.  If the PCID is reused,
bit 63 of %cr3 can be set to avoid TLB flush.

Each cpu has PCID' algorithm generation count, which is saved in the
pmap pcpu block when pcpu PCID is allocated.  On invalidation, the
pmap generation count is zeroed, which signals the context switch code
that already allocated PCID is no longer valid.  The implication is
the TLB shootdown for the given cpu/address space, due to the
allocation of new PCID.

The pm_save mask is no longer has to be tracked, which (significantly)
reduces the targets of the TLB shootdown IPIs.  Previously, pm_save
was reset only on pmap_invalidate_all(), which made it accumulate the
cpuids of all processors on which the thread was scheduled between
full TLB shootdowns.

Besides reducing the amount of TLB shootdowns and removing atomics to
update pm_saves in the context switch code, the algorithm is much
simpler than the maintanence of pm_save and selection of the right
address space in the shootdown IPI handler.

Reviewed by:	alc
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2015-05-09 19:11:01 +00:00
..
acpica Add initial memory locality cost awareness to the VM, and include 2015-05-08 00:56:56 +00:00
bios Add missing header needed by free(9). 2012-09-30 15:42:20 +00:00
cpufreq Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
include Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00
iommu Account for the offset of the page run when allocating the 2015-04-08 01:55:22 +00:00
isa Include mca_machdep.h. 2015-01-18 03:43:47 +00:00
pci Reassign copyright statements on several files from Advanced 2015-04-23 14:22:20 +00:00
x86 If x86 CPU implementation of the MWAIT instruction reasonably 2015-05-09 12:28:48 +00:00
xen Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00