bpf: Use GFP_KERNEL in bpf_event_entry_gen()
authorHou Tao <houtao1@huawei.com>
Thu, 14 Dec 2023 04:30:10 +0000 (12:30 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 14 Dec 2023 04:49:11 +0000 (20:49 -0800)
rcu_read_lock() is no longer held when invoking bpf_event_entry_gen()
which is called by perf_event_fd_array_get_ptr(), so using GFP_KERNEL
instead of GFP_ATOMIC to reduce the possibility of failures due to
out-of-memory.

Acked-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231214043010.3458072-3-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/arraymap.c

index 8d365bda9a8bf1e5cf2b74efb2e09a4b18af94f7..b5ec24b3563eb34cb5d633515560ef6383cfbcc3 100644 (file)
@@ -1195,7 +1195,7 @@ static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file,
 {
        struct bpf_event_entry *ee;
 
-       ee = kzalloc(sizeof(*ee), GFP_ATOMIC);
+       ee = kzalloc(sizeof(*ee), GFP_KERNEL);
        if (ee) {
                ee->event = perf_file->private_data;
                ee->perf_file = perf_file;