aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2013-04-08 19:19:10 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2013-04-08 19:19:10 +0000
commit17dece86fefee7a36604c5ebc9b7dd7f96bc6ebf (patch)
tree417e1a1bd53ca195c061caab891a3d8d940beb2b /sys/sys/pcpu.h
parentad97af7ebdd3833d5b5803324c3c460606a0c626 (diff)
downloadsrc-17dece86fefee7a36604c5ebc9b7dd7f96bc6ebf.tar.gz
src-17dece86fefee7a36604c5ebc9b7dd7f96bc6ebf.zip
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.
Notes
Notes: svn path=/head/; revision=249265
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h16
1 files changed, 16 insertions, 0 deletions
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