From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17B38AD58 for ; Sat, 8 Mar 2025 00:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393937; cv=none; b=hgonuuN7908nACme4gY1xMusR7Re1hFxIdPQVZPWBcvXmow4daYkFqzezdOji6d5oSZ5MdkxH63+JXd0V52sPQ5TaEXjdAJb/zeIngD65M81HLPdYaI66Hh/nQLFwfM/tDEWt33Eh09kbxS7E41tqizZsTW3OMNLl/QPckiLUqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393937; c=relaxed/simple; bh=itceXzcWP1atjoAHUjimAtWQITJXd7w88z0cdHciNBg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=Xcn+HuPgm4vIVBwJ4CIwRdlBRUPGLWpeRk5DaPM04jq8numJjT6i3kZZsxrFO7z0QSW0kdJJvrq5Qxw1+lCdCUTLUgJ4lvegNrABzwTDhly8+Nqn59I/P4UhmhuNNPRv8A8L3bRrnop+rbbgTSHUeRWG/GeUSJCjGcAkDMeaqDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2nRQ8Mfe; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2nRQ8Mfe" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e572cd106f7so3648821276.3 for ; Fri, 07 Mar 2025 16:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393935; x=1741998735; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ivnbhuhI/ixgKyNuqtV9wf0AaXG2gqT9U4XDml1DXZU=; b=2nRQ8MfeNrUSJ6y6rPfcxnWaA8gwbOXfckKIHh2z79iH8cNP+tmWFrBknL4/jecJmA UK6kDxjQdQ74SkrzHNgVJY1arDHjnBo3e6MTtUg+aPMvayhaSvl+r2rt6UI6phukmIeP 5FPgsx53FkBsGKk4QOHZRhGBBUOeUFDkjxRo6QNkabpM5CVR7NaDnzNnuqvzPbhRYpMo Lnzu//CR6TVKKKQnBxcEy0vy0qLuBg9tx1YDVEuqRAFtnBAqvQOaPO0Pemmk3mA1cwHw u+WgC2GuFWwTp96+c7MqBoZUR722Yx+Ga5iL6d6n63EjBlOigfey8ruilN2PjguTwRlM h3gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393935; x=1741998735; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ivnbhuhI/ixgKyNuqtV9wf0AaXG2gqT9U4XDml1DXZU=; b=GVyEMsXKrsqx+YAt1AdCqba+QgohQTf9Bw05gDJCgpWeN7292ETfP2i3cZlDjThYnZ vr3EoA2W2FOi/ns6vm0jkYcoHxSHJaCkJLzad/k4eLM5qDmRqPfwueAJVuK8SaC2e7A8 kwQFXiJOugN85K7dFw26t9AVPoAZlIr5zskbpHe82sJNvvZsK7La6LGZj2gPss84jzLQ RoJexsa6k9i6yrDy5jm9yadrCBOzmjJPz1UhlbaY/xUvgGwfRwpiaCreusTN2oGPYFh3 WsLqpTbPmvC0GdgwLwYfCsHmaHYpDL0oYQAx8l7m/VgoEO/N6Bhlj1J5/VpltdzdnUI/ UwMg== X-Forwarded-Encrypted: i=1; AJvYcCWi4lgEAjHeIUPGNBf4EbWrEdrBxCSY2kA9pHP1hq1uY+prW6Hqg9FqVfairxVRXy+HlMs/7H9uUMqVLP8=@vger.kernel.org X-Gm-Message-State: AOJu0YytIKgqRR49w3/e2ZHHqwDSCnlRXF8f4+alIFK8U0eytX089xum vW8QyumS63+H/JclEUM7wjdFZhMBmfk/2zw0YTTodFAqbpmgF/KkotUAVMgEJO8jJzVnia+eRIn SoRnMuQ== X-Google-Smtp-Source: AGHT+IG6YNEzBmSnRkSpppexP7sY3bjIUwdOpxoYGty73UlROUhquWw1r9gEA9sFFMJohI1jVlJGdzxY77PY X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:728a:0:b0:e60:96b9:bee8 with SMTP id 3f1490d57ef6-e635c1ecad7mr49692276.7.1741393934929; Fri, 07 Mar 2025 16:32:14 -0800 (PST) Date: Fri, 7 Mar 2025 16:31:59 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 01/11] perf dso: Move libunwind dso_data variables into ifdef From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/util/dso.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index bb8e8f444054..dfd763a0bd9d 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -154,10 +154,12 @@ struct dso_data { int status; u32 status_seen; u64 file_size; +#ifdef HAVE_LIBUNWIND_SUPPORT u64 elf_base_addr; u64 debug_frame_offset; u64 eh_frame_hdr_addr; u64 eh_frame_hdr_offset; +#endif }; =20 struct dso_bpf_prog { --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FE381758B for ; Sat, 8 Mar 2025 00:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393939; cv=none; b=HH5FqIQoNMIs547XUtMueTxid3lxdzzkRSoxi6n6fqGdSxd4/Ns7eOQYEiIbfzRN8JWcEzYo9j9M/0Ah3/kBBVz0yWIN7elWH7KZQ5YRyAsKtwmI9uCAQpabWZecUxlxjr3SG9uV1TbPmFGSHoZP3h7p0V6/dlCXX4MkG+aDCHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393939; c=relaxed/simple; bh=mSkwBVNfT/6wF4vL0eBQIDdJqISm30fMkqt/VIArE1s=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=MaLA1aNtiIgA3lmMNsjXRjRbvcm1TAFXM7BGAsfRnK2BskzmkZIvoSKhCp/I+GcEP1BVr/ZDz3wViekz018WK8CHWMP0HSHNdONBxiKQ7A0Kkm8pKbm8X99oyTGrV33tw+PbclqgbMp+OyL53urwAwtCKxIyJlPyjXHgX2e/t/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=X5UjeJMh; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="X5UjeJMh" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fda1dcbdf1so25779397b3.1 for ; Fri, 07 Mar 2025 16:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393937; x=1741998737; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g+tZpNJTrBaubB35oLdUHzvX1yD5fDYk5lRfCYboZyg=; b=X5UjeJMh3qpTTHvqGLxgfwMIhe/VyY99h06M4Q3Tz4ns6Z2eATWoipcojDPrVMvJWX mqoENTy1t99bz/Rx71cKYNX9hxFwWj0s/O9mkdGlHo53y1U3P+l5cOsqXBlAgxBSkeWg RfstpU+jfE3wOeEE8wZ3EPZN9tw/hAlX5Zfb33cTidJJJimBuFr5KYKu8yUHIcP7EF3m wLUCAqRKJnCUr2Qp/8rENNsdBZzcbwBUewRUjZY8HeMh4kZ/KyacYE7lOpU+s2GRxgX6 gdQU7E4XePuSFkxQMEMn75Uiez/Hd+G4uX/wIUbsraO8mPpc0Ir4waJuh2lXcgjRxAYp 9KAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393937; x=1741998737; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g+tZpNJTrBaubB35oLdUHzvX1yD5fDYk5lRfCYboZyg=; b=hhosSaSSoXOqo7Zim5cQ6Dmorx8J5z77O+edUgQwApFLJhsCHePXsXFz55zQoB/sQ4 4URjrHNyNmM8iLPosqTBdPQsmG61Az3tN7+ipR/p+XXgR2auZMtcKFYbapAYfyKHer2w hxJcA+KePPwxGljAeweSwiZAB7R8LJ3ezGtgch036Qlxf23sqEzgYJzaDAh012P2jT2M lGwDeQdNg7rtXBvip+qBKPV39i9dogvHUFjmJ5K5OLMWVO4ZBLfOZfu5vF6iKLHKQrXB innZi7kbXAyipPXO99aPPQ+SbxA6hul574O+xZOU974PWXq9EXQ5H3jwcdaZrKnxu3om rb6Q== X-Forwarded-Encrypted: i=1; AJvYcCV3JucDv46+sbDa1GM8rX5+Zv6KonhLkT42r8dVq+LMMN2Wfk0sMI6elczT+CFfqQ0kXOJSZXs+lx8fQY4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9JubN3qHmg0ezfrtT02Z5t7O9+rdlfPdOd+hMIw9FiI1TvOF0 je/6xe4J9wta+ACI+AvmKa0LtxY95bZYqBUpGuhXwlF3p2p4yrNx3V1seVXxvrrqxPdACs4v4aJ FH8fo9g== X-Google-Smtp-Source: AGHT+IG1pEkPT+xN4RZyrSvyAfvazAGpr/7rp7OJtguwoNBCqz20T1HbpF3aMd2bB+k03a5UXh+CfQdQ37mM X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a5b:f43:0:b0:e63:6c54:95e7 with SMTP id 3f1490d57ef6-e636c5498f0mr16239276.4.1741393937138; Fri, 07 Mar 2025 16:32:17 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:00 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 02/11] perf dso: kernel-doc for enum dso_binary_type From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/util/dso.h | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index dfd763a0bd9d..4aa8c3d36566 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -20,30 +20,83 @@ struct perf_env; #define DSO__NAME_KALLSYMS "[kernel.kallsyms]" #define DSO__NAME_KCORE "[kernel.kcore]" =20 +/** + * enum dso_binary_type - The kind of DSO generally associated with a memo= ry + * region (struct map). + */ enum dso_binary_type { + /** @DSO_BINARY_TYPE__KALLSYMS: Symbols from /proc/kallsyms file. */ DSO_BINARY_TYPE__KALLSYMS =3D 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 f= ile. */ DSO_BINARY_TYPE__GUEST_VMLINUX, + /** @DSO_BINARY_TYPE__JAVA_JIT: Symbols from /tmp/perf.map file. */ DSO_BINARY_TYPE__JAVA_JIT, + /** + * @DSO_BINARY_TYPE__DEBUGLINK: Debug file readable from the file path + * in the .gnu_debuglink ELF section of the dso. + */ DSO_BINARY_TYPE__DEBUGLINK, + /** + * @DSO_BINARY_TYPE__BUILD_ID_CACHE: File named after buildid located in + * the buildid cache with an elf filename. + */ DSO_BINARY_TYPE__BUILD_ID_CACHE, + /** + * @DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO: File named after buildid + * located in the buildid cache with a debug filename. + */ DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__FEDORA_DEBUGINFO: Debug file in /usr/lib/debug + * with .debug suffix. + */ DSO_BINARY_TYPE__FEDORA_DEBUGINFO, + /** @DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: Debug file in /usr/lib/debug. */ DSO_BINARY_TYPE__UBUNTU_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO: dso__long_name debuginfo + * file in /usr/lib/debug/lib rather than the expected + * /usr/lib/debug/usr/lib. + */ DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO, + /** + * @DSO_BINARY_TYPE__BUILDID_DEBUGINFO: File named after buildid located + * in /usr/lib/debug/.build-id/. + */ DSO_BINARY_TYPE__BUILDID_DEBUGINFO, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_DSO: A regular executable/shared-object= file. */ DSO_BINARY_TYPE__SYSTEM_PATH_DSO, + /** @DSO_BINARY_TYPE__GUEST_KMODULE: Guest kernel module .ko file. */ DSO_BINARY_TYPE__GUEST_KMODULE, + /** @DSO_BINARY_TYPE__GUEST_KMODULE_COMP: Guest kernel module .ko.gz file= . */ DSO_BINARY_TYPE__GUEST_KMODULE_COMP, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE: Kernel module .ko file. */ DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE, + /** @DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP: Kernel module .ko.gz file= . */ DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP, + /** @DSO_BINARY_TYPE__KCORE: /proc/kcore file. */ DSO_BINARY_TYPE__KCORE, + /** @DSO_BINARY_TYPE__GUEST_KCORE: Guest /proc/kcore file. */ DSO_BINARY_TYPE__GUEST_KCORE, + /** + * @DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO: Openembedded/Yocto -dbg + * package debug info. + */ DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO, + /** @DSO_BINARY_TYPE__BPF_PROG_INFO: jitted BPF code. */ DSO_BINARY_TYPE__BPF_PROG_INFO, + /** @DSO_BINARY_TYPE__BPF_IMAGE: jitted BPF trampoline or dispatcher code= . */ DSO_BINARY_TYPE__BPF_IMAGE, + /** + * @DSO_BINARY_TYPE__OOL: out of line code such as kprobe-replaced + * instructions or optimized kprobes or ftrace trampolines. + */ DSO_BINARY_TYPE__OOL, + /** @DSO_BINARY_TYPE__NOT_FOUND: Unknown DSO kind. */ DSO_BINARY_TYPE__NOT_FOUND, }; =20 --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65AEA38DF9 for ; Sat, 8 Mar 2025 00:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393942; cv=none; b=bvZHz2H4zbJsYQFCJHQUuPJs67uW2egAhHq2qsY2H3ijP4KDzKLbQCF+Np1Lo43jWRhyZ8Qu4QucwAXPzVU7u2gFhqEfm1Hwb3NA+jT3D9bZBhMne5jnj+IEb3D93ddaOFU2XxvS8GfActQQtFVmxEdnWZRnC1rQP8tHVZHYJ8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393942; c=relaxed/simple; bh=swyL/yxWTikz8l3XHEVTDMsB52H1nY79/FpcTi8lrVI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=IdwGUBC7axbp350EjhLo+mitubs2Obz2uZfXcaCA+ScmhcjOQNPgIxj2/70NYf1CnH/gs0VD9j1wl/leARWPFzrYm2nZySfuc/4YTL323hbYBjp9pCLQhAulGik3E0911gdx9ZKaZQ+5vAFvL/4XEBVSSTM1XnB7QXr/JLeV1ck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ekvbO2K3; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ekvbO2K3" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6feb1097d64so38121407b3.2 for ; Fri, 07 Mar 2025 16:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393939; x=1741998739; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AqadS05IiqX+oCLnfCRhPMkFwGiSn/3QeC8TU0ql0EM=; b=ekvbO2K36vqWI9c0vGv2YWYvtPx7QiWjrFrMexZDCW+1XAK2wZBJzDAiAt9zCZYaaz ah9dPGUfRaTLFArvjV8Ur3wa1AMMfcLCGHp5/5Xig/U816e6uQWMHiszKezhMSk7mNUH OR0rGyO9k564B+JqT/ZMokc/8Hymao9p8dvsxQEO5nPhfNRwZdUWhQLT7ceOntxIoO/j TZJbpjzULjw1mNAFlD1UJkJFXYS9tltRPq6s/f4Wep53DnTS70prNnAr5jUrRmeW5L97 Xlvnc7f+lhT2wwry+uter+DenrJKACSyoqvfY+nFcMG7ROgenZa7hAK8WV0/mDM1oOlZ hMtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393939; x=1741998739; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AqadS05IiqX+oCLnfCRhPMkFwGiSn/3QeC8TU0ql0EM=; b=wXWnOQz1MWKWTpqNuTzkadwNZf3SDLQWagvu6FT7a21aK6o94g6RWFdTrvGIXVZgOC uwcstaYYv+QLMNcBy+BNM9huVqNYOjzYDoKpiskj4a250B336mZrnWLsnM41X/s3Suza gGH/18b367kcsrGKlIO2WS4yM9pAj8NmXM3DUis5/8knUkq4r45orAhIkUfL4MFVgtwg dKu7YY9rLCigoddITdGqPnpD5+Ytr6V4Oc7ArMQLHS30FZ1cOPmNs/rJbSakU28HcRGT oRlohIk8zH6+3fJykIRJuHRYc0SCEuIAjHj0IzbBf0PJ+IQ9Ub1c7Tu3tNJt2aAmr468 OYcg== X-Forwarded-Encrypted: i=1; AJvYcCUfKTyK6S9cZVPPNTzDpe/yixNp4fL1aZqtV3Xuurw5oYvrH3fR6tbjCE6v+V7J/Vd1w63SI5FJRB/pdlc=@vger.kernel.org X-Gm-Message-State: AOJu0Yxmx9TBi5MwbSfceuja3Roc992MANA8EZbxbNpPqbBwWgONQKVD AE5p1rzgaWrdMSPbMWhZPeeK6Uzky7733VSw9JvFb3n1JTNcwmQLC/IVFgBK9N0ld2TRcB29IgU vNipHGw== X-Google-Smtp-Source: AGHT+IHvE48c2lvHpgGakYnTePOoQVgbDE1mMquuzMm7O2A08KHA2Pxg5d2h8LM5j4ifnJpwYuMHbeAlhWkm X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:ec0a:0:b0:e60:97d9:956 with SMTP id 3f1490d57ef6-e635c1123bbmr53201276.3.1741393939346; Fri, 07 Mar 2025 16:32:19 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:01 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 03/11] perf syscalltbl: Remove syscall_table.h From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The definition of "static const char *const syscalltbl[] =3D {" 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 Reviewed-by: Ian Rogers --- 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/arc= h/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/arc= h/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 =3D=3D 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/ar= ch/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 =3D=3D 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/powerpc/include/syscall_table.h b/tools/perf/a= rch/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 =3D=3D 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/riscv/include/syscall_table.h b/tools/perf/arc= h/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 =3D=3D 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/s= h/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/arc= h/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 =3D=3D 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 =3D=3D 64 -#include -#else -#include -#endif diff --git a/tools/perf/arch/xtensa/include/syscall_table.h b/tools/perf/ar= ch/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 @@ =20 #include "syscalltbl.h" #include +#include #include #include =20 #include #include "string2.h" =20 -#include +#if __BITS_PER_LONG =3D=3D 64 + #include +#else + #include +#endif + const int syscalltbl_native_max_id =3D SYSCALLTBL_MAX_ID; static const char *const *syscalltbl_native =3D syscalltbl; =20 --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFBD554670 for ; Sat, 8 Mar 2025 00:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393944; cv=none; b=Y/Eg8xl0j5ORxKy6iaHhvjiUkw+77KJWTRQSBx1PZhRgAzKhxIAVlJdaYUq3LZ48LAKDtS9cf6sx2XvtewlnrjCpieR0JtUBn2gg1cp80QjABsDZwY5bTS7HIpChY1dzuPvwqiv3sBVmbsU7vn4uzyKdCv8BDqCir+PqzcWiWJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393944; c=relaxed/simple; bh=51j0JQwCKLfIqtjUdJi2Z47ymuGZPSnIEL4ZrnqgUQo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZFMMdMc3lgWspdAlda4hsafMuCqcwZGAGQWfb8S/4R+olb6PtFvgxkkqxhcMRRPmaNIaAGlUD2UtkYxo3GQt8GcN6gzQSHjNlqVXP5T6fID8vkaFY1PPFwWE/Hy6hB3pT0k7bXYyrvYk2L4T70iAgyoEe+JcK+D8pqwhH9OaePw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aHp+r7t+; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aHp+r7t+" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6f2737d115eso33512917b3.2 for ; Fri, 07 Mar 2025 16:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393941; x=1741998741; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=TAhKsnqf/Wp2f2WfbkipSd7nOjZwLTYVF9Ek4E/oE+c=; b=aHp+r7t+f+ChDad0pcCA7zluO8/zsG1+C+zDyAx5O1Lrl/lizQiskQUYjd997poRFT Paoxpi2qwDK8tvBnVoxuLyLBb9zVeJDl8l/Jnxo5iqROCELenduuK+O6ltVBgGFWnd/E Dgf5dZIYQtgeSHg8zC7OUTBDd/xWgT8KZrgOivt1KXoUWkMCio82BtTZIvJqeeqZSo91 BHgoJ1MMyDHDoVMAHv5VQyhtNn34McW/W3bL3B0j+wNL5jT2qr0tsjwAy36AgUgs1Oml 1Y46QnzAWo3KwxtQOJOMk9zFbBMBIaSHyA924/DWPlxbjKCqgYhmwPNGiSaJtC7MUzbj cgFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393941; x=1741998741; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TAhKsnqf/Wp2f2WfbkipSd7nOjZwLTYVF9Ek4E/oE+c=; b=AytBNaMibb8oAIAlhbWPG5QFGYoz/QkdE94wKxA9p2nUTenH5vfBDBVw20u3bLmDpG nM2SXFkKubwRlsXRJDFi0cmo7INVeZp8WeYP96+gLosgWVAUlnhF92F/sXZaucVfG6Qv NmAjTYfAyd1qSvpheA9e2xnQYww2cAI1TkGIbEFug2QVc4prNIRKq53lTJwuIll2u2yu W2NXquuPvgQC7BzaiCXyJJV+J87RDSDKCn2ez7Wo0kLLB2qAVnWpwHt2ca2+qPVckBES ad2lXzUg8POa0ot4ctIeNAdRlZ5Ts8l4D6l8cn2V5RFycsYXlq477PtQQ2D/zUFo2wpd Fjtw== X-Forwarded-Encrypted: i=1; AJvYcCWknc/FzMdqL2ssHtemZw68tjeM8UpxbtYtxj9HptgUqhR2D6rgSDGOYZ4acdfV6YYlkVAx+Q0oVNczz1k=@vger.kernel.org X-Gm-Message-State: AOJu0YwGH05ODwhpSd+3rsN/cE6G0AZUhd90MLhkPpkUNGWUSI6qWGtT Nq55Rbu/39K57cai1P5oteW/riZyfVTS2wYf+7aJWN7eIdNQ5x2Cr00NpfPLWBa8R1PD0m1/fgi GtU4jVQ== X-Google-Smtp-Source: AGHT+IHvMBwSpjV05SawdQeDnvO1NysXWTjbmEJ0nWK7el3XmxDMXs7tHdQwLWAKqgCphUNf5PaqFDEdB38d X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:310b:0:b0:e60:92c9:1b63 with SMTP id 3f1490d57ef6-e635bf15b12mr36961276.0.1741393941601; Fri, 07 Mar 2025 16:32:21 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:02 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 04/11] perf trace: Reorganize syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/builtin-trace.c | 177 ++++++++++++++++++++++++------------- 1 file changed, 118 insertions(+), 59 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 092c5f6404ba..f7d035dc0e00 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -66,6 +66,7 @@ #include "syscalltbl.h" #include "../perf.h" #include "trace_augment.h" +#include "dwarf-regs.h" =20 #include #include @@ -86,6 +87,7 @@ =20 #include #include +#include =20 #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); } =20 -/* - * is_exit: is this "exit" or "exit_group"? - * is_open: is this "open" or "openat"? To associate the fd returned in sy= s_exit with the pathname in sys_enter. - * args_size: sum of the sizes of the syscall arguments, anything after th= at 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; } =20 -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 =3D syscalltbl__name(trace->sctbl, id); + const char *name; int err; =20 - if (trace->syscalls.table =3D=3D NULL) { - trace->syscalls.table =3D calloc(trace->sctbl->syscalls.max_id + 1, size= of(*sc)); - if (trace->syscalls.table =3D=3D NULL) - return -ENOMEM; - } - sc =3D trace->syscalls.table + id; if (sc->nonexistent) return -EEXIST; =20 + if (sc->name) { + /* Info already read. */ + return 0; + } + + name =3D syscalltbl__name(trace->sctbl, sc->id); if (name =3D=3D NULL) { sc->nonexistent =3D true; return -EEXIST; @@ -2145,15 +2164,16 @@ static int trace__read_syscall_info(struct trace *t= race, int id) */ if (IS_ERR(sc->tp_format)) { sc->nonexistent =3D true; - return PTR_ERR(sc->tp_format); + err =3D PTR_ERR(sc->tp_format); + sc->tp_format =3D NULL; + return err; } =20 /* * 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; =20 sc->args =3D sc->tp_format->format.fields; @@ -2442,13 +2462,67 @@ static size_t syscall__scnprintf_args(struct syscal= l *sc, char *bf, size_t size, return printed; } =20 +static void syscall__init(struct syscall *sc, int e_machine, int id) +{ + memset(sc, 0, sizeof(*sc)); + sc->e_machine =3D e_machine; + sc->id =3D 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 =3D va, *b =3D vb; + + if (a->e_machine !=3D 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_mach= ine, int id) +{ + struct syscall key =3D { + .e_machine =3D e_machine, + .id =3D id, + }; + struct syscall *sc, *tmp; + + sc =3D bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, + sizeof(struct syscall), syscall__cmp); + if (sc) + return sc; + + tmp =3D reallocarray(trace->syscalls.table, trace->syscalls.table_size + = 1, + sizeof(struct syscall)); + if (!tmp) + return NULL; + + trace->syscalls.table =3D tmp; + sc =3D &trace->syscalls.table[trace->syscalls.table_size++]; + syscall__init(sc, e_machine, id); + qsort(trace->syscalls.table, trace->syscalls.table_size, sizeof(struct sy= scall), + syscall__cmp); + sc =3D 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); =20 -static struct syscall *trace__syscall_info(struct trace *trace, - struct evsel *evsel, int id) +static struct syscall *trace__syscall_info(struct trace *trace, struct evs= el *evsel, + int e_machine, int id) { + struct syscall *sc; int err =3D 0; =20 if (id < 0) { @@ -2473,28 +2547,20 @@ static struct syscall *trace__syscall_info(struct t= race *trace, =20 err =3D -EINVAL; =20 - if (id > trace->sctbl->syscalls.max_id) { - goto out_cant_read; - } - - if ((trace->syscalls.table =3D=3D NULL || trace->syscalls.table[id].name = =3D=3D NULL) && - (err =3D trace__read_syscall_info(trace, id)) !=3D 0) - goto out_cant_read; + sc =3D trace__find_syscall(trace, e_machine, id); + if (sc) + err =3D syscall__read_info(sc, trace); =20 - if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) - goto out_cant_read; - - return &trace->syscalls.table[id]; - -out_cant_read: - if (verbose > 0) { + if (err && verbose > 0) { char sbuf[STRERR_BUFSIZE]; - fprintf(trace->output, "Problems reading syscall %d: %d (%s)", id, -err,= str_error_r(-err, sbuf, sizeof(sbuf))); - if (id <=3D trace->sctbl->syscalls.max_id && trace->syscalls.table[id].n= ame !=3D 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; } =20 struct syscall_stats { @@ -2643,14 +2709,6 @@ static void *syscall__augmented_args(struct syscall = *sc, struct perf_sample *sam return NULL; } =20 -static void syscall__exit(struct syscall *sc) -{ - if (!sc) - return; - - zfree(&sc->arg_fmt); -} - static int trace__sys_enter(struct trace *trace, struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) @@ -2662,7 +2720,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; int augmented_args_size =3D 0; void *augmented_args =3D NULL; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 if (sc =3D=3D NULL) @@ -2736,7 +2794,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args =3D NULL; int augmented_args_size; @@ -2811,7 +2869,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; int alignment =3D trace->args_alignment; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 if (sc =3D=3D NULL) @@ -3164,7 +3222,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); =20 if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -3673,7 +3731,7 @@ static struct bpf_program *trace__find_syscall_bpf_pr= og(struct trace *trace, str =20 static void trace__init_syscall_bpf_progs(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); =20 if (sc =3D=3D NULL) return; @@ -3684,20 +3742,20 @@ static void trace__init_syscall_bpf_progs(struct tr= ace *trace, int id) =20 static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(tra= ce->skel->progs.syscall_unaugmented); } =20 static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trac= e->skel->progs.syscall_unaugmented); } =20 static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, u= nsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc =3D trace__syscall_info(trace, NULL, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment =3D false; @@ -3795,7 +3853,7 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace try_to_find_pair: for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int id =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair =3D trace__syscall_info(trace, NULL, id); + struct syscall *pair =3D trace__syscall_info(trace, NULL, EM_HOST, id); struct bpf_program *pair_prog; bool is_candidate =3D false; =20 @@ -3945,7 +4003,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(s= truct trace *trace) */ for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int key =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc =3D trace__syscall_info(trace, NULL, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); struct bpf_program *pair_prog; int prog_fd; =20 @@ -4761,7 +4819,10 @@ static size_t syscall__dump_stats(struct trace *trac= e, FILE *fp, pct =3D avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /=3D NSEC_PER_MSEC; =20 - sc =3D &trace->syscalls.table[entry->syscall]; + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, EM_HOST, entry->sys= call); + if (!sc) + continue; + printed +=3D fprintf(fp, " %-15s", sc->name); printed +=3D fprintf(fp, " %8" PRIu64 " %6" PRIu64 " %9.3f %9.3f %9.3f", n, stats->nr_failures, entry->msecs, min, avg); @@ -5218,12 +5279,10 @@ static int trace__config(const char *var, const cha= r *value, void *arg) =20 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 =3D 0; i <=3D trace->sctbl->syscalls.max_id; i++) + for (size_t i =3D 0; i < trace->syscalls.table_size; i++) syscall__exit(&trace->syscalls.table[i]); zfree(&trace->syscalls.table); } --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4627384E1C for ; Sat, 8 Mar 2025 00:32:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393948; cv=none; b=A0P7i+Jm4rHz0umd/sp9xZtwdEBu1gNrVkzDvb7g10Ddk3SadmxJaTMRvT2VSVRCOqlE/G8ihX4bK4tJHBln9g9FrxhxakOO8BPpyJaKh9ZmXZIODE7+Q2GC8UWrkQnNLrqQnECXNlXKHg2Egf463gV8029y0lTQ2KEifFTBHzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393948; c=relaxed/simple; bh=fdLTzkXnhsF9Okd9l78nqYFiXZRSCFTfBUPCXsN8w50=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NFmxC9O5wPX/6LCnUaJLUxIlTpEnC7PiXfOe3WLZTOUysu6oseU3gETC8OrfRHvQ01FRz2NbyBz1IpYQSaHDqRm47Kxh2MJddCylG2sk6JXscWf8Uy289wlWC/LUBZgm7QEpjG0T2Czljnr6PdpQQ191RS6OnaVoZ7qJnFOXji4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IWUpuM2W; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IWUpuM2W" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e60aebf48e8so3005389276.0 for ; Fri, 07 Mar 2025 16:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393944; x=1741998744; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wvyYpWfQBWv5IuHUDwA4d3/6bckVC4Sq+TPY4GnHJzI=; b=IWUpuM2Wm6bcnMHRr0GM096P0+FoYdNG09WZ6RiiWSrfvTap3KiosPDpUxbRAcH9/k 0dN8SbLtgdq96MC/Dzw0XaPU1vBfFUQDJtMKPu/yZ6pJCiQXXc810i+r7equPx42sfYs UeLRxfbiETKBWFzl2zfX7JjV78mbYf5fUqfok2B8PU2mKroLBQ9qtbn31CaGxerko20E s4r/JBR3Vw8Lmg7CwvYWnKRbbDYEhBfd2cG4nEzdKIPJcQq32/k7KclflIeoAkzv3cY3 SrpkHxujprI4xrvf9I0wexzdM0BvvPTIcYuCixblni5aBeNg0rLVD0qh+t8oHm+/TY9z Z5Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393944; x=1741998744; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wvyYpWfQBWv5IuHUDwA4d3/6bckVC4Sq+TPY4GnHJzI=; b=FjrdT6/xQaNXrK8j8LhJxP12nTXyeuQcuGWhgqrO+yxaEuypQX0RKy50mrg8rnCxuA rizb2RmNI9Q6UrkgtYh10rqAPXK/Zi0Khf98BJfCh1afD6DiVbVzHGNYwIuHla87lRy7 dtcTfOWYPHn96tOh6KmVjHFcFbtr8S3slVEdpqiZ6x1bqb+tuYgltdBxxWfiGf+Rb+sn lSMFT9O/VvEjxYlI2IzwEL7d9BIu4p0Ei6cONkF/IUWdK5kSY0JnY5TZoclWDJBDjR7W biYIjFzfnw7JobJALYj+n0pFiLMy3zc/FPDoHeFEDpgQI98RQKdPv764OMYmnZsjHLQI A72w== X-Forwarded-Encrypted: i=1; AJvYcCXDmywTCNGIGzGtEYtsWssErd6uGeIBjZA6HGUdrXebyixkLGga71xQDOvKEjFHGvEwqvEFZi05q66Cy00=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8ZRxRoBrvr+8ymy+dB5zd1A/IVDMck3fCmGP9nPcD7+6IKktB 98nY4unwRTUu6KHrNO3zfwePQTvCThz1pMtCkF9H+JWOPNuUJa2kgHAzNYRTkGeNFjGd9kbWzun Bm0uxAw== X-Google-Smtp-Source: AGHT+IEKZNcz5hrinHghqu0DgvrJqqW2FO24LmYZKjAoJRgt8y8Elu8cxdBvFeBxR6cwws4gUjfii/QNmN7v X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:6987:0:b0:e5e:1554:41a4 with SMTP id 3f1490d57ef6-e635c1db8bfmr392544276.6.1741393943920; Fri, 07 Mar 2025 16:32:23 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:03 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 05/11] perf syscalltbl: Remove struct syscalltbl From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/builtin-trace.c | 106 +++++++++++++++++------------ tools/perf/scripts/syscalltbl.sh | 36 ++++------ tools/perf/util/syscalltbl.c | 113 ++++++++++--------------------- tools/perf/util/syscalltbl.h | 22 ++---- 4 files changed, 117 insertions(+), 160 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f7d035dc0e00..cfc8cb8cbef8 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -149,7 +149,6 @@ enum summary_mode { =20 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, str= uct trace *trace) return 0; } =20 - name =3D syscalltbl__name(trace->sctbl, sc->id); + name =3D syscalltbl__name(sc->e_machine, sc->id); if (name =3D=3D NULL) { sc->nonexistent =3D true; return -EEXIST; @@ -2241,10 +2248,14 @@ static int trace__validate_ev_qualifier(struct trac= e *trace) =20 strlist__for_each_entry(pos, trace->ev_qualifier) { const char *sc =3D pos->s; - int id =3D syscalltbl__id(trace->sctbl, sc), match_next =3D -1; + /* + * TODO: Assume more than the validation/warnings are all for + * the same binary type as perf. + */ + int id =3D syscalltbl__id(EM_HOST, sc), match_next =3D -1; =20 if (id < 0) { - id =3D syscalltbl__strglobmatch_first(trace->sctbl, sc, &match_next); + id =3D syscalltbl__strglobmatch_first(EM_HOST, sc, &match_next); if (id >=3D 0) goto matches; =20 @@ -2264,7 +2275,7 @@ static int trace__validate_ev_qualifier(struct trace = *trace) continue; =20 while (1) { - id =3D syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next); + id =3D syscalltbl__strglobmatch_next(EM_HOST, sc, &match_next); if (id < 0) break; if (nr_allocated =3D=3D nr_used) { @@ -2720,6 +2731,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; int augmented_args_size =3D 0; void *augmented_args =3D NULL; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 @@ -2794,6 +2806,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args =3D NULL; @@ -2869,6 +2882,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; int alignment =3D trace->args_alignment; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 @@ -3222,6 +3236,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); =20 if (sc) { @@ -3729,9 +3744,9 @@ static struct bpf_program *trace__find_syscall_bpf_pr= og(struct trace *trace, str return trace->skel->progs.syscall_unaugmented; } =20 -static void trace__init_syscall_bpf_progs(struct trace *trace, int id) +static void trace__init_syscall_bpf_progs(struct trace *trace, int e_machi= ne, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); =20 if (sc =3D=3D NULL) return; @@ -3740,22 +3755,22 @@ static void trace__init_syscall_bpf_progs(struct tr= ace *trace, int id) sc->bpf_prog.sys_exit =3D trace__find_syscall_bpf_prog(trace, sc, sc->fm= t ? sc->fmt->bpf_prog_name.sys_exit : NULL, "exit"); } =20 -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 =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(tra= ce->skel->progs.syscall_unaugmented); } =20 -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 =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trac= e->skel->progs.syscall_unaugmented); } =20 -static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, u= nsigned int *beauty_array) +static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int e_mach= ine, int key, unsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment =3D false; @@ -3851,9 +3866,9 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace return NULL; =20 try_to_find_pair: - for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int id =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair =3D trace__syscall_info(trace, NULL, EM_HOST, id); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(sc->e_machine); i < num= _idx; ++i) { + int id =3D syscalltbl__id_at_idx(sc->e_machine, i); + struct syscall *pair =3D trace__syscall_info(trace, NULL, sc->e_machine,= id); struct bpf_program *pair_prog; bool is_candidate =3D false; =20 @@ -3937,7 +3952,7 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace return NULL; } =20 -static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) +static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace, i= nt e_machine) { int map_enter_fd =3D bpf_map__fd(trace->skel->maps.syscalls_sys_enter); int map_exit_fd =3D bpf_map__fd(trace->skel->maps.syscalls_sys_exit); @@ -3945,27 +3960,27 @@ static int trace__init_syscalls_bpf_prog_array_maps= (struct trace *trace) int err =3D 0; unsigned int beauty_array[6]; =20 - for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int prog_fd, key =3D syscalltbl__id_at_idx(trace->sctbl, i); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(e_machine); i < num_idx= ; ++i) { + int prog_fd, key =3D syscalltbl__id_at_idx(e_machine, i); =20 if (!trace__syscall_enabled(trace, key)) continue; =20 - trace__init_syscall_bpf_progs(trace, key); + trace__init_syscall_bpf_progs(trace, e_machine, key); =20 // It'll get at least the "!raw_syscalls:unaugmented" - prog_fd =3D trace__bpf_prog_sys_enter_fd(trace, key); + prog_fd =3D trace__bpf_prog_sys_enter_fd(trace, e_machine, key); err =3D bpf_map_update_elem(map_enter_fd, &key, &prog_fd, BPF_ANY); if (err) break; - prog_fd =3D trace__bpf_prog_sys_exit_fd(trace, key); + prog_fd =3D trace__bpf_prog_sys_exit_fd(trace, e_machine, key); err =3D bpf_map_update_elem(map_exit_fd, &key, &prog_fd, BPF_ANY); if (err) break; =20 /* 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 =3D trace__bpf_sys_enter_beauty_map(trace, key, (unsigned int *)beau= ty_array); + err =3D trace__bpf_sys_enter_beauty_map(trace, e_machine, key, (unsigned= int *)beauty_array); if (err) continue; err =3D bpf_map_update_elem(beauty_map_fd, &key, beauty_array, BPF_ANY); @@ -4001,9 +4016,9 @@ static int trace__init_syscalls_bpf_prog_array_maps(s= truct 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 =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int key =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(e_machine); i < num_idx= ; ++i) { + int key =3D syscalltbl__id_at_idx(e_machine, i); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, key); struct bpf_program *pair_prog; int prog_fd; =20 @@ -4449,8 +4464,13 @@ static int trace__run(struct trace *trace, int argc,= const char **argv) goto out_error_mem; =20 #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 =20 if (trace->ev_qualifier_ids.nr > 0) { @@ -4475,7 +4495,8 @@ static int trace__run(struct trace *trace, int argc, = const char **argv) * So just disable this beautifier (SCA_FD, SCA_FDAT) when 'close' is * not in use. */ - trace->fd_path_disabled =3D !trace__syscall_enabled(trace, syscalltbl__id= (trace->sctbl, "close")); + /* TODO: support for more than just perf binary machine type close. */ + trace->fd_path_disabled =3D !trace__syscall_enabled(trace, syscalltbl__id= (EM_HOST, "close")); =20 err =3D trace__expand_filters(trace, &evsel); if (err) @@ -4788,7 +4809,7 @@ static struct syscall_entry *syscall__sort_stats(stru= ct hashmap *syscall_stats) return entry; } =20 -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 =3D 0; @@ -4819,7 +4840,7 @@ static size_t syscall__dump_stats(struct trace *trace= , FILE *fp, pct =3D avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /=3D NSEC_PER_MSEC; =20 - sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, EM_HOST, entry->sys= call); + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, e_machine, entry->s= yscall); if (!sc) continue; =20 @@ -4846,14 +4867,14 @@ static size_t syscall__dump_stats(struct trace *tra= ce, FILE *fp, } =20 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); } =20 -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); } =20 static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struc= t trace *trace) @@ -4879,7 +4900,8 @@ static size_t trace__fprintf_thread(FILE *fp, struct = thread *thread, struct trac else if (fputc('\n', fp) !=3D EOF) ++printed; =20 - printed +=3D thread__dump_stats(ttrace, trace, fp); + /* TODO: get e_machine from thread. */ + printed +=3D thread__dump_stats(ttrace, trace, EM_HOST, fp); =20 return printed; } @@ -4940,7 +4962,8 @@ static size_t trace__fprintf_total_summary(struct tra= ce *trace, FILE *fp) else if (fputc('\n', fp) !=3D EOF) ++printed; =20 - printed +=3D system__dump_stats(trace, fp); + /* TODO: get all system e_machines. */ + printed +=3D system__dump_stats(trace, EM_HOST, fp); =20 return printed; } @@ -5132,8 +5155,9 @@ static int trace__parse_events_option(const struct op= tion *opt, const char *str, *sep =3D '\0'; =20 list =3D 0; - if (syscalltbl__id(trace->sctbl, s) >=3D 0 || - syscalltbl__strglobmatch_first(trace->sctbl, s, &idx) >=3D 0) { + /* TODO: support for more than just perf binary machine type syscalls. */ + if (syscalltbl__id(EM_HOST, s) >=3D 0 || + syscalltbl__strglobmatch_first(EM_HOST, s, &idx) >=3D 0) { list =3D 1; goto do_concat; } @@ -5286,7 +5310,6 @@ static void trace__exit(struct trace *trace) syscall__exit(&trace->syscalls.table[i]); zfree(&trace->syscalls.table); } - syscalltbl__delete(trace->sctbl); zfree(&trace->perfconfig_events); } =20 @@ -5435,9 +5458,8 @@ int cmd_trace(int argc, const char **argv) sigaction(SIGCHLD, &sigchld_act, NULL); =20 trace.evlist =3D evlist__new(); - trace.sctbl =3D syscalltbl__new(); =20 - if (trace.evlist =3D=3D NULL || trace.sctbl =3D=3D NULL) { + if (trace.evlist =3D=3D NULL) { pr_err("Not enough memory to run!\n"); err =3D -ENOMEM; goto out; diff --git a/tools/perf/scripts/syscalltbl.sh b/tools/perf/scripts/syscallt= bl.sh index 1ce0d5aa8b50..a39b3013b103 100755 --- a/tools/perf/scripts/syscalltbl.sh +++ b/tools/perf/scripts/syscalltbl.sh @@ -50,37 +50,27 @@ fi infile=3D"$1" outfile=3D"$2" =20 -nxt=3D0 - -syscall_macro() { - nr=3D"$1" - name=3D"$2" - - echo " [$nr] =3D \"$name\"," -} - -emit() { - nr=3D"$1" - entry=3D"$2" - - syscall_macro "$nr" "$entry" -} - -echo "static const char *const syscalltbl[] =3D {" > $outfile - sorted_table=3D$(mktemp /tmp/syscalltbl.XXXXXX) grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table =20 -max_nr=3D0 +echo "static const char *const syscall_num_to_name[] =3D {" > $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=3D$nr + echo " [$nr] =3D \"$name\"," >> $outfile done < $sorted_table +echo "};" >> $outfile =20 -rm -f $sorted_table +echo "static const uint16_t syscall_sorted_names[] =3D {" >> $outfile =20 +# When sorting by name, add a suffix of 0s upto 20 characters so that syst= em +# 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 =3D= 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 =20 -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 =20 #include @@ -20,112 +21,66 @@ #include #endif =20 -const int syscalltbl_native_max_id =3D SYSCALLTBL_MAX_ID; -static const char *const *syscalltbl_native =3D syscalltbl; +const char *syscalltbl__name(int e_machine __maybe_unused, int id) +{ + if (id >=3D 0 && id <=3D (int)ARRAY_SIZE(syscall_num_to_name)) + return syscall_num_to_name[id]; + return NULL; +} =20 -struct syscall { - int id; +struct syscall_cmp_key { const char *name; + const char *const *tbl; }; =20 static int syscallcmpname(const void *vkey, const void *ventry) { - const char *key =3D vkey; - const struct syscall *entry =3D ventry; + const struct syscall_cmp_key *key =3D vkey; + const uint16_t *entry =3D ventry; =20 - return strcmp(key, entry->name); + return strcmp(key->name, key->tbl[*entry]); } =20 -static int syscallcmp(const void *va, const void *vb) +int syscalltbl__id(int e_machine __maybe_unused, const char *name) { - const struct syscall *a =3D va, *b =3D vb; - - return strcmp(a->name, b->name); + struct syscall_cmp_key key =3D { + .name =3D name, + .tbl =3D syscall_num_to_name, + }; + const int *id =3D bsearch(&key, syscall_sorted_names, + ARRAY_SIZE(syscall_sorted_names), + sizeof(syscall_sorted_names[0]), + syscallcmpname); + + return id ? *id : -1; } =20 -static int syscalltbl__init_native(struct syscalltbl *tbl) +int syscalltbl__num_idx(int e_machine __maybe_unused) { - int nr_entries =3D 0, i, j; - struct syscall *entries; - - for (i =3D 0; i <=3D syscalltbl_native_max_id; ++i) - if (syscalltbl_native[i]) - ++nr_entries; - - entries =3D tbl->syscalls.entries =3D malloc(sizeof(struct syscall) * nr_= entries); - if (tbl->syscalls.entries =3D=3D NULL) - return -1; - - for (i =3D 0, j =3D 0; i <=3D syscalltbl_native_max_id; ++i) { - if (syscalltbl_native[i]) { - entries[j].name =3D syscalltbl_native[i]; - entries[j].id =3D i; - ++j; - } - } - - qsort(tbl->syscalls.entries, nr_entries, sizeof(struct syscall), syscallc= mp); - tbl->syscalls.nr_entries =3D nr_entries; - tbl->syscalls.max_id =3D syscalltbl_native_max_id; - return 0; + return ARRAY_SIZE(syscall_sorted_names); } =20 -struct syscalltbl *syscalltbl__new(void) +int syscalltbl__id_at_idx(int e_machine __maybe_unused, int idx) { - struct syscalltbl *tbl =3D 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 <=3D syscalltbl_native_max_id ? syscalltbl_native[id]: NULL; -} - -int syscalltbl__id(struct syscalltbl *tbl, const char *name) -{ - struct syscall *sc =3D 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 =3D tbl->syscalls.entries; - - return idx < tbl->syscalls.nr_entries ? syscalls[idx].id : -1; + return syscall_sorted_names[idx]; } =20 -int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *sysc= all_glob, int *idx) +int syscalltbl__strglobmatch_next(int e_machine __maybe_unused, const char= *syscall_glob, int *idx) { - int i; - struct syscall *syscalls =3D tbl->syscalls.entries; + for (int i =3D *idx + 1; i < (int)ARRAY_SIZE(syscall_sorted_names); ++i) { + const char *name =3D syscall_num_to_name[syscall_sorted_names[i]]; =20 - for (i =3D *idx + 1; i < tbl->syscalls.nr_entries; ++i) { - if (strglobmatch(syscalls[i].name, syscall_glob)) { + if (strglobmatch(name, syscall_glob)) { *idx =3D i; - return syscalls[i].id; + return syscall_sorted_names[i]; } } =20 return -1; } =20 -int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *sys= call_glob, int *idx) +int syscalltbl__strglobmatch_first(int e_machine, const char *syscall_glob= , int *idx) { *idx =3D -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 =20 -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); =20 -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 *sys= call_glob, int *idx); -int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *sysc= all_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); =20 #endif /* __PERF_SYSCALLTBL_H */ --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5921C13AD26 for ; Sat, 8 Mar 2025 00:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393949; cv=none; b=MxqZOCBweo5vQMBKsZNJtrT0DUQdyB85bZEv3zeCVIzJWolHLwUmZV6Hsjak18UVfCMEApwllEFE4A1+l0hqS6uNTXP4hrvKwra/S7kFXgFzGYj9YLVLO/TTkDHjzGKpUToKIa6bM4bQFOfzNQ/hQgSCjg5+fj5W49NUc/f8tYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393949; c=relaxed/simple; bh=CXs5r0h7EJ5ttG4g9B/EkaU928uC5JdyNMpXSExxHu8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=lpLFKeS7NPC4hDGMOqC063PmSDBciwl5SS+EdGFFG2JiCksMtI+BdGeuBVFkrOj4Ba4cLwExk8Blcd7M4+5d0ziB8d9OgBosJbMNRS/TweSjcQ4iS/nJZOTbRwaK4L6Uadp3MJd7DLYPWNJW/jSZb9P6If/rzidHYQCE6mUCAPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CEtm5G5+; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CEtm5G5+" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fda1dcbdf1so25780727b3.1 for ; Fri, 07 Mar 2025 16:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393946; x=1741998746; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=v8nEy5rB/hIdNS8kmhBvsJmZBEly95jw8NQmovPnRcI=; b=CEtm5G5+0iGOirSK5dGG5QUHkAgw4x4N3raad+iezLOS+rQXN9jmjwk37hWbDvQJpG mEVLP+nEBtPHzmppLDH3H1eLdfoHmxIK1LPDPIpg01YefN7HTPZupHZzYXvbSfhpLJtz PE0U/nbm5I0DmN+SxKXosYx4hpWb68naOk3yM3196oFeYQG0Kh3Z1HnYhDwUhKIysneo ltV1fJz9xdYtPZ0RKG8b0wSXdUL9GkRtJu45NrAhsw7tbjMa0f/VLAdwkKwU6LZD5+Gz kv6KQI2MaoJIUoWzs9kMdVyKcYhRmiayCGPJBr7eb7M3i0hqBFiBeFwychSGXZIETQU7 Kiag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393946; x=1741998746; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=v8nEy5rB/hIdNS8kmhBvsJmZBEly95jw8NQmovPnRcI=; b=l92OAYorWzjR79zWiJTnbFpsww2aYGJPsKzdBcI4nYvfdxZMZsOXoxQtG+Ex++xj1g 83g7eH3yQajupTDAH82bE8q1KeKvgcSn0P4yqz8agAXl7bdAFw6MA/vIiqwVgQDlfWMv Wz6ttZoFuyQRz8/4ehWAl2Lx1ApdpwGjK99kyCAFUhMGJnPmWiJEj63wgpIanoxxDs1l 2eO5Ppbpsp5zK/9GF/uqCVZdUeJyaPVNWs/NhtoWNIDJBLU/BUHMxRUxQmen/AK87sUU 7Sa2KkFsZGEnQx+pCue8mbkKWppru7IcSCyNjGgJttv87VZezd/ugmicwcRubqOajdVx uKLA== X-Forwarded-Encrypted: i=1; AJvYcCVzHhm7rVFpuJ4KFcZLtAgm5KpNR5oH/a9x/aAL4rX4CujKU6PkXwC3qsjcbl38960buPrGpqMXbv5dYOI=@vger.kernel.org X-Gm-Message-State: AOJu0YwTVyX3+F/JsWIz/M9WJbdGfBoBfgnEm8d4i69Dmu91ULHeczdf KOFKGvJJ9sw72HeSy1OMurFRH0gqb1hp3hP6mHnG4wekU4mD1P+VCqL3EHzNyHb8F7IuJ89ZZqf bJs0Vqw== X-Google-Smtp-Source: AGHT+IEReJ5DG45Y2N78xw+Wv9anGhMhyh78SY1Xp5hvlU3qYN+t3i78fMBSJgNA1+oBXk1aHtUloiroGn65 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:20b0:b0:6fd:2b79:fb13 with SMTP id 00721157ae682-6febf3b53d7mr4850647b3.6.1741393946311; Fri, 07 Mar 2025 16:32:26 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:04 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 06/11] perf dso: Add support for reading the e_machine type for a dso From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/util/dso.c | 88 ++++++++++++++++++++++++++++++++++++ tools/perf/util/dso.h | 3 ++ tools/perf/util/symbol-elf.c | 27 ----------- 3 files changed, 91 insertions(+), 27 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 5c6e85fdae0d..00fec1bc32bc 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1170,6 +1170,67 @@ ssize_t dso__data_read_offset(struct dso *dso, struc= t machine *machine, return data_read_write_offset(dso, machine, offset, data, size, true); } =20 +uint16_t dso__e_machine(struct dso *dso, struct machine *machine) +{ + uint16_t e_machine =3D EM_NONE; + int fd; + + switch (dso__binary_type(dso)) { + case DSO_BINARY_TYPE__KALLSYMS: + case DSO_BINARY_TYPE__GUEST_KALLSYMS: + case DSO_BINARY_TYPE__VMLINUX: + case DSO_BINARY_TYPE__GUEST_VMLINUX: + case DSO_BINARY_TYPE__GUEST_KMODULE: + case DSO_BINARY_TYPE__GUEST_KMODULE_COMP: + case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE: + case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP: + case DSO_BINARY_TYPE__KCORE: + case DSO_BINARY_TYPE__GUEST_KCORE: + case DSO_BINARY_TYPE__BPF_PROG_INFO: + case DSO_BINARY_TYPE__BPF_IMAGE: + case DSO_BINARY_TYPE__OOL: + case DSO_BINARY_TYPE__JAVA_JIT: + return EM_HOST; + case DSO_BINARY_TYPE__DEBUGLINK: + case DSO_BINARY_TYPE__BUILD_ID_CACHE: + case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO: + case DSO_BINARY_TYPE__SYSTEM_PATH_DSO: + case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO: + case DSO_BINARY_TYPE__FEDORA_DEBUGINFO: + case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: + case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO: + case DSO_BINARY_TYPE__BUILDID_DEBUGINFO: + break; + case DSO_BINARY_TYPE__NOT_FOUND: + default: + return EM_NONE; + } + + pthread_mutex_lock(&dso__data_open_lock); + + /* + * dso__data(dso)->fd might be closed if other thread opened another + * file (dso) due to open file limit (RLIMIT_NOFILE). + */ + try_to_open_dso(dso, machine); + fd =3D dso__data(dso)->fd; + if (fd >=3D 0) { + _Static_assert(offsetof(Elf32_Ehdr, e_machine) =3D=3D 18, "Unexpected of= fset"); + _Static_assert(offsetof(Elf64_Ehdr, e_machine) =3D=3D 18, "Unexpected of= fset"); + if (dso__needs_swap(dso) =3D=3D DSO_SWAP__UNSET) { + unsigned char eidata; + + if (pread(fd, &eidata, sizeof(eidata), EI_DATA) =3D=3D sizeof(eidata)) + dso__swap_init(dso, eidata); + } + if (dso__needs_swap(dso) !=3D DSO_SWAP__UNSET && + pread(fd, &e_machine, sizeof(e_machine), 18) =3D=3D sizeof(e_machine= )) + e_machine =3D DSO__SWAP(dso, uint16_t, e_machine); + } + pthread_mutex_unlock(&dso__data_open_lock); + return e_machine; +} + /** * dso__data_read_addr - Read data from dso address * @dso: dso object @@ -1525,6 +1586,33 @@ void dso__put(struct dso *dso) RC_CHK_PUT(dso); } =20 +int dso__swap_init(struct dso *dso, unsigned char eidata) +{ + static unsigned int const endian =3D 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 !=3D 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 !=3D 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 =3D *bid; diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 4aa8c3d36566..38d9e3eac501 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -730,6 +730,8 @@ bool dso__sorted_by_name(const struct dso *dso); void dso__set_sorted_by_name(struct dso *dso); void dso__sort_by_name(struct dso *dso); =20 +int dso__swap_init(struct dso *dso, unsigned char eidata); + void dso__set_build_id(struct dso *dso, struct build_id *bid); bool dso__build_id_equal(const struct dso *dso, struct build_id *bid); void dso__read_running_kernel_build_id(struct dso *dso, @@ -818,6 +820,7 @@ int dso__data_file_size(struct dso *dso, struct machine= *machine); off_t dso__data_size(struct dso *dso, struct machine *machine); ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size); +uint16_t dso__e_machine(struct dso *dso, struct machine *machine); ssize_t dso__data_read_addr(struct dso *dso, struct map *map, struct machine *machine, u64 addr, u8 *data, ssize_t size); diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 66fd1249660a..71df13a5722a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1173,33 +1173,6 @@ int filename__read_debuglink(const char *filename, c= har *debuglink, =20 #endif =20 -static int dso__swap_init(struct dso *dso, unsigned char eidata) -{ - static unsigned int const endian =3D 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 !=3D 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 !=3D 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; --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D939B1474B8 for ; Sat, 8 Mar 2025 00:32:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393951; cv=none; b=jrCp9DOEQR/wcYrlOTa1qPcAmKSit74KjlRwSNSVyX+lyJzx66EOIsXQ/jHtkk/w+J10V53Fi1FgUTNcR2zmwjxohX3kKMFPgYDHB4LYA6mFuop8kNreOHW3bnE905l9gJ8sXta4UrH1SEFv1VQ9GXk/fdSl38299uLRERIt2wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393951; c=relaxed/simple; bh=HdOOD74kR58kQ17pG9CwaFF99KxFicuZ/9ks/nxTEFw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SnTbpJifjXX1OEHszOlvawjG2KqlDJOsx8b0KYetBHNO09+MghXzcBuZEFwKmxSH2Zf+dSfFejUpmhw7Hd8KxOyi2xuKyqbRBRklAbCvGDZBFQ9mVVN+ksxX+gjCeiF2cpLAfAtA6uPg2VALGaJS1Mheyq3EqGSYtOyrVhjfBBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=htNRXH+7; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="htNRXH+7" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e549b6c54a0so3650364276.3 for ; Fri, 07 Mar 2025 16:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393949; x=1741998749; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=vetkQsewyj1QbRQTjQ9n4OdNuLUxV5BdmsX+IHcqXRY=; b=htNRXH+7Jnc70m2GMM83BgA9CKfmaNXI9D+KwvN3smTkok5o6hFkX2WPcXke2VDb21 LSiJd3YubVbxq++AlBAjt68hbOisfV6n6Jk0enT7B0ftL/7XnTQdtcK6nQq+P0IG/4Aq DS8m+teb5sPkoKTV8IKWotnvedDf5xMGp2WTPKjca6eWPQaiFA99bdmaCmwLOxNtoIj+ WLM39vj1oIaqK46ANCy4Ams9eVo+U1YzwT+0pXDfAzCWxt+6qgz0wFJvwqnXYiLZIsUS uACx/12s0qtBBunzrcVYuPiltfBNz+xSQKnK0nsuS73KH8jeLgDg2vMACcA7vf8UzG3y rZjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393949; x=1741998749; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vetkQsewyj1QbRQTjQ9n4OdNuLUxV5BdmsX+IHcqXRY=; b=nK0EZ8PZEXuH3opsnDz1HabPQFJJJkxc1OHiO/5VZ4hWbKNG+4S8VsuH9/22JZ0Yg2 FKfgjP3SdC7sYzzxXXA+0xn+wesvuEbj/3x2Lg/+Sk/VLp9hMsZMyhgjNYLATP7K905H ngVJx5VFWv6cn0Ut/QmrsR3x0qMrQ7Ur/VnXAu8Cia7RBHY53+rM30dDUkJxfaMCU3wJ 6Z1yMJysbjDc6WXnc3HcKftuoT0eZGU7MSAYRAQORkCmxS0Lx3J5tYJu2VO9KMLMSqYx g13kCAyxeIEa/0uYkP4JIGqEs8q17U7JvGY/ppc65NhjTcdgyE6WqAjQLwI64/Q5ozGu BByQ== X-Forwarded-Encrypted: i=1; AJvYcCW0jM5eRJiVYNRuwZBDm5g4PQZ0anMVXTTkLsdQV9hnRMNRTCqNaFixHKydsWk7O6c+tJBiY+k2qy6zzHc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6OZC+oVzNnTYYSGzS0/R04XBIBRjKr0gyRPxRF3LSERV3ZZ3i 4qZCbSJKFktwo++lffTXDog9HpQgawlrWY29wMMTNrcSK+iFmQejiqROeqpNTPJ8pHeS8oh+hBH SglzzDA== X-Google-Smtp-Source: AGHT+IFN1j1UckDldnGO2oML3Lr7Es90qR+z0qbean5UPIvBHECq0bAZ2WTXIRqKYd/3JIgKQ6nWxFUa5jkt X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:6902:1368:b0:e63:3f3d:a5aa with SMTP id 3f1490d57ef6-e635c1ee91amr406694276.7.1741393948467; Fri, 07 Mar 2025 16:32:28 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:05 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 07/11] perf thread: Add support for reading the e_machine type for a thread From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ian Rogers --- tools/perf/builtin-trace.c | 43 ++++++++++---------- tools/perf/util/thread.c | 80 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/thread.h | 14 ++++++- 3 files changed, 115 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index cfc8cb8cbef8..49199d753b7c 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2729,16 +2729,16 @@ static int trace__sys_enter(struct trace *trace, st= ruct evsel *evsel, int printed =3D 0; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - int augmented_args_size =3D 0; + int augmented_args_size =3D 0, e_machine; void *augmented_args =3D NULL; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; struct thread_trace *ttrace; =20 - if (sc =3D=3D NULL) - return -1; - thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + goto out_put; ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; @@ -2806,17 +2806,18 @@ static int trace__fprintf_sys_enter(struct trace *t= race, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; char msg[1024]; void *args, *augmented_args =3D NULL; - int augmented_args_size; + int augmented_args_size, e_machine; size_t printed =3D 0; =20 - if (sc =3D=3D NULL) - return -1; =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + return -1; ttrace =3D thread__trace(thread, trace); /* * We need to get ttrace just to make sure it is there when syscall__scnp= rintf_args() @@ -2881,15 +2882,15 @@ static int trace__sys_exit(struct trace *trace, str= uct evsel *evsel, bool duration_calculated =3D false; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; - int alignment =3D trace->args_alignment; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + int alignment =3D trace->args_alignment, e_machine; + struct syscall *sc; struct thread_trace *ttrace; =20 - if (sc =3D=3D NULL) - return -1; - thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + goto out_put; ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; @@ -3236,8 +3237,8 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + int e_machine =3D thread ? thread__e_machine(thread, trace->host) : EM_H= OST; + struct syscall *sc =3D trace__syscall_info(trace, evsel, e_machine, id); =20 if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -4881,6 +4882,7 @@ static size_t trace__fprintf_thread(FILE *fp, struct = thread *thread, struct trac { size_t printed =3D 0; struct thread_trace *ttrace =3D thread__priv(thread); + int e_machine =3D thread__e_machine(thread, trace->host); double ratio; =20 if (ttrace =3D=3D NULL) @@ -4900,8 +4902,7 @@ static size_t trace__fprintf_thread(FILE *fp, struct = thread *thread, struct trac else if (fputc('\n', fp) !=3D EOF) ++printed; =20 - /* TODO: get e_machine from thread. */ - printed +=3D thread__dump_stats(ttrace, trace, EM_HOST, fp); + printed +=3D thread__dump_stats(ttrace, trace, e_machine, fp); =20 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" =20 #include =20 @@ -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, } } =20 +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 =3D EM_NONE; + + snprintf(path, sizeof(path), "/proc/%d/exe", pid); + fd =3D open(path, O_RDONLY); + if (fd >=3D 0) { + _Static_assert(offsetof(Elf32_Ehdr, e_machine) =3D=3D 18, "Unexpected of= fset"); + _Static_assert(offsetof(Elf64_Ehdr, e_machine) =3D=3D 18, "Unexpected of= fset"); + if (pread(fd, &e_machine, sizeof(e_machine), 18) !=3D sizeof(e_machine)) + e_machine =3D EM_NONE; + close(fd); + } + return e_machine; +} + +static int thread__e_machine_callback(struct map *map, void *machine) +{ + struct dso *dso =3D map__dso(map); + + _Static_assert(0 =3D=3D 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 =3D RC_CHK_ACCESS(thread)->e_machine; + + if (e_machine !=3D EM_NONE) + return e_machine; + + tid =3D thread__tid(thread); + pid =3D thread__pid(thread); + if (pid !=3D tid) { + struct thread *parent =3D machine__findnew_thread(machine, pid, pid); + + if (parent) { + e_machine =3D 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 =3D maps__for_each_map(thread__maps(thread), + thread__e_machine_callback, + machine); + if (e_machine =3D=3D EM_NONE) { + /* Maps failed, perhaps we're live with map events disabled. */ + bool is_live =3D machine->machines =3D=3D NULL; + + if (!is_live) { + /* Check if the session has a data file. */ + struct perf_session *session =3D container_of(machine->machines, + struct perf_session, + machines); + + is_live =3D !!session->data; + } + /* Read from /proc/pid/exe if live. */ + if (is_live) + e_machine =3D read_proc_e_machine_for_pid(pid); + } + if (e_machine !=3D EM_NONE) + thread__set_e_machine(thread, e_machine); + else + e_machine =3D EM_HOST; + return e_machine; +} + struct thread *thread__main_thread(struct machine *machine, struct thread = *thread) { if (thread__pid(thread) =3D=3D 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(stru= ct thread *thread, int dep RC_CHK_ACCESS(thread)->filter_entry_depth =3D depth; } =20 +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 =3D e_machine; +} + + static inline bool thread__lbr_stitch_enable(const struct thread *thread) { return RC_CHK_ACCESS(thread)->lbr_stitch_enable; --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D77F1494A3 for ; Sat, 8 Mar 2025 00:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393953; cv=none; b=CXn4WFtBGOlAQeDZ6ckChPbs72v+GGkWUwCCbAsejwKtWQwo3z1KI6HaAYglxm+3CCGnasN6MylAME5cZAyl4K5MveFJ8QkGOxXC2d6gGCV0tk0BEQLH4UV9HVX/3UpsyHDlscRqEthJC0HTMPwKsE9BMHaSsMXUD7NEZEyv1/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393953; c=relaxed/simple; bh=uG8R7BvGqk9Vhp7zhRA/OxtARIz2pOPtth17cmzcr4Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ELbkXGZp+GFnYEyOX1MrQF/h24yLvumJnJhpBR8yqNNJ994J9pgtoEF7eX9S0Q0cV9V3tnR8L/eFA2bJNwHFNs08XzQmB3aAxUULFPLCJeih/1ox5VmJC2rK6i1qJ3qsRKD32IQDjLA4FPu1+pslKA0dSkwaCaqChRPLK6Y6SCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yRYsntJv; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yRYsntJv" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e60c24d9fe8so3515881276.0 for ; Fri, 07 Mar 2025 16:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393951; x=1741998751; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XlFNebLAKQij87xZRU0DCWeRHfkQPLeMoGP6veDBAZ4=; b=yRYsntJv7P/shTlidxEaWhSCF4nYeTCBC9XLqIpnovo9HCYoq9Nr2YXFi9vSSoA1QS e5GEtFFonVG2L4xCd/E9cmx0snUxUOgHNHSr1vyjO6MVGgVcma2hiOvT2foybkPpHm8h wH6a5sAJ8VZ3WRcpvwUIVZgBkVzrYA9Ocqk2cRxpGT6Va+3cESAmXegqJp5CKWlUICTd LHCThYUB//93C2QzvZ0vQomO/vr8zYaaSOJz/AXAWtuuYYEI9ZaWhyJRCirHOezfq6fz 9D93a92LrPU3J42ZjOVRehlHXE11iM16Tni9JXidmHX924owiU12jLRWkzr0I/n4idbx lqUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393951; x=1741998751; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XlFNebLAKQij87xZRU0DCWeRHfkQPLeMoGP6veDBAZ4=; b=CCPxYGatI554lGnvy1zdy9JaesE8y5eMOvieFyoGnllKO7TVywHAHzocB/S1NsdClB 30VgR3ucBeLrOoDFs6WRIZCY0FTG1xByUvu3BdIdQf3ND9IyUWrIc70Zxtf0RcJTxxc0 JQZ/tH6Nmjuxy2Fiaka7cwEL4L0iWOkIkY+j1jv+0u672GuUDoLrpXk62X7ZIPMT5QRW OKWnPSAIkOd/vBmRyHsHQ1Y2ONcFiLR///YNN485e8JGfBaoZZKCjYSLe76ynGURUtec s5qwzN68ZYoQQ4LpbfmEbtT/ONAKqZ062iS0AcxYxFUDdd49pBN3OWodibf0WzaHP3B2 PlTw== X-Forwarded-Encrypted: i=1; AJvYcCUVkJejFIIVEdSML/j191GLei4b4NP6Ub4us0/lXCXxuxWzwiTrrp8GdhxcKNGx0JKZfFYWpveFsOZOMK0=@vger.kernel.org X-Gm-Message-State: AOJu0YxAPyvxWEBMQBo/g58waLCCEmZekcOK420KwDCILkLRHLk+Oq7R oXgrUz2QTjeZBvWwwp70YE5k5eNDbWhiaQbf9AGh7WFbmJniZuHpzYQlZKwgkPkHlaqAHOfgzj4 +19scUw== X-Google-Smtp-Source: AGHT+IHB3W/KXCJ++szfS/DeXeYW9m1CyGOsczkykOR5iqkmjGU1F7EbbOZWJrjep+YhntQrISyp3G+pnOEo X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:ce94:0:b0:e57:3500:2294 with SMTP id 3f1490d57ef6-e635c16822cmr44477276.3.1741393950820; Fri, 07 Mar 2025 16:32:30 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:06 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 08/11] perf trace beauty: Add syscalltbl.sh generating all system call tables From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.fastm= ail.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 Reviewed-by: Ian Rogers --- 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 :=3D $(beauty_outdir)/ioctl # Create output directory if not already present $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir= )') =20 +syscall_array :=3D $(beauty_outdir)/syscalltbl.c +syscall_tbl :=3D $(srctree)/tools/perf/trace/beauty/syscalltbl.sh +syscall_tbl_data :=3D $(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 :=3D $(beauty_outdir)/fs_at_flags_array.c fs_at_flags_tbl :=3D $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh =20 @@ -878,6 +886,7 @@ build-dir =3D $(or $(__build-dir),.) =20 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/beaut= y/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=3D$1 +outfile=3D$2 + +build_tables() { + infile=3D"$1" + outfile=3D"$2" + abis=3D$(echo "($3)" | tr ',' '|') + e_machine=3D"$4" + + if [ ! -f "$infile" ] + then + echo "Missing file $infile" + exit 1 + fi + sorted_table=3D$(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}[] =3D {" = >> "$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] =3D \"$name\"," >> "$outfile" + done < "$sorted_table" + echo "};" >> "$outfile" + + echo "static const uint16_t syscall_sorted_names_${e_machine}[] =3D {" >>= "$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 = =3D 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" "$out= file" common,64 EM_ALPHA +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/parisc/entry/syscalls/syscall.tbl" "$ou= tfile" common,64 EM_PARISC +cat >> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/scripts/syscall.tbl" "$outfile" common,64,riscv,r= limit,memfd_secret EM_RISCV +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/sparc/entry/syscalls/syscall.tbl" "$out= file" 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 !=3D 64" >> "$outfile" + +build_outer_table() { + e_machine=3D$1 + outfile=3D"$2" + cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <; Sat, 8 Mar 2025 00:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393956; cv=none; b=fGuWebiTiND88dfYthQ6B6QdO52DVw4+vlleu5Lbyq+WcklrLW+FeoHMtroAVIfhuoat8kqaNXJSJfZV1s+PtH6XuC/y51OKsScXrSsc/z0lkQ14lKlv9O5p4bs3TfJD+AXGUA4Yfmo6ou7f1/vnpFm7a0UdnQyS7FdPiGCRhPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393956; c=relaxed/simple; bh=tkpE5yf6lhv0HCff3vMWjebf55ibmzUj0gG9xamBxYI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=iE0QQMsiUNiMzh4CHd2As+fp2SYDOz6/ymrciGAdYwXWzzjlWbLf4vFthZJIEl1e1hxEESDLPWeeVrcHq+tjmHBGjXYiRxW/374vr3/5TydadpkSoV9bi0uDEUIO+o59j5/WW5SPodGVAwAjUiwCxIib85uubikT4sMGDBgm9SU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=J0Hyhj7f; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J0Hyhj7f" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e5740c858beso2767542276.2 for ; Fri, 07 Mar 2025 16:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393953; x=1741998753; darn=vger.kernel.org; h=content-transfer-encoding:to:from:subject:references:mime-version :message-id:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Uv3gSi2uGb/rZBWAfK/HKSoE0hwzZt2P2jyoBxCTag8=; b=J0Hyhj7f2teSDzB0noRG+aaD0kEjITmrfRt8wa9bgVdMZBhlA7GogHjvs3ae6TNcu9 AywGsbIaA6+uNMG4FFSUdjxHqEmCjV0gaePEX1z/5ixybmu9mdleK7fJDmQV4H3Zz74a COOybBvxUbjCFMi08MMnj+WNMzwMz86mQkLwiw7hkilzAW3GxSabXDVnMEBUL2uheQ2W 604i6Awby10LwxL+PtESNadwno/qRf3qn10VirOgZw6rljWNMYsNSDKq4bKU1uo4JEie 7aPSVxW6+HSokY1tMenqz6aaUd63GKD9S+nfFsfJmiT8ZVCdFRVcgM0uVFpPHP091nld nPpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393953; x=1741998753; h=content-transfer-encoding:to:from:subject:references:mime-version :message-id:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Uv3gSi2uGb/rZBWAfK/HKSoE0hwzZt2P2jyoBxCTag8=; b=oX7x0xf3URFKoFciGqD0+G51RJSyITtRootrngiMZ/8mK01UrtVZWSpgm8T52bDfZF RdDaysWA9TIR7RKWaxZNKL9f93dSWwSWC9dXOYc9OOp6zFiL5JmoeorcdeBk7CHBVJ6Q 7Dz//v+dFccle9/dZX+CarbPFSdo3cE9AzRJr/1KWSbSPgD7VC30TPvzzJ3RLJzpAuiR 3iPM9bTL4ojNo3fLYv/mFDB4wNODEmNty6eZLrISkuu+BfGgI21HeHnXKFB3RdzgnZQq BC4KISg8F1/eNUmj1bfMJqckNFHMJfRkRrBUAI/3jU2nJijq1ZC66FzgANl6I7V9jo/F Di1A== X-Forwarded-Encrypted: i=1; AJvYcCXaEk3ED15x5IsaYglOeMDGPRxvNr7a2yplWaRH2t05bkFQ6QJD+KAq5mN+icALn9ZTwP+2+/NgaVlulCM=@vger.kernel.org X-Gm-Message-State: AOJu0YxlqoKwV3tanTb306wifUuS/7AaZnQctO8nKcAa1+EEmhWfGwd6 Hh1ESu/ltFfpThwGmkUG2w0PrQf2ckMTHNuOerICk7QkllEwIPH9bGGS0ifAQmd4ggS21oQY4Vo qsjia/g== X-Google-Smtp-Source: AGHT+IFs2Qu7hOI+ZkryA/SR8ozQLnfo7wV+jFqgt45ZHjCLNu9+c1jV23yEUzf/okxG+EJas0/wlMjGTuit X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a25:dc47:0:b0:e63:699a:4e6b with SMTP id 3f1490d57ef6-e63699a4ff7mr24016276.4.1741393953007; Fri, 07 Mar 2025 16:32:33 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:07 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 09/11] perf syscalltbl: Use lookup table containing multiple architectures From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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()) = =3D 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|ERRQ= UEUE|NOSIGNAL|WAITFORONE|BATCH|SOCK_DEVMEM|ZEROCOPY|FASTOPEN|CMSG_CLOEXEC|0= x91f80000, addr: 0xe30, addr_len: 0xffce438c) =3D 1475198976 0.042 ( 0.003 ms): a.out/447296 lgetxattr(name: "", value: 0x3, size: = 34) =3D 4160344064 0.054 ( 0.003 ms): a.out/447296 dup2(oldfd: -134422744, newfd: 4) = =3D -1 ENOENT (No such file or directory) 0.060 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct io= vec){.iov_base =3D (void *)0x2e646c2f6374652f,.iov_len =3D (__kernel_size_t= )7307199665335594867,}, vlen: 557056, pos_h: 4160585708) =3D 3 0.074 ( 0.004 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: = 2) =3D 4160237568 0.080 ( 0.001 ms): a.out/447296 lstat(filename: "", statbuf: 0x193f6) = =3D 0 0.089 ( 0.007 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct io= vec){.iov_base =3D (void *)0x3833692f62696c2f,.iov_len =3D (__kernel_size_t= )3276497845987585334,}, vlen: 557056, pos_h: 4160585708) =3D 3 0.097 ( 0.002 ms): a.out/447296 close(fd: 3) = =3D 512 0.103 ( 0.002 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: = 2050) =3D 4157935616 0.107 ( 0.007 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x5, size: 2066) =3D 4158078976 0.116 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x1, size: 2066) =3D 4159639552 0.121 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x3, size: 2066) =3D 4160184320 0.129 ( 0.002 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x3, size: 50) =3D 4160196608 0.138 ( 0.001 ms): a.out/447296 lstat(filename: "") = =3D 0 0.145 ( 0.002 ms): a.out/447296 mq_timedreceive(mqdes: 4291706800, u_m= sg_ptr: 0xf7f9ea48, msg_len: 134616640, u_msg_prio: 0xf7fd7fec, u_abs_timeo= ut: (struct __kernel_timespec){.tv_sec =3D (__kernel_time64_t)-578174027777= 317696,.tv_nsec =3D (long long int)4160349376,}) =3D 0 0.148 ( 0.001 ms): a.out/447296 mkdirat(dfd: -134617816, pathname: " = =EF=BF=BD=EF=BF=BD=EF=BF=BD =EF=BF=BD=EF=BF=BD=EF=BF=BD=E2=96=92=EF=BF=BD= =EF=BF=BD=EF=BF=BD=E2=96=92=EF=BF=BD=EF=BF=BD=EF=BF=BD", mode: IFREG|ISUID|= IRUSR|IWGRP|0xf7fd0000) =3D 447296 0.150 ( 0.001 ms): a.out/447296 process_vm_writev(pid: -134617812, lve= c: (struct iovec){.iov_base =3D (void *)0xf7f9e9c8f7f9e4c0,.iov_len =3D (__= kernel_size_t)4160349376,}, liovcnt: 4160588048, rvec: (struct iovec){}, ri= ovcnt: 4160585708, flags: 4291707352) =3D 0 0.197 ( 0.004 ms): a.out/447296 capget(header: 4160184320, dataptr: 81= 92) =3D 0 0.202 ( 0.002 ms): a.out/447296 capget(header: 1448669184, dataptr: 40= 96) =3D 0 0.208 ( 0.002 ms): a.out/447296 capget(header: 4160577536, dataptr: 81= 92) =3D 0 0.220 ( 0.001 ms): a.out/447296 getxattr(pathname: "", name: "c=EF=BF= =BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD", value: 0xf7f77e34, size:= 1) =3D 0 0.228 ( 0.005 ms): a.out/447296 fchmod(fd: -134729728, mode: IRUGO|IWU= GO|IFREG|IFIFO|ISVTX|IXUSR|0x10000) =3D 0 0.240 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: 0x5658e008= , pos_h: 4160192052) =3D 3 0.250 ( 0.008 ms): a.out/447296 close(fd: 3) = =3D 1436 0.260 ( 0.018 ms): a.out/447296 stat(filename: "", statbuf: 0xffce32ac= ) =3D 1436 0.288 (1000.213 ms): a.out/447296 readlinkat(buf: 0xffce31d4, bufsiz: = 4291703244) =3D 0 ``` After: ``` ? ( ): a.out/442930 ... [continued]: execve()) = =3D 0 0.023 ( 0.002 ms): a.out/442930 brk() = =3D 0x57760000 0.052 ( 0.003 ms): a.out/442930 access(filename: 0xf7f5af28, mode: R) = =3D -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) =3D 3 0.078 ( 0.001 ms): a.out/442930 close(fd: 3) = =3D 0 0.087 ( 0.007 ms): a.out/442930 openat(dfd: CWD, filename: "/lib/i386-= linux-", flags: RDONLY|CLOEXEC|LARGEFILE) =3D 3 0.095 ( 0.002 ms): a.out/442930 read(fd: 3, buf: = 0xffbdbb70, count: 512) =3D 512 0.135 ( 0.001 ms): a.out/442930 close(fd: 3) = =3D 0 0.148 ( 0.001 ms): a.out/442930 set_tid_address(tidptr: 0xf7f2b528) = =3D 442930 (a.out) 0.150 ( 0.001 ms): a.out/442930 set_robust_list(head: 0xf7f2b52c, len:= 12) =3D 0.196 ( 0.004 ms): a.out/442930 mprotect(start: 0xf7f03000, len: 8192,= prot: READ) =3D 0 0.202 ( 0.002 ms): a.out/442930 mprotect(start: 0x5658e000, len: 4096,= prot: READ) =3D 0 0.207 ( 0.002 ms): a.out/442930 mprotect(start: 0xf7f63000, len: 8192,= prot: READ) =3D 0 0.230 ( 0.005 ms): a.out/442930 munmap(addr: 0xf7f10000, len: 103414) = =3D 0 0.244 ( 0.010 ms): a.out/442930 openat(dfd: CWD, filename: 0x5658d008)= =3D 3 0.255 ( 0.007 ms): a.out/442930 read(fd: 3, buf: = 0xffbdb67c, count: 4096) =3D 1436 0.264 ( 0.018 ms): a.out/442930 write(fd: 1, buf: , count:= 1436) =3D 1436 0.292 (1000.173 ms): a.out/442930 clock_nanosleep(rqtp: { .tv_sec: 178= 66546940376776704, .tv_nsec: 4159878336 }, rmtp: 0xffbdb59c) =3D 0 1000.478 ( ): a.out/442930 exit_group() = =3D ? ``` Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins Reviewed-by: Ian Rogers --- tools/perf/util/syscalltbl.c | 89 ++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index 760ac4d0869f..db0d2b81aed1 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -15,16 +15,39 @@ #include #include "string2.h" =20 -#if __BITS_PER_LONG =3D=3D 64 - #include -#else - #include -#endif +#include "trace/beauty/generated/syscalltbl.c" =20 -const char *syscalltbl__name(int e_machine __maybe_unused, int id) +static const struct syscalltbl *find_table(int e_machine) { - if (id >=3D 0 && id <=3D (int)ARRAY_SIZE(syscall_num_to_name)) - return syscall_num_to_name[id]; + static const struct syscalltbl *last_table; + static int last_table_machine =3D EM_NONE; + + /* Tables only exist for EM_SPARC. */ + if (e_machine =3D=3D EM_SPARCV9) + e_machine =3D EM_SPARC; + + if (last_table_machine =3D=3D e_machine && last_table !=3D NULL) + return last_table; + + for (size_t i =3D 0; i < ARRAY_SIZE(syscalltbls); i++) { + const struct syscalltbl *entry =3D &syscalltbls[i]; + + if (entry->e_machine !=3D e_machine && entry->e_machine !=3D EM_NONE) + continue; + + last_table =3D entry; + last_table_machine =3D e_machine; + return entry; + } + return NULL; +} + +const char *syscalltbl__name(int e_machine, int id) +{ + const struct syscalltbl *table =3D find_table(e_machine); + + if (table && id >=3D 0 && id < table->num_to_name_len) + return table->num_to_name[id]; return NULL; } =20 @@ -41,38 +64,54 @@ static int syscallcmpname(const void *vkey, const void = *ventry) return strcmp(key->name, key->tbl[*entry]); } =20 -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 =3D { - .name =3D name, - .tbl =3D syscall_num_to_name, - }; - const int *id =3D bsearch(&key, syscall_sorted_names, - ARRAY_SIZE(syscall_sorted_names), - sizeof(syscall_sorted_names[0]), - syscallcmpname); + const struct syscalltbl *table =3D find_table(e_machine); + struct syscall_cmp_key key; + const int *id; + + if (!table) + return -1; + + key.name =3D name; + key.tbl =3D table->num_to_name; + id =3D bsearch(&key, table->sorted_names, table->sorted_names_len, + sizeof(table->sorted_names[0]), syscallcmpname); =20 return id ? *id : -1; } =20 -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 =3D find_table(e_machine); + + if (!table) + return 0; + + return table->sorted_names_len; } =20 -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 =3D find_table(e_machine); + + if (!table) + return -1; + + assert(idx >=3D 0 && idx < table->sorted_names_len); + return table->sorted_names[idx]; } =20 -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 =3D *idx + 1; i < (int)ARRAY_SIZE(syscall_sorted_names); ++i) { - const char *name =3D syscall_num_to_name[syscall_sorted_names[i]]; + const struct syscalltbl *table =3D find_table(e_machine); + + for (int i =3D *idx + 1; table && i < table->sorted_names_len; ++i) { + const char *name =3D table->num_to_name[table->sorted_names[i]]; =20 if (strglobmatch(name, syscall_glob)) { *idx =3D i; - return syscall_sorted_names[i]; + return table->sorted_names[i]; } } =20 --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5563615B0EE for ; Sat, 8 Mar 2025 00:32:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393959; cv=none; b=DoE3UF94pB6WK60YDn6vEINlqAj+M8e3sBkH9eRv7q4KRyOzbf4MfZluV5ULJinL5bwVVlfBoPLDs7NahEqs2DqYP+VubcQNZnqUMF4vOrhmt7e1gTJS7y84wLOxnQMzDmgDb0YRm+dvU72Y+5OQ7+tEls+3Vlmh6GhhdModKLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393959; c=relaxed/simple; bh=pYYGkWfgCBCxzlnsZrfVOpmQ0aPyc3kL1kYjyR8OuPs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YpXjVgCRzruV0d6y9JrnncJ2H5kjP4IBG4qyNMK1sqQpSKe9OdKxGRH1+HmVCsj300k5oaLgCnn7Scu1Pkb4ldYvCzqD4vVLce7Q/UOj+71kdET6kzBczJHAXXF9XDwA600l5pfqa9J308slkmiPY+v8rj67r9KjqiKGpmlAcRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VN9I+wy1; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VN9I+wy1" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f3ff1ff117so33524867b3.0 for ; Fri, 07 Mar 2025 16:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393955; x=1741998755; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=f45GgMpM3Ox0iyikUDUkLxs1CesX7fkHV4LsmiysvdI=; b=VN9I+wy1jnZF8z7znwgmNZnOQLTkIBilKcBT70+jy0vLcvEZeyx4xGPn312GQfAkYe yhvhaEHUw/dzauVjCWJ7pV7bWLcr68d+17SZ+11zo1zjiB9t057W37+BrOloKXeHdGR2 ALylgBXeZMIMBa8hgMypoz/623igU7WvVm9xyJ9/m2IuDbFtrTfVK70pzObk8yMJnc7T CLQBRZlVoj7cnfsaphPILfgYJQ70YN8fSVQdYqz2svV3BItbvK33l49uoPKs4i03HU2+ DPuvOpNL84xOibjqABf0tha4UyFFHDyoGBpJtSttOQ2rJwbqCgm2jRLWisUxuVc9Gd5Q p9fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393955; x=1741998755; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f45GgMpM3Ox0iyikUDUkLxs1CesX7fkHV4LsmiysvdI=; b=YorxcQWRF8pWCrkHXD+GdKYcNDOxGvVbo8icOgkmtreiRwhYpf5f4cTnfEH+7bl9xX iBWBjNuKXtpZOPqrvDmNcxaYZUB9MUEzv8+6EkPKZ54JXJagHS9ZPoPCM4i2+C11eKRe EhDMBLXqK3U9v8GrJRC9KXte9z2nxUln4Bdy0YSBS7b1iOGDuTw7adj+E1qsMHBUehN5 rjTTMxi9oyV4ZSuxK+TdYb/wfcViddlohFt16Q+a87Gmkk/WT34gnVf5y9vNPELw7V6b JMC/SyRCu0je64q90WQ2lscI8FPxw46H3s4pRlcjiZXa1l08sILAi0+ChFpFL/rrkokh Q6Hw== X-Forwarded-Encrypted: i=1; AJvYcCWEcZCzmANqiln4ygHH7p1tStUJb6YD9ilxcAgX4tKJU1sm5f4irHwn0zjq8cF4YTFhzoOoBIUDIrhXABA=@vger.kernel.org X-Gm-Message-State: AOJu0YxAoQmNnFmKdzVEHqoAMpLWRoTUtSH2xV+8+zJHtXCv5Ulxw5Ls PCdSBXNN/BssGWVdZS7EoFOIH19V3b1YdJPw4tQ7b+BKPMhq2sX8RU3cyk0bp9FayCmPCc3OEcz AhrTHWQ== X-Google-Smtp-Source: AGHT+IEX8Kp3kmlqJY4XoArbicob+cMMoPN1AMYXoDTd1XEAhXrAKzfhns5473W9Ew8DEhOapyIEzMHWAsGM X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:2e82:b0:6fd:a1fa:9d58 with SMTP id 00721157ae682-6febf39c301mr4209877b3.8.1741393955352; Fri, 07 Mar 2025 16:32:35 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:08 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 10/11] perf build: Remove Makefile.syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-5b304e4= 08e11@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 Reviewed-by: Ian Rogers --- 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.sysca= lls 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-du= mp) FEATURE_TESTS :=3D all endif endif -include $(srctree)/tools/perf/scripts/Makefile.syscalls include Makefile.config endif =20 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 +=3D 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 +=3D - -syscalltbl =3D $(srctree)/tools/perf/arch/alpha/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/arc/entry/syscalls/Kbuild b/tools/perf/arch/ar= c/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 +=3D syscalls_32.h diff --git a/tools/perf/arch/arc/entry/syscalls/Makefile.syscalls b/tools/p= erf/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 +=3D arc time32 renameat stat64 rlimit diff --git a/tools/perf/arch/arm/entry/syscalls/Kbuild b/tools/perf/arch/ar= m/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 +=3D oabi -syscalltbl =3D $(srctree)/tools/perf/arch/arm/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/arm/entry/syscalls/Makefile.syscalls b/tools/p= erf/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 +=3D 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 +=3D syscalls_32.h -syscall-y +=3D 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 +=3D -syscall_abis_64 +=3D renameat rlimit memfd_secret - -syscalltbl =3D $(srctree)/tools/perf/arch/arm64/entry/syscalls/syscall_%.t= bl diff --git a/tools/perf/arch/csky/entry/syscalls/Kbuild b/tools/perf/arch/c= sky/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 +=3D 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 +=3D csky time32 stat64 rlimit diff --git a/tools/perf/arch/loongarch/entry/syscalls/Kbuild b/tools/perf/a= rch/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 +=3D syscalls_64.h diff --git a/tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls b/t= ools/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 +=3D diff --git a/tools/perf/arch/mips/entry/syscalls/Kbuild b/tools/perf/arch/m= ips/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 +=3D 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 +=3D n64 - -syscalltbl =3D $(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 +=3D syscalls_32.h -syscall-y +=3D syscalls_64.h diff --git a/tools/perf/arch/parisc/entry/syscalls/Makefile.syscalls b/tool= s/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 +=3D -syscall_abis_64 +=3D - -syscalltbl =3D $(srctree)/tools/perf/arch/parisc/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/powerpc/entry/syscalls/Kbuild b/tools/perf/arc= h/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 +=3D syscalls_32.h -syscall-y +=3D syscalls_64.h diff --git a/tools/perf/arch/powerpc/entry/syscalls/Makefile.syscalls b/too= ls/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 +=3D nospu -syscall_abis_64 +=3D nospu - -syscalltbl =3D $(srctree)/tools/perf/arch/powerpc/entry/syscalls/syscall.t= bl 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 +=3D 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 +=3D riscv memfd_secret -syscall_abis_64 +=3D riscv rlimit memfd_secret diff --git a/tools/perf/arch/s390/entry/syscalls/Kbuild b/tools/perf/arch/s= 390/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 +=3D 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 +=3D renameat rlimit memfd_secret - -syscalltbl =3D $(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 +=3D syscalls_32.h diff --git a/tools/perf/arch/sh/entry/syscalls/Makefile.syscalls b/tools/pe= rf/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 +=3D -syscalltbl =3D $(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 +=3D syscalls_32.h -syscall-y +=3D 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 +=3D -syscall_abis_64 +=3D -syscalltbl =3D $(srctree)/tools/perf/arch/sparc/entry/syscalls/syscall.tbl diff --git a/tools/perf/arch/x86/entry/syscalls/Kbuild b/tools/perf/arch/x8= 6/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 +=3D syscalls_32.h -syscall-y +=3D syscalls_64.h diff --git a/tools/perf/arch/x86/entry/syscalls/Makefile.syscalls b/tools/p= erf/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 +=3D i386 -syscall_abis_64 +=3D - -syscalltbl =3D $(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 +=3D syscalls_32.h diff --git a/tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls b/tool= s/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 +=3D -syscalltbl =3D $(srctree)/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl diff --git a/tools/perf/scripts/Makefile.syscalls b/tools/perf/scripts/Make= file.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 fr= om a -# table that is specific to that architecture. - -PHONY :=3D all -all: - -obj :=3D $(OUTPUT)arch/$(SRCARCH)/include/generated/asm - -syscall_abis_32 :=3D common,32 -syscall_abis_64 :=3D common,64 -syscalltbl :=3D $(srctree)/tools/scripts/syscall.tbl - -# let architectures override $(syscall_abis_%) and $(syscalltbl) --include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.sys= calls -include $(srctree)/tools/build/Build.include --include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild - -systbl :=3D $(srctree)/tools/perf/scripts/syscalltbl.sh - -syscall-y :=3D $(addprefix $(obj)/, $(syscall-y)) - -# Remove stale wrappers when the corresponding files are removed from gene= ric-y -old-headers :=3D $(wildcard $(obj)/*.h) -unwanted :=3D $(filter-out $(syscall-y),$(old-headers)) - -quiet_cmd_remove =3D REMOVE $(unwanted) - cmd_remove =3D rm -f $(unwanted) - -quiet_cmd_systbl =3D SYSTBL $@ - cmd_systbl =3D $(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 :=3D $(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 +=3D FORCE - -FORCE: - -existing-targets :=3D $(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/syscallt= bl.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 ar= e handled)" - exit 1 -} - -# default unless specified by options -abis=3D - -while [ $# -gt 0 ] -do - case $1 in - --abis) - abis=3D$(echo "($2)" | tr ',' '|') - shift 2;; - -*) - echo "$1: unknown option" >&2 - usage;; - *) - break;; - esac -done - -if [ $# -ne 2 ]; then - usage -fi - -infile=3D"$1" -outfile=3D"$2" - -sorted_table=3D$(mktemp /tmp/syscalltbl.XXXXXX) -grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table - -echo "static const char *const syscall_num_to_name[] =3D {" > $outfile -# the params are: nr abi name entry compat -# use _ for intentionally unused variables according to SC2034 -while read nr _ name _ _; do - echo " [$nr] =3D \"$name\"," >> $outfile -done < $sorted_table -echo "};" >> $outfile - -echo "static const uint16_t syscall_sorted_names[] =3D {" >> $outfile - -# When sorting by name, add a suffix of 0s upto 20 characters so that syst= em -# 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 =3D= 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 --=20 2.49.0.rc0.332.g42c0ae87b1-goog From nobody Sat Feb 7 19:04:14 2026 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCAED166F0C for ; Sat, 8 Mar 2025 00:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393960; cv=none; b=taJ9W5Wz5J1jEmR6VeI+DImJyA3tqbUQEW3NRxOBmcZdKuwSqSdTVsocVBvrB+B8oK4BzwkdQQchRDxS7DKbZcMJPR2LzthF4TMUK57txysSV4mzg/M59LhnlqBq7LlGS4dnYRYdFUYnJ+Aj9wh47/JGHmP8Wd0lsXNOaxCNPZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741393960; c=relaxed/simple; bh=UEng1UvNcxBEzMZu5jvHA5kePc7WHOW16EAvxAQg2lE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ehjS71rVwMgLWZzPNEe2csf5IRvWdxpag87k3i10LmV6KFJlyv4LKTmcDhDgAUofh7y/DM0/krwjqnu7RF/hPbyfdTWUsT5x40IbSY41yjnJTNrd1vqewPe+J3eDlmRx9FF5w4VOeX39psS3vYKQzGDz90S2MfcM7w38Gezlq88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=q52g7LWy; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="q52g7LWy" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6fd43b37dc3so35425637b3.3 for ; Fri, 07 Mar 2025 16:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741393957; x=1741998757; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=aBag0ZTpgw2jBnuqcdEe2ctv9zQnS+6XrNEn3QpM0IU=; b=q52g7LWymZwpca1B46+Kt4A1PN+cfwkinkRHiQlhwL5Y+RQxp1mcrl2CDQYC3iZ7OV +ioJ86pHyO3PRmfKtNWY13RhBbDfH31HpsObpwhStRfUyQRLUcTFBsCafcW5CHeNYJxg isImwELXy7Ck75nP+x4lTT2sJZsvHICxpJFXUdArocUslSh6WYFNKPH0yN3hFbM+98+B oTba4kqVY+qhx7WIfQTnCdtQm5N5gc/7M6PvBy65wdfjzzAw3E8btEhv/8Dm4vKCWp0n uTqgRhemXdOs9hpC6p74exmO+8FPEzUfYbTaT2x4467FAtYlNNAjGLWE49J8EGPg/pcC PG4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741393957; x=1741998757; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aBag0ZTpgw2jBnuqcdEe2ctv9zQnS+6XrNEn3QpM0IU=; b=mlJOAMobGjAIt3qX0sZIKRvY8WlOlgF/qoToSjxetg1y181kNpARXm6QNjR1qtsCjD hxgIsSv+Rj8K7srR1ng91SFhLm5EnklnG1Rxgel8MU9JEyqbYMn3FJucYeJLZa3XeBQh qGPaIJNAO5nxeFcCzb4M4HfFHTCntj1prVGxjPYXFuyjTqDNAhU8df3vmb4Z1lcxL5Qc kLoY4NKmopZN6b8XEP5tVxSi3w7CoX6lX2ljakTElq4bFKYeIE/fiCHGAaLFHcFcmD+/ MLMumF7RMkcvDJp7t1QEPG1KxuT8gd2QqINy2uCj9Qd/eqN/GVzAwvObQemtjMhVI1Ka uMLg== X-Forwarded-Encrypted: i=1; AJvYcCVb+68hyab6akb4D59iQQQjp4Vj5budGUauMZWv8uec9jTVvh4g2y4uepnan/YRjSRB6J/OinRfr70dF80=@vger.kernel.org X-Gm-Message-State: AOJu0YxW4IZ6LPT5tAsVnCO1Rlxo1ZXCgly3Zgt1IS/P56StHgnseULS LUhJA47KGDLjMX2ZFpDP0I/WSivjGrWRN36V+GcDpHPLShiwpLyKG5a3D8Tufbe4xGwp9kx8we9 ET0pH6g== X-Google-Smtp-Source: AGHT+IGhJSVrXcuIauCCTdcdrck6v986JR4xLPN3EKMbWJDNglYuGen8NURA01YPhhzdv9BlJdEWKZRc9pFA X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:1541:e490:aa80:5766]) (user=irogers job=sendgmr) by 2002:a05:690c:2901:b0:6eb:ac7:b4bc with SMTP id 00721157ae682-6febf2a661cmr5088337b3.2.1741393957696; Fri, 07 Mar 2025 16:32:37 -0800 (PST) Date: Fri, 7 Mar 2025 16:32:09 -0800 In-Reply-To: <20250308003209.234114-1-irogers@google.com> Message-Id: <20250308003209.234114-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250308003209.234114-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Subject: [PATCH v5 11/11] perf syscalltbl: Mask off ABI type for MIPS system calls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.fastm= ail.com/ When decoding the "id" (aka system call number) for MIPS ignore values greater-than 1000. Signed-off-by: Ian Rogers Reviewed-by: Ian Rogers --- tools/perf/util/syscalltbl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index db0d2b81aed1..ace66e69c1bc 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -46,6 +46,14 @@ const char *syscalltbl__name(int e_machine, int id) { const struct syscalltbl *table =3D find_table(e_machine); =20 + if (e_machine =3D=3D 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 =3D id % 1000; + } if (table && id >=3D 0 && id < table->num_to_name_len) return table->num_to_name[id]; return NULL; --=20 2.49.0.rc0.332.g42c0ae87b1-goog