lkml.org 
[lkml]   [2022]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 bpf-next 5/5] bpf: simplify select_bpf_prog_pack_size
Date
Use huge_vmalloc_supported to simplify select_bpf_prog_pack_size, so that
we don't allocate some huge pages and free them immediately.

Suggested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Song Liu <song@kernel.org>
---
kernel/bpf/core.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 83f5a98517d5..fbbfb7534979 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -854,22 +854,15 @@ static LIST_HEAD(pack_list);
static size_t select_bpf_prog_pack_size(void)
{
size_t size;
- void *ptr;
-
- size = BPF_HPAGE_SIZE * num_online_nodes();
- ptr = module_alloc_huge(size);

- /* Test whether we can get huge pages. If not just use PAGE_SIZE
- * packs.
- */
- if (!ptr || !is_vm_area_hugepages(ptr)) {
+ if (huge_vmalloc_supported()) {
+ size = BPF_HPAGE_SIZE * num_online_nodes();
+ bpf_prog_pack_mask = BPF_HPAGE_MASK;
+ } else {
size = PAGE_SIZE;
bpf_prog_pack_mask = PAGE_MASK;
- } else {
- bpf_prog_pack_mask = BPF_HPAGE_MASK;
}

- vfree(ptr);
return size;
}

--
2.30.2
\
 
 \ /
  Last update: 2022-06-24 23:58    [W:0.072 / U:4.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site