From patchwork Wed Mar 19 05:07:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022041 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 F0D75C35FF1 for ; Wed, 19 Mar 2025 05:11: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=abYRMOxViqYMp92GMDii3ruSxpFYmB3QwrQR3Z5L6HY=; b=oZh2WmnhvEsSMiB/iDmOr7xEtd 5QPvOJVmKhctBAbHN1Woow18rgVGtyjg39s4V9onZtO4FAxkuDFpxfnpnibUcMtK4voCAZR/w5MQb 9hgBgDcmJSqBgVr1H8wzY4LUYZpG+fOg/0Qwc22HAPg4Hby5vJ0lEAriiyOUvcK3naxp2pbYTJgQ0 MJ85HOeBEWuw9w/H99zgeRnIufsYsVdfmFO6PWHDV3tB22yyoHTGjgYA8Y9lD8rRBna6sdtAknrfO ZTEQTzynpNCjNY0Ioeicy09BdrP0zCggzHUtLsOd+hBzT8acQIwQxCLDWimmwW7cAZyt03568Ggvy G/13N6Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulhz-000000081Uc-2ROe; Wed, 19 Mar 2025 05:11:15 +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 1tulef-000000080gE-0Gzc for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:07:50 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e6432a0dad8so4642633276.1 for ; Tue, 18 Mar 2025 22:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360867; x=1742965667; 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=abYRMOxViqYMp92GMDii3ruSxpFYmB3QwrQR3Z5L6HY=; b=yJNhReJzkxm2e8LGhYEiqjWled5/44YViF/cY6eFVtPrRmoNX1Fl5PdOMsgh00ne+p LybWA3kfuqMCUv9jJs3Xz9BIwMmi1g3hK9x2R9EQ6E+DFEWPdiw7T/RmYUyf+8TDBEQU Wx8eGO3ANgLrJog3lub0oSAsMr+30/luv7MIh4S4muWRDE5FP7LMljVRUv8xdD7n6wTh eV2Jvr7KEf7ha1bfo6Yf+7xy+0SGx+OG64ZEc2qz16Fbo2nKDvTHDT+Ne5B8vAZZhUzp f3PaSrb3sh01n+7uwwJBcHgvp5kuLtSBqsWbkLsN7DbJTXFRtnUdph6dBCPgOkfoIomy ZzJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360867; x=1742965667; 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=abYRMOxViqYMp92GMDii3ruSxpFYmB3QwrQR3Z5L6HY=; b=H4g5sP1SrlDOb57ESuPKKSzfszAdjBvQvmy+wpZdVJPPRT8PnfAlamuIkGuZBb31r1 8iI3Gf81E9Xqu/2prJkIGvezep0Ib2FOnMqHgGnQHVVeanGpmvZAU+eElliFEuoYFErK 2CJxxZbjE0w2iyHBKcGL++1JFM6SzQfE85YwqSBU+QpWe2N1+Cc0JRV+5yyRS3OpJaAo LA7CsnJXsnDSH+wBoI9VRMKvgY2Aspe0sQIXfAaFQgxyYdBSaS/1Nr62kuz9KRDBTD93 8ZLyiOhWHQ7GyHORZyZPfbqGx+FpUO2AEV4eGju1BsaocvLShSJa/oP5SrK4taxd4Pb0 3zwg== X-Forwarded-Encrypted: i=1; AJvYcCUdfZxqJHgqM5aLfYvF0Acd+kHMK4esReFjPxt2WI0bCJKLSjhGkhnjPn++Zsy3L/uOG/TLchEBjnGV9/L3AkhA@lists.infradead.org X-Gm-Message-State: AOJu0YzxVHytIK8ePnipXO64agXLw78HLQ5E9M0nN6bJr2Eyw2iP3YD+ Leg6CyalNV6G9ppVb5Aaux1wgByzsFJWQXZVoE8ZwVjOAh6DV93aMNmL1fmRjjzoIaJvlbQ1UDA BRrxyxQ== X-Google-Smtp-Source: AGHT+IGRmoWaZCuVB5ee3Iv2LzVEuNeEJLA9zgD9tzBFtuvqHm9F4Ignee+o0RWj2MTQlY6HLf9109e/Wj7N X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:b323:0:b0:e5b:f74:f5a with SMTP id 3f1490d57ef6-e667b456dc4mr504276.8.1742360867177; Tue, 18 Mar 2025 22:07:47 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:28 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-2-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 01/14] 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-20250318_220749_103080_147D43FD X-CRM114-Status: GOOD ( 12.41 ) 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 846b74510038..2cc1f6593f9e 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -155,10 +155,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 Wed Mar 19 05:07:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022044 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 5FB11C35FF1 for ; Wed, 19 Mar 2025 05:13:10 +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=XQUhpTPLVb6N2m+nc4ISL7gti6LwY0Os+AgxG8mcvpY=; b=HAGC8Umd/IyVrHGlGoe2pjIYmX Gwtq5ftheaICfnqSCuZUvQiGsknT9qzsk0YCFjbeel/KzkNkeX5eYGyF30fk54moV5VF147dcYcQp Vnx76Jb2RTnLAr5tCvcwN9k2j5MKcsXzwxnPqIDR+/qboe/6aqsuKkvxqe3lmDvViDdkZgE+KxosG 9WQeXdhYIvY9XkXib1dj1B4Ufwmf4EknvZV5e3Fe0X4aiFA6NfZWJXl6NixrjdFoUGi76ORVMi7sd 3e49UrR2dUBkEo2hIYEfhrplqrMAhtIQn3KxZ7C9PqMMqHsQdt1QkV96AvuEaDF5Y4rNe5ZRxE6O+ hWmsZQJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulje-000000081nw-0wCh; Wed, 19 Mar 2025 05:12:58 +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 1tuleh-000000080hp-3R0y for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:07:52 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f2a2ab50f6so94862307b3.3 for ; Tue, 18 Mar 2025 22:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360870; x=1742965670; 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=XQUhpTPLVb6N2m+nc4ISL7gti6LwY0Os+AgxG8mcvpY=; b=H9zOjDEHSRtwjh5Bzz9+hjtmSDY8fUaI6sSjDtXCWwMcqY35xCzgH8lMBMClZ3RCch tX8zAYhKM0JAlioSRrH0VUfdvXeBFEFfGMDpXXaHdPpqld5G+w2RidHjEPPIrO7aAoNc t+ikV40RZQhw9iz3of60PXoObjWwHac4LDZd9ZJHdu1m0b3Mkzyd7oue2jsA42W9RmIs zNLcG2dLwH7b7PeEY4UbyaJ8YOJiyhtCxJVh2HeR6D0NtobyUGnuSnyZFV6VBkezfjtI D/X8zRc5Asx8wIBQTqluXsNVPWQ9sj2yJYUUiVgoaUgiEztS/UfEJ4z1pUnXEqykEtmR mHdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360870; x=1742965670; 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=XQUhpTPLVb6N2m+nc4ISL7gti6LwY0Os+AgxG8mcvpY=; b=oN0ROtSLm0KQTdr+Cr++cNl15Kl3dIzAeT4RaVevk6tQlBeAdM91Hf2B/WsPsKsjE3 yIIuWpOaBNxGjlOYH1nHi7LzMD/cC2u6uF1weFNHkxLki+6wRLXI06ji7MwtQnj2MVuf Yb6l7z0INOyWQJxlevgvSLeDR7d6ijxV2Y4o2eK2J1CoTLmQP8vg71Jk82D2V+iuMog7 KKsmQfCudg4+i14oTGZuMRve43pwMEZAzLKTABExY3ekMkW09N4I64lN4WjQWo8osFjZ 2JfcqTGtXLmMdY/3lBq1aR5Ihf4L+KYoin9kA50lZiPfPXDTpRzUt4QLYYa+0O0O8hHd tvfg== X-Forwarded-Encrypted: i=1; AJvYcCWFx4FBc2wpYwyBRhuFjHs+H9eHFKkKuFpLHBzDlE/FfY320dkjLAtUQ+Kqie/fwi08f2ugcWc1Wg9liP9sbUPi@lists.infradead.org X-Gm-Message-State: AOJu0Yz/bICeyKfktQhSxHbEA8MzESoqByJxgV9i9f2ICBvd9HBpSY7K pMTv4+T0MPh30xIPYtqALv6iOetoXKY8zRN19FvL+3VTD4VUlciT5zjsYW8gL+5e0sFDwuooT27 ArSie6Q== X-Google-Smtp-Source: AGHT+IHOW262Yn1ggfPbRXiaD4JOO6KMlLE7LTu3k1LoYE6sevtUdiYlZtBYV3AOcRBRzOEXQI22siUbHecM X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:690c:6912:b0:6f9:98c3:a191 with SMTP id 00721157ae682-7009bf44550mr5967b3.2.1742360869976; Tue, 18 Mar 2025 22:07:49 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:29 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-3-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 02/14] 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-20250318_220751_857054_2714AE54 X-CRM114-Status: GOOD ( 14.57 ) 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 | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 2cc1f6593f9e..53e3b9b337e5 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -20,31 +20,88 @@ 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__GNU_DEBUGDATA: MiniDebuginfo where a compressed + * ELF file is placed in a .gnu_debugdata section. + */ DSO_BINARY_TYPE__GNU_DEBUGDATA, + /** @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 Wed Mar 19 05:07:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022045 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 7C013C35FFC for ; Wed, 19 Mar 2025 05:14:51 +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=NFFalelwH8VoySEJuALgzWg3CwByqG22Rt5iA2R562U=; b=lJfu81mzUEiHGXSnzSDrFFtjhC IClO1JKi/7ea/zks0Ok4GISAFgQAswMA3aR4ZOgpBKKME7nBOcmpTSI2FDYC4Pzu9Xr7ARdrNir7g +BUEAIf0pWeVPR+bboJ5YRZZBdJ6335LKym0ow2a9Go362PCbFX3m2XkSmIZfG33OwDuzBn+tePj5 aOaANZf55xqlU7b/9K1NwvvlY/WQFUYoIlzy2VCTF480jj5UwHV7fVyfMbpKyIRxYUOosfSKtx0PH Cb8YZo9VLYtzelXvs3koUtick2O+vAJf0M79K+whZ4E5+v+TJCdzzwjrZAeoD7M1qbLaXwsxxH9M9 Nna2ckuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tullK-0000000825D-0jl9; Wed, 19 Mar 2025 05:14:42 +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 1tulej-000000080ih-4BcT for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:07:55 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6f2c7008c05so91380727b3.0 for ; Tue, 18 Mar 2025 22:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360872; x=1742965672; 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=NFFalelwH8VoySEJuALgzWg3CwByqG22Rt5iA2R562U=; b=TtXCAZADNhmhtPiHiLD9Y65ZLrFcp/doSRkRhjNrWBjhK/G8T5sz5tsW0r/BQLFwyp 3HYx0Ym9/+3KNMo9Uu0lgkwKdsAUtjU/H8XWrRa3QfL8FFAH+fK5ZE7F2zRj5sRKoIKA fHeqfdrUNyXAxSt1YeFEi9DTc0gA//C/WdtQgq0O8hnrCpAVLWrvZbrpa4GS24jRwxK7 KkoMW1pByjT2Z8bMqvEep3wuTMUJyFcGOjNUm9wsW7Ras/oLp1eiuBCKR2xeTcSBF5FY 6G9vJThD0aNnhm0emve/vSbgwDg5XqxSeVC2pK36rn12Ig15TWA2o5UmJot7AKhxLWGh gXJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360872; x=1742965672; 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=NFFalelwH8VoySEJuALgzWg3CwByqG22Rt5iA2R562U=; b=ngPvnyUPlRTIyrzoBHXlwWsGUcHkQ5uowfiteSOLwc7TQpe/b7IjN19L4k0q3/rB+a 0TVKkErSuSrqPYkGIxXGVDwD7f0MRtoQMaQzXxOAUBgwkdSIRVOKrYc2jaIHEs/E3Bhf LftOSH2iO2n2xkIrs8T0rFp8PEJv80A4JcaXEO3L1Zi4JQNPW7+UZ/BdoiU8VW3Zsrxv dwUxLAJTUKEDCb+jq5wCPskfQQeWZ1c/3vXXQ06qbFiBem2NWf91g8Pc/9FeP1hWodoO QXqEDQQgkhOiL/U9Gai9qEo4dNnI3qPd4kUiIGRui5gdUMFwMWZBrjkNGbKHoqB61zS7 syiw== X-Forwarded-Encrypted: i=1; AJvYcCXjtcfSBUn4LI1d3oUXmLWlIGXOfCJ6AYq4W/9qlhTgii6famcJjwC3vPgvbDOI+Guvl6pOmf3uquvQUsYnrTV2@lists.infradead.org X-Gm-Message-State: AOJu0YzWy/vMMvcht4fKupwCJfKKTx7eXJmtfV9iZwkvc20evPTrBqVW YSvYDN9imRVMYWMpt4rHMi0rJ72v8Gs5ohx5l9Rv26ocLjjpdhiC5TbhlyXvrZe3ogsfXfRMF+B uVWmZ+A== X-Google-Smtp-Source: AGHT+IHKXcOcoX7oZFC1oFuGYiGGZ0j+MiBzxCOjCKBtTzivPnb3bP0kfvlmCNy9iQaR8bqAcvFNPd6Extds X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a5b:a87:0:b0:e60:8793:89b3 with SMTP id 3f1490d57ef6-e667b456b9amr515276.8.1742360872036; Tue, 18 Mar 2025 22:07:52 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:30 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-4-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 03/14] 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-20250318_220754_031945_E0D0BB59 X-CRM114-Status: GOOD ( 16.93 ) 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 Wed Mar 19 05:07:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022050 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 59B6CC35FFB for ; Wed, 19 Mar 2025 05:18:19 +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=O1nK5uvxYAHiuhO7vp1MDxMA7qbFQ4SO2G8OmMvCRSM=; b=vg8Fa6zkToaKAzevGK3Clw1Drh kkDiymwLFLNVPrlk4DrVncj20njTIdtLDT70PS/RRwwRqnnBaxCkm//XlaFkeT+DeSiAe1OxkXQDs mwOCbqfJF6rbaAUCZyqnLIYrJdfnKHGCi3QeOr1iJuCDPCUHG71elK3DjTrWd4HUI0jA24qPDBrOf VB5HlI5N4spJq+GfwPGeXMjxBOM24laaA+ajVItyPzs2mslAkqPT6B/XOs4XrEw19VF0UXJZldqsl l7GYEstqoOMY5FKeg8cNrH7NAOGCrocmIaiSHgcb/ORIyscXBYZJXJZdIpiq1x18IZVi50JBQdNZW S4oPEG0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulod-000000082My-1ZJn; Wed, 19 Mar 2025 05:18:07 +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 1tulem-000000080ji-0T1U for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:01 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e634a124439so9674071276.2 for ; Tue, 18 Mar 2025 22:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360875; x=1742965675; 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=O1nK5uvxYAHiuhO7vp1MDxMA7qbFQ4SO2G8OmMvCRSM=; b=jvQBhtOqXTLtyILfPO8D0wa3RO24tH27JIsZ4GiLKBCKeZ4/XU/x881hs+gIM/8BoI KcFkZirYuKSGmi+c2FTDyaD2VfsBAt2w64riXWf55N4oVH4qSE2toBmBq/3idkB5zqDF C4m4cVT2r8RV2wQrcX92YV7BrUypFBsMpqSlqbIpMgsiiTQ4J072OEp1fGBHaHzOUTGo +iA/vj5ID2j244qy10ZzgXi6bapGcv07y/bSqHV+kyygl+af4WK6nQC+L/0kXCFOElji dCCIVbbO9iLQd6Na807U1EfW1SX7U/GfuxgOL59M8ZUngYg0MOcNE9WoPaYgdDshMVHm 4ogA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360875; x=1742965675; 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=O1nK5uvxYAHiuhO7vp1MDxMA7qbFQ4SO2G8OmMvCRSM=; b=uVSf+Zx1cz6jvuJYCAi9MExU1pcEuwmTi+hMR90uWx5eBgel39npah+APp+ZuP4liC ruKv2cRho0KZdGjPyKzL5fVwUj0OC+SaProrDT7+a9Ta5FS6eN4gQGcYhPvSQs1G71fQ Fwfh3bRyWdv35w1Xiylz/6vHoImB/TkRevGGXqzcmR3KwS11/xYZ674CsZ6IplvVJ+Ya WEAZL1iwXY7KNGR1TIHN5ErCWzwOZpUQIyP/0VR9t5LDHcwfkww8lk9KzTmc8fIrk6ey SRjdjRfsnstJ8SC8IIVyiw8YDlKCuwZ8xuEiB/oInzQsLaT+l6GqZjtuP43NXOt4toou q37g== X-Forwarded-Encrypted: i=1; AJvYcCW9wUHUW2QxceyzyEf1gdSK4IEZ78pJRoEd9x90JrA6HEwtsZHmrHbeblgoCwMgelUYXmYc8zIJkn7q3UErFr/E@lists.infradead.org X-Gm-Message-State: AOJu0YxJB0WEI9Z/dXn9Q9MYC1Lx5BdDgKTRbb6LdCILKfz7tQm/G4tT qjplIr6VDb4TOzJQ3TOM8Fzwh9d6jfg2NbefKiixgV0qC1ub5wg/v1CloRJEZRk9n/DLOOfSt/W HYXoZjQ== X-Google-Smtp-Source: AGHT+IFUeD1q1mcBgOYS6b/K4PBymwrwksBbIlprzmhn8jIvW3OyAPriR4x65RqgffXv43hJ4u3eA1io7qGZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:b183:0:b0:e60:8c57:d650 with SMTP id 3f1490d57ef6-e667b42f1edmr499276.4.1742360874651; Tue, 18 Mar 2025 22:07:54 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:31 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-5-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 04/14] 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-20250318_220756_147147_DD014DCE X-CRM114-Status: GOOD ( 27.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 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 | 197 +++++++++++++++++++++++++------------ 1 file changed, 132 insertions(+), 65 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 092c5f6404ba..bdfd3d5128b7 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,69 @@ 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; + + if (trace->syscalls.table) { + 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 +2549,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; - - if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) - goto out_cant_read; + sc = trace__find_syscall(trace, e_machine, id); + if (sc) + err = syscall__read_info(sc, trace); - 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 +2711,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 +2722,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 +2796,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 +2871,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 +3224,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 +3733,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 +3744,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; @@ -3779,13 +3839,14 @@ static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, unsigne return -1; } -static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace, struct syscall *sc) +static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace, struct syscall *_sc) { + struct syscall sc = *_sc; /* Copy as trace__syscall_info may invalidate pointer. */ struct tep_format_field *field, *candidate_field; /* * We're only interested in syscalls that have a pointer: */ - for (field = sc->args; field; field = field->next) { + for (field = sc.args; field; field = field->next) { if (field->flags & TEP_FIELD_IS_POINTER) goto try_to_find_pair; } @@ -3795,15 +3856,16 @@ 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); + /* calling trace__syscall_info() may invalidate '_sc' */ + struct syscall *pair = trace__syscall_info(trace, NULL, sc.e_machine, id); struct bpf_program *pair_prog; bool is_candidate = false; - if (pair == NULL || pair == sc || + if (pair == NULL || pair->id == sc.id || pair->bpf_prog.sys_enter == trace->skel->progs.syscall_unaugmented) continue; - for (field = sc->args, candidate_field = pair->args; + for (field = sc.args, candidate_field = pair->args; field && candidate_field; field = field->next, candidate_field = candidate_field->next) { bool is_pointer = field->flags & TEP_FIELD_IS_POINTER, candidate_is_pointer = candidate_field->flags & TEP_FIELD_IS_POINTER; @@ -3870,7 +3932,7 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace goto next_candidate; } - pr_debug("Reusing \"%s\" BPF sys_enter augmenter for \"%s\"\n", pair->name, sc->name); + pr_debug("Reusing \"%s\" BPF sys_enter augmenter for \"%s\"\n", pair->name, sc.name); return pair_prog; next_candidate: continue; @@ -3945,7 +4007,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; @@ -3966,7 +4028,11 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) pair_prog = trace__find_usable_bpf_prog_entry(trace, sc); if (pair_prog == NULL) continue; - + /* + * Get syscall info again as find usable entry above might + * modify the syscall table and shuffle it. + */ + sc = trace__syscall_info(trace, NULL, EM_HOST, key); sc->bpf_prog.sys_enter = pair_prog; /* @@ -4761,7 +4827,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 +5287,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 Wed Mar 19 05:07:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022046 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 1FA2DC35FF1 for ; Wed, 19 Mar 2025 05:16:36 +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=hCu3Vx7OmrvmpWlPHZUlvo0KIzrMgeMGs8eeWosVvZ8=; b=SBRYRYu2K1IYKMqfk+mu/2Nyvm SSrVylfFuvUHWM6fV5K/m8WkvxvA9tWj3ny3sfZT9/mgKiFoDp8AW18z4D1Rmojfwq+BFoQXTgMHQ BOG/t/vgZhnFDZzurSlumdjFQjVH5D0wUzF/D63ZzI0lWVIsGQf1dyJvDiFRdp57L9LoiRWVgyhv9 Ah7bdXIsOL2xX4k1dRrEcAZ1QZuZ09mEWtRXUP01CGHAolnUBUWoytnQ8li/eWND6L4Tkt3BH94rU MKtNbivtKkWtJdUZgYlYnvBrHdJ7kPqtC/nJN8eRmxeczLn7bTHCuYjwPojLpOBgrV2y8Ezy6FMMe I94mN1uA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulmy-000000082Gt-2un0; Wed, 19 Mar 2025 05:16:24 +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 1tuleo-000000080kt-1qxb for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:00 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6ef85037f3bso4998847b3.1 for ; Tue, 18 Mar 2025 22:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360877; x=1742965677; 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=hCu3Vx7OmrvmpWlPHZUlvo0KIzrMgeMGs8eeWosVvZ8=; b=uiwLAPZLlXs3jjOBZ11mUJFV/uYZ2LvaFrwhpLeJEyR1qBFRBePBGzUzWnffF+zfxt 7bs39VMWu+2xkvwFZ/7VqQ8H5nbmZH0+YpFaU0FeAi5B4rSwzSsrpzRWtkWXOdY3Fn1t 1fsFWYcD1wkOVRk2fScfs50JxXGEiZ81Ho1EmEKNkLHwnnhb3uaPxjcOeq/hGfj7JTfA AWH801ZFDuUTYFQ1ckQ+HFrZvyoPqQe+Y+iSxyLHLJT6Mbeu4Jaa4pyGvKZ//aniChtq ELXJF2f/Q4M6tZX806Z2bGcU+BnbY21TeAatpzSDTVIEvzPThxcoQK1fqpUIdIoXg7NM gXHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360877; x=1742965677; 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=hCu3Vx7OmrvmpWlPHZUlvo0KIzrMgeMGs8eeWosVvZ8=; b=Am3Vc/V/iXHObUtPlTb7SChdXDkloqN20lArB1u0KLRE8QvxizJBI3kVAfZojujWcO ZXACrq/9eNfceufOrxAJSvtsbkWJBefXTc9dOqb5qn3/FiD0uFWgeYIJ6T+8T807wVD9 3IWd7Agyf2y/TyvG2i8F07D6CDaNJgUHLEebrxb0RbqSEYNZXzL26Jz0XFuuJya0P67Q SxLzkcSgpIMBg64vQjbctKf1JUMZc712cIgioeWVtmxdBhM67cfoSHEjyRAnNEd03Q5y gQpDz2HaQlVlM1Vssd+hltPLnQ5efA+VP/vddp4Pai9oqG/g9m2c+EdNxQxkLmWepk22 rwPQ== X-Forwarded-Encrypted: i=1; AJvYcCUW7qc7uLTNnQAJWv7kOAtaTsfN7z7NeIqVcY9MoH1OHNVI53bORsfIgK5ApSzE29zfdPmhYsTLZnEeJQVv6FnK@lists.infradead.org X-Gm-Message-State: AOJu0YwWFWN+n+xkWjBhpb01jxkhNyfEFUjFZUYzCx6LiWxdgXJfuon3 GRcB3BbH2YmXYqk490rPBn8pF7WKJUQqPJiGQJJoYP6NW9OkFbXzNQ9zN0yc1lAeOgNi1FJ2hAd TjBdmgA== X-Google-Smtp-Source: AGHT+IFFuCfBJcXKbtLFy1Oq1UnQYe25pK9PgSHo3asgGuzg+QqZEsnz8KyEWhdkGx9fDGrtTzz67Y05pfJi X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:6902:20ca:b0:e5b:1418:5733 with SMTP id 3f1490d57ef6-e667b40dd71mr812276.5.1742360877089; Tue, 18 Mar 2025 22:07:57 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:32 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-6-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 05/14] 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-20250318_220758_481255_B06F693B X-CRM114-Status: GOOD ( 29.11 ) 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 bdfd3d5128b7..3017291242cf 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) { @@ -2722,6 +2733,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; @@ -2796,6 +2808,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; @@ -2871,6 +2884,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; @@ -3224,6 +3238,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) { @@ -3731,9 +3746,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; @@ -3742,22 +3757,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; @@ -3854,8 +3869,8 @@ 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); + 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); /* calling trace__syscall_info() may invalidate '_sc' */ struct syscall *pair = trace__syscall_info(trace, NULL, sc.e_machine, id); struct bpf_program *pair_prog; @@ -3941,7 +3956,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); @@ -3949,27 +3964,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); @@ -4005,9 +4020,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; @@ -4032,7 +4047,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) * Get syscall info again as find usable entry above might * modify the syscall table and shuffle it. */ - sc = trace__syscall_info(trace, NULL, EM_HOST, key); + sc = trace__syscall_info(trace, NULL, e_machine, key); sc->bpf_prog.sys_enter = pair_prog; /* @@ -4457,8 +4472,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) { @@ -4483,7 +4503,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) @@ -4796,7 +4817,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; @@ -4827,7 +4848,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; @@ -4854,14 +4875,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) @@ -4887,7 +4908,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; } @@ -4948,7 +4970,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; } @@ -5140,8 +5163,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; } @@ -5294,7 +5318,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); } @@ -5443,9 +5466,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 Wed Mar 19 05:07:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022051 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 4EFFFC35FFB for ; Wed, 19 Mar 2025 05:20:01 +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=lKH0UkDR+38jlOCF0RORoz/lpVr/5XMrklIeecAtae0=; b=3tCHjWE1aw4FzoiPUxmUCtOitH PXA9MikaCetU1ZGTUHD1Qo2khyZC3h39b2XuPSC0Yuz5jV7VFLYoQv3Uc+R0TTTK8G/YPrCvnhgGF nkXhw6vduHWdj0WTFDWvitXAEwlTdmyyDktFVzfdNQqKQ1EcpPjRbfEPkqXO2B+coJYu77M6/e1IS Aos3/h6vEZvz14T3FZAP91p1tS8L2QJ6cAdXxFLhNHQPn/y6yR5xUF1SWkwFee/l3/1rPnNHHzULq XlwWGJTm5XV4tzvaOdnmA2tM2tfb1J8UnCxlD+PU9RIOAU8DqrN+nKbam03fw+OWCsiYUpXO6a1qG 58QZU5CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulqI-000000082aA-2yjC; Wed, 19 Mar 2025 05:19:50 +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 1tuleq-000000080mO-3q3j for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:02 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e3a0f608b88so8148365276.0 for ; Tue, 18 Mar 2025 22:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360879; x=1742965679; 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=lKH0UkDR+38jlOCF0RORoz/lpVr/5XMrklIeecAtae0=; b=SDNsFBujRBnxq9wLPbhVXk8ijZjnPZ9pS6EX/XLwvoYqsoK/ZTKSZvKBut7EAUr4Hi 706eCllDODoxbyNDjeQPAvHxzspAG11fYzSp30RcTx460xT4Hyi3LivO8nX0vBRHL4tx 6jnGkhmAWanQ7XEt8Xe4hNDU106moge8oSsRjFeGXJjxC/K6ySLVumsy3MIqMZ+JDsOT j7abE+RkQrVbEdyqo92t8XcSS963CBde7tCkkLJfnFPX/OWX5moMHFYS9uhon0RZfwHT BF05Q+/KX+7dF3F3Dav4TOVe55K0O8le+lPVo8c4jMY3g7aK86dYOoavDh+SBoYE35kd BHUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360879; x=1742965679; 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=lKH0UkDR+38jlOCF0RORoz/lpVr/5XMrklIeecAtae0=; b=VRAvaFFk452QKZn0aTDA1e7hUiTiOYlP5/ryajvwiAnpoOMRUKe/dQZT1mhJijbOW3 KVqYvnm/KOuEeOzNo45NMxpwtYJ2Nz9nVkHoFLD7dbgFAyY/fpb5mb63nQQjz2uGvoEv zsrPp38URHq/jv48vAX8ziZ5GZwNsVWHKTfub4Pu6elD48vpVTxR4j5ocItUf70EM5fR crKGaSRSCDTJYulHkfLMCcogzvcnkCX+HpMLWhg3YKkkUb7MjvEwVmC9XcLdOQre8z3Z thvuj3eceRhIvApseOCmuyK1B3HefgdOidTMeZ0jda/Dt2uycwPWIowZQCm2uChksRGs EeGQ== X-Forwarded-Encrypted: i=1; AJvYcCW6gABlkKJzt26EaZPNN1EPukj0DdGqZxNOfGgp1qbBzTmXoFcsyiT41+Hgvs5yK9uEPBG/vxvgflm9ZPb81QWu@lists.infradead.org X-Gm-Message-State: AOJu0YyZTriMbP0L28TyHjt0KJdyahiew4Jv0JFJJHINxYlULnWzWyOH xR3EnOKIfMYZJ+q0JRXJNYvmUe89mEPNK/MvUkWHPpqU5EUAZkMGFtSN3a8T15cqAL7b45f3NGY 17SuHCw== X-Google-Smtp-Source: AGHT+IHW5zIoZNQ/PFJ4nieCzozKPWCoO+ogY5Jq02jaNhLsphiocOSJqBwzeG9L8zyDxjhIToN0yhyiQJB3 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:c306:0:b0:e63:c603:37d2 with SMTP id 3f1490d57ef6-e667b44294fmr573276.7.1742360879473; Tue, 18 Mar 2025 22:07:59 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:33 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-7-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 06/14] 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-20250318_220800_957764_5261784F X-CRM114-Status: GOOD ( 19.49 ) 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 | 89 ++++++++++++++++++++++++++++++++++++ tools/perf/util/dso.h | 3 ++ tools/perf/util/symbol-elf.c | 27 ----------- 3 files changed, 92 insertions(+), 27 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index e0111049f6b0..8619b6eea62d 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1194,6 +1194,68 @@ 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__GNU_DEBUGDATA: + 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; + } + + 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); + } + mutex_unlock(dso__data_open_lock()); + return e_machine; +} + /** * dso__data_read_addr - Read data from dso address * @dso: dso object @@ -1549,6 +1611,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 53e3b9b337e5..8c1e7cdbaefd 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -737,6 +737,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, @@ -826,6 +828,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 3fa92697c457..fbf6d0f73af9 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1174,33 +1174,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 Wed Mar 19 05:07:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022052 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 343BEC35FF1 for ; Wed, 19 Mar 2025 05:21:43 +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=OrHbMMe03j2h6U4ZyDmCNi4vPHSyOLjKCo4G6hr5nEQ=; b=NGuwr2/qxyFttpdHA7wl+pN/x+ PtkhRLYDfuVUPwMJTNBqHFahCajPHJPKilQ8QGPOtE+Rs/t7H1FVWP0RnMLOo+0bR+co4cMrJhhdW 7ya4ifIB7wndO60QR5Dy8dzEO7bHi68Wu0lP78dwmspwzvXhZFffrtXKohLCV8HJtb7mvo5UK/FtI w7n2sg19sGrQsTQrUDsJb/2yBmSmgRpIitEd6V8mxuMuDpC+VRcYzkD+TkPbwQfpiqXwC4Pu2N7Ue HiH4Jp9OCqwGu2XsXPqs+1O5lCla3Op3s5zg2SSDUriJvQEfDHu4gL10+2u88kk2iaYCYkvAj6mrY 9F4AVhQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulrx-000000082lX-3rWi; Wed, 19 Mar 2025 05:21:33 +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 1tules-000000080nq-3Vut for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:04 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6f788a1de55so110045847b3.3 for ; Tue, 18 Mar 2025 22:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360882; x=1742965682; 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=OrHbMMe03j2h6U4ZyDmCNi4vPHSyOLjKCo4G6hr5nEQ=; b=aOLUBndhKSmhy/KOzPDLLubv+QJnfIRBEA25Icvb2w19gxm5kuThke73SKAHiuRTgL 6SxiR7IAr+Tm0xrMiTuo2lPET8vLXfMD6Ie9xwV/4At1fGVhRz9bSuVjpDkctMXCOWj6 f6vnKmMG+mAMGYeU46t/d2/bJihvt26Lx/4aFl9IippYLRcUGh0adYWOM3dPdb5H27hY rLYw3AOsSPgctGr71ct96dPdgLBvDk9T01Ks3PKzXZLRRiLYpHcOG4olDbCRnm5AcuhK B5xDyhlkPL78B3FT7OtKKd6nUYsNQzG8MNKuq1KjFuMmQa92lc2l+x6V2EZF7CLNVZlQ bvRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360882; x=1742965682; 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=OrHbMMe03j2h6U4ZyDmCNi4vPHSyOLjKCo4G6hr5nEQ=; b=JSxpSXWunfUiLNU5kpRSZuTyFN0x9KG4RrGuYNzp4gPDg96oSCSfJ5TBcYje/8sQ/H Qk+yrEkiL+TIiF4feNw//iggKLrxMoGizhzdf5D6geWbqjObxKTPvC93vvj+flKDGrdY OPbT2S5xh+BEKlcMYwFtu9sG8JiF1qs29DfCc0P0ASFazj2aNKlqRuEOVfoxRBNGJQTH r2dNP/LHeh0yb4nc4HwVSmuWiFr0M5Pxb6x2YK/p2SWm7zpEpXAUyIiJ6/EHU+tX+1mg 33ZZNzreUNU+rwBl4LyHuK1P2N+vASokURloMCagVYCLmhDJSygGDfu3GCS29Vxhlrhs DD/g== X-Forwarded-Encrypted: i=1; AJvYcCUQho8ZVeQd/Pu0tvi8nPPWh2ktg6CkYPafDbC5NvKiPq9+BNzNVI2y8GkwTh5OPEp2d6KeNgCJCwvzubjsbB88@lists.infradead.org X-Gm-Message-State: AOJu0Yzu+YA8Aq1TOkwlqpemiFIeqeryV1HPCvLz2KU2jH+EUs4805lm U6Zj5UHQLVDPBVKFLcaZyDPyM1A+5QWrf8q8DuLn/3VCdrvyUbjfppy865I0P52sv4yozfYq0F7 7Q83lBQ== X-Google-Smtp-Source: AGHT+IFx9Z0x08GER++C8nD4jZUCyngaSw/7/gURiTevmG+iiTK/bE0OxP7IhHFOsqWZ82+12GwC/FPcL7kJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:f609:0:b0:e63:72df:76f1 with SMTP id 3f1490d57ef6-e667b440409mr802276.6.1742360881675; Tue, 18 Mar 2025 22:08:01 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:34 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-8-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 07/14] 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-20250318_220802_889951_2151669D X-CRM114-Status: GOOD ( 28.70 ) 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 3017291242cf..1c080d95c1e2 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2731,16 +2731,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; @@ -2808,17 +2808,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() @@ -2883,15 +2884,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; @@ -3238,8 +3239,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); @@ -4889,6 +4890,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) @@ -4908,8 +4910,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 Wed Mar 19 05:07:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022057 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 B414DC35FFB for ; Wed, 19 Mar 2025 05:23:27 +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=HZEvb9rP0/Ou5uZ1kbtDkT305lhnhit7GPgOKo0wTf8=; b=skfoN3FO3Xx6hQOlzG/OBimfIX xUi6LIW4JH+edw4YcNRBpfVrHEP6AbrXB8WgBhJZiJYgJz9ncw3G463VkMBH/Imurtm3w/FkQpPQo zgV7Uaex6rpxOT51bZ35+4SEVgeqYhklfkd4lTX7peKP3VcM6rUOsfDrWcnj6WQkMFMZsCN+rzWsq S4dRa3tQqnR75EsJWO00jsvmyL1WkAP0YY3z4zKdKaVoxIFX20L/PtVVcXiBvzj2j9/06V3qTebA9 7ubmvnP+MSionASDasn0bpVXKZ4uOyCvs0mH7NCcp9txjZRN60rL6XlfFOgUVwTkzWCk+J7TeVRhu JwvO/t+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tultc-0000000833E-3xug; Wed, 19 Mar 2025 05:23:16 +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 1tulev-000000080pi-37xN for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:07 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f2737d115eso84465597b3.2 for ; Tue, 18 Mar 2025 22:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360884; x=1742965684; 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=HZEvb9rP0/Ou5uZ1kbtDkT305lhnhit7GPgOKo0wTf8=; b=po1n3KcspqRsvBiIBjx1ERchIlQBWAugSP3KkmAFgiQs/fpb4kswPkH/E8zaeYPNDr +ZtP/utFaHrOQEul2vipItbLerOTNTXcpJ0OLxm1LDiPDySe/xNfRkgs7VzmzJf4JH50 bZU+yOmz9xRK32GT8WruQwW6PgeMxCiIogvlk1Ow5SlMjjD5+6ReKoRSFSv6Q6kmpfKd /uW+O54AQH8yyK9tL+8ijDK8hOTtlVtTOvWITdKu8ndkWRW/DQcVq1uFY9gVUsfNh/LC khfSD1RIX2CJ7BgO3D2j7dMYzyK6P+UBtUdns4nISl8dJDwGko5HBAO130bLV0rVkNzp cX+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360884; x=1742965684; 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=HZEvb9rP0/Ou5uZ1kbtDkT305lhnhit7GPgOKo0wTf8=; b=Mh0VOCD/4K6lG7tBKDCpndFpKvYoAEXp0lHHqJ+DrksGJInoo3DNGnB0Ll3DRTUtA4 +Jhcn7vchfLYSxbKop8d38Vhx4MmQ9X242C7opy2InomMkUiQ/yeAQSqsOQY1tfodqze NxZ+3khmEUhdc8AfW7cmVpFvW2af6qRIbkniNoFpw3PaBDsBuQYvaT6QLOp2coQ/OLsA GylSQlLumtaf2Lv/k58xqQPvnRUU51qUU8ClItWKH52GdrPAJVcPefEvTOYZdgCF5cI8 Fr8nUi/gsmI63dqL2RPLUm+g90Um6Tc3OSa0OMhu7Vk3BBQD2CipZWxp2aIU0GlE/kyg qpBg== X-Forwarded-Encrypted: i=1; AJvYcCW7jYCldWDoefGadKt+DNJf7J6i5nVFYKWtgAqS4Qp2umKhM70ag5WXVdkWXUaGDdOqRsy8JHr1uM0u/XjjqpAU@lists.infradead.org X-Gm-Message-State: AOJu0YyLRg8LYi8uVxZrvy0RZcbJqymen+COc/FOUWEN/Mx51PEuw7EB ChbpBsHhPrlezhLRIqtjo6w0bqH6p1rrB6EVEbQdwtNXzcNaSK8DBMrvuSHQdZ82J5cr3DunHKa j2PO2dw== X-Google-Smtp-Source: AGHT+IGc44u77yeoblmfKZi4hDIZy66Uo8gfvsW5pGD8d9f86tnE8cBwkN363tZeQaj9WwaYrjUTVN2252xA X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a0d:c985:0:b0:6fd:41f6:62cb with SMTP id 00721157ae682-7009c027877mr5907b3.4.1742360884046; Tue, 18 Mar 2025 22:08:04 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:35 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-9-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 08/14] 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-20250318_220805_784672_5188C16F X-CRM114-Status: GOOD ( 21.55 ) 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: 14022068 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 9E05AC35FF1 for ; Wed, 19 Mar 2025 05:34:01 +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=jXG/G1oeYM9b/alKQuuagGTfIpZAhQmz/i2palTHGhI=; b=djwVG3nLQ761hKisv4j6SMA4U5 fFN9/O17G++3g4PUIlbkLbu3mVYsvOun8QsUxNBiMM/+hsfvMTk4LC5TxDndFJgQM2PndaWTcdSjU GiiRx1eekk4eBaUY0FQ4O2eaYsZe79e/wD1u0VaHk5IRv8H/dtfzDqvIybHRCh7WI5b9IxJqPYw8A dIIEF13VsTwdjHchR/ffbWWoPShIrN5E8g5kWsqOB/aPHtbm6mCdIDhvm2xnw4vfdZMX//Dlado/p yegC1ZJnrsRVqSE1XhApLnFHpLoB/UpAO67tahY75Ehb/bhfYCiL2fuDzF6qP6RKr9xdiVjXB13oU Xsq7jbbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tum3q-000000084Gp-2uFB; Wed, 19 Mar 2025 05:33:50 +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 1tuley-000000080rI-0ARJ for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:09 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f2c7746509so97307757b3.1 for ; Tue, 18 Mar 2025 22:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360887; x=1742965687; 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=jXG/G1oeYM9b/alKQuuagGTfIpZAhQmz/i2palTHGhI=; b=gNs8073HhTFFyomE6I5/hO/NFnDrLC2cPNmu86x0GwOe53DcSVBmwq5PZuJWA24oBT GuC7Dt3LTZyk2WwdKYs1QGUy8HqwndpPR4qhaecNbJAsC0oMZmHSo/MjiGC5PSBhcays eKenHqfbcKaAM9UV4+4LVGg9mAdflM78GoZr97jexMxQLeao6Ro1eAd9s5Dwg/RcDwKy HYdcyVW6f/54u2IgC5azmOC8GCRt9bK4ZCf89nxM4gj37v1Kg2pEhjUeX3kMkr4XJjRx wx1lt2eZJ6HXUl7bF1ANF5E3MW1l0fp37osGUztcOw+zfHUhJ9eEg/pp3YbgBBMpuQFQ IoqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360887; x=1742965687; 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=jXG/G1oeYM9b/alKQuuagGTfIpZAhQmz/i2palTHGhI=; b=kSFjZAf+O1d8cn0HhoV57sKhtiUi1u41KYjodK7p7p22I5DirMpalhdmL/aXICyjOj aW6QoG2rQWUrRhKs3/4i8JjBILHlf44D8MRPmUesucEoPHyfGLeAKGJP+qj9x5zpg8+f qUK0M9RJMBkX7NPB5EHqtuXS1EslyfNZnGsm1TGIz8u94Wrf6ti3iB0uZOBusYJdmF+A 1+eIodwj/94YnNKN757Ar9834LMUIG/lh2t1MJYnxfwEa5/vycBvjejseDYpzOrUFUFv CeEE5qf6SV3trZd3JIh3MZ0UfpyWN/vAhgNVYRasJd83YOt1fhmJcbG2bYnzD0YQV/hD AjnQ== X-Forwarded-Encrypted: i=1; AJvYcCW4W9zBLMippm8j7zUxItT8bviyH534R2RCJwpLsC/qoLFW5cZQv5LDypidqRd2W96ed6LZYMLLgyCgx2x5uQxc@lists.infradead.org X-Gm-Message-State: AOJu0YwrsZoRXa+2x8APLWRfXq4J/VwNp5WApmBIp7wy/24NPPGd8HVh 7oJwlRlmvDpaD1vSQ2jhJ4I7Zk1jBeSVXCRCsW3E7Ho9xum/ofCeiMVZIjNhleh0OJotrOIvYpv ikDmeOw== X-Google-Smtp-Source: AGHT+IGfbivFYuMlSyVSguddaatmU/X+LBa+8+b7ZSnFdgYCi37H9xIH1R2JAv8LvsqW9+nMJDArTlk6qjei X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:690c:6ac4:b0:6fe:d1b3:850a with SMTP id 00721157ae682-7009c142bb5mr13627b3.5.1742360886521; Tue, 18 Mar 2025 22:08:06 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:36 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-10-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 09/14] 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-20250318_220808_095578_7567501D X-CRM114-Status: GOOD ( 19.36 ) 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..4e6018e2e0b3 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 uint16_t *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 Wed Mar 19 05:07:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022058 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 C9F14C35FFB for ; Wed, 19 Mar 2025 05:25:27 +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=91LKckxn206QSCaYEQn5crEKBGBeBMVmLqN08/7YChQ=; b=j/3trBEndPlg0oAHBQwK5SJFde 1CrxuS6+QMKYQr9dQQZTO6N5MyXg2iPw5KI6L7W55lOpuMEI0tyi5yQL8XOE2BW4Bzk+/ghrf4aDX YHh3Dit5C8wdI2YznCOgr3WdzwJBcGRYmnhYetwRTn5moTjIKMhbhVPpsAmbCPRA/QyCdflL7OZ6B v0cYRAkrNNpKCh18V+xZev+0KyTlpZC6VHH2MqJe03bABVdttoBEEYXStAxuk31IVO0ALC8m0zNkw 86X2VU9I0NRTkBB+kHtdephygUUz1xeuJYZgG9U5VplfY7wexj/hr1CFVfDHmHGRHUzgNN/aHs0kk UEjm4uJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulvZ-000000083GM-1FV4; Wed, 19 Mar 2025 05:25:17 +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 1tulf0-000000080sK-14Qd for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:11 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e575f472438so10251550276.1 for ; Tue, 18 Mar 2025 22:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360889; x=1742965689; 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=91LKckxn206QSCaYEQn5crEKBGBeBMVmLqN08/7YChQ=; b=zBQWdvFHrYuflX+FsdHtY3VB8wAvtXXO3pYQJje6PTY6QQ2MCcFdKdfV+AscG1Ibkh PEAFG0C6xC8OoDhF9aTRe5VsJ5x+SRsyZrYUGpFasPtCSZJrgyKTGG9SwWWaQmDrrqwQ JF75eub+21aIEXfAvp8++Phpqufg8hL2JIyL/zdeRmrBxCHZ1KU0qGNVhEVkRE/Idenk KFgy1PEThLtED8Dach/LSQ9Y1SoDeT/JOtQAUImqFGZOb82PPFAHZufkxk1c22/xGQzn WtHiygyAbXQrkx70om4fRlTU6rr00R7mcrDbcT15lVmV9JQRf2s8CkyMn/l4oYTnvoR/ vggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360889; x=1742965689; 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=91LKckxn206QSCaYEQn5crEKBGBeBMVmLqN08/7YChQ=; b=MDKgo4yhFtM6sXAZ7DzACfLedILzXzr7gWjE1yxBKtAxeJDVpMJpM2vcdHj7vDX4R4 DWy9bJM69HueWR0GilTnaTWu03eFl0NbPjf6A1fT+a1SJTGv6iH/LPct2RzrZ+NVbNC3 oTaS9MOSJBvYzgpGYHYTW9HvlJWNDALo/fdrrH14HZH9iMnHL1V23B64s/9kpx/zDrfv Ye+cZb61u4o3kX+yCQS/4f7MiE7h+1kI5gua+OtApUoZW3cRdA0VjBiNgHMwU07UcbKL eBaYztH7d8XOMmn07GtITDT2vNyCef2YV/evjiqt+LaqR3x/Vdd7cltQpZZNZSaH9d8h 3kLw== X-Forwarded-Encrypted: i=1; AJvYcCWpQYrVx5ReRcssbb/YBSFlf3e8CnPigKdtja5x6zvnsHLUqKk3UaPoX7d4s2pryYSC3ZcIy3l62/HEvRwVCBLI@lists.infradead.org X-Gm-Message-State: AOJu0YzyifKZ6pi998V76q6OKe9MSrkjUkmakuX6AtqCu0V0n7BPJqnK k136SWFKWVqq2xMeAb8KVXydSJxcBpIellHlP3IQ8vNGdnHQ6KRmeWdhzqD4aaPfTu40ACdiXMC W0FvePA== X-Google-Smtp-Source: AGHT+IFHXmaHccCXeVJjGM4gMlucNwJvXb/MVQlLnZwg2cP8X9M7CzOFPea3GByyOHDkB8mDoEDWuXGbzM7P X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:d30d:0:b0:e60:a52a:377a with SMTP id 3f1490d57ef6-e667b398f78mr547276.2.1742360888783; Tue, 18 Mar 2025 22:08:08 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:37 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-11-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 10/14] 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-20250318_220810_293982_C814A2B6 X-CRM114-Status: GOOD ( 14.62 ) 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 Wed Mar 19 05:07:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022061 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 99C46C35FFB for ; Wed, 19 Mar 2025 05:27:09 +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=ncdSM+lbXMb9xe65qVg6II6RWpGKh15ceN/q8SVr8Hw=; b=vcMI25fkOJHnRU20Z05G25Tsl3 8vkMgOJN9WMDrtUN5JEuOrOayMBC3Htv0zw0vpn4as/oOTDAQndcaDEmGYLEcFuw6WXuJcrP8NuSH geevfZsf2/nuhBrRJGanqn7Y85QcIqMdRcbW6zNx3FuRhEZsY7LSdB7R088l6IA3qXoukfz09e/BH 5D6jNxfUfr8eX0GUqW7JiH6astmBc6VPi3/IrcbfcqAML1zgwxv/i7Eb5GVM7dq0kZQj0QwG38OzF hKQNsNPHbaKunJFEgp7QfSoQ0SVwSWTFs2xhWwPV3LLeSc5a2p1b7VPO7eeybmKOKffMZpuSdpGyc t8+fF9Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulxD-000000083S3-2PCQ; Wed, 19 Mar 2025 05:26:59 +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 1tulf2-000000080u3-3FvE for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:13 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6fecdb96e52so91523357b3.2 for ; Tue, 18 Mar 2025 22:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360891; x=1742965691; 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=ncdSM+lbXMb9xe65qVg6II6RWpGKh15ceN/q8SVr8Hw=; b=TtAjw1fs2dyWbSwhtvhj3+aLu+MH68kwAPrihpKNP7xUTflz2sBAfhZFnjx5jtgPj1 aAJ+eX50sI3EDg7XxMPXRiRxEe2OiLsvD5MKaElXuwQy4jMgBrz5wMelo9WCY0wQV1TN vUiV2E8jEzkZlZTm1EuCbr+btPHNBDDEPHvbp0TzyPk6XKHIUV+XqhkfutLDBA6IuGfD ov8YlAg+0Uv4pRcG5w40XXTR4jTYNVjORMMlopULBkNPnBl+bJKNDEeofuftaKlR2/b/ kO9cON+MEWrg/k+aoKyIyoJm/EyUd4EzfdzSHiWe/oVF4lyfXoxRWS70h5729gGrdXFV NVRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360891; x=1742965691; 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=ncdSM+lbXMb9xe65qVg6II6RWpGKh15ceN/q8SVr8Hw=; b=NJHtbVfcE56WobFS8hqjRyhnQcKTDQf1o7jD/3Bq27EG8dluUcJJUin/nMYlxOPvYx Mn4/zKL0pwg31a3+SPOxCU1oGgqbgdOLtfd3M2XXHYJyk2w3sUZ3JTYlK9w2L3QtHW7D qvj7zoqEnlNjeCoNc4lgblyVuVunAzmm9GqBYgGLy1tlsuUwL2YHxucHbIc0BWR2epnb 0oAXsqUMcSYzaLvc/36fqd908fhiUcsURYG6M0FTJ1HCm8GheSnYxyx4IatwArT8ru7s 9m286PYxti9ZrMtbmtft0i6tS1vkWzVizoDyQ9nygbz8bbBppE/I0H1XjGL/+QYJyTkj vAcg== X-Forwarded-Encrypted: i=1; AJvYcCXs5IXKvcw1nNFYSISkuIlZ6L5WwdaJLSKUepiUxCOjMhusjyZoaSsjkNfrc9Hh1uukhMGqk1euAVs5D/6XGivH@lists.infradead.org X-Gm-Message-State: AOJu0YxySn4scwMcNirfvrFD3b/NXBmQ58b4ssYya9nE1OV8z5jYUtyI 8pTvngOl9q7qKpV1oMcwOaam22yKin9eef0mq/rX9hZ/zyehPh14DXYWtYi15WYi9se22asvSpD eSVNlBw== X-Google-Smtp-Source: AGHT+IE7t62G3L9y/1w7Zr4bPbVHFfW94O8jbx7xn/oloQNZ3Xii0SOFszp47Hze8CWLQYL2UBnV/ggmaf2X X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:690c:6501:b0:6ff:1fac:c4fd with SMTP id 00721157ae682-7009bf39905mr12697b3.2.1742360891193; Tue, 18 Mar 2025 22:08:11 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:38 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-12-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 11/14] 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-20250318_220812_808595_BC9E4724 X-CRM114-Status: GOOD ( 12.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 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 4e6018e2e0b3..67a8ec10e9e4 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; From patchwork Wed Mar 19 05:07:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022063 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 81BD9C35FF1 for ; Wed, 19 Mar 2025 05:30: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=L7xBPeAI1ZGK/na4YhBc+S5M0v2o7F6+AZ1yRtBTaOg=; b=XF9/vVW877Nfewe1mqygtUqXR6 pHXJ8VHjeq49zSIJA3jvvIeoEXWVukQC+xSnB5fEiEjY48EMSU8DMSa9PS1/rdFzlA5Eg8SMpO0gI oCiv2SXcCpY632zAMrSrBT0Iv1z5UgsUE/+r2fddEYTiAEMSSJMfbGQIf8sNs5xORgXNNQtI9nXpN xwFI02NBkNLfD+NpbvzFTX2CCPlNQSdvX0sE9m7iJDflOqXSI5/QjAzKgRWzMRlWvAkTopsBpXpf6 2JOJgqLEaE0sFa3yAHs+uFGekOAa7ZfEmnh50pl9/iHflyJCqhg3ArO/Uw4j9B9IEtnOJm7p4/nTa YyIfcohw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tum0Y-000000083uP-0c4u; Wed, 19 Mar 2025 05:30:26 +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 1tulf5-000000080vH-0SNX for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:20 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6fd010df0f4so101122247b3.3 for ; Tue, 18 Mar 2025 22:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360894; x=1742965694; 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=L7xBPeAI1ZGK/na4YhBc+S5M0v2o7F6+AZ1yRtBTaOg=; b=Hkm/aZK19qspDVCizqXS02qtTnEkyHs4dMQRSt67XqspNC+65BrxJuv+FBFcpkwm22 AwMJAq1xFW2yeZJOkjo9f4l22pB0Bk4Z6lrJi/W+Jc3lioXzRXLr/y6/gWOhdvyXZa4z bN6079pJxlEi+ckQcgr034y682AT+J3bxJZ3hMc3zCeHMm7Iw6LWulewGebJtM8qbDwK /Yw+bQ5D7OXy52O2kU7VG1KSn2sr8BTXSUu2TRUbLBF8jiccN/UbqD7Dv4yOzmSN7evP 3vyQy4tBfj/Z6RrTO0HgVnqKfkjx9peEuc/8hcsmwQIRN0oZKTDIwxk9XMjcSSwQFYxO OXMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360894; x=1742965694; 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=L7xBPeAI1ZGK/na4YhBc+S5M0v2o7F6+AZ1yRtBTaOg=; b=caBk+9wBNcOYY7ISWHBtk7SRKh3MO/OHQ23Iv7IS00K76028YEhxeaBn3xnb1ca1wc avlvhuX9EWrqzykskBCtVMW58tojjPmTYvWFbOnhHmwEjUKi+4selGoPZOYVxBOs94ro juZYYUHmD+4gBXxhcRmNIUZbT8jOCLKHHjwO+mBN3Vm///+vPZUMPifz+2M4s3f+poDy 2PmaSsgUh61Tb2gZJwUtedlY4Zwp0kyPtkQqcrmhvBkCI9FDY45TFxm+I2zVkT9y80Z4 imrp5RODwZbttl1a2B5u5KeCNWlBNG/dnD6kWGti8D85siLbs6TgG4Pwv/nVSerfvnBW tzzA== X-Forwarded-Encrypted: i=1; AJvYcCWmRihtYHCnn6H9ytZGUHXFDex8ecDp5iJNhLBl0b9gZihKLeDgbUnyLzrjs+oVCIZ7D9HkrCwZa4ZKTO5KW2gY@lists.infradead.org X-Gm-Message-State: AOJu0YxYcC0uUfalss0ShvnoUFKDAo3BqgaMMwbC/JMvQShpI8Z+YK+U 5nkpPfuv33uX9pD/QWvgTzJ1fmy0WzebCWRsZGnvLsxyfoYejV0egg7Sikm7ChD2vRkOa/lAIVU Xbit1Ig== X-Google-Smtp-Source: AGHT+IED/ZLlykbehWpsCbnxI7/VEXCzdceMElPMiVtqa8xKpgrgI1AFRxFexUYRexGCPPRyPnT6SSPwC/n+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:6902:1824:b0:e5b:33c4:7279 with SMTP id 3f1490d57ef6-e667b432965mr506276.4.1742360893839; Tue, 18 Mar 2025 22:08:13 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:39 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-13-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 12/14] perf trace: Make syscall table stable 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-20250318_220815_141991_7D0FE3FB X-CRM114-Status: GOOD ( 21.90 ) 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 Namhyung fixed the syscall table being reallocated and moving by reloading the system call pointer after a move: https://lore.kernel.org/lkml/Z9YHCzINiu4uBQ8B@google.com/ This could be brittle so this patch changes the syscall table to be an array of pointers of "struct syscall" that don't move. Remove unnecessary copies and searches with this change. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 87 +++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1c080d95c1e2..a5f31472980b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -151,7 +151,7 @@ struct trace { struct perf_tool tool; struct { /** Sorted sycall numbers used by the trace. */ - struct syscall *table; + struct syscall **table; /** Size of table. */ size_t table_size; struct { @@ -2473,24 +2473,41 @@ 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) +static struct syscall *syscall__new(int e_machine, int id) { - memset(sc, 0, sizeof(*sc)); + struct syscall *sc = zalloc(sizeof(*sc)); + + if (!sc) + return NULL; + sc->e_machine = e_machine; sc->id = id; + return sc; } -static void syscall__exit(struct syscall *sc) +static void syscall__delete(struct syscall *sc) { if (!sc) return; - zfree(&sc->arg_fmt); + free(sc->arg_fmt); + free(sc); +} + +static int syscall__bsearch_cmp(const void *key, const void *entry) +{ + const struct syscall *a = key, *b = *((const struct syscall **)entry); + + if (a->e_machine != b->e_machine) + return a->e_machine - b->e_machine; + + return a->id - b->id; } static int syscall__cmp(const void *va, const void *vb) { - const struct syscall *a = va, *b = vb; + const struct syscall *a = *((const struct syscall **)va); + const struct syscall *b = *((const struct syscall **)vb); if (a->e_machine != b->e_machine) return a->e_machine - b->e_machine; @@ -2504,27 +2521,33 @@ static struct syscall *trace__find_syscall(struct trace *trace, int e_machine, i .e_machine = e_machine, .id = id, }; - struct syscall *sc, *tmp; + struct syscall *sc, **tmp; if (trace->syscalls.table) { - sc = bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, - sizeof(struct syscall), syscall__cmp); - if (sc) - return sc; + struct syscall **sc_entry = bsearch(&key, trace->syscalls.table, + trace->syscalls.table_size, + sizeof(trace->syscalls.table[0]), + syscall__bsearch_cmp); + + if (sc_entry) + return *sc_entry; } + sc = syscall__new(e_machine, id); + if (!sc) + return NULL; + tmp = reallocarray(trace->syscalls.table, trace->syscalls.table_size + 1, - sizeof(struct syscall)); - if (!tmp) + sizeof(trace->syscalls.table[0])); + if (!tmp) { + syscall__delete(sc); 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), + trace->syscalls.table[trace->syscalls.table_size++] = sc; + qsort(trace->syscalls.table, trace->syscalls.table_size, sizeof(trace->syscalls.table[0]), syscall__cmp); - sc = bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, - sizeof(struct syscall), syscall__cmp); return sc; } @@ -3855,14 +3878,14 @@ static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int e_machine, i return -1; } -static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace, struct syscall *_sc) +static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace, + struct syscall *sc) { - struct syscall sc = *_sc; /* Copy as trace__syscall_info may invalidate pointer. */ struct tep_format_field *field, *candidate_field; /* * We're only interested in syscalls that have a pointer: */ - for (field = sc.args; field; field = field->next) { + for (field = sc->args; field; field = field->next) { if (field->flags & TEP_FIELD_IS_POINTER) goto try_to_find_pair; } @@ -3870,18 +3893,17 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace return NULL; try_to_find_pair: - 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); - /* calling trace__syscall_info() may invalidate '_sc' */ - struct syscall *pair = trace__syscall_info(trace, NULL, sc.e_machine, 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; - if (pair == NULL || pair->id == sc.id || + if (pair == NULL || pair->id == sc->id || pair->bpf_prog.sys_enter == trace->skel->progs.syscall_unaugmented) continue; - for (field = sc.args, candidate_field = pair->args; + for (field = sc->args, candidate_field = pair->args; field && candidate_field; field = field->next, candidate_field = candidate_field->next) { bool is_pointer = field->flags & TEP_FIELD_IS_POINTER, candidate_is_pointer = candidate_field->flags & TEP_FIELD_IS_POINTER; @@ -3948,7 +3970,8 @@ static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace goto next_candidate; } - pr_debug("Reusing \"%s\" BPF sys_enter augmenter for \"%s\"\n", pair->name, sc.name); + pr_debug("Reusing \"%s\" BPF sys_enter augmenter for \"%s\"\n", pair->name, + sc->name); return pair_prog; next_candidate: continue; @@ -4044,11 +4067,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace, int e_m pair_prog = trace__find_usable_bpf_prog_entry(trace, sc); if (pair_prog == NULL) continue; - /* - * Get syscall info again as find usable entry above might - * modify the syscall table and shuffle it. - */ - sc = trace__syscall_info(trace, NULL, e_machine, key); + sc->bpf_prog.sys_enter = pair_prog; /* @@ -5316,7 +5335,7 @@ static void trace__exit(struct trace *trace) zfree(&trace->ev_qualifier_ids.entries); if (trace->syscalls.table) { for (size_t i = 0; i < trace->syscalls.table_size; i++) - syscall__exit(&trace->syscalls.table[i]); + syscall__delete(trace->syscalls.table[i]); zfree(&trace->syscalls.table); } zfree(&trace->perfconfig_events); From patchwork Wed Mar 19 05:07:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022062 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 ABF53C35FFC for ; Wed, 19 Mar 2025 05:28:50 +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=y38GESo485gGDIFJ1xMbGn6kWCzBk3/syJLY+zfYrVg=; b=cCcn5UnI1hvuKSiWP/KoaQUEMM pUCq26nVgVcbFwH7RMYVBX3qS9IzJbxcC/pr6ZIKKkhJfk8OJ6/fCBi+HkkYuMYKrkx61glzpcfDO mTa65rTqcFOLacNfB8SsfHAPJM7NWAJG6tk0X7lFnGfWqjwVf34XPA56Wr38NdfmaHlGjsnF0ZNA9 qUCwDWOTUg33oo2tLD0+35IjN+b5M9dvoPGTcGoOvmK2yMfa8X4CDjggYa+oaAI9J78RJMssbJOLS ja7NC0jGjWLekpO0mrbzP7ldRX65+9X1pjzJkmyUzIQ+JFMhvVt+pbiWpGVmG5KwrcaVU/t3yjs3T eupyNwrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tulys-000000083du-3Rhj; Wed, 19 Mar 2025 05:28:42 +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 1tulf7-000000080wb-1BOk for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:18 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6f27dd44f86so86920387b3.0 for ; Tue, 18 Mar 2025 22:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360896; x=1742965696; 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=y38GESo485gGDIFJ1xMbGn6kWCzBk3/syJLY+zfYrVg=; b=gdBZlwNclm8VAz4e7emfYXJP0//w/3ljjjxO6fMcJKHMuULjq6/FMBs7fGzWJh074G KN9cadDtet4QHXW4xbY0WiUmbn0uEQMIZbJjz3SVpfx6+T0uY5JE8LE12+Hk38Ja1ULc shjg4K32SZWuPvRpi1MO5b9GbOUzKZU8zr2uTlKbm7KQuC4ZGr7BYrTmoIqsRQ+6Jw6h omIjHHayUqGfuyKD8RSRcwgzjA4JbkCI/dUhv864ate8jJJHTfWq1BoHznWhNTsVgFHE 2hDAMtGHr8zhzs2oPbTEO6ACAF30qn6dKznUt/pGeSSDl2tdoYpX3A7XdI3icfDCPDYU s4OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360896; x=1742965696; 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=y38GESo485gGDIFJ1xMbGn6kWCzBk3/syJLY+zfYrVg=; b=OUCW5U59kIPPdUGLdvfqPE1T3leKAHnqdnpHXe6tkNgL/Rz1S5GN9f+T4F2YyXE7Pe JaGhDWmXzzPdVeLJKQPOvlXCKhzJO9VgEB4WcUUtXg6NRBvGDiQ6WBHnqHwfENb5A+mB qDRTi92MxaxygG9hC050BHtlxNqu01Z+yP81cGGYGoW5DReI8QcFO/Pbs5sE9W8twSgQ yvMQvqViUy5oJzZtoMS/bZHeJxzBRKa2xcqtqbCcx79/Wc2HMFisvGBGzZwT38METG62 FX7amJyDFWRh8qIReHnw7AtQf6lhC/pYqTOa1jdVZ999V5UrJhzcwvObmQdwkBuXhdq4 d5sw== X-Forwarded-Encrypted: i=1; AJvYcCVoDX+5x/GOEmPpG4y8HlGCXZtsbI+2Nyz6iolM+q32VyknOcoo1spemhnq/Z3FcTTda/cPdoZq4aB+7k4gymS0@lists.infradead.org X-Gm-Message-State: AOJu0YwsObzlyavGxcwOGq4bKFYymqR+vs8OoIbMEej7uIecVI/WBR6s 0astTVfcnwybLEaT7y8WyYV+e2/NVkEZPVJAwp8LUlku0LgHFNKgfFpr8gZpJmczUC1RxElMwKk AwhMo8A== X-Google-Smtp-Source: AGHT+IFPFakwCyr0uM1/sz8X8s9dtQflbQjZm9fJ42RkwL6er5xIYEKy4XS6bbEhodJ8Ew/JRCn4+wa1XjLm X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a05:690c:d8e:b0:6fe:e77c:7741 with SMTP id 00721157ae682-7009c211810mr6127b3.8.1742360896116; Tue, 18 Mar 2025 22:08:16 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:40 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-14-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 13/14] perf trace: Fix BTF memory leak 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-20250318_220817_321569_62C2C64B X-CRM114-Status: GOOD ( 11.59 ) 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 Add missing btf__free in trace__exit. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a5f31472980b..1d4ad5d19b10 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -5339,6 +5339,10 @@ static void trace__exit(struct trace *trace) zfree(&trace->syscalls.table); } zfree(&trace->perfconfig_events); +#ifdef HAVE_LIBBPF_SUPPORT + btf__free(trace->btf); + trace->btf = NULL; +#endif } #ifdef HAVE_BPF_SKEL From patchwork Wed Mar 19 05:07:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 14022067 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 DF28EC35FFC for ; Wed, 19 Mar 2025 05:32:15 +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=jGnh5R7F2nGjibuMN1IiOugHr5YAQ01+XconQh81ims=; b=QoUL9ZWODds2Eqpa0R8jR+r6F7 7nBFi5Y9giydP8pntrz7iVrIeUPAFyxn3WWgnvwZ6IDvSONdOpWjsfcuNvwuSZ7QW8chXdj5A3nUH garmvF/TaDdePIbARG4ieW6VSnaGFBOZNh3wrMJnSBUwrQyZWCtu/26AkRPzQ1q4XpoWi2cnCO/sN /yhnhIBXMf0+aLqfwdV3pMbMFDwUKyrFkqRB+ZtM9fswMvdQlQGqSfiLq0iC0N7UmUecxkboiZk8/ grLIkK2VE+PfK4AkjkBszC+9wrKbspfergd6ZglSFrQQXiUsnKVAi0AbXR1Ehcg8mLIK124M2mPCS IgkUSUEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tum2C-0000000845n-1QVJ; Wed, 19 Mar 2025 05:32: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 1tulf9-000000080xt-490g for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 05:08:21 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e5740c858beso8736085276.2 for ; Tue, 18 Mar 2025 22:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742360899; x=1742965699; 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=jGnh5R7F2nGjibuMN1IiOugHr5YAQ01+XconQh81ims=; b=k9tunLFDqk9h6GWFhNv1fYDO5wCFD3hfO+F7jEOk1p793CekG6UTZgd2IKaOauaP9z 9aot53nDKb9R/eObCurnIAyj868YjaBh3oPYwsxTF0MuyePGkVWaeMJvzzny6tw/hvkK VXzfk0EfdO+squaH1LqYyCxVL54nULLo/Z0go7sV4DJSypEaYMIlIlIJHaze2uq3+Ltf PZmOAFy1y6SdhSQ/CVGuwQ74aSn810UNT6jcYZETPL4PvYYUSj8GuneJVGEFdIILsyp6 yIzpC6RAyf8MIAOVsOfCUkmrGlApxEA5pi/UnXr1ZZZjkmvgk4neUth8dZ9BxSuR8ijr PGAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742360899; x=1742965699; 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=jGnh5R7F2nGjibuMN1IiOugHr5YAQ01+XconQh81ims=; b=fnQ8lh+zn0hpOFMEf8TxnSeVD6qaG5eU1AaDiEzRInRyi7njsgkDO8NrIlJGzmD7Ol Iq1b8C9TCdGSI/jdWwvX3xaXAEgPhfo2Y5VXGT1LZjr0fkPuQf/JPtxUF8AXRXf7TlK0 NqkCeo1lzcOYn81hKw7+05/bu1zXqh0QxiOYwBw4DW/b2gnsul5utEkpaMsw3jMv9TeE myBMbbhyHuHFM5Ko0sx+Vi6Rjhf9adsdgncb6VbOqcU4aLGIszLMTiyLTeeRTRM/NVf3 TrVTYMyc2/8AOvzeELxqk0dSOKsuQop0zirjiMrgNbRSPGNPf4+BxQQ3SHOG6ICirxHh oX0g== X-Forwarded-Encrypted: i=1; AJvYcCWRUeNjyFIp6Ewpbq1tgmmj4Xpij99Fl6JzFyqtdmA7QzEuNKsVmApxg8/3JruIolyCmWkAVPFb9hTRdGMYzuy0@lists.infradead.org X-Gm-Message-State: AOJu0YzryVMe/Y5iyqq/OGE1vM8co/5EOsg8Vbot0z2c7fc6kY2mrxzv m2WyAHB5h9jBDK5WGLRlc+Lo0xtyfCL4altzOD9DoKe39lyDMEJ4Qt3O3MaoPuuW6w8B87qFyz5 A2rQe/Q== X-Google-Smtp-Source: AGHT+IHv1nfcfv3Ye5fOTqwhfAPWbuVvzkQzn8h4pmksBhQF9eFLTiSxCvjG8QByREOpkefDEY1DbG6A3hXY X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8a11:10b5:af90:6031]) (user=irogers job=sendgmr) by 2002:a25:dc03:0:b0:e63:699a:4e6b with SMTP id 3f1490d57ef6-e667b41463bmr514276.4.1742360898600; Tue, 18 Mar 2025 22:08:18 -0700 (PDT) Date: Tue, 18 Mar 2025 22:07:41 -0700 In-Reply-To: <20250319050741.269828-1-irogers@google.com> Message-Id: <20250319050741.269828-15-irogers@google.com> Mime-Version: 1.0 References: <20250319050741.269828-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v7 14/14] perf trace: Fix evlist memory leak 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-20250318_220820_023691_C4E1599D X-CRM114-Status: GOOD ( 14.15 ) 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 Leak sanitizer was reporting a memory leak in the "perf record and replay" test. Add evlist__delete to trace__exit, also ensure trace__exit is called after trace__record. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1d4ad5d19b10..a102748bd0c9 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -5339,6 +5339,8 @@ static void trace__exit(struct trace *trace) zfree(&trace->syscalls.table); } zfree(&trace->perfconfig_events); + evlist__delete(trace->evlist); + trace->evlist = NULL; #ifdef HAVE_LIBBPF_SUPPORT btf__free(trace->btf); trace->btf = NULL; @@ -5719,8 +5721,10 @@ int cmd_trace(int argc, const char **argv) } } - if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) - return trace__record(&trace, argc-1, &argv[1]); + if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) { + err = trace__record(&trace, argc-1, &argv[1]); + goto out; + } /* Using just --errno-summary will trigger --summary */ if (trace.errno_summary && !trace.summary && !trace.summary_only)