Linux Perf Users
 help / color / mirror / Atom feed
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 09/16] perf tools: Add PERF_SAMPLE_HOST_IP parsing, synthesis, and record --host-ip
Date: Tue, 01 Dec 2026 23:36:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-244415@kernel.org> (raw)
In-Reply-To: <20261201232116.1988791-10-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf build-id: redundant host_ip resolution work in
  build_id__mark_dso_hit()
--

commit f48af508d6ae21b2cf368f9f3892365b8960eca5
Author: Ian Rogers <irogers@google.com>

perf tools: Add PERF_SAMPLE_HOST_IP parsing, synthesis, and record --host-ip

This commit adds userspace support for PERF_SAMPLE_HOST_IP, including sample
parsing, synthesis, build-id hit tracking, and a --host-ip option in perf
record.

> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index 02233ef0eafff..cc5ce39ddacd4 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -74,6 +74,33 @@ int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused,
>  
>  	addr_location__exit(&al);
>  
> +	if (sample->host_ip) {
> +		struct machine *host_machine = machine__is_host(machine) ?
> +			machine : (machine->machines ? &machine->machines->host : NULL);
> +
> +		if (host_machine) {
> +			struct thread *host_thread = machine__findnew_thread(host_machine,
> +									     sample->pid,
> +									     sample->tid);
> +			struct maps *host_maps = NULL;
> +
> +			if (machine__kernel_ip(host_machine, sample->host_ip))
> +				host_maps = machine__kernel_maps(host_machine);
> +			else if (host_thread)
> +				host_maps = thread__maps(host_thread);
> +
> +			if (host_maps) {
> +				struct map *host_map = maps__find(host_maps, sample->host_ip);
> +
> +				if (host_map) {
> +					dso__set_hit(map__dso(host_map));
> +					map__put(host_map);
> +				}
> +			}
> +			thread__put(host_thread);
> +		}
> +	}

[Severity: Low]
Does calling machine__kernel_ip() on every non-zero sample->host_ip force an
eager load of the host kernel symbol table even for pure user-space samples?

machine__kernel_ip() calls machine__get_kernel_start(), which invokes
map__load() on the host vmlinux map on the first sample, bypassing
symbol_conf.lazy_load_kernel_maps in cmd_record():

tools/perf/util/machine.c:machine__get_kernel_start() {
	...
	if (map) {
		err = map__load(map);
		/*
		 * On x86_64, PTI entry trampolines are less than the
		 * start of kernel text, but still above 2^63. So leave
		 * kernel_start = 1ULL << 63 for x86_64.
		 */
		if (!err && !machine__is(machine, EM_X86_64))
			machine->kernel_start = map__start(map);
	}
	...
}

In addition, when host_machine == machine and sample->host_ip == sample->ip,
this repeats machine__findnew_thread() (even before checking whether
host_thread is needed for a user-space address) and repeats the map lookup
already done by thread__find_map() above.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201232116.1988791-1-irogers@google.com?part=9

  reply	other threads:[~2026-12-01 23:36 UTC|newest]

Thread overview: 24+ 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 [this message]
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
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
2026-12-01 23:43 ` [RFC PATCH 00/16] perf, kvm: Add PERF_SAMPLE_HOST_IP for host-side guest symbolization 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-244415@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