diff options
| author | Mateusz Guzik <mjg@FreeBSD.org> | 2020-02-12 11:11:22 +0000 |
|---|---|---|
| committer | Mateusz Guzik <mjg@FreeBSD.org> | 2020-02-12 11:11:22 +0000 |
| commit | 3acb6572fc0ef19119240a319873fa75fd597f28 (patch) | |
| tree | 8572faa05e645cfab125ddade3bad5d601fc6374 /sys | |
| parent | 48baf00f547e84a666cb38d3ccba4fe35fa468c1 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/kern/subr_pcpu.c | 1 | ||||
| -rw-r--r-- | sys/riscv/include/pcpu.h | 2 | ||||
| -rw-r--r-- | sys/sys/pcpu.h | 19 | ||||
| -rw-r--r-- | sys/vm/uma_core.c | 15 |
4 files changed, 29 insertions, 8 deletions
diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c index 666428b9b08c..101440e3b1ec 100644 --- a/sys/kern/subr_pcpu.c +++ b/sys/kern/subr_pcpu.c @@ -95,6 +95,7 @@ pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) cpu_pcpu_init(pcpu, cpuid, size); pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue; pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue; + pcpu->pc_zpcpu_offset = zpcpu_offset_cpu(cpuid); } void diff --git a/sys/riscv/include/pcpu.h b/sys/riscv/include/pcpu.h index 28c5a7422d1c..46b258380a10 100644 --- a/sys/riscv/include/pcpu.h +++ b/sys/riscv/include/pcpu.h @@ -48,7 +48,7 @@ struct pmap *pc_curpmap; /* Currently active pmap */ \ uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \ uint32_t pc_hart; /* Hart ID */ \ - char __pad[57] + char __pad[49] #ifdef _KERNEL 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; \ }) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index f4632036ca4e..8618a620ef74 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -2944,34 +2944,39 @@ uma_zwait(uma_zone_t zone) void * uma_zalloc_pcpu_arg(uma_zone_t zone, void *udata, int flags) { - void *item; + void *item, *pcpu_item; #ifdef SMP int i; MPASS(zone->uz_flags & UMA_ZONE_PCPU); #endif item = uma_zalloc_arg(zone, udata, flags & ~M_ZERO); - if (item != NULL && (flags & M_ZERO)) { + if (item == NULL) + return (NULL); + pcpu_item = zpcpu_base_to_offset(item); + if (flags & M_ZERO) { #ifdef SMP for (i = 0; i <= mp_maxid; i++) - bzero(zpcpu_get_cpu(item, i), zone->uz_size); + bzero(zpcpu_get_cpu(pcpu_item, i), zone->uz_size); #else bzero(item, zone->uz_size); #endif } - return (item); + return (pcpu_item); } /* * A stub while both regular and pcpu cases are identical. */ void -uma_zfree_pcpu_arg(uma_zone_t zone, void *item, void *udata) +uma_zfree_pcpu_arg(uma_zone_t zone, void *pcpu_item, void *udata) { + void *item; #ifdef SMP MPASS(zone->uz_flags & UMA_ZONE_PCPU); #endif + item = zpcpu_offset_to_base(pcpu_item); uma_zfree_arg(zone, item, udata); } |
