From patchwork Sat Mar 8 00:31:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 354B1C282DE for ; Sat, 8 Mar 2025 00:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ivnbhuhI/ixgKyNuqtV9wf0AaXG2gqT9U4XDml1DXZU=; b=zPTVdwEsLf37airmKvMHVNEiq8 qcQjRRYpfa2T4216QcHgdQOcA3nM0mt+XOYm/ddCRxniExZr0Rr7kPRvCzgDxk5a3HYfBoaFQosoc ISjuyadaw8HkYJCQv50ZnJIgfEYPmYTvtBJBg8um1lkjfBAAT+3VGEzw0Pr10fV2KIQxGzgutBrrP 8x37w0tIb1c2nQbw0EoHV2wZrQhnb0uiBNJUMe5+9lQEt+o0kQeK33fN5TzbJeMumwvxCD0fm8caG c0V5DnrjwUTIvJqvOX1uVc+uO+hXyQDnW+isKVecAW+uU/WiI73U+gLYj90ezvwmJNq1vqAkpLuGL DDjk6Mqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiAA-0000000Fv2A-3PQH; Sat, 08 Mar 2025 00:35:34 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi6z-0000000FuBo-0ea8 for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:18 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e572cd106f7so3648822276.3 for ; Fri, 07 Mar 2025 16:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393935; x=1741998735; darn=lists.infradead.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ivnbhuhI/ixgKyNuqtV9wf0AaXG2gqT9U4XDml1DXZU=; b=1BpmE79w4/bcB4wtfAwSp3iymDXzzOYYIf3yO4Hdh/928CfAD0SGvjGIIkB3o7fdmt W+dX6YPVhiC1JQ63f51A3TF9bvBILPnvWteqvz23T/xPYXHeW8cLIsWc/lewMS2jpE55 8+/M0272e5PkKzvzAdRflrdWXyBb3eZUzXVQhIvVzZS9QoypHbhEt7EkwpTQlZN51+NR iCmQnVk7Cd3vcVaD2TMIJVsghVcPpvdw5XuTvu2O4rK63ZH8lnd0vvfFGYCGhYHLGye8 PypnR8P5Ixw6SiZVB/x3cH7svuOmXTCB9gapGPv+3I0xuj6TBjctFpjbYbrcJnN7Bb++ zo9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393935; x=1741998735; h=cc: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=ivnbhuhI/ixgKyNuqtV9wf0AaXG2gqT9U4XDml1DXZU=; b=qm3X2J6xeQBS9Xc4ad/zBfY+K9wzTe94vqqYAy+ibocgTjOmYsCa4vmPLLhUUWj8OP Eip8iZtqVmfU/2/SUi4RcTDuAULJ0swI8oG0mq8iYuGaAnWSwhcfOohJgZUEoi194scm OHNrzsga/hu5/tPnUz+LXTDgeC88xZCWfyav/4gw/Um5e+luEem+zWUU9T2aBK6dr90n KxmnhdtV7y/aSFWZbeCAJYwMIB0LllQgNTdypS6Ep48F9mfJgd4Lk5v9FIdRBYIlWHx9 HOx2DMYBBLuYUxj+tKcMnYBU1hEhED6N0eRIkPrDfvyqOrJtQf/ACxoacHzSzbQfTjVO U32A== X-Forwarded-Encrypted: i=1; AJvYcCUYbH+xHcBjWNezMa4dC+SVEotE4QJ02b+rgHIZfwfrjtfaKBhQG0uIxW9EJBXYku+iZWmz97B1ONaz2CKC2ArW@lists.infradead.org X-Gm-Message-State: AOJu0YyCn7H/V6/+1bjd5OEA+mQUFg5Ch2jRNO1rIR/l5D1EYsr5v5fE jfPTjDvET7KfHDHa8fZMhJXxgg70NctRJ49D5i2VTCdlh8Wn/dGWw3a/8QgmiLpXL2Cl1OD5jMf yBLdVdg== X-Google-Smtp-Source: AGHT+IG6YNEzBmSnRkSpppexP7sY3bjIUwdOpxoYGty73UlROUhquWw1r9gEA9sFFMJohI1jVlJGdzxY77PY X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:728a:0:b0:e60:96b9:bee8 with SMTP id 3f1490d57ef6-e635c1ecad7mr49692276.7.1741393934929; Fri, 07 Mar 2025 16:32:14 -0800 (PST) Date: Fri, 7 Mar 2025 16:31:59 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-2-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 01/11] perf dso: Move libunwind dso_data variables into ifdef From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann Cc: Arnaldo Carvalho de Melo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163217_193109_0E72B89E X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The variables elf_base_addr, debug_frame_offset, eh_frame_hdr_addr and eh_frame_hdr_offset are only accessed in unwind-libunwind-local.c which is conditionally built on having libunwind support. Make the variables conditional on libunwind support too. Reviewed-by: Arnaldo Carvalho de Melo Signed-off-by: Ian Rogers --- tools/perf/util/dso.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index bb8e8f444054..dfd763a0bd9d 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -154,10 +154,12 @@ struct dso_data { int status; u32 status_seen; u64 file_size; +#ifdef HAVE_LIBUNWIND_SUPPORT u64 elf_base_addr; u64 debug_frame_offset; u64 eh_frame_hdr_addr; u64 eh_frame_hdr_offset; +#endif }; struct dso_bpf_prog { From patchwork Sat Mar 8 00:32:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 114C2C282DE for ; Sat, 8 Mar 2025 00:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g+tZpNJTrBaubB35oLdUHzvX1yD5fDYk5lRfCYboZyg=; b=Jk1cGeLSWC5C4tVKV10eIr6Wi8 rQCIaZF5yQRik76V17Xod+06mh5x9n8RkO6ww8KiZNxMowfF2ItbsbD0cdeHO51Qc6m9odzSi45Tz dYaa6qjX9K41LbpNcrACqoN6uZu9oFJRM1gcBxatZ0720V2+4ZJxM2s6btul0PNHS86btmPwYmsk/ Oqg+fIyjSV1vGOrCnUmX0Qmy1/gAJkp8DsbOJ9CAnmqgC9gGx/Z1QwRDp6HlP3keT4KVPvHcpTEDN xXeXVZ8FCf51DoMCGfhXcsMj57iA5t6UMLEsx4eSXoq4y2axidPtrCpl5C83oxI4OwGWBnjLa30hU Y0AAxQDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiBm-0000000FvDd-0BSy; Sat, 08 Mar 2025 00:37:14 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi70-0000000FuCu-3Op8 for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:19 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f79c1cf49dso34851657b3.2 for ; Fri, 07 Mar 2025 16:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393937; x=1741998737; darn=lists.infradead.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g+tZpNJTrBaubB35oLdUHzvX1yD5fDYk5lRfCYboZyg=; b=1535k9q00sOX8V0y2wCGneW1s4d2D8gW2SUBpS8IYAkIzJ77jmqD7PLa1c6PNC72N3 FOLw5MknXbAyfi2ViM5yt1c7mRGBmxLWa6vFf+0Xi66GtYa5nzDcWhvp48+R/bBairng y/uRKK5wATSeqlYmiKYHtTRHB4h/LUJ+rY1Wnr2CS3dap3lea3g3Ck5K6zkCH3+zqARZ JeunOcU2EbgdP9oi/qogko3UYBmy257MaYUFh5b3C9k9mSnP/br+Oni++L0n0ECWvEE4 Dfz7cVbCAQ6rCQrSBf7EqirKcps8fmBPG9K6j9ZzQYL1LS/ROPPkT0t+JdlI1lPGKk1I Biiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393937; x=1741998737; h=cc: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=g+tZpNJTrBaubB35oLdUHzvX1yD5fDYk5lRfCYboZyg=; b=Sjx+yLIg0PayGgP6IdYZMVYWRbwOx1yakThgaktzF7AWOOLBrj+0F+uzTQN55Co0cQ fJGGUk1Dw2NVNnlGKc86rNUj6Yq/L+EkXh+aZq+pwtzpZ2ZtO/pylmpC/Cn+spqGJhKu ghHaWoIiA5JYOhokDH49T+D+Ud0HfENx9DhiGEVtayRKGnF7K+sUS5FjJ2a/E7b7ETfN qfDkHJQI0nwPMJkopXVwXO9l4OjWULNpjpT2LD1gZrCHiNCeg0cf4ub7Q1QnXUwIcnNv 7tivuc3u+kJrzVKyylGhFlsj9MBaBcL2iHeC+PrDgcRoX++vP2wI9KcGQeg8SU8JQx4u Uxhw== X-Forwarded-Encrypted: i=1; AJvYcCVOxa0Bg94oSzCssSqGuaqb5eqlwQTNqqNdnJYlqpF2RBYDdY35sBMA6ol/baG8zVm8Fy0soxtZ7RBzb6scTs7F@lists.infradead.org X-Gm-Message-State: AOJu0YydAe+XzbqNMG51qA3H2A6wMCNb7DZLRuE9jchKdkloblHh5m0/ 94VCYBkIlIP57D/RwifSsxm+gdqdh+8j3Y/RbeC2Qz2WfybclyoIjXAmPG+QSpvwzIn3O5GidEK kg2Bbtg== X-Google-Smtp-Source: AGHT+IG1pEkPT+xN4RZyrSvyAfvazAGpr/7rp7OJtguwoNBCqz20T1HbpF3aMd2bB+k03a5UXh+CfQdQ37mM X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a5b:f43:0:b0:e63:6c54:95e7 with SMTP id 3f1490d57ef6-e636c5498f0mr16239276.4.1741393937138; Fri, 07 Mar 2025 16:32:17 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:00 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-3-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 02/11] perf dso: kernel-doc for enum dso_binary_type From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann Cc: Arnaldo Carvalho de Melo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163218_847044_E0AB37D9 X-CRM114-Status: GOOD ( 13.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are many and non-obvious meanings to the dso_binary_type enum values. Add kernel-doc to speed interpretting their meanings. Acked-by: Arnaldo Carvalho de Melo Signed-off-by: Ian Rogers --- tools/perf/util/dso.h | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index dfd763a0bd9d..4aa8c3d36566 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -20,30 +20,83 @@ struct perf_env; #define DSO__NAME_KALLSYMS "[kernel.kallsyms]" #define DSO__NAME_KCORE "[kernel.kcore]" +/** + * enum dso_binary_type - The kind of DSO generally associated with a memory + * region (struct map). + */ enum dso_binary_type { + /** @DSO_BINARY_TYPE__KALLSYMS: Symbols from /proc/kallsyms file. */ DSO_BINARY_TYPE__KALLSYMS = 0, + /** @DSO_BINARY_TYPE__GUEST_KALLSYMS: Guest /proc/kallsyms file. */ DSO_BINARY_TYPE__GUEST_KALLSYMS, + /** @DSO_BINARY_TYPE__VMLINUX: Path to kernel /boot/vmlinux file. */ DSO_BINARY_TYPE__VMLINUX, + /** @DSO_BINARY_TYPE__GUEST_VMLINUX: Path to guest kernel /boot/vmlinux file. */ DSO_BINARY_TYPE__GUEST_VMLINUX, + /** @DSO_BINARY_TYPE__JAVA_JIT: Symbols from /tmp/perf.map file. */ DSO_BINARY_TYPE__JAVA_JIT, + /** + * @DSO_BINARY_TYPE__DEBUGLINK: Debug file readable from the file path + * in the .gnu_debuglink ELF section of the dso. + */ DSO_BINARY_TYPE__DEBUGLINK, + /** + * @DSO_BINARY_TYPE__BUILD_ID_CACHE: File named after buildid located in + * the buildid cache with an elf filename. + */ DSO_BINARY_TYPE__BUILD_ID_CACHE, + /** + * @DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO: File named after buildid + * located in the buildid cache with a debug filename. + */ DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__FEDORA_DEBUGINFO: Debug file in /usr/lib/debug + * with .debug suffix. + */ DSO_BINARY_TYPE__FEDORA_DEBUGINFO, + /** @DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: Debug file in /usr/lib/debug. */ DSO_BINARY_TYPE__UBUNTU_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO: dso__long_name debuginfo + * file in /usr/lib/debug/lib rather than the expected + * /usr/lib/debug/usr/lib. + */ DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__BUILDID_DEBUGINFO: File named after buildid located + * in /usr/lib/debug/.build-id/. + */ DSO_BINARY_TYPE__BUILDID_DEBUGINFO, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_DSO: A regular executable/shared-object file. */ DSO_BINARY_TYPE__SYSTEM_PATH_DSO, + /** @DSO_BINARY_TYPE__GUEST_KMODULE: Guest kernel module .ko file. */ DSO_BINARY_TYPE__GUEST_KMODULE, + /** @DSO_BINARY_TYPE__GUEST_KMODULE_COMP: Guest kernel module .ko.gz file. */ DSO_BINARY_TYPE__GUEST_KMODULE_COMP, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE: Kernel module .ko file. */ DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP: Kernel module .ko.gz file. */ DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP, + /** @DSO_BINARY_TYPE__KCORE: /proc/kcore file. */ DSO_BINARY_TYPE__KCORE, + /** @DSO_BINARY_TYPE__GUEST_KCORE: Guest /proc/kcore file. */ DSO_BINARY_TYPE__GUEST_KCORE, + /** + * @DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO: Openembedded/Yocto -dbg + * package debug info. + */ DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO, + /** @DSO_BINARY_TYPE__BPF_PROG_INFO: jitted BPF code. */ DSO_BINARY_TYPE__BPF_PROG_INFO, + /** @DSO_BINARY_TYPE__BPF_IMAGE: jitted BPF trampoline or dispatcher code. */ DSO_BINARY_TYPE__BPF_IMAGE, + /** + * @DSO_BINARY_TYPE__OOL: out of line code such as kprobe-replaced + * instructions or optimized kprobes or ftrace trampolines. + */ DSO_BINARY_TYPE__OOL, + /** @DSO_BINARY_TYPE__NOT_FOUND: Unknown DSO kind. */ DSO_BINARY_TYPE__NOT_FOUND, }; From patchwork Sat Mar 8 00:32:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B591C28B25 for ; Sat, 8 Mar 2025 00:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AqadS05IiqX+oCLnfCRhPMkFwGiSn/3QeC8TU0ql0EM=; b=PGWNuePZSG5OztlD3G4aK/rgGr ezit/QdYaloArp3gtJOddJYzldD8Oj9DFqWmOTsXS2kjhGBy6iIwI4R28wxyvp6MGwf2HGX5ZEAP4 Zbo4/yFH2BJq9Ic04/T2OXO5hhf06gvuHMRcLQDnOcVcpvLOFs8O+wKjgOCw5JjeuJImoeos/pBYX 2fpmNFUw35qMAKutqN/ICBNyZyPeaIB4eL4Qwgl3HzqwP8+J7Vn9Lko24BpuLnToph7RTqpM1ir/q 2hhWdu+qgxL1QLga57WCzgPil3jqbASv2IanRIZUz5MdsI3Ju+5UNbHZfSyttCtIEtRnWa8oi9BRO 1XwzIstw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiDN-0000000FvUV-1wTe; Sat, 08 Mar 2025 00:38:53 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi72-0000000FuEJ-3287 for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:22 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e634d544bb4so3520838276.2 for ; Fri, 07 Mar 2025 16:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393939; x=1741998739; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AqadS05IiqX+oCLnfCRhPMkFwGiSn/3QeC8TU0ql0EM=; b=MVOAHcGBQfBtzLt5YhWg7opvLCn9Pp0KE87MTOklkmp2q3MZKH4HQL/G0jePdmqfRY tGqtYPMtFdcYrIVDkQb+lGx2RgXDRn1bUbFN9zlV6Kn/03n0Lt0+aCRw+bqiLXzKfC3y /M939lUzJryHq77pyJl74r17oL9GwFT9H1sIu2tEVinKCvrJATVW3Bt6opNVTUB+Qhcd gB3b1bY3A5vnGedLH1jer9LT/barU614eZPFKLbAlSwWQpfbmS6CRYRP7OQueNCEfVvz dVSfCNxqdUuDpWYWMCjCFTwPQncpdZ/jtLMBrJHlARw6zXtPF0qkzG51dfu7ed8YxX9q J1yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393939; x=1741998739; 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=AqadS05IiqX+oCLnfCRhPMkFwGiSn/3QeC8TU0ql0EM=; b=lzCwy8TtYhXN1W4S6dwjEDI/AJB9hpZS5a98KFpa7MC6xmqmO0w+ps4NCaXVcdVqws rrsxgH/5zkMucGw1ZaBQ37BwE8kcguWnErzZo2e9/erE3wpgnp6AgvMwqgnw0ipalki1 6O73egld/e4JaJ63r6ufOXX1jWp/xVACpSdAeE1W0ZB6huVn7rGATLIgPzyEDt5LcT6x lmtMRZ20b/s3Qexrpz05ygoPJOYIxPkqJDmBdO461+OVTnbYf6fE2Yj/9xhWaexCXA5J 44chFOFIShxinxVgj0HBfnHWKHiOznAVdINnlm8InkWz2AGgyWHgd0R4ahABxnbY3kQX EPvg== X-Forwarded-Encrypted: i=1; AJvYcCVtj2F8dce0te7WLC0uRD4KsswUhQixVVww3so2e6Fy/rIZxoNcUNkDSWQGedGMJFgkSeaZ1pqfY4HRD7d83SFb@lists.infradead.org X-Gm-Message-State: AOJu0YxJ1Li5rYJj0iEo3HogdgqFtX0LJ5GNCDUXzfsgGddwpvp0zBI7 Rl1Ubt6863U9YJflc8o0SsbAS/wxFwNEgUQhK/8yfFDNNFYghoJSKa7zMNfvEghF0F5xJN8q0Wa QqZmHxQ== X-Google-Smtp-Source: AGHT+IHvE48c2lvHpgGakYnTePOoQVgbDE1mMquuzMm7O2A08KHA2Pxg5d2h8LM5j4ifnJpwYuMHbeAlhWkm X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:ec0a:0:b0:e60:97d9:956 with SMTP id 3f1490d57ef6-e635c1123bbmr53201276.3.1741393939346; Fri, 07 Mar 2025 16:32:19 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:01 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-4-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 03/11] perf syscalltbl: Remove syscall_table.h From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163220_755831_D6519F82 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The definition of "static const char *const syscalltbl[] = {" is done in a generated syscalls_32.h or syscalls_64.h that is architecture dependent. In order to include the appropriate file a syscall_table.h is found via the perf include path and it includes the syscalls_32.h or syscalls_64.h as appropriate. To support having multiple syscall tables, one for 32-bit and one for 64-bit, or for different architectures, an include path cannot be used. Remove syscall_table.h because of this and inline what it does into syscalltbl.c. For architectures without a syscall_table.h this will cause a failure to include either syscalls_32.h or syscalls_64.h rather than a failure to include syscall_table.h. For architectures that only included one or other, the behavior matches BITS_PER_LONG as previously done on architectures supporting both syscalls_32.h and syscalls_64.h. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/arch/alpha/include/syscall_table.h | 2 -- tools/perf/arch/arc/include/syscall_table.h | 2 -- tools/perf/arch/arm/include/syscall_table.h | 2 -- tools/perf/arch/arm64/include/syscall_table.h | 8 -------- tools/perf/arch/csky/include/syscall_table.h | 2 -- tools/perf/arch/loongarch/include/syscall_table.h | 2 -- tools/perf/arch/mips/include/syscall_table.h | 2 -- tools/perf/arch/parisc/include/syscall_table.h | 8 -------- tools/perf/arch/powerpc/include/syscall_table.h | 8 -------- tools/perf/arch/riscv/include/syscall_table.h | 8 -------- tools/perf/arch/s390/include/syscall_table.h | 2 -- tools/perf/arch/sh/include/syscall_table.h | 2 -- tools/perf/arch/sparc/include/syscall_table.h | 8 -------- tools/perf/arch/x86/include/syscall_table.h | 8 -------- tools/perf/arch/xtensa/include/syscall_table.h | 2 -- tools/perf/util/syscalltbl.c | 8 +++++++- 16 files changed, 7 insertions(+), 67 deletions(-) delete mode 100644 tools/perf/arch/alpha/include/syscall_table.h delete mode 100644 tools/perf/arch/arc/include/syscall_table.h delete mode 100644 tools/perf/arch/arm/include/syscall_table.h delete mode 100644 tools/perf/arch/arm64/include/syscall_table.h delete mode 100644 tools/perf/arch/csky/include/syscall_table.h delete mode 100644 tools/perf/arch/loongarch/include/syscall_table.h delete mode 100644 tools/perf/arch/mips/include/syscall_table.h delete mode 100644 tools/perf/arch/parisc/include/syscall_table.h delete mode 100644 tools/perf/arch/powerpc/include/syscall_table.h delete mode 100644 tools/perf/arch/riscv/include/syscall_table.h delete mode 100644 tools/perf/arch/s390/include/syscall_table.h delete mode 100644 tools/perf/arch/sh/include/syscall_table.h delete mode 100644 tools/perf/arch/sparc/include/syscall_table.h delete mode 100644 tools/perf/arch/x86/include/syscall_table.h delete mode 100644 tools/perf/arch/xtensa/include/syscall_table.h diff --git a/tools/perf/arch/alpha/include/syscall_table.h b/tools/perf/arch/alpha/include/syscall_table.h deleted file mode 100644 index b53e31c15805..000000000000 --- a/tools/perf/arch/alpha/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/arc/include/syscall_table.h b/tools/perf/arch/arc/include/syscall_table.h deleted file mode 100644 index 4c942821662d..000000000000 --- a/tools/perf/arch/arc/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/arm/include/syscall_table.h b/tools/perf/arch/arm/include/syscall_table.h deleted file mode 100644 index 4c942821662d..000000000000 --- a/tools/perf/arch/arm/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/arm64/include/syscall_table.h b/tools/perf/arch/arm64/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/arm64/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/csky/include/syscall_table.h b/tools/perf/arch/csky/include/syscall_table.h deleted file mode 100644 index 4c942821662d..000000000000 --- a/tools/perf/arch/csky/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/loongarch/include/syscall_table.h b/tools/perf/arch/loongarch/include/syscall_table.h deleted file mode 100644 index 9d0646d3455c..000000000000 --- a/tools/perf/arch/loongarch/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/mips/include/syscall_table.h b/tools/perf/arch/mips/include/syscall_table.h deleted file mode 100644 index b53e31c15805..000000000000 --- a/tools/perf/arch/mips/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/parisc/include/syscall_table.h b/tools/perf/arch/parisc/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/parisc/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/powerpc/include/syscall_table.h b/tools/perf/arch/powerpc/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/powerpc/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/riscv/include/syscall_table.h b/tools/perf/arch/riscv/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/riscv/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/s390/include/syscall_table.h b/tools/perf/arch/s390/include/syscall_table.h deleted file mode 100644 index b53e31c15805..000000000000 --- a/tools/perf/arch/s390/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/sh/include/syscall_table.h b/tools/perf/arch/sh/include/syscall_table.h deleted file mode 100644 index 4c942821662d..000000000000 --- a/tools/perf/arch/sh/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/arch/sparc/include/syscall_table.h b/tools/perf/arch/sparc/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/sparc/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/x86/include/syscall_table.h b/tools/perf/arch/x86/include/syscall_table.h deleted file mode 100644 index 7ff51b783000..000000000000 --- a/tools/perf/arch/x86/include/syscall_table.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#if __BITS_PER_LONG == 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/xtensa/include/syscall_table.h b/tools/perf/arch/xtensa/include/syscall_table.h deleted file mode 100644 index 4c942821662d..000000000000 --- a/tools/perf/arch/xtensa/include/syscall_table.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index 928aca4cd6e9..2f76241494c8 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -7,13 +7,19 @@ #include "syscalltbl.h" #include +#include #include #include #include #include "string2.h" -#include +#if __BITS_PER_LONG == 64 + #include +#else + #include +#endif + const int syscalltbl_native_max_id = SYSCALLTBL_MAX_ID; static const char *const *syscalltbl_native = syscalltbl; From patchwork Sat Mar 8 00:32:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACB23C282DE for ; Sat, 8 Mar 2025 00:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TAhKsnqf/Wp2f2WfbkipSd7nOjZwLTYVF9Ek4E/oE+c=; b=b0WYWI4fZ3bacJ53Lxr/OyyZqC Hsx0A647wEyk5NjCYPb4Zt8jONd9ChZXGamDJV/KOF2GTKbDe5r7Ls0AdQCx39FbCPKJwoipp6WIh heHr8+SDPgTc1jkW5jWrO4/CJUJWdCV149Qz58eDTwDx/rqvnLSzh2aXmJdzq1CeFq718LY5d17Ca lrDN44NNQHEVktQk0UfAY5dkEOYztE/yWFYPxHO6HDbXUnajhehxt8iUfyPhaS9EWoTt7ei6k5OvB NtAkfKX8yXQsx5WK0xxeqLX/wSC8lLcvwj++QV++R/R2AI4eYgayuOtLuZk7a1zuqopzFj7GenYq8 uLk1TrTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiEy-0000000FvgJ-2zqJ; Sat, 08 Mar 2025 00:40:32 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi75-0000000FuFY-0oYT for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:24 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e572f6dee18so3668450276.0 for ; Fri, 07 Mar 2025 16:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393942; x=1741998742; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=TAhKsnqf/Wp2f2WfbkipSd7nOjZwLTYVF9Ek4E/oE+c=; b=J3tOoD+gNUY5Zg3srdeKrjgBSAS3q1Htq2WPCeZ+j0cs5TaOZEiopHQ9uBRfsXMUUC 1djC+ql8WAtjEpMrZX/q5AGE/FMlzmdLEGoV3Xog3txYRVRHSWsA6YqTiN1/+I8hT/7i Zz9eND2fyqWx7siH4+X3xqizkhwHvYC92BDLZCXh9gNHUYX4Zy1rr8Gxv0Slpbi7y/3M g9pP85ETKM4D50TLJNpVI1EvEaMvVpOjwBT8DsFFNl+xxHtX9ip0ByoJkD3fCV1lWIu9 Ow/2Lmzo15SVQ2BzDhggY2aJVQVrxL8C+zDatQtBdiXNZX10ZR3+Mu+1gBcrnP6QwldL ZWyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393942; x=1741998742; 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=TAhKsnqf/Wp2f2WfbkipSd7nOjZwLTYVF9Ek4E/oE+c=; b=An1s3p6ruLEN0eRImTx4rmiSiamsJTArFA+ZRYaIHuapKnwslrgumsGVlYihwHd8l6 RezVdV1KfNTUcre0dHjUiIrHkkKmTJQE5tava1oT5N1nbGmMNamTaVOXWu3HPEG4rnhD kvy6QFcOIK+F9Guo5EO1gdEJAybuLvnfK/11F5Qe9eKJ2T/wFeMQl2JV2BkqeA0cyBAg y70+XxgZCrobaobxEdCutPZq6Sj5fhVy38QA/pfOGSW6aWYDX02/LQps4aNvMA45sHid cf7cTuB9IKLVOZ6+neoNEI80v3EfMpRUK6epZOAW59PkL9f/rhlA6+UcfIo4c3F92djI nNUQ== X-Forwarded-Encrypted: i=1; AJvYcCWGEvt7yHLS6G/31QSayWRc8MDGUUMYzn9jHTy/AmEc8ghY90R+afl4P9D2RwOV56q2rinyaxjySPdBfmJ+RrV4@lists.infradead.org X-Gm-Message-State: AOJu0YxVIzlxTeNbbCsRwKumtxyQOMnsYZOLtRQToHbNUooQtsSNhBvS ADcXL/a9BAo42Xk4fDNf8SvC5Xjp00DFD+G+L+IdWkc9bKYILwoSOgK/26KMESy/2nXKIfPfzR4 mOKs+cQ== X-Google-Smtp-Source: AGHT+IHvMBwSpjV05SawdQeDnvO1NysXWTjbmEJ0nWK7el3XmxDMXs7tHdQwLWAKqgCphUNf5PaqFDEdB38d X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:310b:0:b0:e60:92c9:1b63 with SMTP id 3f1490d57ef6-e635bf15b12mr36961276.0.1741393941601; Fri, 07 Mar 2025 16:32:21 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:02 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-5-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 04/11] perf trace: Reorganize syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163223_236695_659FAEF8 X-CRM114-Status: GOOD ( 27.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Identify struct syscall information in the syscalls table by a machine type and syscall number, not just system call number. Having the machine type means that 32-bit system calls can be differentiated from 64-bit ones on a machine capable of both. Having a table for all machine types and all system call numbers would be too large, so maintain a sorted array of system calls as they are encountered. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 177 ++++++++++++++++++++++++------------- 1 file changed, 118 insertions(+), 59 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 092c5f6404ba..f7d035dc0e00 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -66,6 +66,7 @@ #include "syscalltbl.h" #include "../perf.h" #include "trace_augment.h" +#include "dwarf-regs.h" #include #include @@ -86,6 +87,7 @@ #include #include +#include #ifdef HAVE_LIBTRACEEVENT #include @@ -149,7 +151,10 @@ struct trace { struct perf_tool tool; struct syscalltbl *sctbl; struct { + /** Sorted sycall numbers used by the trace. */ struct syscall *table; + /** Size of table. */ + size_t table_size; struct { struct evsel *sys_enter, *sys_exit, @@ -1454,22 +1459,37 @@ static const struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias) return __syscall_fmt__find_by_alias(syscall_fmts, nmemb, alias); } -/* - * is_exit: is this "exit" or "exit_group"? - * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. - * args_size: sum of the sizes of the syscall arguments, anything after that is augmented stuff: pathname for openat, etc. - * nonexistent: Just a hole in the syscall table, syscall id not allocated +/** + * struct syscall */ struct syscall { + /** @e_machine: The ELF machine associated with the entry. */ + int e_machine; + /** @id: id value from the tracepoint, the system call number. */ + int id; struct tep_event *tp_format; int nr_args; + /** + * @args_size: sum of the sizes of the syscall arguments, anything + * after that is augmented stuff: pathname for openat, etc. + */ + int args_size; struct { struct bpf_program *sys_enter, *sys_exit; } bpf_prog; + /** @is_exit: is this "exit" or "exit_group"? */ bool is_exit; + /** + * @is_open: is this "open" or "openat"? To associate the fd returned in + * sys_exit with the pathname in sys_enter. + */ bool is_open; + /** + * @nonexistent: Name lookup failed. Just a hole in the syscall table, + * syscall id not allocated. + */ bool nonexistent; bool use_btf; struct tep_format_field *args; @@ -2107,22 +2127,21 @@ static int syscall__set_arg_fmts(struct syscall *sc) return 0; } -static int trace__read_syscall_info(struct trace *trace, int id) +static int syscall__read_info(struct syscall *sc, struct trace *trace) { char tp_name[128]; - struct syscall *sc; - const char *name = syscalltbl__name(trace->sctbl, id); + const char *name; int err; - if (trace->syscalls.table == NULL) { - trace->syscalls.table = calloc(trace->sctbl->syscalls.max_id + 1, sizeof(*sc)); - if (trace->syscalls.table == NULL) - return -ENOMEM; - } - sc = trace->syscalls.table + id; if (sc->nonexistent) return -EEXIST; + if (sc->name) { + /* Info already read. */ + return 0; + } + + name = syscalltbl__name(trace->sctbl, sc->id); if (name == NULL) { sc->nonexistent = true; return -EEXIST; @@ -2145,15 +2164,16 @@ static int trace__read_syscall_info(struct trace *trace, int id) */ if (IS_ERR(sc->tp_format)) { sc->nonexistent = true; - return PTR_ERR(sc->tp_format); + err = PTR_ERR(sc->tp_format); + sc->tp_format = NULL; + return err; } /* * The tracepoint format contains __syscall_nr field, so it's one more * than the actual number of syscall arguments. */ - if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? - RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields - 1)) + if (syscall__alloc_arg_fmts(sc, sc->tp_format->format.nr_fields - 1)) return -ENOMEM; sc->args = sc->tp_format->format.fields; @@ -2442,13 +2462,67 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, return printed; } +static void syscall__init(struct syscall *sc, int e_machine, int id) +{ + memset(sc, 0, sizeof(*sc)); + sc->e_machine = e_machine; + sc->id = id; +} + +static void syscall__exit(struct syscall *sc) +{ + if (!sc) + return; + + zfree(&sc->arg_fmt); +} + +static int syscall__cmp(const void *va, const void *vb) +{ + const struct syscall *a = va, *b = vb; + + if (a->e_machine != b->e_machine) + return a->e_machine - b->e_machine; + + return a->id - b->id; +} + +static struct syscall *trace__find_syscall(struct trace *trace, int e_machine, int id) +{ + struct syscall key = { + .e_machine = e_machine, + .id = id, + }; + struct syscall *sc, *tmp; + + sc = bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, + sizeof(struct syscall), syscall__cmp); + if (sc) + return sc; + + tmp = reallocarray(trace->syscalls.table, trace->syscalls.table_size + 1, + sizeof(struct syscall)); + if (!tmp) + return NULL; + + trace->syscalls.table = tmp; + sc = &trace->syscalls.table[trace->syscalls.table_size++]; + syscall__init(sc, e_machine, id); + qsort(trace->syscalls.table, trace->syscalls.table_size, sizeof(struct syscall), + syscall__cmp); + sc = bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, + sizeof(struct syscall), syscall__cmp); + return sc; +} + typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel, union perf_event *event, struct perf_sample *sample); -static struct syscall *trace__syscall_info(struct trace *trace, - struct evsel *evsel, int id) +static struct syscall *trace__syscall_info(struct trace *trace, struct evsel *evsel, + int e_machine, int id) { + struct syscall *sc; int err = 0; if (id < 0) { @@ -2473,28 +2547,20 @@ static struct syscall *trace__syscall_info(struct trace *trace, err = -EINVAL; - if (id > trace->sctbl->syscalls.max_id) { - goto out_cant_read; - } - - if ((trace->syscalls.table == NULL || trace->syscalls.table[id].name == NULL) && - (err = trace__read_syscall_info(trace, id)) != 0) - goto out_cant_read; + sc = trace__find_syscall(trace, e_machine, id); + if (sc) + err = syscall__read_info(sc, trace); - if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) - goto out_cant_read; - - return &trace->syscalls.table[id]; - -out_cant_read: - if (verbose > 0) { + if (err && verbose > 0) { char sbuf[STRERR_BUFSIZE]; - fprintf(trace->output, "Problems reading syscall %d: %d (%s)", id, -err, str_error_r(-err, sbuf, sizeof(sbuf))); - if (id <= trace->sctbl->syscalls.max_id && trace->syscalls.table[id].name != NULL) - fprintf(trace->output, "(%s)", trace->syscalls.table[id].name); + + fprintf(trace->output, "Problems reading syscall %d: %d (%s)", id, -err, + str_error_r(-err, sbuf, sizeof(sbuf))); + if (sc && sc->name) + fprintf(trace->output, "(%s)", sc->name); fputs(" information\n", trace->output); } - return NULL; + return err ? NULL : sc; } struct syscall_stats { @@ -2643,14 +2709,6 @@ static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sam return NULL; } -static void syscall__exit(struct syscall *sc) -{ - if (!sc) - return; - - zfree(&sc->arg_fmt); -} - static int trace__sys_enter(struct trace *trace, struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) @@ -2662,7 +2720,7 @@ static int trace__sys_enter(struct trace *trace, struct evsel *evsel, int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; int augmented_args_size = 0; void *augmented_args = NULL; - struct syscall *sc = trace__syscall_info(trace, evsel, id); + struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; if (sc == NULL) @@ -2736,7 +2794,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; - struct syscall *sc = trace__syscall_info(trace, evsel, id); + struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args = NULL; int augmented_args_size; @@ -2811,7 +2869,7 @@ static int trace__sys_exit(struct trace *trace, struct evsel *evsel, struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0; int alignment = trace->args_alignment; - struct syscall *sc = trace__syscall_info(trace, evsel, id); + struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; if (sc == NULL) @@ -3164,7 +3222,7 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel, if (evsel == trace->syscalls.events.bpf_output) { int id = perf_evsel__sc_tp_uint(evsel, id, sample); - struct syscall *sc = trace__syscall_info(trace, evsel, id); + struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -3673,7 +3731,7 @@ static struct bpf_program *trace__find_syscall_bpf_prog(struct trace *trace, str static void trace__init_syscall_bpf_progs(struct trace *trace, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, id); + struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); if (sc == NULL) return; @@ -3684,20 +3742,20 @@ static void trace__init_syscall_bpf_progs(struct trace *trace, int id) static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, id); + struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(trace->skel->progs.syscall_unaugmented); } static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, id); + struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trace->skel->progs.syscall_unaugmented); } static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, unsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc = trace__syscall_info(trace, NULL, key); + struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment = false; @@ -3795,7 +3853,7 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace try_to_find_pair: for (int i = 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int id = syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair = trace__syscall_info(trace, NULL, id); + struct syscall *pair = trace__syscall_info(trace, NULL, EM_HOST, id); struct bpf_program *pair_prog; bool is_candidate = false; @@ -3945,7 +4003,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) */ for (int i = 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int key = syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc = trace__syscall_info(trace, NULL, key); + struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, key); struct bpf_program *pair_prog; int prog_fd; @@ -4761,7 +4819,10 @@ static size_t syscall__dump_stats(struct trace *trace, FILE *fp, pct = avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /= NSEC_PER_MSEC; - sc = &trace->syscalls.table[entry->syscall]; + sc = trace__syscall_info(trace, /*evsel=*/NULL, EM_HOST, entry->syscall); + if (!sc) + continue; + printed += fprintf(fp, " %-15s", sc->name); printed += fprintf(fp, " %8" PRIu64 " %6" PRIu64 " %9.3f %9.3f %9.3f", n, stats->nr_failures, entry->msecs, min, avg); @@ -5218,12 +5279,10 @@ static int trace__config(const char *var, const char *value, void *arg) static void trace__exit(struct trace *trace) { - int i; - strlist__delete(trace->ev_qualifier); zfree(&trace->ev_qualifier_ids.entries); if (trace->syscalls.table) { - for (i = 0; i <= trace->sctbl->syscalls.max_id; i++) + for (size_t i = 0; i < trace->syscalls.table_size; i++) syscall__exit(&trace->syscalls.table[i]); zfree(&trace->syscalls.table); } From patchwork Sat Mar 8 00:32:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F484C282DE for ; Sat, 8 Mar 2025 00:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wvyYpWfQBWv5IuHUDwA4d3/6bckVC4Sq+TPY4GnHJzI=; b=vxYPUqvfrrQR2ty3HNKRpppniH 0z1/nzoFDr6cymBUBK3Oy3l416OL1lijGxyC+EZn+vLdgRc5vDn9ylvUQHVlm7Ar+04hFDoO/P6uV A/dkvjZGc6AP5nV2l8NA5DrkRYWvZJIltw1ihSHd44XU61IshxdAtHQqT+Fl7fEOaDceRamcbdzyD aO/m/DwIrvO8sJL001HJxsgU+N5txELVJtgtCz9TxtaNi1fkfrVK0J8EieS+Dy/WKdeTnKu4mItzj GPHF4EbB4Wpv9Lk6Xf7fiNaxgYx/l2KF+JvcDRIFmgneTAFcP0VbVB+wFsIFUjtQLYNZ63i5xDFzK qLgf8nMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiGZ-0000000Fvws-0HHF; Sat, 08 Mar 2025 00:42:11 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi77-0000000FuH0-3MfL for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:27 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e549c458692so3473515276.2 for ; Fri, 07 Mar 2025 16:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393944; x=1741998744; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wvyYpWfQBWv5IuHUDwA4d3/6bckVC4Sq+TPY4GnHJzI=; b=JNYu8mGqyXlR/qY2bN+8aU7G58Oaq1AlRBeMRoM1T1Tzv3wurKflBr88Lyi97enpVQ Sb3gwHoQeoSIR+b14xKouthukbvkmcsyupluAlwZnQ452t32gZAICsMPql4ri9PIaiXt nMNHKMZTy9+HBxvsmkJqo6Jler++d9hTQf4+/KHrMRX/NPgBTd68kTZyDuCXwMJr+zWX NHdM0Yj30ef600zkt7QJx0Nb/VEdaGI9BKhwrWQpm/pFb0kH9XCXBsN2ic09OkJ7ICh5 1vgHjejd/6Rwqfq/RvbUNsdVzveJzllWAKMYjuXyfYqB+IdAINt7tsFEH8gS4PTmqo2K 3XdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393944; x=1741998744; 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=wvyYpWfQBWv5IuHUDwA4d3/6bckVC4Sq+TPY4GnHJzI=; b=uT/CQSG9/e+ZGBlqm3bEgUGKRnTjmi5YssZiGNkQkGdqKRU6Ipc0N2N6wCoGEr8AzD 8qcDKnhhPLapXQZKQ7uUWjAeUWd2+MWDNUZCZzAaVIPj0fKcAIEpZsmaBemhZKb0Ev3M V8xhFPnq6G98d8Eh4rMswXg3agDGUHvhID2Jc1feq1f3eE/DqRvQG6HhkfaAFbsVfRAB KpM7Z+BlZIb+kNW1s1FX2atVCOucXu/giMLlzP+0TcW0kZSQwE2z5kGor4c4MZgkx24T MMSm7UYmggp17FA8ZVIzXRAwplwjEz8//VY+IdnQcG4w/zfJWsUXxAHpH7jKAHeBjDo/ P4hg== X-Forwarded-Encrypted: i=1; AJvYcCWr9W7LnEyH0LluaChPUnTpYAQWdHojbU2o1r00uoef5Prp0VYSRTNm+AmZHrvc/jNkYjTOaoQL6y9I72ZhL3sA@lists.infradead.org X-Gm-Message-State: AOJu0YzZ6lu39njKoA3qKnmEqcoIoY6AXPEBdokiB1OBb60XskD+jkT8 UrCjGPJBxA5indWh0Cuw+dfRjVLBnBXSzhKRTxh/uqRHIBWEl2XWFPRAfzmD+ZplgubwCCWPkYN AE9iqyw== X-Google-Smtp-Source: AGHT+IEKZNcz5hrinHghqu0DgvrJqqW2FO24LmYZKjAoJRgt8y8Elu8cxdBvFeBxR6cwws4gUjfii/QNmN7v X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:6987:0:b0:e5e:1554:41a4 with SMTP id 3f1490d57ef6-e635c1db8bfmr392544276.6.1741393943920; Fri, 07 Mar 2025 16:32:23 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:03 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-6-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 05/11] perf syscalltbl: Remove struct syscalltbl From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163225_851259_C2314CF6 X-CRM114-Status: GOOD ( 28.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The syscalltbl held entries of system call name and number pairs, generated from a native syscalltbl at start up. As there are gaps in the system call number there is a notion of index into the table. Going forward we want the system call table to be identifiable by a machine type, for example, i386 vs x86-64. Change the interface to the syscalltbl so (1) a (currently unused machine type of EM_HOST) is passed (2) the index to syscall number and system call name mapping is computed at build time. Two tables are used for this, an array of system call number to name, an array of system call numbers sorted by the system call name. The sorted array doesn't store strings in part to save memory and relocations. The index notion is carried forward and is an index into the sorted array of system call numbers, the data structures are opaque (held only in syscalltbl.c), and so the number of indices for a machine type is exposed as a new API. The arrays are computed in the syscalltbl.sh script and so no start-up time computation and storage is necessary. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 106 +++++++++++++++++------------ tools/perf/scripts/syscalltbl.sh | 36 ++++------ tools/perf/util/syscalltbl.c | 113 ++++++++++--------------------- tools/perf/util/syscalltbl.h | 22 ++---- 4 files changed, 117 insertions(+), 160 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f7d035dc0e00..cfc8cb8cbef8 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -149,7 +149,6 @@ enum summary_mode { struct trace { struct perf_tool tool; - struct syscalltbl *sctbl; struct { /** Sorted sycall numbers used by the trace. */ struct syscall *table; @@ -188,6 +187,14 @@ struct trace { pid_t *entries; struct bpf_map *map; } filter_pids; + /* + * TODO: The map is from an ID (aka system call number) to struct + * syscall_stats. If there is >1 e_machine, such as i386 and x86-64 + * processes, then the stats here will gather wrong the statistics for + * the non EM_HOST system calls. A fix would be to add the e_machine + * into the key, but this would make the code inconsistent with the + * per-thread version. + */ struct hashmap *syscall_stats; double duration_filter; double runtime_ms; @@ -2141,7 +2148,7 @@ static int syscall__read_info(struct syscall *sc, struct trace *trace) return 0; } - name = syscalltbl__name(trace->sctbl, sc->id); + name = syscalltbl__name(sc->e_machine, sc->id); if (name == NULL) { sc->nonexistent = true; return -EEXIST; @@ -2241,10 +2248,14 @@ static int trace__validate_ev_qualifier(struct trace *trace) strlist__for_each_entry(pos, trace->ev_qualifier) { const char *sc = pos->s; - int id = syscalltbl__id(trace->sctbl, sc), match_next = -1; + /* + * TODO: Assume more than the validation/warnings are all for + * the same binary type as perf. + */ + int id = syscalltbl__id(EM_HOST, sc), match_next = -1; if (id < 0) { - id = syscalltbl__strglobmatch_first(trace->sctbl, sc, &match_next); + id = syscalltbl__strglobmatch_first(EM_HOST, sc, &match_next); if (id >= 0) goto matches; @@ -2264,7 +2275,7 @@ static int trace__validate_ev_qualifier(struct trace *trace) continue; while (1) { - id = syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next); + id = syscalltbl__strglobmatch_next(EM_HOST, sc, &match_next); if (id < 0) break; if (nr_allocated == nr_used) { @@ -2720,6 +2731,7 @@ static int trace__sys_enter(struct trace *trace, struct evsel *evsel, int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; int augmented_args_size = 0; void *augmented_args = NULL; + /* TODO: get e_machine from thread. */ struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; @@ -2794,6 +2806,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; + /* TODO: get e_machine from thread. */ struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args = NULL; @@ -2869,6 +2882,7 @@ static int trace__sys_exit(struct trace *trace, struct evsel *evsel, struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0; int alignment = trace->args_alignment; + /* TODO: get e_machine from thread. */ struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; @@ -3222,6 +3236,7 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel, if (evsel == trace->syscalls.events.bpf_output) { int id = perf_evsel__sc_tp_uint(evsel, id, sample); + /* TODO: get e_machine from thread. */ struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); if (sc) { @@ -3729,9 +3744,9 @@ static struct bpf_program *trace__find_syscall_bpf_prog(struct trace *trace, str return trace->skel->progs.syscall_unaugmented; } -static void trace__init_syscall_bpf_progs(struct trace *trace, int id) +static void trace__init_syscall_bpf_progs(struct trace *trace, int e_machine, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, id); if (sc == NULL) return; @@ -3740,22 +3755,22 @@ static void trace__init_syscall_bpf_progs(struct trace *trace, int id) sc->bpf_prog.sys_exit = trace__find_syscall_bpf_prog(trace, sc, sc->fmt ? sc->fmt->bpf_prog_name.sys_exit : NULL, "exit"); } -static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int id) +static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int e_machine, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(trace->skel->progs.syscall_unaugmented); } -static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) +static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int e_machine, int id) { - struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trace->skel->progs.syscall_unaugmented); } -static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, unsigned int *beauty_array) +static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int e_machine, int key, unsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, key); + struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment = false; @@ -3851,9 +3866,9 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace return NULL; try_to_find_pair: - for (int i = 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int id = syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair = trace__syscall_info(trace, NULL, EM_HOST, id); + for (int i = 0, num_idx = syscalltbl__num_idx(sc->e_machine); i < num_idx; ++i) { + int id = syscalltbl__id_at_idx(sc->e_machine, i); + struct syscall *pair = trace__syscall_info(trace, NULL, sc->e_machine, id); struct bpf_program *pair_prog; bool is_candidate = false; @@ -3937,7 +3952,7 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace return NULL; } -static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) +static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace, int e_machine) { int map_enter_fd = bpf_map__fd(trace->skel->maps.syscalls_sys_enter); int map_exit_fd = bpf_map__fd(trace->skel->maps.syscalls_sys_exit); @@ -3945,27 +3960,27 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) int err = 0; unsigned int beauty_array[6]; - for (int i = 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int prog_fd, key = syscalltbl__id_at_idx(trace->sctbl, i); + for (int i = 0, num_idx = syscalltbl__num_idx(e_machine); i < num_idx; ++i) { + int prog_fd, key = syscalltbl__id_at_idx(e_machine, i); if (!trace__syscall_enabled(trace, key)) continue; - trace__init_syscall_bpf_progs(trace, key); + trace__init_syscall_bpf_progs(trace, e_machine, key); // It'll get at least the "!raw_syscalls:unaugmented" - prog_fd = trace__bpf_prog_sys_enter_fd(trace, key); + prog_fd = trace__bpf_prog_sys_enter_fd(trace, e_machine, key); err = bpf_map_update_elem(map_enter_fd, &key, &prog_fd, BPF_ANY); if (err) break; - prog_fd = trace__bpf_prog_sys_exit_fd(trace, key); + prog_fd = trace__bpf_prog_sys_exit_fd(trace, e_machine, key); err = bpf_map_update_elem(map_exit_fd, &key, &prog_fd, BPF_ANY); if (err) break; /* use beauty_map to tell BPF how many bytes to collect, set beauty_map's value here */ memset(beauty_array, 0, sizeof(beauty_array)); - err = trace__bpf_sys_enter_beauty_map(trace, key, (unsigned int *)beauty_array); + err = trace__bpf_sys_enter_beauty_map(trace, e_machine, key, (unsigned int *)beauty_array); if (err) continue; err = bpf_map_update_elem(beauty_map_fd, &key, beauty_array, BPF_ANY); @@ -4001,9 +4016,9 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) * first and second arg (this one on the raw_syscalls:sys_exit prog * array tail call, then that one will be used. */ - for (int i = 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int key = syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc = trace__syscall_info(trace, NULL, EM_HOST, key); + for (int i = 0, num_idx = syscalltbl__num_idx(e_machine); i < num_idx; ++i) { + int key = syscalltbl__id_at_idx(e_machine, i); + struct syscall *sc = trace__syscall_info(trace, NULL, e_machine, key); struct bpf_program *pair_prog; int prog_fd; @@ -4449,8 +4464,13 @@ static int trace__run(struct trace *trace, int argc, const char **argv) goto out_error_mem; #ifdef HAVE_BPF_SKEL - if (trace->skel && trace->skel->progs.sys_enter) - trace__init_syscalls_bpf_prog_array_maps(trace); + if (trace->skel && trace->skel->progs.sys_enter) { + /* + * TODO: Initialize for all host binary machine types, not just + * those matching the perf binary. + */ + trace__init_syscalls_bpf_prog_array_maps(trace, EM_HOST); + } #endif if (trace->ev_qualifier_ids.nr > 0) { @@ -4475,7 +4495,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) * So just disable this beautifier (SCA_FD, SCA_FDAT) when 'close' is * not in use. */ - trace->fd_path_disabled = !trace__syscall_enabled(trace, syscalltbl__id(trace->sctbl, "close")); + /* TODO: support for more than just perf binary machine type close. */ + trace->fd_path_disabled = !trace__syscall_enabled(trace, syscalltbl__id(EM_HOST, "close")); err = trace__expand_filters(trace, &evsel); if (err) @@ -4788,7 +4809,7 @@ static struct syscall_entry *syscall__sort_stats(struct hashmap *syscall_stats) return entry; } -static size_t syscall__dump_stats(struct trace *trace, FILE *fp, +static size_t syscall__dump_stats(struct trace *trace, int e_machine, FILE *fp, struct hashmap *syscall_stats) { size_t printed = 0; @@ -4819,7 +4840,7 @@ static size_t syscall__dump_stats(struct trace *trace, FILE *fp, pct = avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /= NSEC_PER_MSEC; - sc = trace__syscall_info(trace, /*evsel=*/NULL, EM_HOST, entry->syscall); + sc = trace__syscall_info(trace, /*evsel=*/NULL, e_machine, entry->syscall); if (!sc) continue; @@ -4846,14 +4867,14 @@ static size_t syscall__dump_stats(struct trace *trace, FILE *fp, } static size_t thread__dump_stats(struct thread_trace *ttrace, - struct trace *trace, FILE *fp) + struct trace *trace, int e_machine, FILE *fp) { - return syscall__dump_stats(trace, fp, ttrace->syscall_stats); + return syscall__dump_stats(trace, e_machine, fp, ttrace->syscall_stats); } -static size_t system__dump_stats(struct trace *trace, FILE *fp) +static size_t system__dump_stats(struct trace *trace, int e_machine, FILE *fp) { - return syscall__dump_stats(trace, fp, trace->syscall_stats); + return syscall__dump_stats(trace, e_machine, fp, trace->syscall_stats); } static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trace *trace) @@ -4879,7 +4900,8 @@ static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trac else if (fputc('\n', fp) != EOF) ++printed; - printed += thread__dump_stats(ttrace, trace, fp); + /* TODO: get e_machine from thread. */ + printed += thread__dump_stats(ttrace, trace, EM_HOST, fp); return printed; } @@ -4940,7 +4962,8 @@ static size_t trace__fprintf_total_summary(struct trace *trace, FILE *fp) else if (fputc('\n', fp) != EOF) ++printed; - printed += system__dump_stats(trace, fp); + /* TODO: get all system e_machines. */ + printed += system__dump_stats(trace, EM_HOST, fp); return printed; } @@ -5132,8 +5155,9 @@ static int trace__parse_events_option(const struct option *opt, const char *str, *sep = '\0'; list = 0; - if (syscalltbl__id(trace->sctbl, s) >= 0 || - syscalltbl__strglobmatch_first(trace->sctbl, s, &idx) >= 0) { + /* TODO: support for more than just perf binary machine type syscalls. */ + if (syscalltbl__id(EM_HOST, s) >= 0 || + syscalltbl__strglobmatch_first(EM_HOST, s, &idx) >= 0) { list = 1; goto do_concat; } @@ -5286,7 +5310,6 @@ static void trace__exit(struct trace *trace) syscall__exit(&trace->syscalls.table[i]); zfree(&trace->syscalls.table); } - syscalltbl__delete(trace->sctbl); zfree(&trace->perfconfig_events); } @@ -5435,9 +5458,8 @@ int cmd_trace(int argc, const char **argv) sigaction(SIGCHLD, &sigchld_act, NULL); trace.evlist = evlist__new(); - trace.sctbl = syscalltbl__new(); - if (trace.evlist == NULL || trace.sctbl == NULL) { + if (trace.evlist == NULL) { pr_err("Not enough memory to run!\n"); err = -ENOMEM; goto out; diff --git a/tools/perf/scripts/syscalltbl.sh b/tools/perf/scripts/syscalltbl.sh index 1ce0d5aa8b50..a39b3013b103 100755 --- a/tools/perf/scripts/syscalltbl.sh +++ b/tools/perf/scripts/syscalltbl.sh @@ -50,37 +50,27 @@ fi infile="$1" outfile="$2" -nxt=0 - -syscall_macro() { - nr="$1" - name="$2" - - echo " [$nr] = \"$name\"," -} - -emit() { - nr="$1" - entry="$2" - - syscall_macro "$nr" "$entry" -} - -echo "static const char *const syscalltbl[] = {" > $outfile - sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table -max_nr=0 +echo "static const char *const syscall_num_to_name[] = {" > $outfile # the params are: nr abi name entry compat # use _ for intentionally unused variables according to SC2034 while read nr _ name _ _; do - emit "$nr" "$name" >> $outfile - max_nr=$nr + echo " [$nr] = \"$name\"," >> $outfile done < $sorted_table +echo "};" >> $outfile -rm -f $sorted_table +echo "static const uint16_t syscall_sorted_names[] = {" >> $outfile +# When sorting by name, add a suffix of 0s upto 20 characters so that system +# calls that differ with a numerical suffix don't sort before those +# without. This default behavior of sort differs from that of strcmp used at +# runtime. Use sed to strip the trailing 0s suffix afterwards. +grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | awk '{printf $3; for (i = length($3); i < 20; i++) { printf "0"; }; print " " $1}'| sort | sed 's/\([a-zA-Z1-9]\+\)0\+ \([0-9]\+\)/\1 \2/' > $sorted_table +while read name nr; do + echo " $nr, /* $name */" >> $outfile +done < $sorted_table echo "};" >> $outfile -echo "#define SYSCALLTBL_MAX_ID ${max_nr}" >> $outfile +rm -f $sorted_table diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index 2f76241494c8..760ac4d0869f 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -20,112 +21,66 @@ #include #endif -const int syscalltbl_native_max_id = SYSCALLTBL_MAX_ID; -static const char *const *syscalltbl_native = syscalltbl; +const char *syscalltbl__name(int e_machine __maybe_unused, int id) +{ + if (id >= 0 && id <= (int)ARRAY_SIZE(syscall_num_to_name)) + return syscall_num_to_name[id]; + return NULL; +} -struct syscall { - int id; +struct syscall_cmp_key { const char *name; + const char *const *tbl; }; static int syscallcmpname(const void *vkey, const void *ventry) { - const char *key = vkey; - const struct syscall *entry = ventry; + const struct syscall_cmp_key *key = vkey; + const uint16_t *entry = ventry; - return strcmp(key, entry->name); + return strcmp(key->name, key->tbl[*entry]); } -static int syscallcmp(const void *va, const void *vb) +int syscalltbl__id(int e_machine __maybe_unused, const char *name) { - const struct syscall *a = va, *b = vb; - - return strcmp(a->name, b->name); + struct syscall_cmp_key key = { + .name = name, + .tbl = syscall_num_to_name, + }; + const int *id = bsearch(&key, syscall_sorted_names, + ARRAY_SIZE(syscall_sorted_names), + sizeof(syscall_sorted_names[0]), + syscallcmpname); + + return id ? *id : -1; } -static int syscalltbl__init_native(struct syscalltbl *tbl) +int syscalltbl__num_idx(int e_machine __maybe_unused) { - int nr_entries = 0, i, j; - struct syscall *entries; - - for (i = 0; i <= syscalltbl_native_max_id; ++i) - if (syscalltbl_native[i]) - ++nr_entries; - - entries = tbl->syscalls.entries = malloc(sizeof(struct syscall) * nr_entries); - if (tbl->syscalls.entries == NULL) - return -1; - - for (i = 0, j = 0; i <= syscalltbl_native_max_id; ++i) { - if (syscalltbl_native[i]) { - entries[j].name = syscalltbl_native[i]; - entries[j].id = i; - ++j; - } - } - - qsort(tbl->syscalls.entries, nr_entries, sizeof(struct syscall), syscallcmp); - tbl->syscalls.nr_entries = nr_entries; - tbl->syscalls.max_id = syscalltbl_native_max_id; - return 0; + return ARRAY_SIZE(syscall_sorted_names); } -struct syscalltbl *syscalltbl__new(void) +int syscalltbl__id_at_idx(int e_machine __maybe_unused, int idx) { - struct syscalltbl *tbl = malloc(sizeof(*tbl)); - if (tbl) { - if (syscalltbl__init_native(tbl)) { - free(tbl); - return NULL; - } - } - return tbl; -} - -void syscalltbl__delete(struct syscalltbl *tbl) -{ - zfree(&tbl->syscalls.entries); - free(tbl); -} - -const char *syscalltbl__name(const struct syscalltbl *tbl __maybe_unused, int id) -{ - return id <= syscalltbl_native_max_id ? syscalltbl_native[id]: NULL; -} - -int syscalltbl__id(struct syscalltbl *tbl, const char *name) -{ - struct syscall *sc = bsearch(name, tbl->syscalls.entries, - tbl->syscalls.nr_entries, sizeof(*sc), - syscallcmpname); - - return sc ? sc->id : -1; -} - -int syscalltbl__id_at_idx(struct syscalltbl *tbl, int idx) -{ - struct syscall *syscalls = tbl->syscalls.entries; - - return idx < tbl->syscalls.nr_entries ? syscalls[idx].id : -1; + return syscall_sorted_names[idx]; } -int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx) +int syscalltbl__strglobmatch_next(int e_machine __maybe_unused, const char *syscall_glob, int *idx) { - int i; - struct syscall *syscalls = tbl->syscalls.entries; + for (int i = *idx + 1; i < (int)ARRAY_SIZE(syscall_sorted_names); ++i) { + const char *name = syscall_num_to_name[syscall_sorted_names[i]]; - for (i = *idx + 1; i < tbl->syscalls.nr_entries; ++i) { - if (strglobmatch(syscalls[i].name, syscall_glob)) { + if (strglobmatch(name, syscall_glob)) { *idx = i; - return syscalls[i].id; + return syscall_sorted_names[i]; } } return -1; } -int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx) +int syscalltbl__strglobmatch_first(int e_machine, const char *syscall_glob, int *idx) { *idx = -1; - return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx); + return syscalltbl__strglobmatch_next(e_machine, syscall_glob, idx); } diff --git a/tools/perf/util/syscalltbl.h b/tools/perf/util/syscalltbl.h index 362411a6d849..2bb628eff367 100644 --- a/tools/perf/util/syscalltbl.h +++ b/tools/perf/util/syscalltbl.h @@ -2,22 +2,12 @@ #ifndef __PERF_SYSCALLTBL_H #define __PERF_SYSCALLTBL_H -struct syscalltbl { - struct { - int max_id; - int nr_entries; - void *entries; - } syscalls; -}; +const char *syscalltbl__name(int e_machine, int id); +int syscalltbl__id(int e_machine, const char *name); +int syscalltbl__num_idx(int e_machine); +int syscalltbl__id_at_idx(int e_machine, int idx); -struct syscalltbl *syscalltbl__new(void); -void syscalltbl__delete(struct syscalltbl *tbl); - -const char *syscalltbl__name(const struct syscalltbl *tbl, int id); -int syscalltbl__id(struct syscalltbl *tbl, const char *name); -int syscalltbl__id_at_idx(struct syscalltbl *tbl, int idx); - -int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx); -int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx); +int syscalltbl__strglobmatch_first(int e_machine, const char *syscall_glob, int *idx); +int syscalltbl__strglobmatch_next(int e_machine, const char *syscall_glob, int *idx); #endif /* __PERF_SYSCALLTBL_H */ From patchwork Sat Mar 8 00:32:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5658EC282DE for ; Sat, 8 Mar 2025 00:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v8nEy5rB/hIdNS8kmhBvsJmZBEly95jw8NQmovPnRcI=; b=L7UqLOADn7uwNCFxA/TbE1zGIh 6QhXw1fdxo3w4tTcS/BjNl2o30EAI8NCmaaUstZVzrvhgYE7JM4NnevgSc9sTv4EgeCVga2uisaYf M5ddu20+pbvRDiL+9WNsU2WfQBG2mVBvesXZMOlU1qrH0rCunOBwyoY0tFsu44c7XSVVBW/v3M7RK /KtK9YaZxZm0zE+m1/ldu8IJnDK4IZItR6ziP3Zx0oxyWho34L0C5qkTVCWHWFNZhLaMnxZfhKMWl jZTbasAiw9r5Y4M/0mwP3XMbfXtzXFRz8U1Czcag4ZFyxg6lh/YInLh/tVekHEVaMRw6GsNokwL6H KxJ88jWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiIA-0000000FwBu-1XBG; Sat, 08 Mar 2025 00:43:50 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi79-0000000FuI4-2oDG for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6f79c1cf49dso34853257b3.2 for ; Fri, 07 Mar 2025 16:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393946; x=1741998746; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=v8nEy5rB/hIdNS8kmhBvsJmZBEly95jw8NQmovPnRcI=; b=Jowb8eQtKsvYbFG75xi5rXrRCfMKC+Ez3V8uagitDBoJjrN+VFESbq53zonX/lQ8z9 0jaNz39wOJd7L+f1veqVJVMckrEJ7GqXX0JLVYA1YKdNoS/IE05bj9Jt2CN9e6FMpjxd XHtgUHe0FoKgcPO16q09Zy1mzTADkdGY66c/h2Jz6VBbrZlFZSm3UKMuoVGrLBoNysqa hlovEIE6VPRuwmKGgkLQXjfBe+Rk6eREYzeyr9bhZWtVp87b8O8I8WJAVrvg5Hga8EOn NfN3xy3OWfYXJ/ABCQdrfNaLwRVd5D+MCKIp5E7KMNCPK55hwYmbYd10metaxkO8s1Da Ar/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393946; x=1741998746; 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=v8nEy5rB/hIdNS8kmhBvsJmZBEly95jw8NQmovPnRcI=; b=prB5SyQBK/QMkyytV1CFW+MDEdlVEANo5a3nd7b13dZIWOYAhBP5M5TDbMDpyFAKbQ qS/5BJKp4GAP0JaLKeBwisIKJel3KeoIXoTyDE1Hqkl3k2J15OIssrQyv0xrpZTZzuQC 6zSIgoUk75pPZRJiI49vI1doy/IPCKB8/tNT/upTKKrNY2PTWlUdLH+7DXExr4zKFE3O QCJFzIRbfoxWAKYI3EXkPST4F88B62JBBUXJ4wTzMQgQ8LKYjuEU3GO4wrjzMMBNgx8p JnNhiBW1IuoHcQx3wXq16qaHkwaNzo1E6BIYXwZpOeihd197uBwZkkNM47IdmlzZIioz i3NQ== X-Forwarded-Encrypted: i=1; AJvYcCU0kh+Y9W+Of4r2gDtuPewuL1CyBsVLNDF0eyq0C9XutTCEYL6vA2Yez0MCr4FBHbC4sD4VTgFqaazVrkD+l2bJ@lists.infradead.org X-Gm-Message-State: AOJu0Yw9Sbw2jF1VeIP/L2CVW+vEfbnGYAEb0Tjb7gmwZlXB5XvaaHFo /GXhSkeTCazhd3VIdaV4AkxnRS5yw8GvYbbsC1x4Y7u9xJmZ7Awnq8HDfInFglHq0cAl9edyn66 WY40DFw== X-Google-Smtp-Source: AGHT+IEReJ5DG45Y2N78xw+Wv9anGhMhyh78SY1Xp5hvlU3qYN+t3i78fMBSJgNA1+oBXk1aHtUloiroGn65 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:20b0:b0:6fd:2b79:fb13 with SMTP id 00721157ae682-6febf3b53d7mr4850647b3.6.1741393946311; Fri, 07 Mar 2025 16:32:26 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:04 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-7-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 06/11] perf dso: Add support for reading the e_machine type for a dso From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163227_731209_4DA02106 X-CRM114-Status: GOOD ( 18.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For ELF file dsos read the e_machine from the ELF header. For kernel types assume the e_machine matches the perf tool. In other cases return EM_NONE. When reading from the ELF header use DSO__SWAP that may need dso->needs_swap initializing. Factor out dso__swap_init to allow this. Signed-off-by: Ian Rogers --- tools/perf/util/dso.c | 88 ++++++++++++++++++++++++++++++++++++ tools/perf/util/dso.h | 3 ++ tools/perf/util/symbol-elf.c | 27 ----------- 3 files changed, 91 insertions(+), 27 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 5c6e85fdae0d..00fec1bc32bc 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1170,6 +1170,67 @@ ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, return data_read_write_offset(dso, machine, offset, data, size, true); } +uint16_t dso__e_machine(struct dso *dso, struct machine *machine) +{ + uint16_t e_machine = EM_NONE; + int fd; + + switch (dso__binary_type(dso)) { + case DSO_BINARY_TYPE__KALLSYMS: + case DSO_BINARY_TYPE__GUEST_KALLSYMS: + case DSO_BINARY_TYPE__VMLINUX: + case DSO_BINARY_TYPE__GUEST_VMLINUX: + case DSO_BINARY_TYPE__GUEST_KMODULE: + case DSO_BINARY_TYPE__GUEST_KMODULE_COMP: + case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE: + case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP: + case DSO_BINARY_TYPE__KCORE: + case DSO_BINARY_TYPE__GUEST_KCORE: + case DSO_BINARY_TYPE__BPF_PROG_INFO: + case DSO_BINARY_TYPE__BPF_IMAGE: + case DSO_BINARY_TYPE__OOL: + case DSO_BINARY_TYPE__JAVA_JIT: + return EM_HOST; + case DSO_BINARY_TYPE__DEBUGLINK: + case DSO_BINARY_TYPE__BUILD_ID_CACHE: + case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO: + case DSO_BINARY_TYPE__SYSTEM_PATH_DSO: + case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO: + case DSO_BINARY_TYPE__FEDORA_DEBUGINFO: + case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: + case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO: + case DSO_BINARY_TYPE__BUILDID_DEBUGINFO: + break; + case DSO_BINARY_TYPE__NOT_FOUND: + default: + return EM_NONE; + } + + pthread_mutex_lock(&dso__data_open_lock); + + /* + * dso__data(dso)->fd might be closed if other thread opened another + * file (dso) due to open file limit (RLIMIT_NOFILE). + */ + try_to_open_dso(dso, machine); + fd = dso__data(dso)->fd; + if (fd >= 0) { + _Static_assert(offsetof(Elf32_Ehdr, e_machine) == 18, "Unexpected offset"); + _Static_assert(offsetof(Elf64_Ehdr, e_machine) == 18, "Unexpected offset"); + if (dso__needs_swap(dso) == DSO_SWAP__UNSET) { + unsigned char eidata; + + if (pread(fd, &eidata, sizeof(eidata), EI_DATA) == sizeof(eidata)) + dso__swap_init(dso, eidata); + } + if (dso__needs_swap(dso) != DSO_SWAP__UNSET && + pread(fd, &e_machine, sizeof(e_machine), 18) == sizeof(e_machine)) + e_machine = DSO__SWAP(dso, uint16_t, e_machine); + } + pthread_mutex_unlock(&dso__data_open_lock); + return e_machine; +} + /** * dso__data_read_addr - Read data from dso address * @dso: dso object @@ -1525,6 +1586,33 @@ void dso__put(struct dso *dso) RC_CHK_PUT(dso); } +int dso__swap_init(struct dso *dso, unsigned char eidata) +{ + static unsigned int const endian = 1; + + dso__set_needs_swap(dso, DSO_SWAP__NO); + + switch (eidata) { + case ELFDATA2LSB: + /* We are big endian, DSO is little endian. */ + if (*(unsigned char const *)&endian != 1) + dso__set_needs_swap(dso, DSO_SWAP__YES); + break; + + case ELFDATA2MSB: + /* We are little endian, DSO is big endian. */ + if (*(unsigned char const *)&endian != 0) + dso__set_needs_swap(dso, DSO_SWAP__YES); + break; + + default: + pr_err("unrecognized DSO data encoding %d\n", eidata); + return -EINVAL; + } + + return 0; +} + void dso__set_build_id(struct dso *dso, struct build_id *bid) { RC_CHK_ACCESS(dso)->bid = *bid; diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 4aa8c3d36566..38d9e3eac501 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -730,6 +730,8 @@ bool dso__sorted_by_name(const struct dso *dso); void dso__set_sorted_by_name(struct dso *dso); void dso__sort_by_name(struct dso *dso); +int dso__swap_init(struct dso *dso, unsigned char eidata); + void dso__set_build_id(struct dso *dso, struct build_id *bid); bool dso__build_id_equal(const struct dso *dso, struct build_id *bid); void dso__read_running_kernel_build_id(struct dso *dso, @@ -818,6 +820,7 @@ int dso__data_file_size(struct dso *dso, struct machine *machine); off_t dso__data_size(struct dso *dso, struct machine *machine); ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size); +uint16_t dso__e_machine(struct dso *dso, struct machine *machine); ssize_t dso__data_read_addr(struct dso *dso, struct map *map, struct machine *machine, u64 addr, u8 *data, ssize_t size); diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 66fd1249660a..71df13a5722a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1173,33 +1173,6 @@ int filename__read_debuglink(const char *filename, char *debuglink, #endif -static int dso__swap_init(struct dso *dso, unsigned char eidata) -{ - static unsigned int const endian = 1; - - dso__set_needs_swap(dso, DSO_SWAP__NO); - - switch (eidata) { - case ELFDATA2LSB: - /* We are big endian, DSO is little endian. */ - if (*(unsigned char const *)&endian != 1) - dso__set_needs_swap(dso, DSO_SWAP__YES); - break; - - case ELFDATA2MSB: - /* We are little endian, DSO is big endian. */ - if (*(unsigned char const *)&endian != 0) - dso__set_needs_swap(dso, DSO_SWAP__YES); - break; - - default: - pr_err("unrecognized DSO data encoding %d\n", eidata); - return -EINVAL; - } - - return 0; -} - bool symsrc__possibly_runtime(struct symsrc *ss) { return ss->dynsym || ss->opdsec; From patchwork Sat Mar 8 00:32:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B404C282DE for ; Sat, 8 Mar 2025 00:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vetkQsewyj1QbRQTjQ9n4OdNuLUxV5BdmsX+IHcqXRY=; b=anxTE0tn5HnrMlfODF0Epc4tHW +uMQVAIkCfDNoIug74NQUiSYvWogH/aLaDS5CK0SZ8id9YTMJC/NKfhuJMT5FDeYCTuSC8uLICH/x WiAOykaMG4ZGsb0BV00gXnIu8pj9UDHaQykpBsFeu+CzR0JMlSSF6V6+7LlA/H0A57Ct0dXeXoPyr GGzHoXEXaX1eWO6ezWA4zmaRev4WpxMVsy3V6lJM27wbVyjdoVjNsueSeiZFaRpcj3JSLrJYn7LaW lss+i+TVglRQaQNQlh22RLSbdhgpXqZB83/K/14OyRV6vS4L33awDdVDBanOJQcz9AZKay6edPXyY r8aF2O2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiJm-0000000FwIv-0l4s; Sat, 08 Mar 2025 00:45:30 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi7B-0000000FuJp-4A5E for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:31 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6fd541f4b43so28740737b3.0 for ; Fri, 07 Mar 2025 16:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393949; x=1741998749; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=vetkQsewyj1QbRQTjQ9n4OdNuLUxV5BdmsX+IHcqXRY=; b=lx3317jxgMCLOT/4MOCmE/HKshZ7KBiPpxxbkkmnvcGmAu70VDHJnIcCkzJV7N8i1O Kw+HKuZ+lRzrBrVKETXalRoWBxY0RS0Im7gREe52NGNuOd1K6V5HeyPkJldghkIio08E negzmI/SD93/Zi8IExuBVOY0SrIG8teV6ZU8dP7QGhrKI2IqTh6MU2Z3iKA9Sdd2LAoq 4knSwTXpoOuzEc059XEYOA0iyY+LYzqk54WHqzN2HknNhOpvYmeCe8Y3si3Y2+Au7WUT yvh6+IzuYI88hYDICETawxDI5rJfPcpC2BiQEr9Zoa45JdOJlrjqZ/WN6vGJAofgy5mY d59A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393949; x=1741998749; 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=vetkQsewyj1QbRQTjQ9n4OdNuLUxV5BdmsX+IHcqXRY=; b=EfBWiboinaBRTeKWi12J3iBmPkH58fXHpmNxxwCJi3OqWxwwccUGArmcNhif9JxxLi Jfye1jcvi3iwjFuLMASvl14Tw2X7ZyY+xL8Q/lr20hMDaFZo1LjeJTDVuPb9Y34CRVkV k0Qt6kH6Qc8LJHUOHKleFrZ7CqzIF9H6dRTV7Ya70m4NzIc97M/2UKl+ihgNTGEQxTu8 dGWsy5nDF2t89bhZQncOnpAe4/0OA5mZcKov7/MZhnM7XtaUzhMcALc7yUWCkRyTd0Xw 9W4o+tZ4ugHVQiIjTGMI2sA/S93K9tmzpdr+Bzx99inxvQ0whu/qz+d7IRh4l8WIZNf7 aVIw== X-Forwarded-Encrypted: i=1; AJvYcCVvNHsZ29+4voL3Z6ErmkysaUQIkjVG7C/sxeUwouc2FRkfByapwuZ71mBcz9ru5vLZEnZZqNBZQYwp98Mzy4Tc@lists.infradead.org X-Gm-Message-State: AOJu0Yw0jEDvQvAv4VtMJ54BdTMFvhsrL8okx1zF9/muP/E0PTU75fPR NAFy8JWm+m5q6sjqwU0HqS/ZUpNXXnvQxukTaPdj7wMtGO5zAiOTgyRarxvJGCZgW7IdwM95xK+ GXeNTmw== X-Google-Smtp-Source: AGHT+IFN1j1UckDldnGO2oML3Lr7Es90qR+z0qbean5UPIvBHECq0bAZ2WTXIRqKYd/3JIgKQ6nWxFUa5jkt X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:6902:1368:b0:e63:3f3d:a5aa with SMTP id 3f1490d57ef6-e635c1ee91amr406694276.7.1741393948467; Fri, 07 Mar 2025 16:32:28 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:05 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-8-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 07/11] perf thread: Add support for reading the e_machine type for a thread From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163230_034941_EBC1AA8B X-CRM114-Status: GOOD ( 28.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org First try to read the e_machine from the dsos associated with the thread's maps. If live use the executable from /proc/pid/exe and read the e_machine from the ELF header. On failure use EM_HOST. Change builtin-trace syscall functions to pass e_machine from the thread rather than EM_HOST, so that in later patches when syscalltbl can use the e_machine the system calls are specific to the architecture. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 43 ++++++++++---------- tools/perf/util/thread.c | 80 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/thread.h | 14 ++++++- 3 files changed, 115 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index cfc8cb8cbef8..49199d753b7c 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2729,16 +2729,16 @@ static int trace__sys_enter(struct trace *trace, struct evsel *evsel, int printed = 0; struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; - int augmented_args_size = 0; + int augmented_args_size = 0, e_machine; void *augmented_args = NULL; - /* TODO: get e_machine from thread. */ - struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; struct thread_trace *ttrace; - if (sc == NULL) - return -1; - thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine = thread__e_machine(thread, trace->host); + sc = trace__syscall_info(trace, evsel, e_machine, id); + if (sc == NULL) + goto out_put; ttrace = thread__trace(thread, trace); if (ttrace == NULL) goto out_put; @@ -2806,17 +2806,18 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; - /* TODO: get e_machine from thread. */ - struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; char msg[1024]; void *args, *augmented_args = NULL; - int augmented_args_size; + int augmented_args_size, e_machine; size_t printed = 0; - if (sc == NULL) - return -1; thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine = thread__e_machine(thread, trace->host); + sc = trace__syscall_info(trace, evsel, e_machine, id); + if (sc == NULL) + return -1; ttrace = thread__trace(thread, trace); /* * We need to get ttrace just to make sure it is there when syscall__scnprintf_args() @@ -2881,15 +2882,15 @@ static int trace__sys_exit(struct trace *trace, struct evsel *evsel, bool duration_calculated = false; struct thread *thread; int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0; - int alignment = trace->args_alignment; - /* TODO: get e_machine from thread. */ - struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); + int alignment = trace->args_alignment, e_machine; + struct syscall *sc; struct thread_trace *ttrace; - if (sc == NULL) - return -1; - thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine = thread__e_machine(thread, trace->host); + sc = trace__syscall_info(trace, evsel, e_machine, id); + if (sc == NULL) + goto out_put; ttrace = thread__trace(thread, trace); if (ttrace == NULL) goto out_put; @@ -3236,8 +3237,8 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel, if (evsel == trace->syscalls.events.bpf_output) { int id = perf_evsel__sc_tp_uint(evsel, id, sample); - /* TODO: get e_machine from thread. */ - struct syscall *sc = trace__syscall_info(trace, evsel, EM_HOST, id); + int e_machine = thread ? thread__e_machine(thread, trace->host) : EM_HOST; + struct syscall *sc = trace__syscall_info(trace, evsel, e_machine, id); if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -4881,6 +4882,7 @@ static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trac { size_t printed = 0; struct thread_trace *ttrace = thread__priv(thread); + int e_machine = thread__e_machine(thread, trace->host); double ratio; if (ttrace == NULL) @@ -4900,8 +4902,7 @@ static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trac else if (fputc('\n', fp) != EOF) ++printed; - /* TODO: get e_machine from thread. */ - printed += thread__dump_stats(ttrace, trace, EM_HOST, fp); + printed += thread__dump_stats(ttrace, trace, e_machine, fp); return printed; } diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 0ffdd52d86d7..89585f53c1d5 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include +#include #include #include #include @@ -16,6 +18,7 @@ #include "symbol.h" #include "unwind.h" #include "callchain.h" +#include "dwarf-regs.h" #include @@ -51,6 +54,7 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread__set_ppid(thread, -1); thread__set_cpu(thread, -1); thread__set_guest_cpu(thread, -1); + thread__set_e_machine(thread, EM_NONE); thread__set_lbr_stitch_enable(thread, false); INIT_LIST_HEAD(thread__namespaces_list(thread)); INIT_LIST_HEAD(thread__comm_list(thread)); @@ -423,6 +427,82 @@ void thread__find_cpumode_addr_location(struct thread *thread, u64 addr, } } +static uint16_t read_proc_e_machine_for_pid(pid_t pid) +{ + char path[6 /* "/proc/" */ + 11 /* max length of pid */ + 5 /* "/exe\0" */]; + int fd; + uint16_t e_machine = EM_NONE; + + snprintf(path, sizeof(path), "/proc/%d/exe", pid); + fd = open(path, O_RDONLY); + if (fd >= 0) { + _Static_assert(offsetof(Elf32_Ehdr, e_machine) == 18, "Unexpected offset"); + _Static_assert(offsetof(Elf64_Ehdr, e_machine) == 18, "Unexpected offset"); + if (pread(fd, &e_machine, sizeof(e_machine), 18) != sizeof(e_machine)) + e_machine = EM_NONE; + close(fd); + } + return e_machine; +} + +static int thread__e_machine_callback(struct map *map, void *machine) +{ + struct dso *dso = map__dso(map); + + _Static_assert(0 == EM_NONE, "Unexpected EM_NONE"); + if (!dso) + return EM_NONE; + + return dso__e_machine(dso, machine); +} + +uint16_t thread__e_machine(struct thread *thread, struct machine *machine) +{ + pid_t tid, pid; + uint16_t e_machine = RC_CHK_ACCESS(thread)->e_machine; + + if (e_machine != EM_NONE) + return e_machine; + + tid = thread__tid(thread); + pid = thread__pid(thread); + if (pid != tid) { + struct thread *parent = machine__findnew_thread(machine, pid, pid); + + if (parent) { + e_machine = thread__e_machine(parent, machine); + thread__set_e_machine(thread, e_machine); + return e_machine; + } + /* Something went wrong, fallback. */ + } + /* Reading on the PID thread. First try to find from the maps. */ + e_machine = maps__for_each_map(thread__maps(thread), + thread__e_machine_callback, + machine); + if (e_machine == EM_NONE) { + /* Maps failed, perhaps we're live with map events disabled. */ + bool is_live = machine->machines == NULL; + + if (!is_live) { + /* Check if the session has a data file. */ + struct perf_session *session = container_of(machine->machines, + struct perf_session, + machines); + + is_live = !!session->data; + } + /* Read from /proc/pid/exe if live. */ + if (is_live) + e_machine = read_proc_e_machine_for_pid(pid); + } + if (e_machine != EM_NONE) + thread__set_e_machine(thread, e_machine); + else + e_machine = EM_HOST; + return e_machine; +} + struct thread *thread__main_thread(struct machine *machine, struct thread *thread) { if (thread__pid(thread) == thread__tid(thread)) diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 6cbf6eb2812e..cd574a896418 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -60,7 +60,11 @@ DECLARE_RC_STRUCT(thread) { struct srccode_state srccode_state; bool filter; int filter_entry_depth; - + /** + * @e_machine: The ELF EM_* associated with the thread. EM_NONE if not + * computed. + */ + uint16_t e_machine; /* LBR call stack stitch */ bool lbr_stitch_enable; struct lbr_stitch *lbr_stitch; @@ -302,6 +306,14 @@ static inline void thread__set_filter_entry_depth(struct thread *thread, int dep RC_CHK_ACCESS(thread)->filter_entry_depth = depth; } +uint16_t thread__e_machine(struct thread *thread, struct machine *machine); + +static inline void thread__set_e_machine(struct thread *thread, uint16_t e_machine) +{ + RC_CHK_ACCESS(thread)->e_machine = e_machine; +} + + static inline bool thread__lbr_stitch_enable(const struct thread *thread) { return RC_CHK_ACCESS(thread)->lbr_stitch_enable; From patchwork Sat Mar 8 00:32:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D52CC282DE for ; Sat, 8 Mar 2025 00:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XlFNebLAKQij87xZRU0DCWeRHfkQPLeMoGP6veDBAZ4=; b=jhtKc/4zTB35iMcXQ0sVr9GnYi mX8lgkgtLxFiOJ1q+Bz+Bhe6ldpc3QAROrwglN9Bo4zlBkr1PrKcyfspDAd2yf7i6YewIaSVC8ON6 XCWkP6olWSWmI5YlA78C82BXEGyrAAtbWg/rYdVuYb5Vpipad6ZxeGK6yn6W34TKWl0znb+pc88M+ T3sLOjvuRlGqIHh0XaGAq1iMGUKjm91f29qj1uUIM6s6s8ZcPuz+jFuI9bc9FVLWHY8JqrvYZdbhh WPltF/RIVC/enkYmxbtFjM9AMeFX3954Bg3Cv37aL3km9RZe8BGLHdQiuVX3/DxAWS1uiov9zy1LC 8BUX/v0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiLM-0000000FwZH-1rRz; Sat, 08 Mar 2025 00:47:08 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi7E-0000000FuKv-1Yf9 for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:33 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e6372ccd355so279503276.1 for ; Fri, 07 Mar 2025 16:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393951; x=1741998751; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XlFNebLAKQij87xZRU0DCWeRHfkQPLeMoGP6veDBAZ4=; b=YKXnnqMFxMAR3nPVK3u6nZbNlRhA2sDNFxK0a22HgKyDOB7JiM8Jv5hqm+sVbwouzx oN8NlDJAB3BW1NpSfyFGPWMuHIpInHzDE1Pjpl0+lqLBzJpCtq9RjfYFZaNP60F7H/n8 FMQmhE5XnQ5kWLYgZAX++VT9tVwC2irdf+BddbvGZi1oDhTuGEWinYM+yOymDqaCwdo5 ODGSqeCuY5zUf59366lI4x0NU/ROdZ3iN8IpDMPMmZ/RktXhUA0fPkl65BJmj4+R3vKn hnetSSstoJbIK+9p9ubdNRRAkpX9i8wBIMJz+qeUthRVy/No4G6TMNwTFkMAo7o0Nsfh RObA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393951; x=1741998751; 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=XlFNebLAKQij87xZRU0DCWeRHfkQPLeMoGP6veDBAZ4=; b=J8AmU6OyjxuvbXS2Oy0cNhS0UVyueGq1QciyxdLjfjbbxT3Gd1xHTMUCv2pKLxl6jP IvbRMlMafPTYAhLkrtWDjDf9KRgYdnKtQohOBYJF1O2+odONd+xwhcsTMbB4b0seWGPi DM1cNa654ZQRH7AH4TGrWFSsfBiNpqQ4tIOFcPSLvjy3XkWZ2j0vUcsn6cb+7v6A8h9o muIzmSvz1SCZG56D1g0ByRUQr/Pe/qSvjIxzwJvGBswcpC+uq6DS+jv0skOXWVDFFw0s 0sFK2ol9gjfBb1jgSirgi615GbiDU5V+NkkAF65WoBb96HOSXyZtERYCbEDLB5fUK793 CjDA== X-Forwarded-Encrypted: i=1; AJvYcCVl7o4y7Vnav+/mMxgYwu3sxcIF+I7ZLQRBGDtH2Zdc8DCAprje6YuAPxptunahQIckEKsCM3GepH3JNh4yw0wV@lists.infradead.org X-Gm-Message-State: AOJu0Yyd3gLl/fsHUrq0ugFKn60jkwPcrTYz5f4PFgn3XBaKrYD61n+2 TxAXQqi48sDZYdc8FQPCYWTu8oo0dwzn/3RWoFKoXvWH5hNUrv40As6cFbemVy4pMW5ahapH/qU HXKyNhg== X-Google-Smtp-Source: AGHT+IHB3W/KXCJ++szfS/DeXeYW9m1CyGOsczkykOR5iqkmjGU1F7EbbOZWJrjep+YhntQrISyp3G+pnOEo X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:ce94:0:b0:e57:3500:2294 with SMTP id 3f1490d57ef6-e635c16822cmr44477276.3.1741393950820; Fri, 07 Mar 2025 16:32:30 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:06 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-9-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 08/11] perf trace beauty: Add syscalltbl.sh generating all system call tables From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163232_417377_B520CECB X-CRM114-Status: GOOD ( 20.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than generating individual syscall header files generate a single trace/beauty/generated/syscalltbl.c. In a syscalltbls array have references to each architectures tables along with the corresponding e_machine. When the 32-bit or 64-bit table is ambiguous, match the perf binary's type. For ARM32 don't use the arm64 32-bit table which is smaller. EM_NONE is present for is no machine matches. Conditionally compile the tables, only having the appropriate 32 and 64-bit table. If ALL_SYSCALLTBL is defined all tables can be compiled. Add comment for noreturn column suggested by Arnd Bergmann: https://lore.kernel.org/lkml/d47c35dd-9c52-48e7-a00d-135572f11fbb@app.fastmail.com/ and added in commit 9142be9e6443 ("x86/syscall: Mark exit[_group] syscall handlers __noreturn"). Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/Makefile.perf | 9 + tools/perf/trace/beauty/syscalltbl.sh | 274 ++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100755 tools/perf/trace/beauty/syscalltbl.sh diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index d0b50ccc9d7b..f949ec72f3d2 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -559,6 +559,14 @@ beauty_ioctl_outdir := $(beauty_outdir)/ioctl # Create output directory if not already present $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)') +syscall_array := $(beauty_outdir)/syscalltbl.c +syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh +syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \ + $(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl) + +$(syscall_array): $(syscall_tbl) $(syscall_tbl_data) + $(Q)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@ + fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh @@ -878,6 +886,7 @@ build-dir = $(or $(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders \ arm64-sysreg-defs \ + $(syscall_array) \ $(fs_at_flags_array) \ $(clone_flags_array) \ $(drm_ioctl_array) \ diff --git a/tools/perf/trace/beauty/syscalltbl.sh b/tools/perf/trace/beauty/syscalltbl.sh new file mode 100755 index 000000000000..1199618dc178 --- /dev/null +++ b/tools/perf/trace/beauty/syscalltbl.sh @@ -0,0 +1,274 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Generate all syscall tables. +# +# Each line of the syscall table should have the following format: +# +# NR ABI NAME [NATIVE] [COMPAT [noreturn]] +# +# NR syscall number +# ABI ABI name +# NAME syscall name +# NATIVE native entry point (optional) +# COMPAT compat entry point (optional) +# noreturn system call doesn't return (optional) +set -e + +usage() { + cat >&2 < + + path to kernel tools directory + output header file +EOF + exit 1 +} + +if [ $# -ne 2 ]; then + usage +fi +tools_dir=$1 +outfile=$2 + +build_tables() { + infile="$1" + outfile="$2" + abis=$(echo "($3)" | tr ',' '|') + e_machine="$4" + + if [ ! -f "$infile" ] + then + echo "Missing file $infile" + exit 1 + fi + sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) + grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > "$sorted_table" + + echo "static const char *const syscall_num_to_name_${e_machine}[] = {" >> "$outfile" + # the params are: nr abi name entry compat + # use _ for intentionally unused variables according to SC2034 + while read -r nr _ name _ _; do + echo " [$nr] = \"$name\"," >> "$outfile" + done < "$sorted_table" + echo "};" >> "$outfile" + + echo "static const uint16_t syscall_sorted_names_${e_machine}[] = {" >> "$outfile" + + # When sorting by name, add a suffix of 0s upto 20 characters so that + # system calls that differ with a numerical suffix don't sort before + # those without. This default behavior of sort differs from that of + # strcmp used at runtime. Use sed to strip the trailing 0s suffix + # afterwards. + grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | awk '{printf $3; for (i = length($3); i < 20; i++) { printf "0"; }; print " " $1}'| sort | sed 's/\([a-zA-Z1-9]\+\)0\+ \([0-9]\+\)/\1 \2/' > "$sorted_table" + while read -r name nr; do + echo " $nr, /* $name */" >> "$outfile" + done < "$sorted_table" + echo "};" >> "$outfile" + + rm -f "$sorted_table" +} + +rm -f "$outfile" +cat >> "$outfile" < +#include +#include +#include + +struct syscalltbl { + const char *const *num_to_name; + const uint16_t *sorted_names; + uint16_t e_machine; + uint16_t num_to_name_len; + uint16_t sorted_names_len; +}; + +#if defined(ALL_SYSCALLTBL) || defined(__alpha__) +EOF +build_tables "$tools_dir/perf/arch/alpha/entry/syscalls/syscall.tbl" "$outfile" common,64 EM_ALPHA +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/parisc/entry/syscalls/syscall.tbl" "$outfile" common,64 EM_PARISC +cat >> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/scripts/syscall.tbl" "$outfile" common,64,riscv,rlimit,memfd_secret EM_RISCV +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/sparc/entry/syscalls/syscall.tbl" "$outfile" common,64 EM_SPARC +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/scripts/syscall.tbl" "$outfile" common,64 EM_NONE +echo "#endif //__BITS_PER_LONG != 64" >> "$outfile" + +build_outer_table() { + e_machine=$1 + outfile="$2" + cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" < X-Patchwork-Id: 14007323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25143C28B25 for ; Sat, 8 Mar 2025 00:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:To:From:Subject:References:Mime-Version:Message-Id:In-Reply-To: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Uv3gSi2uGb/rZBWAfK/HKSoE0hwzZt2P2jyoBxCTag8=; b=rFp6cOrO+jsOzNiP+QtoSXj5Dz uFDn+/Aisqia4ijMO09o3H9XFefZ2IAmakpx9pCq638V3B78ONribvPBMgZIAdQas8lJ3i17pqsoF ZtRmveW+YihPi4rVqdCZeVcUwF7GWHlfHeSsRFrXPr8s57y+n/z6mK2hDVxODfZr3wmV5YKrnAkwJ 0EJ2i8xgzVIkcCGtuF9hnS7sftiQKHHkwxCeVJh84VYEdnZvUfXbErqM5Mu1HzqMPdF1fbk6KXdW3 YMNaQk+sUgpYk3PjLb0IW5I4zeo/K62RjceGnfoZRVErtgosqa6xbughaaBJ583VIMPo8PB2J4FBy tw2TWrHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiMx-0000000FwqM-1ZSw; Sat, 08 Mar 2025 00:48:47 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi7G-0000000FuLu-2sRo for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:36 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e6372ccd355so279524276.1 for ; Fri, 07 Mar 2025 16:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393953; x=1741998753; darn=lists.infradead.org; h=content-transfer-encoding:to:from:subject:references:mime-version :message-id:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Uv3gSi2uGb/rZBWAfK/HKSoE0hwzZt2P2jyoBxCTag8=; b=g/EDMNdw6WhIH0rS0sqsa0qjQaAqPs58c/VMgJJ26dqcEaLWzMjSlDe8CXRbgc6vLR 8ZVFOTkAYRYdNXLKZnSjktN/9Di4ny9CXyt+J8v9JmihiH21BmKLdyX0HTd2jcVlAeH4 guAQfALYO87SuR6IFbad1yML6KMGmiSOO31d8g85oBzWwg4Ved+5tZfzGxkkGmOY6e4J YDD8dshPYJCtjBzi5QmEBQ80aKZe+HqsMHD6Ws9C5wJkHEJwTp6z053qyWLg5s+3/y/j BvayiCkHX+i+/X2nvcovFUX8GC0wpD3n49kaILLFNd2GGquoWYYL2R45SEh2pSlBGJkW yowA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393953; x=1741998753; h=content-transfer-encoding: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=Uv3gSi2uGb/rZBWAfK/HKSoE0hwzZt2P2jyoBxCTag8=; b=A7jHLbkbDCQSjC5luPvtqgfgMEtqDkG+eOzvFoNZ6pK3UHuFxK4xJ9k7lmDG/RXcVC PWl/lEuSWm7kVK0a/tEq7ydSS07v4JJ850b8/OPUjcxuDM/FedZ+fkHpHmNxTRVUCcpB prMjruowH8q2/scUNp5rTLo8gf6P9g4FDIftjZWu2pv93iWYfoRhZqhCp+aZjQRGWbgp bLYbnMb0s/+2ZXo/8eheL7o+NhsdU0bwed3j4HiOOM5JG8TDqc51Wf7zFnF6tiKR4bTD KSEzCIL8t/NMTuFOhIc+xR3UvZRnJwaCFijoZWBKOZWNwdL6zGz3l/P8W06RWxnYrw1B 3csw== X-Forwarded-Encrypted: i=1; AJvYcCUcLaoImusb7OjfZ4n0wHRrSb7sw8TYllUyJZp3pgea519k3HM6pWS5VLxNtUzDwJWzTp9e5KSzQTxOLoMoBiTj@lists.infradead.org X-Gm-Message-State: AOJu0YxFRTBMK+nMlKs/Uo/yuNOybvcde9HbLzp6Wfb3YejSyY8NmOl7 I85EtwgGDNS0553N3cO6aVR8x0xBCke6nCiiAPlfbViEO+pzyxq4gCjPeFEqP+zflkSxvG5G78M lfgTV6A== X-Google-Smtp-Source: AGHT+IFs2Qu7hOI+ZkryA/SR8ozQLnfo7wV+jFqgt45ZHjCLNu9+c1jV23yEUzf/okxG+EJas0/wlMjGTuit X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:dc47:0:b0:e63:699a:4e6b with SMTP id 3f1490d57ef6-e63699a4ff7mr24016276.4.1741393953007; Fri, 07 Mar 2025 16:32:33 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:07 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-10-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 09/11] perf syscalltbl: Use lookup table containing multiple architectures From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163234_720070_BE751A3D X-CRM114-Status: GOOD ( 18.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to use the lookup table containing all architectures rather than tables matching the perf binary. This fixes perf trace when executed on a 32-bit i386 binary on an x86-64 machine. Note in the following the system call names of the 32-bit i386 binary as seen by an x86-64 perf. Before: ``` ? ( ): a.out/447296 ... [continued]: munmap()) = 0 0.024 ( 0.001 ms): a.out/447296 recvfrom(ubuf: 0x2, size: 4160585708, flags: DONTROUTE|CTRUNC|TRUNC|DONTWAIT|EOR|WAITALL|FIN|SYN|CONFIRM|RST|ERRQUEUE|NOSIGNAL|WAITFORONE|BATCH|SOCK_DEVMEM|ZEROCOPY|FASTOPEN|CMSG_CLOEXEC|0x91f80000, addr: 0xe30, addr_len: 0xffce438c) = 1475198976 0.042 ( 0.003 ms): a.out/447296 lgetxattr(name: "", value: 0x3, size: 34) = 4160344064 0.054 ( 0.003 ms): a.out/447296 dup2(oldfd: -134422744, newfd: 4) = -1 ENOENT (No such file or directory) 0.060 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct iovec){.iov_base = (void *)0x2e646c2f6374652f,.iov_len = (__kernel_size_t)7307199665335594867,}, vlen: 557056, pos_h: 4160585708) = 3 0.074 ( 0.004 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: 2) = 4160237568 0.080 ( 0.001 ms): a.out/447296 lstat(filename: "", statbuf: 0x193f6) = 0 0.089 ( 0.007 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct iovec){.iov_base = (void *)0x3833692f62696c2f,.iov_len = (__kernel_size_t)3276497845987585334,}, vlen: 557056, pos_h: 4160585708) = 3 0.097 ( 0.002 ms): a.out/447296 close(fd: 3) = 512 0.103 ( 0.002 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: 2050) = 4157935616 0.107 ( 0.007 ms): a.out/447296 lgetxattr(pathname: "", name: "", value: 0x5, size: 2066) = 4158078976 0.116 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", value: 0x1, size: 2066) = 4159639552 0.121 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", value: 0x3, size: 2066) = 4160184320 0.129 ( 0.002 ms): a.out/447296 lgetxattr(pathname: "", name: "", value: 0x3, size: 50) = 4160196608 0.138 ( 0.001 ms): a.out/447296 lstat(filename: "") = 0 0.145 ( 0.002 ms): a.out/447296 mq_timedreceive(mqdes: 4291706800, u_msg_ptr: 0xf7f9ea48, msg_len: 134616640, u_msg_prio: 0xf7fd7fec, u_abs_timeout: (struct __kernel_timespec){.tv_sec = (__kernel_time64_t)-578174027777317696,.tv_nsec = (long long int)4160349376,}) = 0 0.148 ( 0.001 ms): a.out/447296 mkdirat(dfd: -134617816, pathname: " ��� ���▒���▒���", mode: IFREG|ISUID|IRUSR|IWGRP|0xf7fd0000) = 447296 0.150 ( 0.001 ms): a.out/447296 process_vm_writev(pid: -134617812, lvec: (struct iovec){.iov_base = (void *)0xf7f9e9c8f7f9e4c0,.iov_len = (__kernel_size_t)4160349376,}, liovcnt: 4160588048, rvec: (struct iovec){}, riovcnt: 4160585708, flags: 4291707352) = 0 0.197 ( 0.004 ms): a.out/447296 capget(header: 4160184320, dataptr: 8192) = 0 0.202 ( 0.002 ms): a.out/447296 capget(header: 1448669184, dataptr: 4096) = 0 0.208 ( 0.002 ms): a.out/447296 capget(header: 4160577536, dataptr: 8192) = 0 0.220 ( 0.001 ms): a.out/447296 getxattr(pathname: "", name: "c������", value: 0xf7f77e34, size: 1) = 0 0.228 ( 0.005 ms): a.out/447296 fchmod(fd: -134729728, mode: IRUGO|IWUGO|IFREG|IFIFO|ISVTX|IXUSR|0x10000) = 0 0.240 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: 0x5658e008, pos_h: 4160192052) = 3 0.250 ( 0.008 ms): a.out/447296 close(fd: 3) = 1436 0.260 ( 0.018 ms): a.out/447296 stat(filename: "", statbuf: 0xffce32ac) = 1436 0.288 (1000.213 ms): a.out/447296 readlinkat(buf: 0xffce31d4, bufsiz: 4291703244) = 0 ``` After: ``` ? ( ): a.out/442930 ... [continued]: execve()) = 0 0.023 ( 0.002 ms): a.out/442930 brk() = 0x57760000 0.052 ( 0.003 ms): a.out/442930 access(filename: 0xf7f5af28, mode: R) = -1 ENOENT (No such file or directory) 0.059 ( 0.009 ms): a.out/442930 openat(dfd: CWD, filename: "/etc/ld.so.cache", flags: RDONLY|CLOEXEC|LARGEFILE) = 3 0.078 ( 0.001 ms): a.out/442930 close(fd: 3) = 0 0.087 ( 0.007 ms): a.out/442930 openat(dfd: CWD, filename: "/lib/i386-linux-", flags: RDONLY|CLOEXEC|LARGEFILE) = 3 0.095 ( 0.002 ms): a.out/442930 read(fd: 3, buf: 0xffbdbb70, count: 512) = 512 0.135 ( 0.001 ms): a.out/442930 close(fd: 3) = 0 0.148 ( 0.001 ms): a.out/442930 set_tid_address(tidptr: 0xf7f2b528) = 442930 (a.out) 0.150 ( 0.001 ms): a.out/442930 set_robust_list(head: 0xf7f2b52c, len: 12) = 0.196 ( 0.004 ms): a.out/442930 mprotect(start: 0xf7f03000, len: 8192, prot: READ) = 0 0.202 ( 0.002 ms): a.out/442930 mprotect(start: 0x5658e000, len: 4096, prot: READ) = 0 0.207 ( 0.002 ms): a.out/442930 mprotect(start: 0xf7f63000, len: 8192, prot: READ) = 0 0.230 ( 0.005 ms): a.out/442930 munmap(addr: 0xf7f10000, len: 103414) = 0 0.244 ( 0.010 ms): a.out/442930 openat(dfd: CWD, filename: 0x5658d008) = 3 0.255 ( 0.007 ms): a.out/442930 read(fd: 3, buf: 0xffbdb67c, count: 4096) = 1436 0.264 ( 0.018 ms): a.out/442930 write(fd: 1, buf: , count: 1436) = 1436 0.292 (1000.173 ms): a.out/442930 clock_nanosleep(rqtp: { .tv_sec: 17866546940376776704, .tv_nsec: 4159878336 }, rmtp: 0xffbdb59c) = 0 1000.478 ( ): a.out/442930 exit_group() = ? ``` Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/util/syscalltbl.c | 89 ++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index 760ac4d0869f..db0d2b81aed1 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -15,16 +15,39 @@ #include #include "string2.h" -#if __BITS_PER_LONG == 64 - #include -#else - #include -#endif +#include "trace/beauty/generated/syscalltbl.c" -const char *syscalltbl__name(int e_machine __maybe_unused, int id) +static const struct syscalltbl *find_table(int e_machine) { - if (id >= 0 && id <= (int)ARRAY_SIZE(syscall_num_to_name)) - return syscall_num_to_name[id]; + static const struct syscalltbl *last_table; + static int last_table_machine = EM_NONE; + + /* Tables only exist for EM_SPARC. */ + if (e_machine == EM_SPARCV9) + e_machine = EM_SPARC; + + if (last_table_machine == e_machine && last_table != NULL) + return last_table; + + for (size_t i = 0; i < ARRAY_SIZE(syscalltbls); i++) { + const struct syscalltbl *entry = &syscalltbls[i]; + + if (entry->e_machine != e_machine && entry->e_machine != EM_NONE) + continue; + + last_table = entry; + last_table_machine = e_machine; + return entry; + } + return NULL; +} + +const char *syscalltbl__name(int e_machine, int id) +{ + const struct syscalltbl *table = find_table(e_machine); + + if (table && id >= 0 && id < table->num_to_name_len) + return table->num_to_name[id]; return NULL; } @@ -41,38 +64,54 @@ static int syscallcmpname(const void *vkey, const void *ventry) return strcmp(key->name, key->tbl[*entry]); } -int syscalltbl__id(int e_machine __maybe_unused, const char *name) +int syscalltbl__id(int e_machine, const char *name) { - struct syscall_cmp_key key = { - .name = name, - .tbl = syscall_num_to_name, - }; - const int *id = bsearch(&key, syscall_sorted_names, - ARRAY_SIZE(syscall_sorted_names), - sizeof(syscall_sorted_names[0]), - syscallcmpname); + const struct syscalltbl *table = find_table(e_machine); + struct syscall_cmp_key key; + const int *id; + + if (!table) + return -1; + + key.name = name; + key.tbl = table->num_to_name; + id = bsearch(&key, table->sorted_names, table->sorted_names_len, + sizeof(table->sorted_names[0]), syscallcmpname); return id ? *id : -1; } -int syscalltbl__num_idx(int e_machine __maybe_unused) +int syscalltbl__num_idx(int e_machine) { - return ARRAY_SIZE(syscall_sorted_names); + const struct syscalltbl *table = find_table(e_machine); + + if (!table) + return 0; + + return table->sorted_names_len; } -int syscalltbl__id_at_idx(int e_machine __maybe_unused, int idx) +int syscalltbl__id_at_idx(int e_machine, int idx) { - return syscall_sorted_names[idx]; + const struct syscalltbl *table = find_table(e_machine); + + if (!table) + return -1; + + assert(idx >= 0 && idx < table->sorted_names_len); + return table->sorted_names[idx]; } -int syscalltbl__strglobmatch_next(int e_machine __maybe_unused, const char *syscall_glob, int *idx) +int syscalltbl__strglobmatch_next(int e_machine, const char *syscall_glob, int *idx) { - for (int i = *idx + 1; i < (int)ARRAY_SIZE(syscall_sorted_names); ++i) { - const char *name = syscall_num_to_name[syscall_sorted_names[i]]; + const struct syscalltbl *table = find_table(e_machine); + + for (int i = *idx + 1; table && i < table->sorted_names_len; ++i) { + const char *name = table->num_to_name[table->sorted_names[i]]; if (strglobmatch(name, syscall_glob)) { *idx = i; - return syscall_sorted_names[i]; + return table->sorted_names[i]; } } From patchwork Sat Mar 8 00:32:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB52CC28B25 for ; Sat, 8 Mar 2025 02:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=f45GgMpM3Ox0iyikUDUkLxs1CesX7fkHV4LsmiysvdI=; b=XzbhFxhgmvoL8FOVRReCAzdqZ+ PhSt2En6tZ/mk4FLon4sB86xtPqeJdZPh3piU5pJB+eXiWf5Dc2J8eycjOChjgahdrRtEIiAY75ht SRG5IVtwr7SN27sASbmUHeo13bQ5KEmJm4aMC2qIqwUphx8wb5Ph6wkNLPEfDX3l0AFQlHbM9E1mr J3zCdEiVHQ5pYBq4c7x9/Vgs3cfJhEBwQxkLin19YiHP9gSB4NVi0xObD4Jrw49ci+TWK0qxftLpA zZRtFvKAoH7EoSQ9CmXfonQpI1d+yTAuoqtzHjyg5Hin0y28WiSLtYu8fkhN6VVVJJBgE9cZYpM3N liei5u+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqjXv-0000000G294-2BqM; Sat, 08 Mar 2025 02:04:11 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi7I-0000000FuNq-3mc6 for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:38 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f3ff1ff117so33524877b3.0 for ; Fri, 07 Mar 2025 16:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393955; x=1741998755; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=f45GgMpM3Ox0iyikUDUkLxs1CesX7fkHV4LsmiysvdI=; b=rjBmbdO6nPeTfWB91U+TJYMB6N+IaNhBSQ0EWZRKo+BWrDnYkiJtMk7dCnRycOTPdR 4JDC7efC9XawUqY4rNXLDhHibjWPdeBVthPKc/wk7gH+zJsioVCQiyKjX2quYpxlyzKW vsC1sXTRxPl/JrF5qSyb6hzHmtSfZLuAWmIjJNv6qRtNmIxxG1WneGeAZat+Vgy+btU0 PbqNH9UNN1Urky1zJf8IY/jy2pDkfcnzFIxgVOPkUxKj3SSeqOvb3wOkW529qwBnAibB 6PWEUxc0Z1g480k6g0sX3r6/MNM0MOHYDwzv/lQ3iIpKC9yHUupvXP9fa+tOkGXUZJ1C PrYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393955; x=1741998755; 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=f45GgMpM3Ox0iyikUDUkLxs1CesX7fkHV4LsmiysvdI=; b=HLoafLM+JhY3min2zjpkFYpuCMAQnpY9T23mBpcA4p7yP6g/NP8B6mb6Dc8t/Va+xt BMduuyBBEqptZMGTx32rDHgdmVTjdJFfFad9TBB5BdUrasfwUiokl6BNIVHLDbgWM1qK T2RWIw2PsSePc73Czkvb8QmdltdiebXRwXwcIhOfSYVMEEmlK7kTBxE2hJ4Hbwh4/yFD OLUCXSixrR5mJRgE0VKqVG66SHbYejaEQBYRyIifX7GLbDHxzi93ssqo7jrRLzOnXkvu BKG82Qb8x99eqQ78BzmeyEA0w2VD/pn9JP2uBDruvid6tIRuHcudN4AYEoIo6Gw+T2u3 5vLA== X-Forwarded-Encrypted: i=1; AJvYcCWvaDoqGR4ckqKHCsCs9LGs1+GQP9Wj3QYguxbXiY1pmw9rs0HYgnzg1c8sGnGTjSbpULeR17TeXav7BRUeQ72V@lists.infradead.org X-Gm-Message-State: AOJu0YxzDFY+aa2biscfyAN6TCXheHa28H8BMFzaE/7KdkNlI3jlCLBz uQX4Mlo9M5zhraQNI7qggjlnyGXMDBJ/IWdiX8sqaOFEJ1VckL4IMu86FifmEh4+70xnNfCC9ca IHlcSMQ== X-Google-Smtp-Source: AGHT+IEX8Kp3kmlqJY4XoArbicob+cMMoPN1AMYXoDTd1XEAhXrAKzfhns5473W9Ew8DEhOapyIEzMHWAsGM X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:2e82:b0:6fd:a1fa:9d58 with SMTP id 00721157ae682-6febf39c301mr4209877b3.8.1741393955352; Fri, 07 Mar 2025 16:32:35 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:08 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-11-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 10/11] perf build: Remove Makefile.syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163236_952876_87149F2D X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now a single beauty file is generated and used by all architectures, remove the per-architecture Makefiles, Kbuild files and previous generator script. Note: there was conversation with Charlie Jenkins and they'd written an alternate approach to support multiple architectures: https://lore.kernel.org/all/20250114-perf_syscall_arch_runtime-v1-1-5b304e408e11@rivosinc.com/ It would have been better to have helped Charlie fix their series (my apologies) but they agreed that the approach taken here was likely best for longer term maintainability: https://lore.kernel.org/lkml/Z6Jk_UN9i69QGqUj@ghost/ Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/Makefile.perf | 1 - tools/perf/arch/alpha/entry/syscalls/Kbuild | 2 - .../alpha/entry/syscalls/Makefile.syscalls | 5 -- tools/perf/arch/arc/entry/syscalls/Kbuild | 2 - .../arch/arc/entry/syscalls/Makefile.syscalls | 3 - tools/perf/arch/arm/entry/syscalls/Kbuild | 4 - .../arch/arm/entry/syscalls/Makefile.syscalls | 2 - tools/perf/arch/arm64/entry/syscalls/Kbuild | 3 - .../arm64/entry/syscalls/Makefile.syscalls | 6 -- tools/perf/arch/csky/entry/syscalls/Kbuild | 2 - .../csky/entry/syscalls/Makefile.syscalls | 3 - .../perf/arch/loongarch/entry/syscalls/Kbuild | 2 - .../entry/syscalls/Makefile.syscalls | 3 - tools/perf/arch/mips/entry/syscalls/Kbuild | 2 - .../mips/entry/syscalls/Makefile.syscalls | 5 -- tools/perf/arch/parisc/entry/syscalls/Kbuild | 3 - .../parisc/entry/syscalls/Makefile.syscalls | 6 -- tools/perf/arch/powerpc/entry/syscalls/Kbuild | 3 - .../powerpc/entry/syscalls/Makefile.syscalls | 6 -- tools/perf/arch/riscv/entry/syscalls/Kbuild | 2 - .../riscv/entry/syscalls/Makefile.syscalls | 4 - tools/perf/arch/s390/entry/syscalls/Kbuild | 2 - .../s390/entry/syscalls/Makefile.syscalls | 5 -- tools/perf/arch/sh/entry/syscalls/Kbuild | 2 - .../arch/sh/entry/syscalls/Makefile.syscalls | 4 - tools/perf/arch/sparc/entry/syscalls/Kbuild | 3 - .../sparc/entry/syscalls/Makefile.syscalls | 5 -- tools/perf/arch/x86/entry/syscalls/Kbuild | 3 - .../arch/x86/entry/syscalls/Makefile.syscalls | 6 -- tools/perf/arch/xtensa/entry/syscalls/Kbuild | 2 - .../xtensa/entry/syscalls/Makefile.syscalls | 4 - tools/perf/scripts/Makefile.syscalls | 61 --------------- tools/perf/scripts/syscalltbl.sh | 76 ------------------- 33 files changed, 242 deletions(-) delete mode 100644 tools/perf/arch/alpha/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/alpha/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/arc/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/arc/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/arm/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/arm/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/arm64/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/arm64/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/csky/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/csky/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/loongarch/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/mips/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/mips/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/parisc/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/parisc/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/powerpc/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/powerpc/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/riscv/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/riscv/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/s390/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/s390/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/sh/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/sh/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/sparc/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/sparc/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/x86/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/x86/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/xtensa/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/scripts/Makefile.syscalls delete mode 100755 tools/perf/scripts/syscalltbl.sh diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index f949ec72f3d2..f3cd8de15d1a 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -339,7 +339,6 @@ ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump) FEATURE_TESTS := all endif endif -include $(srctree)/tools/perf/scripts/Makefile.syscalls include Makefile.config endif diff --git a/tools/perf/arch/alpha/entry/syscalls/Kbuild b/tools/perf/arch/alpha/entry/syscalls/Kbuild deleted file mode 100644 index 9a41e3572c3a..000000000000 --- a/tools/perf/arch/alpha/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/alpha/entry/syscalls/Makefile.syscalls b/tools/perf/arch/alpha/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 690168aac34d..000000000000 --- a/tools/perf/arch/alpha/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_64 += - -syscalltbl = $(srctree)/tools/perf/arch/alpha/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/arc/entry/syscalls/Kbuild b/tools/perf/arch/arc/entry/syscalls/Kbuild deleted file mode 100644 index 11707c481a24..000000000000 --- a/tools/perf/arch/arc/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h diff --git a/tools/perf/arch/arc/entry/syscalls/Makefile.syscalls b/tools/perf/arch/arc/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 391d30ab7a83..000000000000 --- a/tools/perf/arch/arc/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += arc time32 renameat stat64 rlimit diff --git a/tools/perf/arch/arm/entry/syscalls/Kbuild b/tools/perf/arch/arm/entry/syscalls/Kbuild deleted file mode 100644 index 9d777540f089..000000000000 --- a/tools/perf/arch/arm/entry/syscalls/Kbuild +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += oabi -syscalltbl = $(srctree)/tools/perf/arch/arm/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/arm/entry/syscalls/Makefile.syscalls b/tools/perf/arch/arm/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 11707c481a24..000000000000 --- a/tools/perf/arch/arm/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h diff --git a/tools/perf/arch/arm64/entry/syscalls/Kbuild b/tools/perf/arch/arm64/entry/syscalls/Kbuild deleted file mode 100644 index 84c6599b4ea6..000000000000 --- a/tools/perf/arch/arm64/entry/syscalls/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/arm64/entry/syscalls/Makefile.syscalls b/tools/perf/arch/arm64/entry/syscalls/Makefile.syscalls deleted file mode 100644 index e7e78c2d1c02..000000000000 --- a/tools/perf/arch/arm64/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += -syscall_abis_64 += renameat rlimit memfd_secret - -syscalltbl = $(srctree)/tools/perf/arch/arm64/entry/syscalls/syscall_%.tbl diff --git a/tools/perf/arch/csky/entry/syscalls/Kbuild b/tools/perf/arch/csky/entry/syscalls/Kbuild deleted file mode 100644 index 11707c481a24..000000000000 --- a/tools/perf/arch/csky/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h diff --git a/tools/perf/arch/csky/entry/syscalls/Makefile.syscalls b/tools/perf/arch/csky/entry/syscalls/Makefile.syscalls deleted file mode 100644 index ea2dd10d0571..000000000000 --- a/tools/perf/arch/csky/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += csky time32 stat64 rlimit diff --git a/tools/perf/arch/loongarch/entry/syscalls/Kbuild b/tools/perf/arch/loongarch/entry/syscalls/Kbuild deleted file mode 100644 index 9a41e3572c3a..000000000000 --- a/tools/perf/arch/loongarch/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls b/tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 47d32da2aed8..000000000000 --- a/tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_64 += diff --git a/tools/perf/arch/mips/entry/syscalls/Kbuild b/tools/perf/arch/mips/entry/syscalls/Kbuild deleted file mode 100644 index 9a41e3572c3a..000000000000 --- a/tools/perf/arch/mips/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/mips/entry/syscalls/Makefile.syscalls b/tools/perf/arch/mips/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 9ee914bdfb05..000000000000 --- a/tools/perf/arch/mips/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_64 += n64 - -syscalltbl = $(srctree)/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl diff --git a/tools/perf/arch/parisc/entry/syscalls/Kbuild b/tools/perf/arch/parisc/entry/syscalls/Kbuild deleted file mode 100644 index 84c6599b4ea6..000000000000 --- a/tools/perf/arch/parisc/entry/syscalls/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/parisc/entry/syscalls/Makefile.syscalls b/tools/perf/arch/parisc/entry/syscalls/Makefile.syscalls deleted file mode 100644 index ae326fecb83b..000000000000 --- a/tools/perf/arch/parisc/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += -syscall_abis_64 += - -syscalltbl = $(srctree)/tools/perf/arch/parisc/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/powerpc/entry/syscalls/Kbuild b/tools/perf/arch/powerpc/entry/syscalls/Kbuild deleted file mode 100644 index 84c6599b4ea6..000000000000 --- a/tools/perf/arch/powerpc/entry/syscalls/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/powerpc/entry/syscalls/Makefile.syscalls b/tools/perf/arch/powerpc/entry/syscalls/Makefile.syscalls deleted file mode 100644 index e35afbc57c79..000000000000 --- a/tools/perf/arch/powerpc/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += nospu -syscall_abis_64 += nospu - -syscalltbl = $(srctree)/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/riscv/entry/syscalls/Kbuild b/tools/perf/arch/riscv/entry/syscalls/Kbuild deleted file mode 100644 index 9a41e3572c3a..000000000000 --- a/tools/perf/arch/riscv/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/riscv/entry/syscalls/Makefile.syscalls b/tools/perf/arch/riscv/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 9668fd1faf60..000000000000 --- a/tools/perf/arch/riscv/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += riscv memfd_secret -syscall_abis_64 += riscv rlimit memfd_secret diff --git a/tools/perf/arch/s390/entry/syscalls/Kbuild b/tools/perf/arch/s390/entry/syscalls/Kbuild deleted file mode 100644 index 9a41e3572c3a..000000000000 --- a/tools/perf/arch/s390/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/s390/entry/syscalls/Makefile.syscalls b/tools/perf/arch/s390/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 9762d7abf17c..000000000000 --- a/tools/perf/arch/s390/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_64 += renameat rlimit memfd_secret - -syscalltbl = $(srctree)/tools/perf/arch/s390/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/sh/entry/syscalls/Kbuild b/tools/perf/arch/sh/entry/syscalls/Kbuild deleted file mode 100644 index 11707c481a24..000000000000 --- a/tools/perf/arch/sh/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h diff --git a/tools/perf/arch/sh/entry/syscalls/Makefile.syscalls b/tools/perf/arch/sh/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 25080390e4ed..000000000000 --- a/tools/perf/arch/sh/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += -syscalltbl = $(srctree)/tools/perf/arch/sh/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/sparc/entry/syscalls/Kbuild b/tools/perf/arch/sparc/entry/syscalls/Kbuild deleted file mode 100644 index 84c6599b4ea6..000000000000 --- a/tools/perf/arch/sparc/entry/syscalls/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/sparc/entry/syscalls/Makefile.syscalls b/tools/perf/arch/sparc/entry/syscalls/Makefile.syscalls deleted file mode 100644 index 212c1800b644..000000000000 --- a/tools/perf/arch/sparc/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += -syscall_abis_64 += -syscalltbl = $(srctree)/tools/perf/arch/sparc/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/x86/entry/syscalls/Kbuild b/tools/perf/arch/x86/entry/syscalls/Kbuild deleted file mode 100644 index 84c6599b4ea6..000000000000 --- a/tools/perf/arch/x86/entry/syscalls/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h -syscall-y += syscalls_64.h diff --git a/tools/perf/arch/x86/entry/syscalls/Makefile.syscalls b/tools/perf/arch/x86/entry/syscalls/Makefile.syscalls deleted file mode 100644 index db3d5d6d4e56..000000000000 --- a/tools/perf/arch/x86/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += i386 -syscall_abis_64 += - -syscalltbl = $(srctree)/tools/perf/arch/x86/entry/syscalls/syscall_%.tbl diff --git a/tools/perf/arch/xtensa/entry/syscalls/Kbuild b/tools/perf/arch/xtensa/entry/syscalls/Kbuild deleted file mode 100644 index 11707c481a24..000000000000 --- a/tools/perf/arch/xtensa/entry/syscalls/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -syscall-y += syscalls_32.h diff --git a/tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls b/tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls deleted file mode 100644 index d4aa2358460c..000000000000 --- a/tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -syscall_abis_32 += -syscalltbl = $(srctree)/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl diff --git a/tools/perf/scripts/Makefile.syscalls b/tools/perf/scripts/Makefile.syscalls deleted file mode 100644 index 8bf55333262e..000000000000 --- a/tools/perf/scripts/Makefile.syscalls +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# This Makefile generates headers in -# tools/perf/arch/$(SRCARCH)/include/generated/asm from the architecture's -# syscall table. This will either be from the generic syscall table, or from a -# table that is specific to that architecture. - -PHONY := all -all: - -obj := $(OUTPUT)arch/$(SRCARCH)/include/generated/asm - -syscall_abis_32 := common,32 -syscall_abis_64 := common,64 -syscalltbl := $(srctree)/tools/scripts/syscall.tbl - -# let architectures override $(syscall_abis_%) and $(syscalltbl) --include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.syscalls -include $(srctree)/tools/build/Build.include --include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild - -systbl := $(srctree)/tools/perf/scripts/syscalltbl.sh - -syscall-y := $(addprefix $(obj)/, $(syscall-y)) - -# Remove stale wrappers when the corresponding files are removed from generic-y -old-headers := $(wildcard $(obj)/*.h) -unwanted := $(filter-out $(syscall-y),$(old-headers)) - -quiet_cmd_remove = REMOVE $(unwanted) - cmd_remove = rm -f $(unwanted) - -quiet_cmd_systbl = SYSTBL $@ - cmd_systbl = $(CONFIG_SHELL) $(systbl) \ - $(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \ - --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ - $< $@ - -all: $(syscall-y) - $(if $(unwanted),$(call cmd,remove)) - @: - -$(obj)/syscalls_%.h: $(syscalltbl) $(systbl) FORCE - $(call if_changed,systbl) - -targets := $(syscall-y) - -# Create output directory. Skip it if at least one old header exists -# since we know the output directory already exists. -ifeq ($(old-headers),) -$(shell mkdir -p $(obj)) -endif - -PHONY += FORCE - -FORCE: - -existing-targets := $(wildcard $(sort $(targets))) - --include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) - -.PHONY: $(PHONY) diff --git a/tools/perf/scripts/syscalltbl.sh b/tools/perf/scripts/syscalltbl.sh deleted file mode 100755 index a39b3013b103..000000000000 --- a/tools/perf/scripts/syscalltbl.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 -# -# Generate a syscall table header. -# -# Each line of the syscall table should have the following format: -# -# NR ABI NAME [NATIVE] [COMPAT] -# -# NR syscall number -# ABI ABI name -# NAME syscall name -# NATIVE native entry point (optional) -# COMPAT compat entry point (optional) - -set -e - -usage() { - echo >&2 "usage: $0 [--abis ABIS] INFILE OUTFILE" >&2 - echo >&2 - echo >&2 " INFILE input syscall table" - echo >&2 " OUTFILE output header file" - echo >&2 - echo >&2 "options:" - echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" - exit 1 -} - -# default unless specified by options -abis= - -while [ $# -gt 0 ] -do - case $1 in - --abis) - abis=$(echo "($2)" | tr ',' '|') - shift 2;; - -*) - echo "$1: unknown option" >&2 - usage;; - *) - break;; - esac -done - -if [ $# -ne 2 ]; then - usage -fi - -infile="$1" -outfile="$2" - -sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) -grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table - -echo "static const char *const syscall_num_to_name[] = {" > $outfile -# the params are: nr abi name entry compat -# use _ for intentionally unused variables according to SC2034 -while read nr _ name _ _; do - echo " [$nr] = \"$name\"," >> $outfile -done < $sorted_table -echo "};" >> $outfile - -echo "static const uint16_t syscall_sorted_names[] = {" >> $outfile - -# When sorting by name, add a suffix of 0s upto 20 characters so that system -# calls that differ with a numerical suffix don't sort before those -# without. This default behavior of sort differs from that of strcmp used at -# runtime. Use sed to strip the trailing 0s suffix afterwards. -grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | awk '{printf $3; for (i = length($3); i < 20; i++) { printf "0"; }; print " " $1}'| sort | sed 's/\([a-zA-Z1-9]\+\)0\+ \([0-9]\+\)/\1 \2/' > $sorted_table -while read name nr; do - echo " $nr, /* $name */" >> $outfile -done < $sorted_table -echo "};" >> $outfile - -rm -f $sorted_table From patchwork Sat Mar 8 00:32:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14007327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48686C282DE for ; Sat, 8 Mar 2025 00:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aBag0ZTpgw2jBnuqcdEe2ctv9zQnS+6XrNEn3QpM0IU=; b=Dv+KcHc0ZNEM9rTiYkn5E/1BKN BTDHUnaWcb0n5/M1vIEdxF6BMMTs5dfDByZAVTbs44MWW2ZN8V1BoFYN4xl7l9y1b+xEEa+fzEZG8 LzWmepJf6I5QMeWEnAJR44IvGAFCQ09jMMq77bEMF5K+vp/t6MOi6ewlM5nboZhow/Movylm5nGd8 fx+xG9+OhUDSvfZAkVBUL2tJdlmlLZb8cPw/1RtpxEhkLzze7ph6QcFo4vvTgrjxKx4QsyO8w1kYv +f4Sy9lnjXj+pf5ebQjHQzo9gn25YPGBd2lIAb+pvhFh/srYr6GByNt0gjLbYJwVK2NYdLw8NMSHn NowiZT9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqiQ8-0000000Fx6i-4Abq; Sat, 08 Mar 2025 00:52:04 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqi7L-0000000FuPG-0jPB for linux-arm-kernel@lists.infradead.org; Sat, 08 Mar 2025 00:32:40 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6f4348c854eso33792997b3.2 for ; Fri, 07 Mar 2025 16:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393957; x=1741998757; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=aBag0ZTpgw2jBnuqcdEe2ctv9zQnS+6XrNEn3QpM0IU=; b=ijkkhllG/PvPrXfSpuATvtfCvW0mYxXm/46nWFvVffXBsdlsRMEpWkRyv636VVWlNf CRHJjilUiuBlrBRqWTXJHJJucZZ7XEAowjv0baozToFEmcvdFu0pU9rBwtSYmErouVcf H0g0C6gF/9xE1V3gYJ0sVVny58+iphp4YAUfYmEF7WVdhLY6rZastMWf0GSy6Cq0MOch ooCfG5hhCgE5ARkU0rq7hgDW9XxdtvIp/LrcK0IJaLefVcM7MrDtlNs84r+bi0wBbQDe jnQlCTbnZdYll/IrLeFAhB37ZAsSux+eIrjQovL3+5Zc3Ra7pbBOOMxdxC+HuZKfC1m6 +HMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393957; x=1741998757; 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=aBag0ZTpgw2jBnuqcdEe2ctv9zQnS+6XrNEn3QpM0IU=; b=Z6SUin+Rxy1eoakaIVSjyBAdK3IjHh7GG4UpZJ+Vjpl5DK+MegSXDjaALAS/wsXHQD EAymLJEh3elYKEbLRGuCeS2DpxZdZHB34j5ZfG6YBtM+9MSDRt4rfjP8kLpNjO4GX+ju 6KJP0Y+DPRy5dgqoy/4jRyXxJwqO0tLiM4DN93HGK9UeLg8Kj9XMdeXexBoaBmshp16r sQx22rQzucJa4GFxEecViO26yCVU1qwnoU3lHUu8S/vgTACv+PfmzFTf90nqfJgl6NaA d2qHAEgz21OcFgESyqMb9qjJFUkIMyCIs9qrWUiuYJyD0WDayQRDEF5Rm/ct6vPuufj4 B4kA== X-Forwarded-Encrypted: i=1; AJvYcCUAVthHiDMWb4q7DWMmK5Gk4YKjFAxgTLPClZJrjCmE9FrGjk9msz7WYn8BpqvhKi/CIXneIUHwhZ7lHPKDbTZX@lists.infradead.org X-Gm-Message-State: AOJu0YwD6003FThaJ3HiF0ltFQ67CtiHETncqqEVb+Z9ShJjId2oq7Ko UZSTMF899Pwt5+EuBxLALYfcXxhwTPXx0vIgPz3wcTUMT/hUdgOilVbKj4NRMEwCzlS0rKSEClr F3ThdXw== X-Google-Smtp-Source: AGHT+IGhJSVrXcuIauCCTdcdrck6v986JR4xLPN3EKMbWJDNglYuGen8NURA01YPhhzdv9BlJdEWKZRc9pFA X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:2901:b0:6eb:ac7:b4bc with SMTP id 00721157ae682-6febf2a661cmr5088337b3.2.1741393957696; Fri, 07 Mar 2025 16:32:37 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:09 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-12-irogers@google.com> Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 11/11] perf syscalltbl: Mask off ABI type for MIPS system calls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250307_163239_207454_70347FEB X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Arnd Bergmann described that MIPS system calls don't necessarily start from 0 as an ABI prefix is applied: https://lore.kernel.org/lkml/8ed7dfb2-1e4d-4aa4-a04b-0397a89365d1@app.fastmail.com/ When decoding the "id" (aka system call number) for MIPS ignore values greater-than 1000. Signed-off-by: Ian Rogers --- tools/perf/util/syscalltbl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index db0d2b81aed1..ace66e69c1bc 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -46,6 +46,14 @@ const char *syscalltbl__name(int e_machine, int id) { const struct syscalltbl *table = find_table(e_machine); + if (e_machine == EM_MIPS && id > 1000) { + /* + * MIPS may encode the N32/64/O32 type in the high part of + * syscall number. Mask this off if present. See the values of + * __NR_N32_Linux, __NR_64_Linux, __NR_O32_Linux and __NR_Linux. + */ + id = id % 1000; + } if (table && id >= 0 && id < table->num_to_name_len) return table->num_to_name[id]; return NULL;