From owner-svn-src-all@FreeBSD.ORG Mon Apr 8 19:19:12 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 56C2BCD4; Mon, 8 Apr 2013 19:19:12 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 492382B8; Mon, 8 Apr 2013 19:19:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r38JJCix088656; Mon, 8 Apr 2013 19:19:12 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r38JJAvB088644; Mon, 8 Apr 2013 19:19:10 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201304081919.r38JJAvB088644@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 8 Apr 2013 19:19:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249265 - in head/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2013 19:19:12 -0000 Author: glebius Date: Mon Apr 8 19:19:10 2013 New Revision: 249265 URL: http://svnweb.freebsd.org/changeset/base/249265 Log: Merge from projects/counters: Pad struct pcpu so that its size is denominator of PAGE_SIZE. This is done to reduce memory waste in UMA_PCPU_ZONE zones. Sponsored by: Nginx, Inc. Modified: head/sys/amd64/include/pcpu.h head/sys/arm/include/pcpu.h head/sys/i386/include/pcpu.h head/sys/ia64/include/pcpu.h head/sys/mips/include/pcpu.h head/sys/powerpc/include/pcpu.h head/sys/sparc64/include/pcpu.h head/sys/sys/pcpu.h Modified: head/sys/amd64/include/pcpu.h ============================================================================== --- head/sys/amd64/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/amd64/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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 Modified: head/sys/arm/include/pcpu.h ============================================================================== --- head/sys/arm/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/arm/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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; Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/i386/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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 Modified: head/sys/ia64/include/pcpu.h ============================================================================== --- head/sys/ia64/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/ia64/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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 Modified: head/sys/mips/include/pcpu.h ============================================================================== --- head/sys/mips/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/mips/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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]; Modified: head/sys/powerpc/include/pcpu.h ============================================================================== --- head/sys/powerpc/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/powerpc/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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 */ Modified: head/sys/sparc64/include/pcpu.h ============================================================================== --- head/sys/sparc64/include/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/sparc64/include/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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 Modified: head/sys/sys/pcpu.h ============================================================================== --- head/sys/sys/pcpu.h Mon Apr 8 19:10:45 2013 (r249264) +++ head/sys/sys/pcpu.h Mon Apr 8 19:19:10 2013 (r249265) @@ -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