From nobody Sun Apr 5 16:31:35 2026 Received: from mail-yx1-f49.google.com (mail-yx1-f49.google.com [74.125.224.49]) (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 4E7AF3F23AD for ; Mon, 9 Mar 2026 17:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773078961; cv=none; b=ndwAZK0Sv3bpw3iK6YE7/F2IhN0TwABJwBGJuQX/PCORQlgUEIGhn7OaGMnzxRXw4T6K7VIkeO+F6aPoPxtMXb2JptkuBCHteXn+/+bUxOq/j/CAmmyte/L/6jToG0KigKJO8xgrosK3ZnmuUT1NnOdaQX7zYS4h96Rost8SwBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773078961; c=relaxed/simple; bh=aLAu5L0fib6HrBbWc1UtveitoT71aNAt4ZUMnsx8dho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/k839AM0OIiLbCFp098r3FK/r+habWnDrkBtekiHeFcBVIE3MsgEzjZZpmrg3HAqRTlQL3317zEoFICCTsqOl2ek9WUN02hTta1f9AXX+tRVBKGSdINWJnfkjQg11yqX/2w/GVYIYFRjluarO8sHsU0CeSUTMgtZ/r/cgUAtzY= 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=Avdkf+yA; arc=none smtp.client-ip=74.125.224.49 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="Avdkf+yA" Received: by mail-yx1-f49.google.com with SMTP id 956f58d0204a3-64ad9fabd08so10142499d50.2 for ; Mon, 09 Mar 2026 10:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncsu.edu; s=google; t=1773078956; x=1773683756; 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=ZCxAsFvxZFzdJH9MRwGNnxrTqhY6BlYrnwFDORcP738=; b=Avdkf+yAfDD3RY3Xb1GXiMz56HWZW+x3cTiP3yM34TR2jBh00IWAosDznPJHQWIR7h RS5qw3ZohpDsQTgxQB2QoGQ0cq+fQyvQZPzzki7UftDkxbR3oHgmT/lZSX1LCsnRwjrO 3yPl4e3SyMo3OV5spm0/NnKii7z3qGCayXNQ69bGYItwB0sC3wMHiPhAKE5AkKY9nmSk E7ztARpdniAokPbIm1rVMT7VlXZqqAsXrRLoZEDCblDTmN1E3Yi6dtgcEdE+qng7UG/A /xKACCD05Kmy6YQh6SvaLo6yTz2SsbTAxxk1gdgs0RR/yMvgEbODrFmsEYO6/GcCOzNX 0r3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773078956; x=1773683756; 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=ZCxAsFvxZFzdJH9MRwGNnxrTqhY6BlYrnwFDORcP738=; b=JcozaKxx7wttInk0LaHdaHnctny0zjNfyGB3GxkHrQeUL0h92giiXIFp45HbUnVoDM ajg/AnhSbsE6VJfpt/KM7XIbbR4D2ObwPHEaUQMYP4z1cfFLeZcNTaR3P1F+z51eH6+X twF9bX+p8gvxHX0z2FcFvslrdCud/bbxyiq8nY2mo/NadEvT6jxGwMuPwHA7C7KNE2k4 hVxqRpKf8ys7rxjlwemHtpJWKb0y3NBhOOZOnZhItKvpA0whOLPr+MfIqYCAmf0KgyJl HC/Ztw7G0f/QjlOc3zhtQpmEUH7LBQRubzw5iWKT5PT6zA22B3fOFCCyntPaxMjT4HcP MacQ== X-Forwarded-Encrypted: i=1; AJvYcCWyhb7jFldG48V0MJR1M9yXNp9xG+OCnOtFTUvZ1eGarnCLIA1IsBvnvNqf8x+gb1ITNOTIzmz5bgeK3Sg=@vger.kernel.org X-Gm-Message-State: AOJu0YyJWzAk4vNm5o/TIQ0RrSMUkdBABddi7j71+NL63NOI1c78z9FB ucVlj7wJflrjXtg46pPueBlJoRHU26pU+65FbQqrWAZ2HU3TIlAv26oQcvFrlEz6bQ== X-Gm-Gg: ATEYQzw15fKVmPz34edNjqAl0MUNdUhLuDnHSObihNsM7t9qAtog4i7cX80dhv4RDvy FIiBlzVZ3hdjDa2U2ZwdTVuqlzTTvgkv7iGfVD2H1b7Yon8LD63kbCdbuhhfeVQyxvwX0g+LDSF 5QRP7RhQ6OF08uhA7+z4dPekJXUgCGBvvoN+21wLVx4T8apvlcfS9gu8hKKxLM6I4EdLtHL2/xi JD91HXcQ7NC5Lue7g2fNyz7K3VFLFK6FVmCCw0XaY3Je+54MWhUty3s3dqSY2/UZsORE1anMGq7 xMsBjzMV82pPAv+50FauY6sqAc9yvhjLKMZGS6leSniuWy4lcoGSPqr0IfMRtBa3ULp6Do1XHwp cIPOXXfiCDzYGhVA62QtI2nj3YBKkTiCC6EJim0i9o24ldrBJwSC9JMoRF/WhiNqk6+vx/bYZag xbdtA8/+YRZDsNLeI7ui5KKpADKTAjPUjo+YQl2rz/TRr7+s+El5j4G8Xx X-Received: by 2002:a05:690e:4012:b0:646:b1f3:aeb2 with SMTP id 956f58d0204a3-64d1405ec3fmr11748106d50.3.1773078955907; Mon, 09 Mar 2026 10:55:55 -0700 (PDT) Received: from um773-cachyos.sd.ncsu.edu ([152.7.255.206]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64d176e70e7sm4992535d50.20.2026.03.09.10.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2026 10:55:55 -0700 (PDT) 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 v2 04/11] perf annotate-data: Improve type comparison from different scopes Date: Mon, 9 Mar 2026 13:55:17 -0400 Message-ID: <20260309175546.916039-5-zli94@ncsu.edu> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309175546.916039-1-zli94@ncsu.edu> References: <20260309175546.916039-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 23a09bf58f86..6fe2efd48a83 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1629,7 +1629,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.53.0