Lines Matching refs:stk

159 static int __idr_get_empty_slot(struct idr *idp, struct idr_layer **stk)  in __idr_get_empty_slot()  argument
169 stk[layer + 1] = NULL; // 标志为数组末尾 in __idr_get_empty_slot()
174 stk[layer] = cur_layer; in __idr_get_empty_slot()
196 stk[layer]->ary[pos] = cur_layer; // 最后别忘了记录儿子节点 in __idr_get_empty_slot()
213 static __always_inline void __idr_mark_full(struct idr *idp, int id, struct idr_layer **stk, int ma… in __idr_mark_full() argument
216 if (unlikely(NULL == stk[0] || NULL == idp->top)) in __idr_mark_full()
225 stk[0]->full |= (1ull << layer_id); in __idr_mark_full()
227 stk[0]->bitmap |= (1ull << layer_id); in __idr_mark_full()
229 for (int i = 1; stk[i]; ++i) in __idr_mark_full()
234 stk[i]->bitmap |= (1ull << layer_id); in __idr_mark_full()
235 if (stk[i - 1]->full == IDR_FULL) in __idr_mark_full()
236 stk[i]->full |= (1ull << layer_id); in __idr_mark_full()
248 static __always_inline int __idr_get_path(struct idr *idp, int id, struct idr_layer **stk) in __idr_get_path() argument
259 stk[layer + 1] = NULL; // 标志数组结尾 in __idr_get_path()
270 stk[layer] = cur_layer; in __idr_get_path()
294 static __always_inline void __idr_erase_full(struct idr *idp, int id, struct idr_layer **stk, int m… in __idr_erase_full() argument
297 if (unlikely(NULL == stk[0] || NULL == idp->top)) in __idr_erase_full()
307 stk[0]->ary[layer_id] = NULL; in __idr_erase_full()
308 stk[0]->bitmap ^= (1ull << layer_id); in __idr_erase_full()
310 if (mark != 2 && ((stk[0]->full >> layer_id) & 1)) in __idr_erase_full()
311 stk[0]->full ^= (1ull << layer_id); in __idr_erase_full()
314 for (int layer = 1; stk[layer]; ++layer) in __idr_erase_full()
319 if (NULL == stk[layer - 1]->bitmap) // 儿子是空节点 in __idr_erase_full()
321 stk[layer]->ary[layer_id] = NULL; in __idr_erase_full()
322 stk[layer]->bitmap ^= (1ull << layer_id); in __idr_erase_full()
324 if ((stk[layer]->full >> layer_id) & 1) in __idr_erase_full()
325 stk[layer]->full ^= (1ull << layer_id); in __idr_erase_full()
327 __idr_layer_free(stk[layer - 1]); in __idr_erase_full()
328 stk[layer - 1] = NULL; // 释放空间记得设置为 NULL in __idr_erase_full()
330 else if (stk[layer - 1]->full != IDR_FULL) in __idr_erase_full()
332 if ((stk[layer]->full >> layer_id) & 1) in __idr_erase_full()
333 stk[layer]->full ^= (1ull << layer_id); in __idr_erase_full()
359 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; in __idr_get_new_above_int() local
364 int64_t id = __idr_get_empty_slot(idp, stk); in __idr_get_new_above_int()
368 stk[0]->ary[IDR_MASK & id] = ptr; in __idr_get_new_above_int()
369 __idr_mark_full(idp, id, stk, 2); in __idr_get_new_above_int()
406 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; in idr_remove() local
408 if (0 == __idr_get_path(idp, __id, stk)) in idr_remove()
411 void *ret = stk[0]->ary[__id & IDR_MASK]; in idr_remove()
412 __idr_erase_full(idp, __id, stk, 0); in idr_remove()
432 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; in __idr_remove_all_with_free() local
437 stk[layer + 1] = NULL; // 标记数组结尾 in __idr_remove_all_with_free()
443 stk[layer] = cur_layer; // 入栈 in __idr_remove_all_with_free()
448 stk[layer]->ary[id] = NULL; in __idr_remove_all_with_free()
465 cur_layer = stk[layer]; // 出栈 in __idr_remove_all_with_free()
571 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; in idr_find_next_getid() local
585 stk[layer + 1] = NULL; // 标记数组结尾 in idr_find_next_getid()
599 stk[layer] = cur_layer; in idr_find_next_getid()
637 cur_layer = stk[layer]; in idr_find_next_getid()
924 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; // 你可以选择memset(0) in ida_alloc() local
929 int64_t idr_id = __idr_get_empty_slot(&ida_p->idr, stk); in ida_alloc()
932 if (unlikely(NULL == stk[0])) in ida_alloc()
940 if (NULL == stk[0]->ary[layer_id]) in ida_alloc()
941 stk[0]->ary[layer_id] = __get_ida_bitmap(ida_p, 0); in ida_alloc()
943 if (unlikely(NULL == stk[0]->ary[layer_id])) in ida_alloc()
946 struct ida_bitmap *bmp = (struct ida_bitmap *)stk[0]->ary[layer_id]; in ida_alloc()
953 __idr_mark_full(&ida_p->idr, idr_id, stk, (bmp->count == IDA_FULL ? 2 : 1)); in ida_alloc()
999 struct idr_layer *stk[MAX_LEVEL + 1] = {0}; in ida_remove() local
1002 if (0 == __idr_get_path(&ida_p->idr, idr_id, stk)) in ida_remove()
1005 struct ida_bitmap *b_p = (struct ida_bitmap *)(stk[0]->ary[idr_id & IDR_MASK]); in ida_remove()
1014 __idr_erase_full(&ida_p->idr, idr_id, stk, (b_p->count > 0 ? 1 : 0)); in ida_remove()
1018 if (stk[0]) // stk[0] 有可能在 __idr_erase_full 里面已经kfree了 in ida_remove()
1019 stk[0]->ary[idr_id & IDR_MASK] = NULL; // 记得设置为空 in ida_remove()