path: root/sys/sys/pcpu.h
diff options
authorKonstantin Belousov <kib@FreeBSD.org>2019-08-29 07:25:27 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-08-29 07:25:27 +0000
commita2a0f90654eeca563cf47f043d6c1a14e6a7e289 (patch)
tree0f0f88ea65718314696b068de30da60a01a3fdb8 /sys/sys/pcpu.h
parent4b4d1b818e84c6eee3c06f60315510bf34729aba (diff)
Centralize __pcpu definitions.
Many extern struct pcpu <something>__pcpu declarations were copied/pasted in sources. The issue is that the definition is MD, but it cannot be provided by machine/pcpu.h due to actual struct pcpu defined in sys/pcpu.h later than the inclusion of machine/pcpu.h. This forced the copying when other code needed direct access to __pcpu. There is no way around it, due to machine/pcpu.h supplying part of struct pcpu fields. To work around the problem, add a new machine/pcpu_aux.h header, which should fill any needed MD definitions after struct pcpu definition is completed. This allows to remove copies of __pcpu spread around the source. Also on x86 it makes it possible to remove work arounds like OFFSETOF_CURTHREAD or clang specific warnings supressions. Reported and tested by: lwhsu, bcran Reviewed by: imp, markj (previous version) Discussed with: jhb Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D21418
Notes: svn path=/head/; revision=351594
Diffstat (limited to 'sys/sys/pcpu.h')
1 files changed, 6 insertions, 16 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 1d0829ee43c7..5298f38fe4ec 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -216,26 +216,16 @@ extern struct cpuhead cpuhead;
extern struct pcpu *cpuid_to_pcpu[];
#define curcpu PCPU_GET(cpuid)
-#define curproc (curthread->td_proc)
-#ifndef curthread
-#define curthread PCPU_GET(curthread)
#define curvidata PCPU_GET(vidata)
-#ifdef CTASSERT
-#if defined(__i386__) || defined(__amd64__)
-/* Required for counters(9) to work on x86. */
-CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE);
- * 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 /* UMA_PCPU_ALLOC_SIZE && x86 */
-#endif /* CTASSERT */
+#include <machine/pcpu_aux.h>
+#ifndef curthread
+#define curthread PCPU_GET(curthread)
+#define curproc (curthread->td_proc)
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
static inline void *