Lines Matching defs:map
22 struct bpf_map map;
29 static struct bpf_cgroup_storage_map *map_to_storage(struct bpf_map *map)
31 return container_of(map, struct bpf_cgroup_storage_map, map);
34 static bool attach_type_isolated(const struct bpf_map *map)
36 return map->key_size == sizeof(struct bpf_cgroup_storage_key);
39 static int bpf_cgroup_storage_key_cmp(const struct bpf_cgroup_storage_map *map,
42 if (attach_type_isolated(&map->map)) {
67 cgroup_storage_lookup(struct bpf_cgroup_storage_map *map,
70 struct rb_root *root = &map->root;
74 spin_lock_bh(&map->lock);
82 switch (bpf_cgroup_storage_key_cmp(map, key, &storage->key)) {
91 spin_unlock_bh(&map->lock);
97 spin_unlock_bh(&map->lock);
102 static int cgroup_storage_insert(struct bpf_cgroup_storage_map *map,
105 struct rb_root *root = &map->root;
114 switch (bpf_cgroup_storage_key_cmp(map, &storage->key, &this->key)) {
134 struct bpf_cgroup_storage_map *map = map_to_storage(_map);
137 storage = cgroup_storage_lookup(map, key, false);
144 static long cgroup_storage_update_elem(struct bpf_map *map, void *key,
154 !btf_record_has_field(map->record, BPF_SPIN_LOCK)))
157 storage = cgroup_storage_lookup((struct bpf_cgroup_storage_map *)map,
163 copy_map_value_locked(map, storage->buf->data, value, false);
167 new = bpf_map_kmalloc_node(map, struct_size(new, data, map->value_size),
169 map->numa_node);
173 memcpy(&new->data[0], value, map->value_size);
174 check_and_init_map_value(map, new->data);
185 struct bpf_cgroup_storage_map *map = map_to_storage(_map);
191 storage = cgroup_storage_lookup(map, key, false);
214 struct bpf_cgroup_storage_map *map = map_to_storage(_map);
223 storage = cgroup_storage_lookup(map, key, false);
248 struct bpf_cgroup_storage_map *map = map_to_storage(_map);
251 spin_lock_bh(&map->lock);
253 if (list_empty(&map->list))
257 storage = cgroup_storage_lookup(map, key, true);
265 storage = list_first_entry(&map->list,
269 spin_unlock_bh(&map->lock);
271 if (attach_type_isolated(&map->map)) {
281 spin_unlock_bh(&map->lock);
289 struct bpf_cgroup_storage_map *map;
316 map = bpf_map_area_alloc(sizeof(struct bpf_cgroup_storage_map), numa_node);
317 if (!map)
320 /* copy mandatory map attributes */
321 bpf_map_init_from_attr(&map->map, attr);
323 spin_lock_init(&map->lock);
324 map->root = RB_ROOT;
325 INIT_LIST_HEAD(&map->list);
327 return &map->map;
332 struct bpf_cgroup_storage_map *map = map_to_storage(_map);
333 struct list_head *storages = &map->list;
345 WARN_ON(!RB_EMPTY_ROOT(&map->root));
346 WARN_ON(!list_empty(&map->list));
348 bpf_map_area_free(map);
351 static long cgroup_storage_delete_elem(struct bpf_map *map, void *key)
356 static int cgroup_storage_check_btf(const struct bpf_map *map,
361 if (attach_type_isolated(map)) {
414 static void cgroup_storage_seq_show_elem(struct bpf_map *map, void *key,
422 storage = cgroup_storage_lookup(map_to_storage(map), key, false);
428 btf_type_seq_show(map->btf, map->btf_key_type_id, key, m);
429 stype = cgroup_storage_type(map);
432 btf_type_seq_show(map->btf, map->btf_value_type_id,
439 btf_type_seq_show(map->btf, map->btf_value_type_id,
449 static u64 cgroup_storage_map_usage(const struct bpf_map *map)
482 static size_t bpf_cgroup_storage_calculate_size(struct bpf_map *map, u32 *pages)
486 if (cgroup_storage_type(map) == BPF_CGROUP_STORAGE_SHARED) {
487 size = sizeof(struct bpf_storage_buffer) + map->value_size;
491 size = map->value_size;
504 struct bpf_map *map;
508 map = prog->aux->cgroup_storage[stype];
509 if (!map)
512 size = bpf_cgroup_storage_calculate_size(map, &pages);
514 storage = bpf_map_kmalloc_node(map, sizeof(struct bpf_cgroup_storage),
515 gfp, map->numa_node);
520 storage->buf = bpf_map_kmalloc_node(map, size, gfp,
521 map->numa_node);
524 check_and_init_map_value(map, storage->buf->data);
526 storage->percpu_buf = bpf_map_alloc_percpu(map, size, 8, gfp);
531 storage->map = (struct bpf_cgroup_storage_map *)map;
561 struct bpf_map *map;
566 map = &storage->map->map;
567 stype = cgroup_storage_type(map);
578 struct bpf_cgroup_storage_map *map;
586 map = storage->map;
588 spin_lock_bh(&map->lock);
589 WARN_ON(cgroup_storage_insert(map, storage));
590 list_add(&storage->list_map, &map->list);
592 spin_unlock_bh(&map->lock);
597 struct bpf_cgroup_storage_map *map;
603 map = storage->map;
605 spin_lock_bh(&map->lock);
606 root = &map->root;
611 spin_unlock_bh(&map->lock);