From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: bot+bpf-ci@kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, eddyz87@gmail.com, memxor@gmail.com,
song@kernel.org
Cc: bpf@vger.kernel.org, kernel-team@meta.com, martin.lau@kernel.org,
yonghong.song@linux.dev, clm@meta.com
Subject: Re: [PATCH bpf-next v2] bpf: Better build_id caching in stack_map_get_build_id_offset()
Date: Fri, 12 Jun 2026 16:59:08 -0700 [thread overview]
Message-ID: <86f85bd8-e950-401f-945a-b3cb8b3abc34@linux.dev> (raw)
In-Reply-To: <f9a5887f90f678d4fbbb021bd603652762132041a16f93a84a99f3607195ebb1@mail.kernel.org>
On 6/12/26 3:37 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
>> index 77ba03216c09..822b5cb188ea 100644
>> --- a/kernel/bpf/stackmap.c
>> +++ b/kernel/bpf/stackmap.c
>
> [ ... ]
>
>> @@ -343,8 +410,8 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
>> struct mmap_unlock_irq_work *work = NULL;
>> bool irq_work_busy = bpf_mmap_unlock_get_irq_work(&work);
>> bool has_user_ctx = user && current && current->mm;
>> - struct vm_area_struct *vma, *prev_vma = NULL;
>> - const unsigned char *prev_build_id = NULL;
>> + struct stack_map_build_id_cache cache = {};
>> + struct vm_area_struct *vma;
>> int i;
>>
>> if (may_fault && has_user_ctx) {
>
> [ ... ]
>
>> @@ -365,27 +432,29 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
>>
>> for (i = 0; i < trace_nr; i++) {
>> u64 ip = READ_ONCE(id_offs[i].ip);
>> - u64 offset;
>>
>> - if (prev_build_id && range_in_vma(prev_vma, ip, ip)) {
>> - vma = prev_vma;
>> - offset = stack_map_build_id_offset(vma->vm_pgoff, vma->vm_start, ip);
>> - stack_map_build_id_set_valid(&id_offs[i], offset, prev_build_id);
>> + if (!stack_map_build_id_set_from_cache(&cache, &id_offs[i], ip))
>> continue;
>> - }
>> +
>> vma = find_vma(current->mm, ip);
>> if (!vma || vma_is_anonymous(vma) ||
>> fetch_build_id(vma, id_offs[i].build_id, may_fault)) {
>> - /* per entry fall back to ips */
>> + /* per entry fall back to ips; cache build-ID-less range */
>> stack_map_build_id_set_ip(&id_offs[i]);
>> - prev_vma = vma;
>> - prev_build_id = NULL;
>> + if (vma)
>> + stack_map_build_id_cache_set_unresolved(&cache,
>> + vma->vm_start, vma->vm_end);
>> continue;
>> }
>> - offset = stack_map_build_id_offset(vma->vm_pgoff, vma->vm_start, ip);
>> - stack_map_build_id_set_valid(&id_offs[i], offset, id_offs[i].build_id);
>> - prev_vma = vma;
>> - prev_build_id = id_offs[i].build_id;
>> + /* mmap_lock is held for the whole loop, so the cached VMA
>> + * fields stay valid; no file pinning is needed here.
>> + */
> ^^^^
>
> This isn't a bug, but should the comment text start on the line after the
> opening /* to match the BPF multi-line comment style?
sigh... Looks like this also was present in v1, and I missed it.
I'll wait in case there is more feedback before making a v3.
>
> The other multi-line comments added in this patch follow that convention,
> such as in the new stack_map_build_id_cache structure and the helper
> functions.
>
>> + stack_map_build_id_set_valid(&id_offs[i],
>> + stack_map_build_id_offset(vma->vm_pgoff, vma->vm_start, ip),
>> + id_offs[i].build_id);
>> + stack_map_build_id_cache_set_resolved(&cache, NULL, id_offs[i].build_id,
>> + vma->vm_start, vma->vm_end,
>> + vma->vm_pgoff);
>> }
>> bpf_mmap_unlock_mm(work, current->mm);
>> }
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/27446103592
next prev parent reply other threads:[~2026-06-12 23:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 22:06 [PATCH bpf-next v2] bpf: Better build_id caching in stack_map_get_build_id_offset() Ihor Solodrai
2026-06-12 22:37 ` bot+bpf-ci
2026-06-12 23:59 ` Ihor Solodrai [this message]
2026-06-13 1:45 ` Alexei Starovoitov
2026-06-13 4:38 ` Ihor Solodrai
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=86f85bd8-e950-401f-945a-b3cb8b3abc34@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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