aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/include/counter.h9
-rw-r--r--sys/amd64/include/pcpu.h3
-rw-r--r--sys/i386/include/pcpu.h2
-rw-r--r--sys/sys/pcpu.h21
4 files changed, 19 insertions, 16 deletions
diff --git a/sys/amd64/include/counter.h b/sys/amd64/include/counter.h
index 2255a0575a0c..b09790fcb34e 100644
--- a/sys/amd64/include/counter.h
+++ b/sys/amd64/include/counter.h
@@ -83,11 +83,18 @@ counter_u64_zero_inline(counter_u64_t c)
static inline void
counter_u64_add(counter_u64_t c, int64_t inc)
{
-
+ int64_t *p;
+#ifdef notyet
__asm __volatile("addq\t%1,%%gs:(%0)"
:
: "r" ((char *)c - (char *)&__pcpu[0]), "ri" (inc)
: "memory", "cc");
+#endif
+ /* temporary */
+ critical_enter();
+ p = zpcpu_get(c);
+ *p += inc;
+ critical_exit();
}
#endif /* ! __MACHINE_COUNTER_H__ */
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
index f1493176708a..0cd476a6cae3 100644
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -76,7 +76,8 @@
uint32_t pc_pcid_gen; \
uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \
uint32_t pc_ibpb_set; \
- char __pad[3288] /* pad to UMA_PCPU_ALLOC_SIZE */
+ char __pad[216] /* be divisor of PAGE_SIZE \
+ after cache alignment */
#define PC_DBREG_CMD_NONE 0
#define PC_DBREG_CMD_LOAD 1
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
index 50864d7d3648..be4594963fe5 100644
--- a/sys/i386/include/pcpu.h
+++ b/sys/i386/include/pcpu.h
@@ -80,7 +80,7 @@
caddr_t pc_pmap_eh_ptep; \
uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \
uint32_t pc_ibpb_set; \
- char __pad[3610]
+ char __pad[538]
#ifdef _KERNEL
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index cba9d6e89797..9ba2adfdbff8 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -185,6 +185,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);
@@ -201,19 +209,6 @@ extern struct pcpu *cpuid_to_pcpu[];
#define UMA_PCPU_ALLOC_SIZE PAGE_SIZE
-#ifdef CTASSERT
-#if defined(__i386__) || defined(__amd64__)
-/* Required for counters(9) to work on x86. */
-CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE);
-#else
-/*
- * 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 */
-
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
static inline void *
zpcpu_get(void *base)