Lines Matching +full:lock +full:- +full:less
1 // SPDX-License-Identifier: GPL-2.0
41 private(A) struct bpf_spin_lock lock; variable
51 static bool less(struct bpf_rb_node *node_a, const struct bpf_rb_node *node_b) in less() function
59 return a->key < b->key; in less()
70 return node_a->key < node_b->key; in less_a()
75 struct bpf_spin_lock *lock) in __insert_in_tree_and_list() argument
81 return -1; in __insert_in_tree_and_list()
84 m->key = 123; in __insert_in_tree_and_list()
85 m->list_data = 456; in __insert_in_tree_and_list()
87 bpf_spin_lock(lock); in __insert_in_tree_and_list()
88 if (bpf_rbtree_add(root, &n->r, less)) { in __insert_in_tree_and_list()
89 /* Failure to insert - unexpected */ in __insert_in_tree_and_list()
90 bpf_spin_unlock(lock); in __insert_in_tree_and_list()
92 return -2; in __insert_in_tree_and_list()
94 bpf_spin_unlock(lock); in __insert_in_tree_and_list()
96 bpf_spin_lock(lock); in __insert_in_tree_and_list()
97 if (bpf_list_push_front(head, &m->l)) { in __insert_in_tree_and_list()
98 /* Failure to insert - unexpected */ in __insert_in_tree_and_list()
99 bpf_spin_unlock(lock); in __insert_in_tree_and_list()
100 return -3; in __insert_in_tree_and_list()
102 bpf_spin_unlock(lock); in __insert_in_tree_and_list()
107 struct bpf_spin_lock *lock) in __stash_map_insert_tree() argument
114 return -1; in __stash_map_insert_tree()
118 return -2; in __stash_map_insert_tree()
120 n->key = val; in __stash_map_insert_tree()
123 n = bpf_kptr_xchg(&mapval->node, n); in __stash_map_insert_tree()
127 return -3; in __stash_map_insert_tree()
130 bpf_spin_lock(lock); in __stash_map_insert_tree()
131 if (bpf_rbtree_add(root, &m->r, less)) { in __stash_map_insert_tree()
132 /* Failure to insert - unexpected */ in __stash_map_insert_tree()
133 bpf_spin_unlock(lock); in __stash_map_insert_tree()
134 return -4; in __stash_map_insert_tree()
136 bpf_spin_unlock(lock); in __stash_map_insert_tree()
141 struct bpf_spin_lock *lock, in __read_from_tree() argument
146 long res = -99; in __read_from_tree()
148 bpf_spin_lock(lock); in __read_from_tree()
152 bpf_spin_unlock(lock); in __read_from_tree()
153 return -1; in __read_from_tree()
157 res = n->key; in __read_from_tree()
160 bpf_spin_unlock(lock); in __read_from_tree()
165 bpf_spin_unlock(lock); in __read_from_tree()
167 return -2; in __read_from_tree()
174 struct bpf_spin_lock *lock, in __read_from_list() argument
179 long res = -99; in __read_from_list()
181 bpf_spin_lock(lock); in __read_from_list()
185 bpf_spin_unlock(lock); in __read_from_list()
186 return -1; in __read_from_list()
190 res = n->list_data; in __read_from_list()
193 if (bpf_list_push_back(head, &n->l)) { in __read_from_list()
194 bpf_spin_unlock(lock); in __read_from_list()
195 return -2; in __read_from_list()
199 bpf_spin_unlock(lock); in __read_from_list()
210 long val = -99; in __read_from_unstash()
214 return -1; in __read_from_unstash()
216 n = bpf_kptr_xchg(&mapval->node, n); in __read_from_unstash()
218 return -2; in __read_from_unstash()
220 val = n->key; in __read_from_unstash()
233 err = __insert_in_tree_and_list(&head, &root, &lock); \
237 err = __read_from_tree(&root, &lock, rem_tree); \
243 err = __read_from_list(&head, &lock, rem_list); \
253 * - it should have refcount = 2
254 * - removing / not removing the node_data from a collection after
272 err = __insert_in_tree_and_list(&head, &root, &lock); \
276 err = __read_from_list(&head, &lock, rem_list); \
282 err = __read_from_tree(&root, &lock, rem_tree); \
305 __success __retval(-1) \
310 err = __insert_in_tree_and_list(&head, &root, &lock); \
314 err = read_fn(&read_root, &lock, true); \
320 err = read_fn(&read_root, &lock, true); \
327 /* Insert into both tree and list, then try reading-and-removing from either twice
329 * The second read-and-remove should fail on read step since the node has
332 INSERT_DOUBLE_READ_AND_DEL(__read_from_tree, root, "insert_double_del: 2x read-and-del from tree");
333 INSERT_DOUBLE_READ_AND_DEL(__read_from_list, head, "insert_double_del: 2x read-and-del from list");
343 err = __stash_map_insert_tree(0, 42, &root, &lock); \
347 err = __read_from_tree(&root, &lock, rem_tree); \
381 bpf_rbtree_add(&aroot, &n->node, less_a); in rbtree_refcounted_node_ref_escapes()
387 m->key = 2; in rbtree_refcounted_node_ref_escapes()
403 m->key = 2; in rbtree_refcounted_node_ref_escapes_owning_input()
406 bpf_rbtree_add(&aroot, &n->node, less_a); in rbtree_refcounted_node_ref_escapes_owning_input()
422 n = bpf_kptr_xchg(&mapval->node, n); in __stash_map_empty_xchg()
462 n = bpf_kptr_xchg(&mapval->node, NULL); in rbtree_wrong_owner_remove_fail_b()
468 bpf_rbtree_add(&broot, &n->r, less); in rbtree_wrong_owner_remove_fail_b()
486 m = bpf_kptr_xchg(&mapval->node, NULL); in rbtree_wrong_owner_remove_fail_a2()
489 bpf_spin_lock(&lock); in rbtree_wrong_owner_remove_fail_a2()
491 /* make m non-owning ref */ in rbtree_wrong_owner_remove_fail_a2()
492 bpf_list_push_back(&head, &m->l); in rbtree_wrong_owner_remove_fail_a2()
493 res = bpf_rbtree_remove(&root, &m->r); in rbtree_wrong_owner_remove_fail_a2()
495 bpf_spin_unlock(&lock); in rbtree_wrong_owner_remove_fail_a2()
517 bpf_spin_lock(&lock); in BPF_PROG()
518 bpf_rbtree_add(&root, &n->r, less); in BPF_PROG()
530 bpf_spin_unlock(&lock); in BPF_PROG()
551 bpf_spin_lock(&lock); in BPF_PROG()
552 bpf_rbtree_add(&root, &n->r, less); in BPF_PROG()
564 bpf_spin_unlock(&lock); in BPF_PROG()