Lines Matching full:ma

513 int bpf_mem_alloc_init(struct bpf_mem_alloc *ma, int size, bool percpu)  in bpf_mem_alloc_init()  argument
526 ma->percpu = percpu; in bpf_mem_alloc_init()
541 ma->objcg = objcg; in bpf_mem_alloc_init()
552 ma->cache = pc; in bpf_mem_alloc_init()
562 ma->objcg = objcg; in bpf_mem_alloc_init()
577 ma->caches = pcc; in bpf_mem_alloc_init()
581 int bpf_mem_alloc_percpu_init(struct bpf_mem_alloc *ma, struct obj_cgroup *objcg) in bpf_mem_alloc_percpu_init() argument
589 ma->caches = pcc; in bpf_mem_alloc_percpu_init()
590 ma->objcg = objcg; in bpf_mem_alloc_percpu_init()
591 ma->percpu = true; in bpf_mem_alloc_percpu_init()
595 int bpf_mem_alloc_percpu_unit_init(struct bpf_mem_alloc *ma, int size) in bpf_mem_alloc_percpu_unit_init() argument
610 objcg = ma->objcg; in bpf_mem_alloc_percpu_unit_init()
611 pcc = ma->caches; in bpf_mem_alloc_percpu_unit_init()
662 static void check_leaked_objs(struct bpf_mem_alloc *ma) in check_leaked_objs() argument
668 if (ma->cache) { in check_leaked_objs()
670 c = per_cpu_ptr(ma->cache, cpu); in check_leaked_objs()
674 if (ma->caches) { in check_leaked_objs()
676 cc = per_cpu_ptr(ma->caches, cpu); in check_leaked_objs()
685 static void free_mem_alloc_no_barrier(struct bpf_mem_alloc *ma) in free_mem_alloc_no_barrier() argument
687 check_leaked_objs(ma); in free_mem_alloc_no_barrier()
688 free_percpu(ma->cache); in free_mem_alloc_no_barrier()
689 free_percpu(ma->caches); in free_mem_alloc_no_barrier()
690 ma->cache = NULL; in free_mem_alloc_no_barrier()
691 ma->caches = NULL; in free_mem_alloc_no_barrier()
694 static void free_mem_alloc(struct bpf_mem_alloc *ma) in free_mem_alloc() argument
710 free_mem_alloc_no_barrier(ma); in free_mem_alloc()
715 struct bpf_mem_alloc *ma = container_of(work, struct bpf_mem_alloc, work); in free_mem_alloc_deferred() local
717 free_mem_alloc(ma); in free_mem_alloc_deferred()
718 kfree(ma); in free_mem_alloc_deferred()
721 static void destroy_mem_alloc(struct bpf_mem_alloc *ma, int rcu_in_progress) in destroy_mem_alloc() argument
729 free_mem_alloc_no_barrier(ma); in destroy_mem_alloc()
733 copy = kmemdup(ma, sizeof(*ma), GFP_KERNEL); in destroy_mem_alloc()
736 free_mem_alloc(ma); in destroy_mem_alloc()
741 memset(ma, 0, sizeof(*ma)); in destroy_mem_alloc()
746 void bpf_mem_alloc_destroy(struct bpf_mem_alloc *ma) in bpf_mem_alloc_destroy() argument
752 if (ma->cache) { in bpf_mem_alloc_destroy()
755 c = per_cpu_ptr(ma->cache, cpu); in bpf_mem_alloc_destroy()
762 if (ma->objcg) in bpf_mem_alloc_destroy()
763 obj_cgroup_put(ma->objcg); in bpf_mem_alloc_destroy()
764 destroy_mem_alloc(ma, rcu_in_progress); in bpf_mem_alloc_destroy()
766 if (ma->caches) { in bpf_mem_alloc_destroy()
769 cc = per_cpu_ptr(ma->caches, cpu); in bpf_mem_alloc_destroy()
779 if (ma->objcg) in bpf_mem_alloc_destroy()
780 obj_cgroup_put(ma->objcg); in bpf_mem_alloc_destroy()
781 destroy_mem_alloc(ma, rcu_in_progress); in bpf_mem_alloc_destroy()
895 void notrace *bpf_mem_alloc(struct bpf_mem_alloc *ma, size_t size) in bpf_mem_alloc() argument
903 if (!ma->percpu) in bpf_mem_alloc()
909 ret = unit_alloc(this_cpu_ptr(ma->caches)->cache + idx); in bpf_mem_alloc()
913 void notrace bpf_mem_free(struct bpf_mem_alloc *ma, void *ptr) in bpf_mem_free() argument
926 unit_free(this_cpu_ptr(ma->caches)->cache + idx, ptr); in bpf_mem_free()
929 void notrace bpf_mem_free_rcu(struct bpf_mem_alloc *ma, void *ptr) in bpf_mem_free_rcu() argument
942 unit_free_rcu(this_cpu_ptr(ma->caches)->cache + idx, ptr); in bpf_mem_free_rcu()
945 void notrace *bpf_mem_cache_alloc(struct bpf_mem_alloc *ma) in bpf_mem_cache_alloc() argument
949 ret = unit_alloc(this_cpu_ptr(ma->cache)); in bpf_mem_cache_alloc()
953 void notrace bpf_mem_cache_free(struct bpf_mem_alloc *ma, void *ptr) in bpf_mem_cache_free() argument
958 unit_free(this_cpu_ptr(ma->cache), ptr); in bpf_mem_cache_free()
961 void notrace bpf_mem_cache_free_rcu(struct bpf_mem_alloc *ma, void *ptr) in bpf_mem_cache_free_rcu() argument
966 unit_free_rcu(this_cpu_ptr(ma->cache), ptr); in bpf_mem_cache_free_rcu()
991 void notrace *bpf_mem_cache_alloc_flags(struct bpf_mem_alloc *ma, gfp_t flags) in bpf_mem_cache_alloc_flags() argument
996 c = this_cpu_ptr(ma->cache); in bpf_mem_cache_alloc_flags()