aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-02-12 11:11:22 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-02-12 11:11:22 +0000
commit3acb6572fc0ef19119240a319873fa75fd597f28 (patch)
tree8572faa05e645cfab125ddade3bad5d601fc6374 /sys/sys/pcpu.h
parent48baf00f547e84a666cb38d3ccba4fe35fa468c1 (diff)
downloadsrc-3acb6572fc0ef19119240a319873fa75fd597f28.tar.gz
src-3acb6572fc0ef19119240a319873fa75fd597f28.zip
Store offset into zpcpu allocations in the per-cpu area.
This shorten zpcpu_get and allows more optimizations. Reviewed by: jeff Differential Revision: https://reviews.freebsd.org/D23570
Notes
Notes: svn path=/head/; revision=357804
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 0a6764b80e9d..954fba8507e2 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -194,6 +194,7 @@ struct pcpu {
struct rm_queue pc_rm_queue; /* rmlock list of trackers */
uintptr_t pc_dynamic; /* Dynamic per-cpu data area */
uint64_t pc_early_dummy_counter; /* Startup time counter(9) */
+ uintptr_t pc_zpcpu_offset; /* Offset into zpcpu allocs */
/*
* Keep MD fields last, so that CPU-specific variations on a
@@ -227,14 +228,28 @@ extern struct pcpu *cpuid_to_pcpu[];
#endif
#define curproc (curthread->td_proc)
+#ifndef zpcpu_offset_cpu
+#define zpcpu_offset_cpu(cpu) (UMA_PCPU_ALLOC_SIZE * cpu)
+#endif
+#ifndef zpcpu_offset
+#define zpcpu_offset() (PCPU_GET(zpcpu_offset))
+#endif
+
+#ifndef zpcpu_base_to_offset
+#define zpcpu_base_to_offset(base) (base)
+#endif
+#ifndef zpcpu_offset_to_base
+#define zpcpu_offset_to_base(base) (base)
+#endif
+
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
#define zpcpu_get(base) ({ \
- __typeof(base) _ptr = (void *)((char *)(base) + UMA_PCPU_ALLOC_SIZE * curcpu); \
+ __typeof(base) _ptr = (void *)((char *)(base) + zpcpu_offset()); \
_ptr; \
})
#define zpcpu_get_cpu(base, cpu) ({ \
- __typeof(base) _ptr = (void *)((char *)(base) + UMA_PCPU_ALLOC_SIZE * cpu); \
+ __typeof(base) _ptr = (void *)((char *)(base) + zpcpu_offset_cpu(cpu)); \
_ptr; \
})