summaryrefslogtreecommitdiffstats
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2013-04-08 19:19:10 +0000
committerglebius <glebius@FreeBSD.org>2013-04-08 19:19:10 +0000
commit8c6eba117e357de0d074eaba6b730cc2261cd9e0 (patch)
tree417e1a1bd53ca195c061caab891a3d8d940beb2b /sys/sys/pcpu.h
parent7f9db020a246190e72c9b9656997403221c48a3a (diff)
downloadFreeBSD-src-8c6eba117e357de0d074eaba6b730cc2261cd9e0.zip
FreeBSD-src-8c6eba117e357de0d074eaba6b730cc2261cd9e0.tar.gz
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.
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 e860385..c73cc53 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
OpenPOWER on IntegriCloud