From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: <bpf@vger.kernel.org>, <andrii@kernel.org>, <eddyz87@gmail.com>,
<memxor@gmail.com>, <daniel@iogearbox.net>
Subject: Re: [PATCH bpf-next v3 5/7] selftests/bpf: libarena: Refill local caches in batches
Date: Wed, 28 Oct 2026 04:51:31 +0000 [thread overview]
Message-ID: <DMG79K7GBDII.CT0J80HSK1KX@gmail.com> (raw)
In-Reply-To: <CABFh=a704QpvYLiTq7h7VO0KK6bsFWRamz87mgS9=7=Mt=B_aw@mail.gmail.com>
On Tue, Oct 27, 2026 at 01:57 PM Emil Tsalapatis <emil@etsalapatis.com> wrote:
> On Tue, Oct 27, 2026 at 7:51 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
>>
>> On Thu, Oct 22, 2026 at 05:20 PM Emil Tsalapatis <emil@etsalapatis.com> wrote:
>> > + if (buddy_alloc_bulk(buddy, size, BUDDY_CACHE_BATCH_ORDER,
>> > + (void __arena * __arena *)slots->objects))
>> > + return NULL;
>>
>> This asks for one block of order + 3. When the existing chunks have free
>> objects of this order, but no such block, it goes to buddy_chunk_get().
>> Before this patch the existing chunks served such buddy_alloc().
>>
>> A sleepable prog takes another 1 MiB chunk.
>> A non-sleepable prog loses 1 MiB of buddy->vaddr in every buddy_alloc():
>>
>> buddy_alloc() the cache is empty
>> buddy_cache_refill()
>> buddy_alloc_bulk() no free block of order + 3
>> buddy_chunk_get()
>> buddy_alloc_arena_vaddr() buddy->vaddr += 1 MiB
>> bpf_arena_free_pages() deferred to a worker
>> bpf_arena_alloc_pages() the range is still reserved: NULL
>> buddy_alloc_memory() one object from the existing chunks
>> the cache is still empty
>>
>> After 1024 of them buddy_alloc_arena_vaddr() fails for sleepable progs
>> too.
>>
>> Should the refill look at the existing chunks only,
>> like buddy_alloc_nogrow() in your other series?
>
> I think that'd be a fair policy, the downside would be that
> consecutive allocations
> would fall through the cache, but that's a fair tradeoff. It's easier
> for a user to
> preallocate memory into the allocator from the mapping as opposed to having
> to deal with the fragmentation you're describing.
Thanks. Makes sense to me.
next prev parent reply other threads:[~2026-10-28 4:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 0:20 [PATCH bpf-next v3 0/7] bpf libarena allocator improvements Emil Tsalapatis
2026-10-23 0:20 ` [PATCH bpf-next v3 1/7] selftests/bpf: libarena: Add bulk buddy allocation helpers Emil Tsalapatis
2026-10-23 0:49 ` bot+bpf-ci
2026-10-23 0:20 ` [PATCH bpf-next v3 2/7] selftests/bpf: Add a parallel buddy allocator benchmark Emil Tsalapatis
2026-10-23 0:20 ` [PATCH bpf-next v3 3/7] selftests/bpf: libarena: Add buddy per-CPU caches Emil Tsalapatis
2026-10-23 0:49 ` bot+bpf-ci
2026-10-23 0:20 ` [PATCH bpf-next v3 4/7] selftests/bpf: libarena: Handle NMI reentrancy Emil Tsalapatis
2026-10-27 19:49 ` Alexei Starovoitov
2026-10-27 21:03 ` Emil Tsalapatis
2026-10-23 0:20 ` [PATCH bpf-next v3 5/7] selftests/bpf: libarena: Refill local caches in batches Emil Tsalapatis
2026-10-27 19:50 ` Alexei Starovoitov
2026-10-27 20:57 ` Emil Tsalapatis
2026-10-28 4:51 ` Alexei Starovoitov [this message]
2026-10-23 0:20 ` [PATCH bpf-next v3 6/7] selftests/bpf: libarena: Add a transfer cache Emil Tsalapatis
2026-10-27 19:52 ` Alexei Starovoitov
2026-10-27 20:51 ` Emil Tsalapatis
2026-10-23 0:20 ` [PATCH bpf-next v3 7/7] selftests/bpf: libarena: Cover buddy cache fast paths Emil Tsalapatis
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=DMG79K7GBDII.CT0J80HSK1KX@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=memxor@gmail.com \
/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