函数源码 |
Source File:kernel\bpf\local_storage.c |
Create Date:2022-07-27 14:31:42 |
首页 | Copyright©Brick |
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | struct bpf_cgroup_storage *bpf_cgroup_storage_alloc( struct bpf_prog *prog, enum bpf_cgroup_storage_type stype) { struct bpf_cgroup_storage *storage; struct bpf_map *map; gfp_t flags; size_t size; u32 pages; map = prog->aux->cgroup_storage[stype]; if (!map) return NULL; size = bpf_cgroup_storage_calculate_size(map, &pages); if (bpf_map_charge_memlock(map, pages)) return ERR_PTR(-EPERM); storage = kmalloc_node( sizeof ( struct bpf_cgroup_storage), __GFP_ZERO | GFP_USER, map->numa_node); if (!storage) goto enomem; flags = __GFP_ZERO | GFP_USER; if (stype == BPF_CGROUP_STORAGE_SHARED) { storage->buf = kmalloc_node(size, flags, map->numa_node); if (!storage->buf) goto enomem; check_and_init_map_lock(map, storage->buf->data); } else { storage->percpu_buf = __alloc_percpu_gfp(size, 8, flags); if (!storage->percpu_buf) goto enomem; } storage->map = ( struct bpf_cgroup_storage_map *)map; return storage; enomem: bpf_map_uncharge_memlock(map, pages); kfree(storage); return ERR_PTR(-ENOMEM); } |