From nobody Tue Dec 2 01:06:35 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 6F6B7269CE7 for ; Mon, 1 Dec 2025 20:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764622532; cv=none; b=SoLeJD6w8zDUaqv4U9AIlMysP/vq2q5MStRX/x5nw5YZOGf2aXP+U964XGkB9tCXEIyuAqU9GONlST+8n5Gq8rW7wG6FeBjnI8CQbeZBdtgTnwytSLzyeLWgopM6BrCjb5jMjXosXpZ2ShoDAM/mCpYRjQWDSlmORsvRvH2S4hE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764622532; c=relaxed/simple; bh=RGdmhyBYFRnGgFw20jM0roDN+95aj0Dmbo2wN7m/qV4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=UnCU9ZebQ680hB+D0CctwoCTyP7GJmxU9r1O9RAK6MuTbGZ5OCYfIqr/iY9OdVUYrgTcbxE3Bo1MCfhH3n20FFvZEklYAsezWR6wc+8bhM0oAoTY7uXaSjhprERKwPf1e9IqmQBIl7uKZvU9wr5t69h61UtMBxUKzhxes9rUYCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4WJ96559; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4WJ96559" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b969f3f5c13so4737077a12.0 for ; Mon, 01 Dec 2025 12:55:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764622530; x=1765227330; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=nuvqYDAGbb4tGYCC6QK3TUQ9PWdRvfqu3GrG0lS3IVQ=; b=4WJ96559VIGAaEALefJFSywyqSKX97vmrU3b8y7AuhfkssiFgamEO0w2V3IZoN04eM FWHhmIywjEca7SpAzKCmC0HZfLtaJF+tL5G5za4dnRd0Vc3ZXhZBYWPG6q6sJbs+ebJ3 jEYHKaJD468Hk4CLGHTyDVCTYeJ1xkde5t6uE1OQnr1UiPdnEP5lMmLjLhAEGT4ZPXUq qxCneXcSHcKkI5iNFJCn2tFOmTadjMQ4k/ZAwsfbpPOK2UpBSAyJIkcTB11XXfoJFOmc IS0H9W5W8pTuHlBMqDBbO9yQRok0c8Haw7potcOadDRRYGu5kcAleWtxL8PhtWv9lg8K 5LLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764622530; x=1765227330; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nuvqYDAGbb4tGYCC6QK3TUQ9PWdRvfqu3GrG0lS3IVQ=; b=wNF5qIFc/H9k7By8OzGJHtHEXIOwaJTjdx/dP6BywUrZl01C3LhB0sP7SCmQ5Wb/Np gLZXIRDzCvGOuwEoaFDIbNPkOtymm0IHx8bHhJ2yUmXcJgtbchuAOON/cnVHXTor8mMS EOlik0UclPBvTPk5JLLWlvBRbX/0UdkSk3xaKuUVsFbuZ1SaR30shyaXdaII1C6JRvAX lOeQJXWLa4Wp+QiYf/AD0wslXeeot1ThLY5yqq37mbVraoIWufyZ17x6u9FsBwb9qMyb DXhXJ0KlHAWmweNOaXRg5SwgOBCMbMPfSqQNw+nNyetbh+xCGBqmxA9hOdn+jRpgY5u7 fpTg== X-Forwarded-Encrypted: i=1; AJvYcCUTK9TdWlltzp7NJCmT+ERUfVrXW+7ukVxhgdHJrot+O+fQI+8JVkP1/nkOOA35cSNczvpg2LMVo+JZna4=@vger.kernel.org X-Gm-Message-State: AOJu0YzTOQLy7M20UsbxLo/4zKFxrhaxS8+C0xZPsvKrQbD5VFdT3wb/ OgZTIM4m1u9uxAvieKNMNnROa61N0Nwh/BpjgO+BIny2aEUqWHwYQtGWN9J8DlIPMVhIqdK0Hkf RZq1auPQ06w== X-Google-Smtp-Source: AGHT+IFFXPeFIT+moZ3s44tHExWRRKrP5myjYRtAUhgxSg5dgFVxNxqkGlXQGLrK0E1CN+rPJMvc0QOl3Lch X-Received: from dybgu41.prod.google.com ([2002:a05:7301:22a9:b0:2a9:7031:8efc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:fe46:b0:2a4:5028:342d with SMTP id 5a478bee46e88-2a9418914f7mr11875973eec.33.1764622529695; Mon, 01 Dec 2025 12:55:29 -0800 (PST) Date: Mon, 1 Dec 2025 12:55:01 -0800 In-Reply-To: <20251201205509.195451-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251201205509.195451-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.158.g65b55ccf14-goog Message-ID: <20251201205509.195451-3-irogers@google.com> Subject: [PATCH v2 02/10] perf symbol: Reduce scope of arch__sym_update From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , James Clark , John Garry , Will Deacon , Leo Yan , Athira Rajeev , tanze , Stephen Brennan , Andi Kleen , Chun-Tse Shao , Thomas Falcon , Dapeng Mi , "Dr. David Alan Gilbert" , Christophe Leroy , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , "Masami Hiramatsu (Google)" , Alexandre Ghiti , Haibo Xu , Sergei Trofimovich , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than being a weak arch function, use the e_machine from the ELF header to determine whether to update or not. This should make the function work cross-platform, it also reduces the function's scope. Note, the previous PPC code would compile both for 32 and 64-bit and when _CALL_ELF=3D=3D2. Similar testing could be done using the ELF file's e_machine for PPC32 and e_flags for not EF_PPC_EMB. It can also be done on the symbol for a non-zero st_other. Given we're just copying the value, which would otherwise be 0, there's no need to introduce a st_other !=3D 0 test. The value is only used in arch__fix_tev_from_maps on PowerPC in the PPC64_LOCAL_ENTRY_OFFSET macro, where 64-bit is assumed. Signed-off-by: Ian Rogers --- tools/perf/arch/powerpc/util/sym-handling.c | 7 ------- tools/perf/util/symbol-elf.c | 9 ++++++--- tools/perf/util/symbol.h | 4 ---- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/= powerpc/util/sym-handling.c index 947bfad7aa59..afefa9bd0c93 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c @@ -66,13 +66,6 @@ const char *arch__normalize_symbol_name(const char *name) =20 #if defined(_CALL_ELF) && _CALL_ELF =3D=3D 2 =20 -#ifdef HAVE_LIBELF_SUPPORT -void arch__sym_update(struct symbol *s, GElf_Sym *sym) -{ - s->arch_sym =3D sym->st_other; -} -#endif - #define PPC64LE_LEP_OFFSET 8 =20 void arch__fix_tev_from_maps(struct perf_probe_event *pev, diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f661ea6c8ac2..99b1e060acf5 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1338,8 +1338,11 @@ static u64 ref_reloc(struct kmap *kmap) return 0; } =20 -void __weak arch__sym_update(struct symbol *s __maybe_unused, - GElf_Sym *sym __maybe_unused) { } +static void arch__sym_update(int e_machine, const GElf_Sym *sym, struct sy= mbol *s) +{ + if (e_machine =3D=3D EM_PPC64) + s->arch_sym =3D sym->st_other; +} =20 static int dso__process_kernel_symbol(struct dso *dso, struct map *map, GElf_Sym *sym, GElf_Shdr *shdr, @@ -1718,7 +1721,7 @@ dso__load_sym_internal(struct dso *dso, struct map *m= ap, struct symsrc *syms_ss, if (!f) goto out_elf_end; =20 - arch__sym_update(f, &sym); + arch__sym_update(ehdr.e_machine, &sym, f); =20 __symbols__insert(dso__symbols(curr_dso), f, dso__kernel(dso)); nr++; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 9aa0016937b7..f12bb3d0e08b 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -216,10 +216,6 @@ int setup_list(struct strlist **list, const char *list= _str, int setup_intlist(struct intlist **list, const char *list_str, const char *list_name); =20 -#ifdef HAVE_LIBELF_SUPPORT -void arch__sym_update(struct symbol *s, GElf_Sym *sym); -#endif - const char *arch__normalize_symbol_name(const char *name); #define SYMBOL_A 0 #define SYMBOL_B 1 --=20 2.52.0.158.g65b55ccf14-goog