Lines Matching +full:per +full:- +full:cpu
1 .\"-
31 .Nd Kernel Dynamic Per-CPU Memory Allocator
34 .Ss Per-CPU Variable Definition and Declaration
38 .Ss Current CPU Accessor Functions
42 .Ss Named CPU Accessor Functions
43 .Fn DPCPU_ID_PTR "cpu" "name"
44 .Fn DPCPU_ID_GET "cpu" "name"
45 .Fn DPCPU_ID_SET "cpu" "name" "value"
48 instantiates one instance of a global variable with each CPU in the system.
49 Dynamically allocated per-CPU variables are defined using
56 If no initialization is provided, then each per-CPU instance of the variable
57 will be zero-filled (i.e., as though allocated in BSS):
58 .Bd -literal -offset 1234
63 per-CPU instance to be initialized with the value:
64 .Bd -literal -offset 1234
72 .Bd -literal -offset 1234
77 produces a declaration of the per-CPU variable suitable for use in header
80 The current CPU's variable instance can be accessed via
82 (which returns a pointer to the per-CPU instance),
84 (which retrieves the value of the per-CPU instance),
87 (which sets the value of the per-CPU instance).
94 accessor functions, which accept an additional CPU ID argument,
95 .Ar cpu .
104 This requires additional care when reasoning about and protecting per-CPU
110 Alternatively, it may be desirable to cache the CPU ID at the start of a
111 sequence of accesses, using suitable synchronization to make non-atomic
113 .Bd -literal -offset 1234
120 int cpu, value;
129 * only from the current CPU.
138 * Protect with a per-CPU mutex, tolerating migration, but
141 * per-CPU variable is safe as long as the correct mutex is
144 cpu = curcpu;
145 mtx_lock(DPCPU_ID_PTR(cpu, foo_lock));
146 value = DPCPU_ID_GET(cpu, foo_int);
148 DPCPU_ID_SET(cpu, foo_int);
149 mtx_unlock(DPCPU_ID_PTR(cpu, foo_lock));