From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: bpf@vger.kernel.org
Cc: andrii@kernel.org, memxor@gmail.com, akpm@linux-foundation.org,
peterz@infradead.org, vbabka@suse.cz, houtao1@huawei.com,
hannes@cmpxchg.org, shakeel.butt@linux.dev, mhocko@suse.com,
tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com
Subject: [PATCH bpf-next 2/2] bpf: Use try_alloc_page() to allocate pages for bpf needs.
Date: Fri, 15 Nov 2024 17:48:54 -0800 [thread overview]
Message-ID: <20241116014854.55141-2-alexei.starovoitov@gmail.com> (raw)
In-Reply-To: <20241116014854.55141-1-alexei.starovoitov@gmail.com>
From: Alexei Starovoitov <ast@kernel.org>
Incomplete patch.
If the __GFP_TRYLOCK approach is acceptable the support
for memcg charging and async page freeing will follow.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 58190ca724a2..26e6cffb2fe9 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -581,12 +581,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);
+ /* TODO: add async memcg charge */
+ pg = try_alloc_page(nid);
if (pg) {
pages[i] = pg;
continue;
}
+ /* TODO: add async page free */
for (j = 0; j < i; j++)
__free_page(pages[j]);
ret = -ENOMEM;
--
2.43.5
next prev parent reply other threads:[~2024-11-16 1:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 1:48 [PATCH bpf-next 1/2] mm, bpf: Introduce __GFP_TRYLOCK for opportunistic page allocation Alexei Starovoitov
2024-11-16 1:48 ` Alexei Starovoitov [this message]
2024-11-16 19:42 ` Peter Zijlstra
2024-11-16 21:13 ` Alexei Starovoitov
2024-11-16 21:34 ` Alexei Starovoitov
2024-11-16 21:41 ` Alexei Starovoitov
2024-11-17 10:54 ` Peter Zijlstra
2024-11-17 10:50 ` Peter Zijlstra
2024-11-17 10:54 ` Vlastimil Babka
2024-11-19 0:40 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241116014854.55141-2-alexei.starovoitov@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=houtao1@huawei.com \
--cc=kernel-team@fb.com \
--cc=linux-mm@kvack.org \
--cc=memxor@gmail.com \
--cc=mhocko@suse.com \
--cc=peterz@infradead.org \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox