Function report | 
Source Code:kernel\bpf\hashtab.c | 
Create Date:2022-07-28 13:09:23 | 
| Last Modify:2022-05-23 09:15:29 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:htab_map_alloc
Proto:static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
Type:struct bpf_map
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| union bpf_attr * | attr | 
| 297 | percpu = one of enum bpf_map_type == BPF_MAP_TYPE_PERCPU_HASH || one of enum bpf_map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH | 
| 299 | lru = one of enum bpf_map_type == BPF_MAP_TYPE_LRU_HASH || one of enum bpf_map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH | 
| 307 | prealloc = Not ( BPF_MAP_CREATE related * flags defined above. & lags for BPF_MAP_CREATE command ) | 
| 312 | htab = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc). | 
| 316 | bpf_map_init_from_attr( & map, attr) | 
| 318 | If percpu_lru Then | 
| 335 | If percpu Then size of each element in bytes += size of * | 
| 342 | If number of hash buckets == 0 || number of hash buckets > U32_MAX / sizeof(structbucket) Then Go to free_htab | 
| 346 | cost = number of hash buckets * sizeof(structbucket) + size of each element in bytes * max_entries | 
| 352 | Else cost += size of each element in bytes * num_possible_cpus() | 
| 356 | err = bpf_map_charge_init( & memory, cost) | 
| 361 | buckets = bpf_map_area_alloc( number of hash buckets * sizeof(structbucket), numa_node) | 
| 364 | If Not buckets Then Go to free_charge | 
| 367 | If map_flags & Zero-initialize hash function seed. This should only be used for testing. Then hashrnd = 0 | 
| 369 | Else hashrnd = get_random_int() | 
| 372 | When i < number of hash buckets cycle | 
| 373 | INIT_HLIST_NULLS_HEAD( & head, i) | 
| 374 | raw_spin_lock_init( & lock) | 
| 377 | If prealloc Then | 
| 378 | err = prealloc_init(htab) | 
| 379 | If err Then Go to free_buckets | 
| 386 | err = alloc_extra_elems(htab) | 
| 387 | If err Then Go to free_prealloc | 
| 392 | Return map | 
| 394 | free_prealloc : | 
| 395 | prealloc_destroy(htab) | 
| 396 | free_buckets : | 
| 397 | bpf_map_area_free(buckets) | 
| 398 | free_charge : | 
| 399 | bpf_map_charge_finish( & memory) | 
| 400 | free_htab : | 
| Name | Describe | 
|---|---|
| htab_of_map_alloc | 
| Source code conversion tool public plug-in interface  | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion  |