summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-08-30 07:59:49 +0000
committerkib <kib@FreeBSD.org>2013-08-30 07:59:49 +0000
commita2b5da0090b331918b7db2ece8b9ca5d545d4a6c (patch)
tree04770c540ba8145f9288bad14ac5d4d59ac30c95 /sys/amd64/include
parent748f95c68727abdadaf3ea8816cc19784d05411d (diff)
downloadFreeBSD-src-a2b5da0090b331918b7db2ece8b9ca5d545d4a6c.zip
FreeBSD-src-a2b5da0090b331918b7db2ece8b9ca5d545d4a6c.tar.gz
Implement support for the process-context identifiers ('PCID') on
Intel CPUs. The feature tags TLB entries with the Id of the address space and allows to avoid TLB invalidation on the context switch, it is available only in the long mode. In the microbenchmarks, using the PCID decreased latency of the context switches by ~30% on SandyBridge class desktop CPUs, measured with the lat_ctx program from lmbench. If available, use INVPCID instruction when a TLB entry in non-current address space needs to be invalidated. The instruction is typically available on the Haswell. If needed, the use of PCID can be turned off with the vm.pmap.pcid_enabled loader tunable set to 0. The state of the feature is reported by the vm.pmap.pcid_enabled sysctl. The sysctl vm.pmap.pcid_save_cnt reports the number of context switches which avoided invalidating the TLB; compare with the total number of context switches, available as sysctl vm.stats.sys.v_swtch. Sponsored by: The FreeBSD Foundation Reviewed by: alc Tested by: pho, bf
Diffstat (limited to 'sys/amd64/include')
-rw-r--r--sys/amd64/include/pcpu.h2
-rw-r--r--sys/amd64/include/pmap.h2
-rw-r--r--sys/amd64/include/smp.h15
3 files changed, 13 insertions, 6 deletions
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
index 1c83c2a..0e11975 100644
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -67,6 +67,8 @@
struct system_segment_descriptor *pc_ldt; \
/* Pointer to the CPU TSS descriptor */ \
struct system_segment_descriptor *pc_tss; \
+ uint64_t pc_pm_save_cnt; \
+ char pc_invpcid_descr[16]; \
u_int pc_cmci_mask; /* MCx banks for CMCI */ \
uint64_t pc_dbreg[16]; /* ddb debugging regs */ \
int pc_dbreg_cmd; /* ddb debugging reg cmd */ \
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
index aacb9ba..fa42389 100644
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -240,6 +240,8 @@ struct pmap {
pml4_entry_t *pm_pml4; /* KVA of level 4 page table */
TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
cpuset_t pm_active; /* active on cpus */
+ cpuset_t pm_save; /* Context valid on cpus mask */
+ int pm_pcid; /* context id */
/* spare u_int here due to padding */
struct pmap_statistics pm_stats; /* pmap statistics */
struct vm_radix pm_root; /* spare page table pages */
diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h
index 16d87ea..d6cd476 100644
--- a/sys/amd64/include/smp.h
+++ b/sys/amd64/include/smp.h
@@ -54,6 +54,8 @@ inthand_t
IDTVEC(cpususpend), /* CPU suspends & waits to be resumed */
IDTVEC(rendezvous); /* handle CPU rendezvous */
+struct pmap;
+
/* functions in mp_machdep.c */
void cpu_add(u_int apic_id, char boot_cpu);
void cpustop_handler(void);
@@ -67,13 +69,14 @@ int ipi_nmi_handler(void);
void ipi_selected(cpuset_t cpus, u_int ipi);
u_int mp_bootaddress(u_int);
void smp_cache_flush(void);
-void smp_invlpg(vm_offset_t addr);
-void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr);
-void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva);
-void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
+void smp_invlpg(struct pmap *pmap, vm_offset_t addr);
+void smp_masked_invlpg(cpuset_t mask, struct pmap *pmap, vm_offset_t addr);
+void smp_invlpg_range(struct pmap *pmap, vm_offset_t startva,
vm_offset_t endva);
-void smp_invltlb(void);
-void smp_masked_invltlb(cpuset_t mask);
+void smp_masked_invlpg_range(cpuset_t mask, struct pmap *pmap,
+ vm_offset_t startva, vm_offset_t endva);
+void smp_invltlb(struct pmap *pmap);
+void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap);
#endif /* !LOCORE */
#endif /* SMP */
OpenPOWER on IntegriCloud