From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796168486; b=wpZH9uT6Z0ks+jSNVroh8CPMced0e6sF2XmMfmS+9ar+0wCRmi8nVv837GiWq6xbtymb eI4vGRFyQzJYu3fGSZLo8Obk+DoDm9L1JPhpqDGk+8MUHbfHHkjIU7GogQAk82R5d689I KZLcKHxp/JEsyUu9wsuMYhQVE89sqk1Otg9aZDuwtudxM3xis+zYrHFGfnd4U5QBAlyHj GZotYz7SLelIBuxiu6AuoDBOU32+qM03Z2kLDDgsSeYAEaTka/vgzi9iLnHVmAf0EVYQY OQQPVsSlPZ/sZRvSO7X0AMWKV8s0C1eciIue3GnGoyaDkQq7TuLZU1w+4Z77xWaa2zQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796168486; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=fW9QQJMGeL4z7P6+9rsyK7JEGxDbL2d2kXpPyFaF3dA=; b=hCPJHUx4DGJyry0x5ITJ49ZHf+Dl9ukhtmFgsuyJije3GtGo5RY8o83HZWw8RRpyc/rZ QeHDe6LMdqUpUuZg5mIUk8RxgEOtZ0iFuwqqdY9keOVKyrUd/iJbE9bVZfyrUXLX1a8Kj QBieIJHjLyosjnGeUOLKVpUp/ks99PiTxWYIIB13QY4kgpPu9BQSdm9LL1ZpmfKNQLdY0 pYRlRL+qPqyJsEs2Ch2jf4Y5VhyhrAq87og7ML8UWXIAsOUoRmLdpT3xQWGpfuiLmDYKE TR+28Ij/cu+sDipPRdWq/VCdSlLXcvW3xJ6PJ0pkRLerLlJ3rwY5Vjnf2RX1d7g5MpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="hsfl7k+/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA23A606A31A; Tue, 1 Dec 2026 23:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hsfl7k+/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97FD61F00893; Tue, 1 Dec 2026 23:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796168486; bh=fW9QQJMGeL4z7P6+9rsyK7JEGxDbL2d2kXpPyFaF3dA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hsfl7k+/fg2dt13nD1VGbAjLK5ljTv2GlyXMvDLphP+dfAms0uRF5muwOAmg6v+8s mjVlY3VuY244gIs2/GVF4YvbtD2s/FAuch8aCYpr8H0b5blTRfn59SKY0p1tKtzkv+ MlK6utHBwDQtWGmZngt9hFfqJkwyHB9YE68fYTXiMpUup5pm++8Zkb2O88/vQtWYQE yH+fqts1we2eX0W1r5e9SlfajXQSQgfEr1jove6TwDv3mT3/QUUEDgC4wzFTP9fVl5 HWNP+paufpFztbhdXxVFohUubZpSxkQSUck9wVKl9EScg7sCP9+yDXhb0KVj0DzUzQ +WAw5SDiIQkrQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 11/16] perf report, script: Add host_ip, host_dso, and host_sym fields Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" Cc: linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, bpf@vger.kernel.org In-Reply-To: <20261201232116.1988791-12-irogers@google.com> References: <20261201232116.1988791-1-irogers@google.com> <20261201232116.1988791-12-irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 23:41:26 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] perf sort: double unmapping of host_ip in hist_entry__host_sym_snprintf() - [Medium] perf sort: strict weak ordering violation in sort__host_sym_cmp() - [Low] perf script: symoff and dsoff validation ignores host_sym and host_dso - [Low] perf hist: missing verbose width for unresolved HISTC_HOST_SYMBOL -- commit 976f06507181de924b5188635a7f011b6d5746e0 Author: Ian Rogers perf report, script: Add host_ip, host_dso, and host_sym fields This commit records resolved host map, symbol, and address fields on struct hist_entry and adds host_ip, host_dso, and host_sym sort keys and output fields to perf report and perf script. > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index b6691ebb1b4ef..f1f0e388d713e 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c [ ... ] > @@ -2745,6 +2763,36 @@ static void process_event(struct perf_script *scri= pt, > symbol_conf.bt_stop_list, fp); > } > =20 > + if (PRINT_FIELD(HOST_IP) || PRINT_FIELD(HOST_SYM) || PRINT_FIELD(HOST_D= SO)) { > + struct perf_sample host_sample =3D *sample; > + struct addr_location host_al; > + unsigned int host_opts =3D 0; > + > + if (PRINT_FIELD(HOST_IP)) > + host_opts |=3D EVSEL__PRINT_IP; > + if (PRINT_FIELD(HOST_SYM)) > + host_opts |=3D EVSEL__PRINT_SYM; > + if (PRINT_FIELD(HOST_DSO)) > + host_opts |=3D EVSEL__PRINT_DSO; > + if (PRINT_FIELD(DSOFF)) > + host_opts |=3D EVSEL__PRINT_DSOFF; > + if (PRINT_FIELD(SYMOFFSET)) > + host_opts |=3D EVSEL__PRINT_SYMOFFSET; [Severity: Low] Should evsel__check_attr() and perf_session__check_output_opt() also account for HOST_SYM and HOST_DSO when validating SYMOFFSET and DSOFF? evsel__check_attr() rejects PRINT_FIELD(SYMOFFSET) when !PRINT_FIELD(SYM), = so running perf script with -F -sym,+host_sym or -F host_sym,symoff fails with -EINVAL. Likewise, perf_session__check_output_opt() unconditionally sets PERF_OUTPUT_DSO whenever PERF_OUTPUT_DSOFF is requested, even if only host_dso was selected. > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > index 364754e9d12aa..50ecb65a354ad 100644 > --- a/tools/perf/util/hist.c > +++ b/tools/perf/util/hist.c > @@ -119,6 +119,24 @@ void hists__calc_col_len(struct hists *hists, struct= hist_entry *h) > hists__new_col_len(hists, HISTC_DSO, len); > } > =20 > + if (h->host_ms.sym) { > + symlen =3D h->host_ms.sym->namelen + 4; > + if (verbose > 0) > + symlen +=3D BITS_PER_LONG / 4 + 2 + 3; > + hists__new_col_len(hists, HISTC_HOST_SYMBOL, symlen); > + } else { > + symlen =3D unresolved_col_width + 4 + 2; > + hists__new_col_len(hists, HISTC_HOST_SYMBOL, symlen); > + hists__set_unres_dso_col_len(hists, HISTC_HOST_DSO); > + } [Severity: Low] Does the unresolved branch here and hists__sort_list_width() in tools/perf/ui/hist.c miss the verbose address-and-origin prefix width for HISTC_HOST_SYMBOL? _hist_entry__sym_snprintf() prints the verbose prefix even when ms->sym is NULL, and hists__sort_list_width() only checks hists__has(hists, sym) before adding 3 + BITS_PER_LONG / 4. When running perf report -v sorted by host_sym without sym, unresolved host symbols can overflow the calculated column width and truncate the output line in hists__fprintf(). > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c > index 58638ec9ae0ed..229b836479c45 100644 > --- a/tools/perf/util/sort.c > +++ b/tools/perf/util/sort.c [ ... ] > +/* --sort host_sym */ > + > +static int64_t > +sort__host_sym_cmp(struct hist_entry *left, struct hist_entry *right) > +{ > + int64_t ret; > + > + if (!left->host_ms.sym && !right->host_ms.sym) > + return sort__host_ip_cmp(left, right); > + > + ret =3D sort__host_dso_cmp(left, right); > + if (ret !=3D 0) > + return ret; > + > + return _sort__sym_cmp(left->host_ms.sym, right->host_ms.sym); > +} [Severity: Medium] Does comparing sort__host_ip_cmp() before sort__host_dso_cmp() when both symbols are NULL break comparator transitivity for the hists RB-tree? When one entry has a symbol and the other does not, sort__host_sym_cmp() orders them by host DSO first, whereas two unresolved entries are ordered by unmapped host_ip across different DSOs. Three entries across DSOs liba.so (sym =3D=3D NULL, host_ip =3D 0x3000), libb.so (sym !=3D NULL), and libc.so (sym =3D=3D NULL, host_ip =3D 0x1000) can then form a cycle A > B > C > A, corrupting RB-tree lookups under --sort host_sym. In addition, if two unresolved entries with different host_ms.map pointers share the same unmapped host_ip, sort__host_sym_cmp() returns 0 and hists__findnew_entry() overwrites he->host_ms.map in place without rebalancing the RB-tree. > +static int64_t > +sort__host_sym_sort(struct hist_entry *left, struct hist_entry *right) > +{ > + if (!left->host_ms.sym || !right->host_ms.sym) > + return cmp_null(left->host_ms.sym, right->host_ms.sym); > + > + return strcmp(right->host_ms.sym->name, left->host_ms.sym->name); > +} > + > +static int hist_entry__host_sym_snprintf(struct hist_entry *he, char *bf, > + size_t size, unsigned int width) > +{ > + struct dso *dso =3D he->host_ms.map ? map__dso(he->host_ms.map) : NULL; > + char level =3D (dso && dso__kernel(dso)) ? 'k' : '.'; > + u64 ip =3D he->host_ip; > + > + if (!he->host_ms.sym && he->host_ms.map) > + ip =3D map__unmap_ip(he->host_ms.map, ip); > + > + return _hist_entry__sym_snprintf(&he->host_ms, ip, level, bf, size, wid= th); > +} [Severity: Medium] Doesn't calling map__unmap_ip() here cause _hist_entry__sym_snprintf() to unmap ip a second time in verbose mode? tools/perf/util/sort.c:_hist_entry__sym_snprintf() { ... if (verbose > 0) { struct dso *dso =3D map ? map__dso(map) : NULL; char o =3D map ? dso__symtab_origin(dso) : '!'; u64 rip =3D ip; if (dso && dso__kernel(dso) && dso__adjust_symbols(dso)) rip =3D map__unmap_ip(map, ip); ... } Because he->host_ip already holds al->host_addr when he->host_ms.map is present (matching how he->ip holds al->addr in hist_entry__sym_snprintf()), pre-unmapping ip when !he->host_ms.sym && he->host_ms.map causes adjusted kernel and module DSOs to be unmapped twice under perf report -v, printing a bogus address. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201232116.1988= 791-1-irogers@google.com?part=3D11