Skip to content

Commit

Permalink
bpf: Use try_alloc_pages() to allocate pages for bpf needs.
Browse files Browse the repository at this point in the history
Use try_alloc_pages() and free_pages_nolock()

Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
Alexei Starovoitov authored and Kernel Patches Daemon committed Dec 10, 2024
1 parent cac35e4 commit 9dcb7b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ int bpf_map_alloc_pages(const struct bpf_map *map, gfp_t gfp, int nid,
old_memcg = set_active_memcg(memcg);
#endif
for (i = 0; i < nr_pages; i++) {
pg = alloc_pages_node(nid, gfp | __GFP_ACCOUNT, 0);
pg = try_alloc_pages(nid, 0);

if (pg) {
pages[i] = pg;
continue;
}
for (j = 0; j < i; j++)
__free_page(pages[j]);
free_pages_nolock(pages[j], 0);
ret = -ENOMEM;
break;
}
Expand Down

0 comments on commit 9dcb7b3

Please sign in to comment.