From nobody Tue Feb 10 16:18:20 2026 Received: from mail-yx1-f44.google.com (mail-yx1-f44.google.com [74.125.224.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93ADA2BE62E for ; Tue, 27 Jan 2026 02:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479602; cv=none; b=Zk2jXGmFXuS8MQbIL+D5biJ9E9c4ckdq4K6EowxymtwkBMoGHehOFgytmPDmA0OE8fr57QR8FPpraRjxHh66z2PGiOaOp6b2XqamAexriau5eghEqkA3q6+bkFLmKU8P8Zf+UBoSE10NjwM/L06d3Im8XFZ/fUZyNx8PDPhog7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479602; c=relaxed/simple; bh=qhOxCaKgcUM5iY1rf7o/kU9mLoxJMGT3w3Oo56OLRqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eep5Us9+C7zCUvP/itJ5L1OsYkT/sBl23XfjrDERV+E5wIU2GU8vOGtuHqBUQwG6Rwh1EZGq+depc75+ZvQFeJJU4PsNas02MjAAmbgJlzYRLuLSXCDhzhvkUX/LiLoinIwhijLvQxPjK2IoSyx+fHjn3/pkgHF28pFj0u/6OAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ncsu.edu; spf=pass smtp.mailfrom=ncsu.edu; dkim=pass (2048-bit key) header.d=ncsu.edu header.i=@ncsu.edu header.b=C+MyFG3N; arc=none smtp.client-ip=74.125.224.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ncsu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ncsu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ncsu.edu header.i=@ncsu.edu header.b="C+MyFG3N" Received: by mail-yx1-f44.google.com with SMTP id 956f58d0204a3-649605d3664so3513552d50.3 for ; Mon, 26 Jan 2026 18:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncsu.edu; s=google; t=1769479598; x=1770084398; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GS6cufmSv5Bys/J7tQyqhkjwp+KCu1swmTcv6haTRuI=; b=C+MyFG3NQJaNmzUHOxSPDDyPk6zF7KaRJtVGiB6b5dzi8SCbA5iwQ++fVy/9/p8LBD 2HFyESRfFi/gv+s3yTqxHverncDqbkVbmz+NXhybkKnAFPwoEFRSdbIO+CqGaP8O+u2Y lihBi30TRADe1+7C3+Odn/5G/59sqsru2Iq4cWZ9CYQieTMntNYrnMdQFVpH2Ru4ADq6 5gekU7LCVdi/foUhZY75hv0r+QWPCgSYjg/CjdgvrcOb3xWHZnrcv6rl34IS6kqyXk+p KnPMuGHlpHusyFZa4/rMjRJJEap4hg3uA21o8EjJAKGoKorDr2KXwsdu7BxUMLmgvw4R QwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769479598; x=1770084398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=GS6cufmSv5Bys/J7tQyqhkjwp+KCu1swmTcv6haTRuI=; b=nAcbFZAvhMN9XTTjsBNm99gB9YNa7tOPvK8JREH7CrpZTQfubljj8tm7NUfAACo7Q7 f7UtDdBMV/46dbePksCtI25pPCxh/ZqYeX4qFWoa6QtlAlpBuN7NWFiKrad7uwf7xYOw pl61jF2+R4BP85x6ksIl9Rp663jOCNreNPYwCOkG+5ftQbM1xVbJRJSKFLWrxnbKEgIC nJSkz/LOM3AB3ElgjNjY9GO3GRU6VtwOqRml1F/QBDcjEpgnNVsFCBM7SgUpt4RcIZkW cNOetqEmEvOpPBzqPn5DSmW0rbUZZhd6msTOVkKeR7lj89lMh25zHLgEbuGy4rOlcNcd 8wMg== X-Forwarded-Encrypted: i=1; AJvYcCXImyV/SrhnOXD1vUPUVv78dhDWPlCgbkfc0j5wfSzidZW9MiPw6D+ySRA+pJx/efHNoMAmkKapNeV+q+8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/ldxGAW0EssiwcgH2Nt5Pkrd0kiuDrfSD0uvv3rOVcIUu6AjK lMpcdvnnHY+mgh6M8x32hhAVuEK5oIyzaaO94jY5b/Moom2R/QFfwMLTClsAVTcy0A== X-Gm-Gg: AZuq6aK9ipMh1MqsOtChxjTB1Fsjs1gYD+0ucTruWisTAojGKM/6NSecm0r5JY+Mzug 8x6LJyzlJNpxZapnb0OK+vDKAKxXmlX9STxoA3uZpK7OaRnHpzZqqiFn1CNKqZESLCK/PXYO4Ua MLtElEYAFEf5q0TVK9vHpXB7rOExLTnNdV/V6TAKAEmNPXIZ2vaXsZojqIVy+P5odqd7oGCzhb8 aEioIJXbnn6bGqi/gKSh2z8FmBekz1e30KR9zniaVcoZT+KfjguRuY+x7E75iDsgLMrj00UPJJ3 t9T95+xfjXFK35u2ILRN6JbBeUMTZoAD9SNxj9gSEW4lkF5LuXURuIHGKUK4pmEW7p7cr+4JC+6 NkbnT7smUBk1xQIuE6TUYKJFBH9yiepkusF8U/T5+/4haBW+xxZjqq7pKMveaMjfqI9XQ4NIkl6 twLV4Cb/rBqQ== X-Received: by 2002:a05:690e:d88:b0:649:34da:fbc0 with SMTP id 956f58d0204a3-6498fbed29amr16218d50.7.1769479598080; Mon, 26 Jan 2026 18:06:38 -0800 (PST) Received: from um773-cachyos ([2600:1700:cc0:94af:eca6:9ff9:6f3c:5de9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6496855d65esm4217415d50.12.2026.01.26.18.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 18:06:37 -0800 (PST) From: Zecheng Li To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Zecheng Li , xliuprof@google.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zecheng Li Subject: [PATCH v1 04/11] perf annotate-data: Improve type comparison from different scopes Date: Mon, 26 Jan 2026 21:04:57 -0500 Message-ID: <20260127020617.2804780-5-zli94@ncsu.edu> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260127020617.2804780-1-zli94@ncsu.edu> References: <20260127020617.2804780-1-zli94@ncsu.edu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zecheng Li When comparing types from different scopes, first compare their type offsets. A larger offset means the field belongs to an outer (enclosing) struct. This helps resolve cases where a pointer is found in an inner scope, but a struct containing that pointer exists in an outer scope. Previously, is_better_type would prefer the pointer type, but the struct type is actually more complete and should be chosen. Prefer types from outer scopes when is_better_type cannot determine a better type. This is a heuristic for the case `struct A { struct B; }` where A and B have the same size but I think in most cases A is in the outer scope and should be preferred. Signed-off-by: Zecheng Li Signed-off-by: Zecheng Li --- tools/perf/util/annotate-data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-dat= a.c index 8ff1972981b7..8ea3e8b024e8 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1634,7 +1634,9 @@ static int find_data_type_die(struct data_loc_info *d= loc, Dwarf_Die *type_die) pr_debug_dtp("type_offset=3D%#x\n", type_offset); } =20 - if (!found || is_better_type(type_die, &mem_die)) { + if (!found || dloc->type_offset < type_offset || + (dloc->type_offset =3D=3D type_offset && + !is_better_type(&mem_die, type_die))) { *type_die =3D mem_die; dloc->type_offset =3D type_offset; found =3D true; --=20 2.52.0