Lines Matching refs:v
124 static void test_kptr_unref(struct map_value *v) in test_kptr_unref() argument
128 p = v->unref_ptr; in test_kptr_unref()
130 WRITE_ONCE(v->unref_ptr, p); in test_kptr_unref()
136 WRITE_ONCE(v->unref_ptr, p); in test_kptr_unref()
138 WRITE_ONCE(v->unref_ptr, NULL); in test_kptr_unref()
141 static void test_kptr_ref(struct map_value *v) in test_kptr_ref() argument
145 p = v->ref_ptr; in test_kptr_ref()
147 WRITE_ONCE(v->unref_ptr, p); in test_kptr_ref()
159 p = bpf_kptr_xchg(&v->ref_ptr, NULL); in test_kptr_ref()
172 WRITE_ONCE(v->unref_ptr, p); in test_kptr_ref()
179 p = bpf_kptr_xchg(&v->ref_ptr, p); in test_kptr_ref()
189 static void test_kptr(struct map_value *v) in test_kptr() argument
191 test_kptr_unref(v); in test_kptr()
192 test_kptr_ref(v); in test_kptr()
198 struct map_value *v; in test_map_kptr() local
202 v = bpf_map_lookup_elem(&map, &key); \ in test_map_kptr()
203 if (!v) \ in test_map_kptr()
205 test_kptr(v) in test_map_kptr()
221 struct map_value *v; in BPF_PROG() local
223 v = bpf_cgrp_storage_get(&cgrp_ls_map, cgrp, NULL, BPF_LOCAL_STORAGE_GET_F_CREATE); in BPF_PROG()
224 if (v) in BPF_PROG()
225 test_kptr(v); in BPF_PROG()
233 struct map_value *v; in BPF_PROG() local
238 v = bpf_task_storage_get(&task_ls_map, task, NULL, BPF_LOCAL_STORAGE_GET_F_CREATE); in BPF_PROG()
239 if (v) in BPF_PROG()
240 test_kptr(v); in BPF_PROG()
247 struct map_value *v; in BPF_PROG() local
249 v = bpf_inode_storage_get(&inode_ls_map, inode, NULL, BPF_LOCAL_STORAGE_GET_F_CREATE); in BPF_PROG()
250 if (v) in BPF_PROG()
251 test_kptr(v); in BPF_PROG()
258 struct map_value *v; in test_sk_map_kptr() local
264 v = bpf_sk_storage_get(&sk_ls_map, sk, NULL, BPF_LOCAL_STORAGE_GET_F_CREATE); in test_sk_map_kptr()
265 if (v) in test_sk_map_kptr()
266 test_kptr(v); in test_sk_map_kptr()
273 struct map_value *v; in test_map_in_map_kptr() local
281 v = bpf_map_lookup_elem(map, &key); \ in test_map_in_map_kptr()
282 if (!v) \ in test_map_in_map_kptr()
284 test_kptr(v) in test_map_in_map_kptr()
306 int test_map_kptr_ref_pre(struct map_value *v) in test_map_kptr_ref_pre() argument
323 p = bpf_kptr_xchg(&v->ref_ptr, p); in test_map_kptr_ref_pre()
331 p = bpf_kptr_xchg(&v->ref_ptr, NULL); in test_map_kptr_ref_pre()
343 p = bpf_kptr_xchg(&v->ref_ptr, p); in test_map_kptr_ref_pre()
360 int test_map_kptr_ref_post(struct map_value *v) in test_map_kptr_ref_post() argument
364 p_st = v->ref_ptr; in test_map_kptr_ref_post()
368 p = bpf_kptr_xchg(&v->ref_ptr, NULL); in test_map_kptr_ref_post()
376 p = bpf_kptr_xchg(&v->ref_ptr, p); in test_map_kptr_ref_post()
388 v = bpf_map_lookup_elem(&map, &key); \
389 if (!v) \
391 ret = test_map_kptr_ref_pre(v); \
396 v = bpf_map_lookup_percpu_elem(&map, &key, 0); \
397 if (!v) \
399 ret = test_map_kptr_ref_pre(v); \
406 struct map_value *v, val = {}; in test_map_kptr_ref1() local
434 v = bpf_map_lookup_elem(&map, &key); \
435 if (!v) \
437 ret = test_map_kptr_ref_post(v); \
442 v = bpf_map_lookup_percpu_elem(&map, &key, 0); \
443 if (!v) \
445 ret = test_map_kptr_ref_post(v); \
452 struct map_value *v; in test_map_kptr_ref2() local
494 struct map_value *v; in test_ls_map_kptr_ref1() local
499 v = bpf_task_storage_get(&task_ls_map, current, NULL, 0); in test_ls_map_kptr_ref1()
500 if (v) in test_ls_map_kptr_ref1()
502 v = bpf_task_storage_get(&task_ls_map, current, NULL, BPF_LOCAL_STORAGE_GET_F_CREATE); in test_ls_map_kptr_ref1()
503 if (!v) in test_ls_map_kptr_ref1()
505 return test_map_kptr_ref_pre(v); in test_ls_map_kptr_ref1()
512 struct map_value *v; in test_ls_map_kptr_ref2() local
517 v = bpf_task_storage_get(&task_ls_map, current, NULL, 0); in test_ls_map_kptr_ref2()
518 if (!v) in test_ls_map_kptr_ref2()
520 return test_map_kptr_ref_post(v); in test_ls_map_kptr_ref2()
527 struct map_value *v; in test_ls_map_kptr_ref_del() local
532 v = bpf_task_storage_get(&task_ls_map, current, NULL, 0); in test_ls_map_kptr_ref_del()
533 if (!v) in test_ls_map_kptr_ref_del()
535 if (!v->ref_ptr) in test_ls_map_kptr_ref_del()