From mboxrd@z Thu Jan 1 00:00:00 1970 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 76FE138FA6 for ; Tue, 18 Mar 2025 03:31:56 +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=1742268718; cv=none; b=C+lUPyU37U7ebhPEEwGf/cCidl6omEIaGv3/4GQt97TPkUnU56tg8KBhISo/RAALWw/Q0wtzt2T57IZucfJ/Usq93Wc36uEgbquJ5dEWnzpzGj0iXxCBHNG71hOWGqDKYVFjYaLQ1XHEivl0JZQpWoLYjsyTlnmDNf8LBaL9D2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742268718; c=relaxed/simple; bh=1yZIGt3DKRdlue/d3WB55lTXnJZm/oUVgrp46lM5e84=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=MtZMl1YglgBrNmeiBXKRt22QBzfiS9CDT2GXwLwmeMqN5ew0YzAFSRxvvJQOP1a8HEgDedpgQCjw5CAPdGU0GPK+gbLXe5GFmQJG7Z/xbuJdSE5mexORAy6tm5S9fGLxcRe2Nnmucqk3AR03Ab0XkL5Oeb/wthBSWC1z3Qorl7A= 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=fmgx2W1I; 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="fmgx2W1I" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fec6c91630so72822667b3.2 for ; Mon, 17 Mar 2025 20:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742268715; x=1742873515; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=O6jYOEZJ3OW4S4UgPo7ewxZ2AGniQHsoCOaT7n3A/Yw=; b=fmgx2W1IVDFIOUVZnt2QB4xBpumiQ8oiD6vB6G2hw5vwLSkIgBU4K2itMN3jxmMSsw eDVn/cxt/KdWf7PYqWHrOd8+x7MThn20KRAk8qFjZQzqsinsSbs2vzQ5NXSr4/zRhFAe N9tAUqBRT6XHZko9nNYZm+5yzyGaFewkK+IDveL+GXnQTNX9CykjUxtavDjEKkOfSvAS VoGlYxsjgboBEhb6pUIfUebzdkyQm81kt/eFde5uw1ecbzcVc0Dt2RGw88jxmiU+suiy Or6w9lXkwhE8duQKZg6rYkhMpr7ZSIlPwk4+aPrnTmwXrEtQRsWBgKyin3g7cEM5uipe Oumw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742268715; x=1742873515; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=O6jYOEZJ3OW4S4UgPo7ewxZ2AGniQHsoCOaT7n3A/Yw=; b=K5J3yFRI0KrCVCstL9HdkJoN0vtrmwaBBtnZikt9UbRzOCGJwSWpFh/xeeHwdEhbsF Yaw/2gJGdAYZqCu/qpkXQYerz2fUSVmlcnTqhgCPRlqnOPQB1OVbnrziUQxqMuMdrI6J jAJQfDxf1ZN05f/l0cibJsXVcXZqRkNEyc+j3cYHP0XQS5PcHKpmxQIcGwydAQvbhLSU V9Tht5K0AvlZjDT2leLYioNF0pvRrz0vKp/o4AmYKTV4d+akZSsRzJ6JfOSNS+WwJhJL 30bwFAyUkRlfRUzTYkZk1bYH538Qb2/Aar+eNM+oJVmfwNB56fIrnwQN4o29N5tAj8rh MOEQ== X-Forwarded-Encrypted: i=1; AJvYcCXInJsGtd905N0Fjfan+b3HQ4CFyKebleg9PrMQd40VjobcRjNADluoV55ofe3FVDle+o5IrdHrf9iX@vger.kernel.org X-Gm-Message-State: AOJu0YxEYWTK6TMwn/fHNTNpP8Xn4Hiy1W9M/eTeB5+KS98YuPOHMXom cr6gI8sWhSNaLdTKW7PqDA4fLlNS6TVcRWDFSj8FBqwlcGyta9QHxR+1/cEtgKiA88aBhREOFs7 WofpVyg== X-Google-Smtp-Source: AGHT+IGWLXi0Ulvos+ECuvLqqq6W6YPJYqsOKusGddCdZkUuPPupyRUAOCc5cJVqolHmWqyG8r4jrkj2Nift X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:ef29:15ce:a42a:b69f]) (user=irogers job=sendgmr) by 2002:a05:690c:6c85:b0:6fe:ec98:e8ae with SMTP id 00721157ae682-6ff45b894femr271357b3.0.1742268715224; Mon, 17 Mar 2025 20:31:55 -0700 (PDT) Date: Mon, 17 Mar 2025 20:31:37 -0700 Message-Id: <20250318033150.119174-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-csky@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.49.0.rc1.451.g8f38331e32-goog Subject: [PATCH v6 00/13] perf: Support multiple system call tables in the build 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-Type: text/plain; charset="UTF-8" This work builds on the clean up of system call tables and removal of libaudit by Charlie Jenkins . The system call table in perf trace is used to map system call numbers to names and vice versa. Prior to these changes, a single table matching the perf binary's build was present. The table would be incorrect if tracing say a 32-bit binary from a 64-bit version of perf, the names and numbers wouldn't match. Change the build so that a single system call file is built and the potentially multiple tables are identifiable from the ELF machine type of the process being examined. To determine the ELF machine type, the executable's maps are searched and the associated DSOs ELF headers are read. When this fails and when live, /proc/pid/exe's ELF header is read. Fallback to using the perf's binary type when unknown. Remove some runtime types used by the system call tables and make equivalents generated at build time. v6: Incorporate Namhyung's fixes: https://lore.kernel.org/lkml/Z9PCjQ8PhOadVGQ8@google.com/ https://lore.kernel.org/lkml/Z9YHCzINiu4uBQ8B@google.com/ Which highlighted an issue with syscall pointers becoming stale. Add a patch 12 to make the syscall table a table of pointers that don't move so that struct syscalls don't move. Add a patch 13 fixing a BTF memory leak. v5: Add byte swap to dso__e_machine and fix comment as suggested by Namhyung. v4: Add reading the e_machine from the thread's maps dsos, only read from /proc/pid/exe on failure and when live as requested by Namhyung. Add patches to add dso comments and remove unused dso_data variables that are unused without libunwind. v3: Add Charlie's reviewed-by tags. Incorporate feedback from Arnd Bergmann on additional optional column and MIPS system call numbering. Rebase past Namhyung's global system call statistics and add comments that they don't yet support an e_machine other than EM_HOST. v2: Change the 1 element cache for the last table as suggested by Howard Chu, add Howard's reviewed-by tags. Add a comment and apology to Charlie for not doing better in guiding: https://lore.kernel.org/all/20250114-perf_syscall_arch_runtime-v1-1-5b304e408e11@rivosinc.com/ After discussion on v1 and he agreed this patch series would be the better direction. Ian Rogers (13): perf dso: Move libunwind dso_data variables into ifdef perf dso: kernel-doc for enum dso_binary_type perf syscalltbl: Remove syscall_table.h perf trace: Reorganize syscalls perf syscalltbl: Remove struct syscalltbl perf dso: Add support for reading the e_machine type for a dso perf thread: Add support for reading the e_machine type for a thread perf trace beauty: Add syscalltbl.sh generating all system call tables perf syscalltbl: Use lookup table containing multiple architectures perf build: Remove Makefile.syscalls perf syscalltbl: Mask off ABI type for MIPS system calls perf trace: Make syscall table stable perf trace: Fix BTF memory leak tools/perf/Makefile.perf | 10 +- tools/perf/arch/alpha/entry/syscalls/Kbuild | 2 - .../alpha/entry/syscalls/Makefile.syscalls | 5 - tools/perf/arch/alpha/include/syscall_table.h | 2 - tools/perf/arch/arc/entry/syscalls/Kbuild | 2 - .../arch/arc/entry/syscalls/Makefile.syscalls | 3 - tools/perf/arch/arc/include/syscall_table.h | 2 - tools/perf/arch/arm/entry/syscalls/Kbuild | 4 - .../arch/arm/entry/syscalls/Makefile.syscalls | 2 - tools/perf/arch/arm/include/syscall_table.h | 2 - tools/perf/arch/arm64/entry/syscalls/Kbuild | 3 - .../arm64/entry/syscalls/Makefile.syscalls | 6 - tools/perf/arch/arm64/include/syscall_table.h | 8 - tools/perf/arch/csky/entry/syscalls/Kbuild | 2 - .../csky/entry/syscalls/Makefile.syscalls | 3 - tools/perf/arch/csky/include/syscall_table.h | 2 - .../perf/arch/loongarch/entry/syscalls/Kbuild | 2 - .../entry/syscalls/Makefile.syscalls | 3 - .../arch/loongarch/include/syscall_table.h | 2 - tools/perf/arch/mips/entry/syscalls/Kbuild | 2 - .../mips/entry/syscalls/Makefile.syscalls | 5 - tools/perf/arch/mips/include/syscall_table.h | 2 - tools/perf/arch/parisc/entry/syscalls/Kbuild | 3 - .../parisc/entry/syscalls/Makefile.syscalls | 6 - .../perf/arch/parisc/include/syscall_table.h | 8 - tools/perf/arch/powerpc/entry/syscalls/Kbuild | 3 - .../powerpc/entry/syscalls/Makefile.syscalls | 6 - .../perf/arch/powerpc/include/syscall_table.h | 8 - tools/perf/arch/riscv/entry/syscalls/Kbuild | 2 - .../riscv/entry/syscalls/Makefile.syscalls | 4 - tools/perf/arch/riscv/include/syscall_table.h | 8 - tools/perf/arch/s390/entry/syscalls/Kbuild | 2 - .../s390/entry/syscalls/Makefile.syscalls | 5 - tools/perf/arch/s390/include/syscall_table.h | 2 - tools/perf/arch/sh/entry/syscalls/Kbuild | 2 - .../arch/sh/entry/syscalls/Makefile.syscalls | 4 - tools/perf/arch/sh/include/syscall_table.h | 2 - tools/perf/arch/sparc/entry/syscalls/Kbuild | 3 - .../sparc/entry/syscalls/Makefile.syscalls | 5 - tools/perf/arch/sparc/include/syscall_table.h | 8 - tools/perf/arch/x86/entry/syscalls/Kbuild | 3 - .../arch/x86/entry/syscalls/Makefile.syscalls | 6 - tools/perf/arch/x86/include/syscall_table.h | 8 - tools/perf/arch/xtensa/entry/syscalls/Kbuild | 2 - .../xtensa/entry/syscalls/Makefile.syscalls | 4 - .../perf/arch/xtensa/include/syscall_table.h | 2 - tools/perf/builtin-trace.c | 333 ++++++++++++------ tools/perf/scripts/Makefile.syscalls | 61 ---- tools/perf/scripts/syscalltbl.sh | 86 ----- tools/perf/trace/beauty/syscalltbl.sh | 274 ++++++++++++++ tools/perf/util/dso.c | 89 +++++ tools/perf/util/dso.h | 62 ++++ tools/perf/util/symbol-elf.c | 27 -- tools/perf/util/syscalltbl.c | 148 ++++---- tools/perf/util/syscalltbl.h | 22 +- tools/perf/util/thread.c | 80 +++++ tools/perf/util/thread.h | 14 +- 57 files changed, 835 insertions(+), 541 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/alpha/include/syscall_table.h 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/arc/include/syscall_table.h 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/arm/include/syscall_table.h 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/arm64/include/syscall_table.h 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/csky/include/syscall_table.h delete mode 100644 tools/perf/arch/loongarch/entry/syscalls/Kbuild delete mode 100644 tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls delete mode 100644 tools/perf/arch/loongarch/include/syscall_table.h 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/mips/include/syscall_table.h 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/parisc/include/syscall_table.h 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/powerpc/include/syscall_table.h 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/riscv/include/syscall_table.h 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/s390/include/syscall_table.h 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/sh/include/syscall_table.h 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/sparc/include/syscall_table.h 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/x86/include/syscall_table.h 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/arch/xtensa/include/syscall_table.h delete mode 100644 tools/perf/scripts/Makefile.syscalls delete mode 100755 tools/perf/scripts/syscalltbl.sh create mode 100755 tools/perf/trace/beauty/syscalltbl.sh -- 2.49.0.rc1.451.g8f38331e32-goog