Lines Matching defs:lc
64 * localcount_init(lc)
70 * when done with lc.
73 localcount_init(struct localcount *lc)
76 lc->lc_totalp = NULL;
77 lc->lc_percpu = percpu_alloc(sizeof(int64_t));
81 * localcount_drain(lc, cv, interlock)
83 * Wait for all acquired references to lc to drain. Caller must
86 * same as are passed to localcount_release for this lc.
93 * The localcount object lc may be used only with localcount_fini
98 localcount_drain(struct localcount *lc, kcondvar_t *cv, kmutex_t *interlock)
103 KASSERT(lc->lc_totalp == NULL);
106 lc->lc_totalp = &total;
112 * CPUs will have witnessed the nonnull value of lc->lc_totalp,
116 xc_wait(xc_broadcast(0, &localcount_xc, lc, interlock));
128 lc, total);
132 /* Paranoia: Cause any further use of lc->lc_totalp to crash. */
133 lc->lc_totalp = (void *)(uintptr_t)1;
137 * localcount_fini(lc)
143 localcount_fini(struct localcount *lc)
146 KASSERT(lc->lc_totalp == (void *)(uintptr_t)1);
147 percpu_free(lc->lc_percpu, sizeof(uint64_t));
161 struct localcount *lc = cookie0;
167 localp = percpu_getref(lc->lc_percpu);
169 *lc->lc_totalp += *localp;
172 percpu_putref(lc->lc_percpu);
177 * localcount_adjust(lc, delta)
180 * for lc.
183 localcount_adjust(struct localcount *lc, int delta)
188 localp = percpu_getref(lc->lc_percpu);
192 percpu_putref(lc->lc_percpu);
196 * localcount_acquire(lc)
198 * Acquire a reference to lc.
216 localcount_acquire(struct localcount *lc)
219 KASSERT(lc->lc_totalp == NULL);
220 localcount_adjust(lc, +1);
222 if (atomic_inc_32_nv(&lc->lc_refcnt) == 0)
228 * localcount_release(lc, cv, interlock)
230 * Release a reference to lc. If there is a concurrent
234 * the same as are passed to localcount_drain for this lc.
240 localcount_release(struct localcount *lc, kcondvar_t *cv, kmutex_t *interlock)
245 * lc->lc_totalp as null, then they won't start cv_wait until
250 * lc->lc_totalp as null, this CPU will not wake
256 if (__predict_false(lc->lc_totalp != NULL)) {
262 if (--*lc->lc_totalp == 0)
268 localcount_adjust(lc, -1);
270 if (atomic_dec_32_nv(&lc->lc_refcnt) == UINT_MAX)
277 * localcount_debug_refcnt(lc)
279 * Return a total reference count of lc. It returns a correct value
283 localcount_debug_refcnt(const struct localcount *lc)
287 return lc->lc_refcnt;