From nobody Mon Nov 25 04:54:41 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 2F13913DDA7 for ; Thu, 31 Oct 2024 01:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730339025; cv=none; b=LOMUHbWoRGm+elqq5OLcK/0BGx3mnIw7YMcgfDvi2zAXkij/9IYKWE/hE0QrNFNofQHcGu57iA71vmFQdWjrsuc8ieJChEQ/moszTQkD05tdD6t/l53rvbeKf+PJmG0uehS0I4BByXGrgzLB9gs8zE1ZjLTuM5U6DEBDIeGmLgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730339025; c=relaxed/simple; bh=82bijJeRZvQKffUYSp6pgeymdNvCFHYsEPeLvVMlPr4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DwwV7UlwAIs/0UxxjeA+tNGtq4KCQsiNVnrar/MSl9iQyBpoYlfPGBLxTjWh6CF59wHLXku0q0qlGN1z5zQlscnJvqZX8Khgi/4fCbssveNMHFFBVptpHR9AdrWXOnKi4xQa8UaLBDFoW/P+tqMlsFTYm8MM4ayHIZtMzmTZAzM= 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=eonBIH3z; arc=none smtp.client-ip=209.85.128.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="eonBIH3z" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e3497c8eb0so6020717b3.0 for ; Wed, 30 Oct 2024 18:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730339022; x=1730943822; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ZD7VBq2UGR6iF+9N7VjgPo1K8yaYKmQwzvOlxr3CE1U=; b=eonBIH3zCzg8KRJaTDSDHr9rkgvGAszuxrCer46Fm8KbzCsDqLRL0fxvy+NjO2Nf3k H1/+tVhvsIvtv6yj5LnQD2QUxZ/xR1ouPh6eoFhTPx2Ca3fKmoQLQ8UmvyKr56Qkea1d iG7Y9IUZW21KA/sItudj4lQSY3zVL6NoDcp//zLVl25JtfQPnYWrVn/sWX3uZqnawSWS /c+118dg10aKeEJCilSQgievuD9vcbQ4kWkJ3LLstqJP1JH16rS26z8FUt7aLBlgmj49 zdrPuwjlfyenBd2HejP7YXPMNiknziQIzqYZCZZcmRa+u7jqmptGXs8FEfAMzhDKfG1P +7nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730339022; x=1730943822; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZD7VBq2UGR6iF+9N7VjgPo1K8yaYKmQwzvOlxr3CE1U=; b=dT6+NmJqkAn4KecAFBJWLsM7+hLiIoi5S8FX7KYe1in+J78yivYo96HC7wA8d0ijR7 GUISBtRn1IyqY7Ubsey8d2f72/ILOZaJBYtHSfyqm96hYWWl8LV2MI88ozmtHKJBEmxg O0eHrVuGDWtCdzWV/LNVNH6JNAPjfBRdiioZ8NPte3wq1Ps7FsFDvk5reEGL3OzFhiVh 85Ilsba/7CIGlOn8AC4jmyv3zVflRBzRcZA1RJkgwHsncU/8vTkpZIFquxxTIRkBDStt KH+pRhmNIrpXzBaCwi2t6zPg2h7Toa/Qp8gUr44GE/x73MfWc1IYLTJhdxvSu15Zo0Oo c5iw== X-Forwarded-Encrypted: i=1; AJvYcCWfXqo5zOIpS5xbVCK88W3lqEGhbpp0DBLb9+DsNglg8L4lb0aJhZj+CVpkztoAOEOaIaSugxhBG9AXF8A=@vger.kernel.org X-Gm-Message-State: AOJu0Ywsg7g4u3jrt2w5HXPMF/fs0+9rF1KcZe/5MiJqY+D7VuxtZkgW Uz0GPvhiuoDdEPzsx6dAbwYpRYFcPAMLQZ5QGJ2b8LIMsH5K5PVzAP1cvgW/8R5MJ1/24IgY9UP D71cCIw== X-Google-Smtp-Source: AGHT+IGD2zl5CoM1dn1fd62QFAfNFk6dQhVlQX2zqIA8JQBYZtzbSCfBNBohWHmQXmShCDO3HgNQb3NdUTNe X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:ad0f:67e7:f1a6:84c4]) (user=irogers job=sendgmr) by 2002:a0d:d1c3:0:b0:6d9:d865:46c7 with SMTP id 00721157ae682-6ea5576f128mr31617b3.2.1730339022068; Wed, 30 Oct 2024 18:43:42 -0700 (PDT) Date: Wed, 30 Oct 2024 18:42:42 -0700 In-Reply-To: <20241031014252.753588-1-irogers@google.com> Message-Id: <20241031014252.753588-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241031014252.753588-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 11/21] perf x86: Define arch_fetch_insn in NO_AUXTRACE builds From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , Josh Poimboeuf , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" archinsn.c containing arch_fetch_insn was only enabled with CONFIG_AUXTRACE, but this meant that a NO_AUXTRACE build on x86 would use the empty weak version of arch_fetch_insn - weak symbols are a frequent source of errors like this and are outside of the C specification. Change it so that archinsn.c is always built on x86 and make the weak symbol empty version of arch_fetch_insn a strong one guarded by ifdefs. arch_fetch_insn on x86 depends on insn_decode which is a function included then built into intel-pt-insn-decoder.c. intel-pt-insn-decoder.c isn't built in a NO_AUXTRACE=3D1 build. Separate the insn_decode function from intel-pt-insn-decoder.c by just directly compiling the relevant file. Guard this compilation to be for either always on x86 (because of the use in arch_fetch_insn) or when auxtrace is enabled. Apply the CFLAGS overrides as necessary, reducing the amount of code where warnings are disabled. Signed-off-by: Ian Rogers Tested-by: Adrian Hunter --- tools/perf/arch/x86/util/Build | 2 +- tools/perf/util/Build | 2 +- tools/perf/util/intel-pt-decoder/Build | 18 ++++++++++++++---- .../intel-pt-decoder/intel-pt-insn-decoder.c | 3 --- tools/perf/util/trace-event-scripting.c | 4 +++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build index bc56a8e70f34..c5df4a2cf180 100644 --- a/tools/perf/arch/x86/util/Build +++ b/tools/perf/arch/x86/util/Build @@ -18,6 +18,6 @@ perf-util-$(CONFIG_LOCAL_LIBUNWIND) +=3D unwind-libunw= ind.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) +=3D unwind-libdw.o =20 perf-util-$(CONFIG_AUXTRACE) +=3D auxtrace.o -perf-util-$(CONFIG_AUXTRACE) +=3D archinsn.o +perf-util-y +=3D archinsn.o perf-util-$(CONFIG_AUXTRACE) +=3D intel-pt.o perf-util-$(CONFIG_AUXTRACE) +=3D intel-bts.o diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 650974413849..340544a6f5ec 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -122,7 +122,7 @@ perf-util-y +=3D iostat.o perf-util-y +=3D stream.o perf-util-y +=3D kvm-stat.o perf-util-$(CONFIG_AUXTRACE) +=3D auxtrace.o -perf-util-$(CONFIG_AUXTRACE) +=3D intel-pt-decoder/ +perf-util-y +=3D intel-pt-decoder/ perf-util-$(CONFIG_AUXTRACE) +=3D intel-pt.o perf-util-$(CONFIG_AUXTRACE) +=3D intel-bts.o perf-util-$(CONFIG_AUXTRACE) +=3D arm-spe.o diff --git a/tools/perf/util/intel-pt-decoder/Build b/tools/perf/util/intel= -pt-decoder/Build index 30793d08c6d4..f99d150059b9 100644 --- a/tools/perf/util/intel-pt-decoder/Build +++ b/tools/perf/util/intel-pt-decoder/Build @@ -9,14 +9,24 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tabl= es_script) $(inat_table =20 # Busybox's diff doesn't have -I, avoid warning in the case =20 -$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-deco= der/intel-pt-insn-decoder.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c +ifeq ($(SRCARCH),x86) + perf-util-y +=3D inat.o insn.o +else + perf-util-$(CONFIG_AUXTRACE) +=3D inat.o insn.o +endif + +$(OUTPUT)util/intel-pt-decoder/inat.o: $(srctree)/tools/arch/x86/lib/inat.= c $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(call rule_mkdir) $(call if_changed_dep,cc_o_c) =20 -CFLAGS_intel-pt-insn-decoder.o +=3D -I$(OUTPUT)util/intel-pt-decoder +CFLAGS_inat.o +=3D -I$(OUTPUT)util/intel-pt-decoder + +$(OUTPUT)util/intel-pt-decoder/insn.o: $(srctree)/tools/arch/x86/lib/insn.c + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) =20 ifeq ($(CC_NO_CLANG), 1) - CFLAGS_intel-pt-insn-decoder.o +=3D -Wno-override-init + CFLAGS_insn.o +=3D -Wno-override-init endif =20 -CFLAGS_intel-pt-insn-decoder.o +=3D -Wno-packed +CFLAGS_insn.o +=3D -Wno-packed diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c b/too= ls/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c index 47cf35799a4d..8fabddc1c0da 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c @@ -11,9 +11,6 @@ #include #include "../../../arch/x86/include/asm/insn.h" =20 -#include "../../../arch/x86/lib/inat.c" -#include "../../../arch/x86/lib/insn.c" - #include "event.h" =20 #include "intel-pt-insn-decoder.h" diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trac= e-event-scripting.c index 2e9da0b089ef..8d71998a9ecd 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -272,11 +272,13 @@ void setup_perl_scripting(void) #endif #endif =20 -__weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused, +#if !defined(__i386__) && !defined(__x86_64__) +void arch_fetch_insn(struct perf_sample *sample __maybe_unused, struct thread *thread __maybe_unused, struct machine *machine __maybe_unused) { } +#endif =20 void script_fetch_insn(struct perf_sample *sample, struct thread *thread, struct machine *machine, bool native_arch) --=20 2.47.0.163.g1226f6d8fa-goog