From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.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 CDCE33F39EE for ; Tue, 2 Jun 2026 15:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780413952; cv=none; b=nVBK181vd+1c+JmZeAOJ9UWZ3JKTkdpcauV3hl6cUK4yMbXobHbV10pLGBX2CC0bfG12eJzedo8gXoFRRDdbht0QDrQP0+Mo/TIAn75Kg9UwKdtl+rxaEtgz74iH/aaTGme71AffX0P99Gx4gyTpKQV1mUbU90gWmBwbrRR67wI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780413952; c=relaxed/simple; bh=Z4WrN2+59MV/rg4sfdg9lA449vNSt4qPYiJQIWHMBoA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QJWN/yugFeORZG3PeaaSN31gNpS8nG01TUEFhBBwC5T263Sz30Ty+k4F8ul3slXsRsNafOmNUCgAp/4JZPmxFNF3a9E/4V2ERusvddnL7ESJZBWNkTDd25FmHJOwOP+PzHvM06MhioSiolKt1ZdCrkfLMvQofvN1kcKG7mkf5gs= 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=cHpOT/OE; arc=none smtp.client-ip=74.125.82.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="cHpOT/OE" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-304ec73b015so6545536eec.1 for ; Tue, 02 Jun 2026 08:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780413950; x=1781018750; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VKmVi04Xi/VezwoSJHiJtxgWwe8v8etyrpuu8J1PVow=; b=cHpOT/OEgbZR75uBRgqUZxEpYX7h5px/RexbA6cj6fQ9J2qubmxEGRWtHjMe2GFyNF +YxS0NRgLmtcJKxhqGuPVN0JFKlk82Q2gpf9OXRL5lIs9D9ubVIAf7MDyQoYyrOlyyt2 Enugjl3oW/PskPxxjhy+kLLc4oEpWtfe7YEFKm6dXW8MtogdFspNbhERyCHgGVmeoTi2 1EeSwMmoU/GiEXZghI00ZxmvUrTvjYC9ZlzAMGdalI5DP76ZFu/tkoUJSBbeE4ChCuTa 75eemB2VkTnHP/wynGz4Ja1fl8RdcCEYr/QXze7hF3Ocxv5qjY0LEEBTehvcVy1AdztJ zMWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780413950; x=1781018750; h=cc: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=VKmVi04Xi/VezwoSJHiJtxgWwe8v8etyrpuu8J1PVow=; b=KN/wSZQNYfk4c++zzuIkUhw8lTKDBixCAds3V43lpvYXCfu+ulP18vm688yGFzds1L nxx/m0AvMtxBVDD6hSSlMgHKVvSamE8Kq3G+vPhKCzkjpHWAY1Qunph/s39UOK8eMMBC Nm0yWeRYqNDsmvBmFw6g6dCmyKHvC5ahRfJK/1k9MJrYWLnsxvulayJ/mcgVaVUiwcfi rRBb9ssKk83PdYCxXjFchHP5rqcdUoLp8C+RaEimpg8GRUv5WDkIbNCTWfoxHKOwXAsT BG0v50JpeLIcwX9Ci5TJlVqJ2OuSd3lttjN+Ql8U+ODkn0F59dny5C9ihxdPkLHu+ajc LGiw== X-Forwarded-Encrypted: i=1; AFNElJ9y/HrK1uhtlctegp5R7ant1Td8cRaWc8+KxHNWCOnAKXd0Fs5Pism2MV+qmiFp4Bcsz+QT98cqVez6BFpHH2Px@vger.kernel.org X-Gm-Message-State: AOJu0YyCmoUP6P6xceo9r/qT3BJpWHShn6/cDJzjnQlGGxejmlQMsjgw 0RKNtrHe3As/LGqEhMKKzE9iT8ZYB04WrooXVPIxTh3sn4N6LgDnXDaHbBRtxzKUzMwfDC6DMdc P5+kOBSIabQ== X-Received: from dyaf4-n2.prod.google.com ([2002:a05:693c:8384:20b0:2f1:5dbf:fd4e]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:4306:b0:2ef:9961:27fa with SMTP id 5a478bee46e88-304fa5ee3bcmr8041922eec.18.1780413949696; Tue, 02 Jun 2026 08:25:49 -0700 (PDT) Date: Tue, 2 Jun 2026 08:25:04 -0700 In-Reply-To: <20260602152516.2831152-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260602062452.2583619-1-irogers@google.com> <20260602152516.2831152-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.929.g9b7fa37559-goog Message-ID: <20260602152516.2831152-8-irogers@google.com> Subject: [PATCH v12 07/19] perf machine: Use perf_env e_machine rather than arch From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: agordeev@linux.ibm.com, gor@linux.ibm.com, hca@linux.ibm.com, jameshongleiwang@126.com, japo@linux.ibm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-s390@vger.kernel.org, sumanthk@linux.ibm.com, tmricht@linux.ibm.com Content-Type: text/plain; charset="UTF-8" The arch string is derived from uname and may be normalized causing potential differences meaning the ELF machine can be more precise. Reduce the scope of machine__is as often it is better to use a thread for the e_machine rather than the machine. Switch from string to ELF machine constant comparisons. Signed-off-by: Ian Rogers --- tools/perf/util/machine.c | 35 ++++++++++++++++++----------------- tools/perf/util/machine.h | 2 -- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e5d1e8b882a9..47be7a44a5f7 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -9,6 +9,7 @@ #include "debug.h" #include "dso.h" #include "env.h" +#include "dwarf-regs.h" #include "event.h" #include "evsel.h" #include "hist.h" @@ -1627,10 +1628,24 @@ static bool machine__uses_kcore(struct machine *machine) return dsos__for_each_dso(&machine->dsos, machine__uses_kcore_cb, NULL) != 0 ? true : false; } +static bool machine__is(struct machine *machine, uint16_t e_machine) +{ + if (!machine) + return false; + + if (!machine->env) { + if (machine__is_host(machine)) + return e_machine == EM_HOST; + return false; + } + + return perf_env__e_machine(machine->env, NULL) == e_machine; +} + static bool perf_event__is_extra_kernel_mmap(struct machine *machine, struct extra_kernel_map *xm) { - return machine__is(machine, "x86_64") && + return machine__is(machine, EM_X86_64) && is_entry_trampoline(xm->name); } @@ -2786,7 +2801,7 @@ static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, static u64 get_leaf_frame_caller(struct perf_sample *sample, struct thread *thread, int usr_idx) { - if (machine__normalized_is(maps__machine(thread__maps(thread)), "arm64")) + if (thread__e_machine(thread, /*machine=*/NULL, /*e_flags=*/NULL) == EM_AARCH64) return get_leaf_frame_caller_aarch64(sample, thread, usr_idx); else return 0; @@ -3157,20 +3172,6 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, return 0; } -/* - * Compares the raw arch string. N.B. see instead perf_env__arch() or - * machine__normalized_is() if a normalized arch is needed. - */ -bool machine__is(struct machine *machine, const char *arch) -{ - return machine && !strcmp(perf_env__raw_arch(machine->env), arch); -} - -bool machine__normalized_is(struct machine *machine, const char *arch) -{ - return machine && !strcmp(perf_env__arch(machine->env), arch); -} - int machine__nr_cpus_avail(struct machine *machine) { return machine ? perf_env__nr_cpus_avail(machine->env) : 0; @@ -3197,7 +3198,7 @@ int machine__get_kernel_start(struct machine *machine) * start of kernel text, but still above 2^63. So leave * kernel_start = 1ULL << 63 for x86_64. */ - if (!err && !machine__is(machine, "x86_64")) + if (!err && !machine__is(machine, EM_X86_64)) machine->kernel_start = map__start(map); } return err; diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 048b24e9bd38..aaddfb70ea66 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -224,8 +224,6 @@ static inline bool machine__is_host(struct machine *machine) } bool machine__is_lock_function(struct machine *machine, u64 addr); -bool machine__is(struct machine *machine, const char *arch); -bool machine__normalized_is(struct machine *machine, const char *arch); int machine__nr_cpus_avail(struct machine *machine); struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); -- 2.54.0.929.g9b7fa37559-goog