diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h index 2188442f773c..bb7d33950535 100644 --- a/sys/amd64/include/pcpu.h +++ b/sys/amd64/include/pcpu.h @@ -77,7 +77,9 @@ /* Pointer to the CPU TSS descriptor */ \ struct system_segment_descriptor *pc_tss; \ u_int pc_cmci_mask /* MCx banks for CMCI */ \ - PCPU_XEN_FIELDS + PCPU_XEN_FIELDS; \ + char __pad[293] /* be divisor of PAGE_SIZE \ + after cache alignment */ #ifdef _KERNEL diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h index 43ffb44afec2..cd5006caa84e 100644 --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -48,12 +48,13 @@ struct vmspace; unsigned int pc_vfpmvfr0; \ unsigned int pc_vfpmvfr1; \ struct thread *pc_vfpcthread; \ - struct pmap *pc_curpmap; + struct pmap *pc_curpmap; \ + char __pad[133] #else -#define PCPU_MD_FIELDS +#define PCPU_MD_FIELDS \ + char __pad[157] #endif - #ifdef _KERNEL struct pcb; diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index aa1066d2a1ee..3606d12dd1be 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -74,18 +74,22 @@ struct shadow_time_info { int pc_resched_irq; \ int pc_callfunc_irq; \ int pc_virq_to_irq[NR_VIRQS]; \ - int pc_ipi_to_irq[NR_IPIS] + int pc_ipi_to_irq[NR_IPIS]; \ + char __pad[77] #elif defined(XENHVM) #define PCPU_XEN_FIELDS \ ; \ unsigned int pc_last_processed_l1i; \ - unsigned int pc_last_processed_l2i + unsigned int pc_last_processed_l2i; \ + char __pad[229] #else /* !XEN && !XENHVM */ -#define PCPU_XEN_FIELDS +#define PCPU_XEN_FIELDS \ + ; \ + char __pad[237] #endif diff --git a/sys/ia64/include/pcpu.h b/sys/ia64/include/pcpu.h index 5ad61ba9a8b7..0f2a6f39947e 100644 --- a/sys/ia64/include/pcpu.h +++ b/sys/ia64/include/pcpu.h @@ -64,7 +64,8 @@ struct pcpu_md { #define PCPU_MD_FIELDS \ uint32_t pc_acpi_id; /* ACPI CPU id. */ \ - struct pcpu_md pc_md /* MD fields. */ + struct pcpu_md pc_md; /* MD fields. */ \ + char __pad[1265] #ifdef _KERNEL diff --git a/sys/mips/include/pcpu.h b/sys/mips/include/pcpu.h index b8928a1171a9..89b65257cefd 100644 --- a/sys/mips/include/pcpu.h +++ b/sys/mips/include/pcpu.h @@ -33,13 +33,29 @@ #include -#define PCPU_MD_FIELDS \ +#define PCPU_MD_COMMON_FIELDS \ pd_entry_t *pc_segbase; /* curthread segbase */ \ struct pmap *pc_curpmap; /* pmap of curthread */ \ u_int32_t pc_next_asid; /* next ASID to alloc */ \ u_int32_t pc_asid_generation; /* current ASID generation */ \ u_int pc_pending_ipis; /* IPIs pending to this CPU */ +#ifdef __mips_n64 +#define PCPU_MD_MIPS64_FIELDS \ + PCPU_MD_COMMON_FIELDS \ + char __pad[61] +#else +#define PCPU_MD_MIPS32_FIELDS \ + PCPU_MD_COMMON_FIELDS \ + char __pad[133] +#endif + +#ifdef __mips_n64 +#define PCPU_MD_FIELDS PCPU_MD_MIPS64_FIELDS +#else +#define PCPU_MD_FIELDS PCPU_MD_MIPS32_FIELDS +#endif + #ifdef _KERNEL extern char pcpu_space[MAXCPU][PAGE_SIZE * 2]; diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h index bd1466177508..66ad4b23a3fa 100644 --- a/sys/powerpc/include/pcpu.h +++ b/sys/powerpc/include/pcpu.h @@ -51,13 +51,15 @@ struct pmap; register_t pc_disisave[CPUSAVE_LEN]; \ register_t pc_dbsave[CPUSAVE_LEN]; -#define PCPU_MD_AIM32_FIELDS +#define PCPU_MD_AIM32_FIELDS \ + /* char __pad[0] */ #define PCPU_MD_AIM64_FIELDS \ struct slb pc_slb[64]; \ struct slb **pc_userslb; \ register_t pc_slbsave[18]; \ - uint8_t pc_slbstack[1024]; + uint8_t pc_slbstack[1024]; \ + char __pad[1137] #ifdef __powerpc64__ #define PCPU_MD_AIM_FIELDS PCPU_MD_AIM64_FIELDS @@ -76,7 +78,8 @@ struct pmap; register_t pc_booke_tlbsave[BOOKE_TLBSAVE_LEN]; \ register_t pc_booke_tlb_level; \ uint32_t *pc_booke_tlb_lock; \ - int pc_tid_next; + int pc_tid_next; \ + char __pad[173] /* Definitions for register offsets within the exception tmp save areas */ #define CPUSAVE_R27 0 /* where r27 gets saved */ diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h index 033f7e52c21e..dbcc59c6cd4b 100644 --- a/sys/sparc64/include/pcpu.h +++ b/sys/sparc64/include/pcpu.h @@ -60,7 +60,8 @@ struct pmap; u_int pc_node; \ u_int pc_tlb_ctx; \ u_int pc_tlb_ctx_max; \ - u_int pc_tlb_ctx_min + u_int pc_tlb_ctx_min; \ + char __pad[405] #ifdef _KERNEL diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index e86038565755..c73cc5364a62 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -180,6 +180,14 @@ struct pcpu { PCPU_MD_FIELDS; } __aligned(CACHE_LINE_SIZE); +#ifdef CTASSERT +/* + * To minimize memory waste in per-cpu UMA zones, size of struct pcpu + * should be denominator of PAGE_SIZE. + */ +CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE); +#endif + #ifdef _KERNEL STAILQ_HEAD(cpuhead, pcpu); @@ -194,6 +202,14 @@ extern struct pcpu *cpuid_to_pcpu[]; #endif #define curvidata PCPU_GET(vidata) +/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ +static inline void * +zpcpu_get(void *base) +{ + + return ((char *)(base) + sizeof(struct pcpu) * curcpu); +} + /* * Machine dependent callouts. cpu_pcpu_init() is responsible for * initializing machine dependent fields of struct pcpu, and