From cbe7d2bf7355416815c878e839d03028f4724dfb Mon Sep 17 00:00:00 2001 From: Emil Tsalapatis Date: Fri, 2 Oct 2026 10:52:13 +0000 Subject: bpf: Add sleepable argument to bpf_alloc_pages() bpf_alloc_pages() currently decides whether it may use the blocking page allocator from the current execution context alone. Let callers further restrict that choice by passing whether their context is sleepable. Use the blocking allocator only when both the caller and runtime context allow sleeping. Add __GFP_RETRY_MAYFAIL so this path can reclaim without invoking the OOM killer when the allocation is charged to another memcg. Existing non-sleepable callers retain the no-lock allocation behavior. Signed-off-by: Emil Tsalapatis Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261002105218.6171-3-emil@etsalapatis.com --- include/linux/bpf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 904b539810c7..670eb9f3f20a 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -2902,9 +2902,9 @@ struct bpf_map *bpf_map_get_curr_or_next(u32 *id); struct bpf_prog *bpf_prog_get_curr_or_next(u32 *id); -struct page *bpf_alloc_page(int nid); +struct page *bpf_alloc_page(int nid, bool sleepable); int bpf_alloc_pages(int nid, unsigned long nr_pages, - struct llist_head *pages); + struct llist_head *pages, bool sleepable); void bpf_free_pages(struct llist_head *pages); #ifdef CONFIG_MEMCG void bpf_map_memcg_enter(const struct bpf_map *map, struct mem_cgroup **old_memcg, -- cgit v1.2.3