From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org, kvm@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [RFC PATCH 13/16] perf record: Filter runtime hypervisor data mmaps with BPF for --host-ip
Date: Tue, 01 Dec 2026 23:43:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-244430@kernel.org> (raw)
In-Reply-To: <20261201232116.1988791-14-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf bpf: direct field access in perf_kvm_mmap_filter() breaks
GEN_VMLINUX_H=1
--
commit ee1db873881f238429396b011d3810e0ce79e595
Author: Ian Rogers <irogers@google.com>
perf record: Filter runtime hypervisor data mmaps with BPF for --host-ip
This commit adds the kvm_mmap_filter BPF skeleton and attaches it via
attr.mmap_bpf to filter runtime non-executable file-backed hypervisor
mappings during perf record --host-ip.
> diff --git a/tools/perf/util/bpf_skel/kvm_mmap_filter.bpf.c b/tools/perf/util/bpf_skel/kvm_mmap_filter.bpf.c
> new file mode 100644
> index 0000000000000..3f089412fa594
> --- /dev/null
> +++ b/tools/perf/util/bpf_skel/kvm_mmap_filter.bpf.c
> @@ -0,0 +1,79 @@
[ ... ]
> +SEC("perf_event")
> +int perf_kvm_mmap_filter(void *ctx)
> +{
> + struct bpf_perf_event_data_kern *kctx;
> + struct vm_area_struct *vma;
> + struct file *file;
> + struct inode *inode;
> + struct mm_struct *mm;
> + unsigned int nlink;
> + unsigned short mode;
> + __u32 tgid;
> +
> + kctx = bpf_cast_to_kern_ctx(ctx);
> + if (!bpf_core_field_exists(kctx->vma))
> + return 0;
> +
> + vma = kctx->vma;
[ ... ]
> + mm = BPF_CORE_READ(vma, vm_mm);
> + if (mm && bpf_core_field_exists(mm->notifier_subscriptions) &&
> + BPF_CORE_READ(mm, notifier_subscriptions) != NULL) {
> + __u8 one = 1;
> +
> + bpf_map_update_elem(&hypervisor_pids, &tgid, &one, BPF_ANY);
> + return 1;
> + }
[Severity: Low]
Does referencing kctx->vma and mm->notifier_subscriptions directly on
struct bpf_perf_event_data_kern and struct mm_struct break builds with
GEN_VMLINUX_H=1?
When GEN_VMLINUX_H=1 is set, tools/perf/bpf_skel.mak generates vmlinux.h
from the host kernel BTF instead of using the bundled header. If that BTF
comes from a kernel predating bpf_perf_event_data_kern::vma or built
without CONFIG_MMU_NOTIFIER, the fields do not exist on the static struct
types and clang fails at compile time despite the bpf_core_field_exists()
guards. Defining local ___new CO-RE struct flavors (such as
struct bpf_perf_event_data_kern___new and struct mm_struct___new) avoids
relying on the generated vmlinux.h definitions.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201232116.1988791-1-irogers@google.com?part=13
next prev parent reply other threads:[~2026-12-01 23:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:21 [RFC PATCH 00/16] perf, kvm: Add PERF_SAMPLE_HOST_IP for host-side guest symbolization Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 01/16] perf/core: Add PERF_SAMPLE_HOST_IP sample format Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 02/16] perf/core, bpf: Support BPF filtering of mmap_data events Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 03/16] KVM: Add NMI-safe guest-to-host IP translation infrastructure Ian Rogers
2026-12-01 23:40 ` sashiko-bot
2026-12-01 23:21 ` [RFC PATCH 04/16] KVM: x86: Implement kvm_arch_vcpu_get_ip_gpa() Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 05/16] KVM: arm64: " Ian Rogers
2026-12-01 23:41 ` sashiko-bot
2026-12-01 23:21 ` [RFC PATCH 06/16] KVM: riscv: " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 07/16] KVM: loongarch: " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 08/16] tools headers UAPI: Sync linux/perf_event.h with the kernel sources Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 09/16] perf tools: Add PERF_SAMPLE_HOST_IP parsing, synthesis, and record --host-ip Ian Rogers
2026-12-01 23:36 ` sashiko-bot
2026-12-01 23:21 ` [RFC PATCH 10/16] perf symbol: Support host IP resolution and guest fallback symbolization Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 11/16] perf report, script: Add host_ip, host_dso, and host_sym fields Ian Rogers
2026-12-01 23:41 ` sashiko-bot
2026-12-01 23:21 ` [RFC PATCH 12/16] perf record: Synthesize hypervisor file-backed data mappings for --host-ip Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 13/16] perf record: Filter runtime hypervisor data mmaps with BPF " Ian Rogers
2026-12-01 23:43 ` sashiko-bot [this message]
2026-12-01 23:21 ` [RFC PATCH 14/16] perf bpf-filter: Support host_ip in BPF sample filters Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 15/16] perf aslr: Anonymize sampled host_ip values Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 16/16] perf test: Add PERF_SAMPLE_HOST_IP symbolization, sorting, and ASLR tests Ian Rogers
2026-12-01 23:40 ` sashiko-bot
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=sashiko-outbox-244430@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.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