Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/pcpu.h
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | struct pcpu { | ||||
long pc_cp_time[CPUSTATES]; /* statclock ticks */ | long pc_cp_time[CPUSTATES]; /* statclock ticks */ | ||||
struct device *pc_device; | struct device *pc_device; | ||||
void *pc_netisr; /* netisr SWI cookie */ | void *pc_netisr; /* netisr SWI cookie */ | ||||
int pc_unused1; /* unused field */ | int pc_unused1; /* unused field */ | ||||
int pc_domain; /* Memory domain. */ | int pc_domain; /* Memory domain. */ | ||||
struct rm_queue pc_rm_queue; /* rmlock list of trackers */ | struct rm_queue pc_rm_queue; /* rmlock list of trackers */ | ||||
uintptr_t pc_dynamic; /* Dynamic per-cpu data area */ | uintptr_t pc_dynamic; /* Dynamic per-cpu data area */ | ||||
uint64_t pc_early_dummy_counter; /* Startup time counter(9) */ | 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 | * Keep MD fields last, so that CPU-specific variations on a | ||||
* single architecture don't result in offset variations of | * single architecture don't result in offset variations of | ||||
* the machine-independent fields of the pcpu. Even though | * the machine-independent fields of the pcpu. Even though | ||||
* the pcpu structure is private to the kernel, some ports | * the pcpu structure is private to the kernel, some ports | ||||
* (e.g., lsof, part of gtop) define _KERNEL and include this | * (e.g., lsof, part of gtop) define _KERNEL and include this | ||||
* header. While strictly speaking this is wrong, there's no | * header. While strictly speaking this is wrong, there's no | ||||
Show All 17 Lines | |||||
#include <machine/pcpu_aux.h> | #include <machine/pcpu_aux.h> | ||||
#ifndef curthread | #ifndef curthread | ||||
#define curthread PCPU_GET(curthread) | #define curthread PCPU_GET(curthread) | ||||
#endif | #endif | ||||
#define curproc (curthread->td_proc) | #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_real_to_pcpu | |||||
#define zpcpu_real_to_pcpu(base) base | |||||
#endif | |||||
#ifndef zpcpu_pcpu_to_real | |||||
#define zpcpu_pcpu_to_real(base) base | |||||
#endif | |||||
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ | /* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ | ||||
#define zpcpu_get(base) ({ \ | #define zpcpu_get(base) ({ \ | ||||
__typeof(base) _ptr = (void *)((char *)(base) + UMA_PCPU_ALLOC_SIZE * curcpu); \ | __typeof(base) _ptr = (void *)((char *)(base) + zpcpu_offset()); \ | ||||
_ptr; \ | _ptr; \ | ||||
}) | }) | ||||
#define zpcpu_get_cpu(base, cpu) ({ \ | #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; \ | _ptr; \ | ||||
}) | }) | ||||
/* | /* | ||||
* This operation is NOT atomic and does not post any barriers. | * This operation is NOT atomic and does not post any barriers. | ||||
* If you use this the assumption is that the target CPU will not | * If you use this the assumption is that the target CPU will not | ||||
* be modifying this variable. | * be modifying this variable. | ||||
* If you need atomicity use xchg. | * If you need atomicity use xchg. | ||||
Show All 33 Lines |