Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'bpf-use-gfp_kernel-in-bpf_event_entry_gen'

Hou Tao says:

====================
The simple patch set aims to replace GFP_ATOMIC by GFP_KERNEL in
bpf_event_entry_gen(). These two patches in the patch set were
preparatory patches in "Fix the release of inner map" patchset [1] and
are not needed for v2, so re-post it to bpf-next tree.

Patch #1 reduces the scope of rcu_read_lock when updating fd map and
patch #2 replaces GFP_ATOMIC by GFP_KERNEL. Please see individual
patches for more details.

Change Log:
v3:
* patch #1: fallback to patch #1 in v1. Update comments in
bpf_fd_htab_map_update_elem() to explain the reason for
rcu_read_lock() (Alexei)

v2: https://lore.kernel.org/bpf/20231211073843.1888058-1-houtao@huaweicloud.com/
* patch #1: add rcu_read_lock/unlock() for bpf_fd_array_map_update_elem
as well to make it consistent with
bpf_fd_htab_map_update_elem and update commit message
accordingly (Alexei)
* patch #1/#2: collects ack tags from Yonghong

v1: https://lore.kernel.org/bpf/20231208103357.2637299-1-houtao@huaweicloud.com/

[1]: https://lore.kernel.org/bpf/20231107140702.1891778-1-houtao@huaweicloud.com/
====================

Link: https://lore.kernel.org/r/20231214043010.3458072-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+7 -5
+1 -1
kernel/bpf/arraymap.c
··· 1195 1195 { 1196 1196 struct bpf_event_entry *ee; 1197 1197 1198 - ee = kzalloc(sizeof(*ee), GFP_ATOMIC); 1198 + ee = kzalloc(sizeof(*ee), GFP_KERNEL); 1199 1199 if (ee) { 1200 1200 ee->event = perf_file->private_data; 1201 1201 ee->perf_file = perf_file;
+6
kernel/bpf/hashtab.c
··· 2523 2523 if (IS_ERR(ptr)) 2524 2524 return PTR_ERR(ptr); 2525 2525 2526 + /* The htab bucket lock is always held during update operations in fd 2527 + * htab map, and the following rcu_read_lock() is only used to avoid 2528 + * the WARN_ON_ONCE in htab_map_update_elem(). 2529 + */ 2530 + rcu_read_lock(); 2526 2531 ret = htab_map_update_elem(map, key, &ptr, map_flags); 2532 + rcu_read_unlock(); 2527 2533 if (ret) 2528 2534 map->ops->map_fd_put_ptr(map, ptr, false); 2529 2535
-4
kernel/bpf/syscall.c
··· 184 184 err = bpf_percpu_cgroup_storage_update(map, key, value, 185 185 flags); 186 186 } else if (IS_FD_ARRAY(map)) { 187 - rcu_read_lock(); 188 187 err = bpf_fd_array_map_update_elem(map, map_file, key, value, 189 188 flags); 190 - rcu_read_unlock(); 191 189 } else if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS) { 192 - rcu_read_lock(); 193 190 err = bpf_fd_htab_map_update_elem(map, map_file, key, value, 194 191 flags); 195 - rcu_read_unlock(); 196 192 } else if (map->map_type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY) { 197 193 /* rcu_read_lock() is not needed */ 198 194 err = bpf_fd_reuseport_array_update_elem(map, key, value,