Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2013 06:32:47 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r245773 - in projects/counters/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include sys
Message-ID:  <201301220632.r0M6WlCD041241@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Tue Jan 22 06:32:46 2013
New Revision: 245773
URL: http://svnweb.freebsd.org/changeset/base/245773

Log:
  To reduce memory waste in UMA_ZONE_PCPU zones, pad struct pcpu on all
  architectures so that sizeof(struct pcpu) is denominator of PAGE_SIZE.
  
  Provide CTASSERT() that would force that.
  
  Since struct pcpu is CACHE_SIZE aligned, the padding size was chosen
  to be just +1 byte to a multiple of CACHE_SIZE. This allows future
  growing of MD pcpu fields without recalculating padding size. However,
  once it grows beyond CACHE_SIZE, the assert will fail and someone will
  need to reconsider padding size.

Modified:
  projects/counters/sys/amd64/include/pcpu.h
  projects/counters/sys/arm/include/pcpu.h
  projects/counters/sys/i386/include/pcpu.h
  projects/counters/sys/ia64/include/pcpu.h
  projects/counters/sys/mips/include/pcpu.h
  projects/counters/sys/powerpc/include/pcpu.h
  projects/counters/sys/sparc64/include/pcpu.h
  projects/counters/sys/sys/pcpu.h

Modified: projects/counters/sys/amd64/include/pcpu.h
==============================================================================
--- projects/counters/sys/amd64/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/amd64/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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: projects/counters/sys/arm/include/pcpu.h
==============================================================================
--- projects/counters/sys/arm/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/arm/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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: projects/counters/sys/i386/include/pcpu.h
==============================================================================
--- projects/counters/sys/i386/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/i386/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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: projects/counters/sys/ia64/include/pcpu.h
==============================================================================
--- projects/counters/sys/ia64/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/ia64/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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: projects/counters/sys/mips/include/pcpu.h
==============================================================================
--- projects/counters/sys/mips/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/mips/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -33,13 +33,29 @@
 
 #include <machine/pte.h>
 
-#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: projects/counters/sys/powerpc/include/pcpu.h
==============================================================================
--- projects/counters/sys/powerpc/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/powerpc/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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]		/* no pad for now */
 
 #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: projects/counters/sys/sparc64/include/pcpu.h
==============================================================================
--- projects/counters/sys/sparc64/include/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/sparc64/include/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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: projects/counters/sys/sys/pcpu.h
==============================================================================
--- projects/counters/sys/sys/pcpu.h	Tue Jan 22 06:23:18 2013	(r245772)
+++ projects/counters/sys/sys/pcpu.h	Tue Jan 22 06:32:46 2013	(r245773)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301220632.r0M6WlCD041241>