From nobody Tue Dec 16 22:03:26 2025 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 33C732586E4 for ; Mon, 10 Feb 2025 16:51:15 +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=1739206280; cv=none; b=XS1ThZ9DsLEMUEU+1j+t3YNnZZvet8WEz+TKKRmyPObSnNANuIfvenWES2qWUy3Tgwci5yH6dy94UqVFXYwB5q2euPmLsrHI5652dNfosR+TXCYtDUPGIobHKtKXBhlFuAPDsfO18URFAx4gxlGVHePGvpAYA+CE2zpqdeIVApI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206280; c=relaxed/simple; bh=YT8KlPL9wtk8Q8VP6p5i62j+YN3+9mtkfyQRAssUQ6o=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FlJDeH6MWRlMMI+oxqRKINUpDQg7sm0gP+I+q+HaNsTWxZsEmUJ5i7Fdr7fgLPXla5Gcuwkj8oAH3SRIXJyKMsZZde92u4QprQM7NDkUc7fbIIBqNKOcT1H3wG/AP8UcqYgkyaLUQyrtGAQqsrl7eXyY+DWn5Z3USCZGfivDXrY= 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=JML+cLbu; 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="JML+cLbu" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f46924f63eso66698347b3.0 for ; Mon, 10 Feb 2025 08:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206275; x=1739811075; 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=RirwOEvFTr+iQTMC7nBuBTQw9Ik098EayI6xPJbtYXE=; b=JML+cLbuMGcRQD1+FsuVMZMXyRELGvUkNo0e9HJPXzISrFaxnIqt3imoWhf+0WaolH MS+saG0FoZ+oGvH0UYOiFTSA1JCK0FV7fcdKTGPYilEQgA38fbjFanhItn5KdlwgqXPI cs5fyeLfMitaXfWUP60w/VScw6aAI/zfwuDmGNFmRBrk28TNKuk4+xRSVkiKywZlp+tc U6mtariMRQZZh+X3n478axHqT2vskpoCzTZk9kGgMd1587EhaP2pXrfCY6I3DFbCaxO/ PYgQ98St5f6crIOOLu9YfPt0NZOvlnHBCDgrO+lO61SBw7rGOMgMYWbcx+h6CrOZ+NG6 5G8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206275; x=1739811075; 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=RirwOEvFTr+iQTMC7nBuBTQw9Ik098EayI6xPJbtYXE=; b=hWzYyGRYmHozXnMU/MeFru42ZrKj98KwIr69RZAFB825XRhgRLyf8FAAGEzLVAGShP 3z+Lm2y8fSwhVqOtY4bYjG3rE2iJ/rfkFr+GCHQKHN4FwJ6LTOX/8gl3LsToc5GtpB/A YA1lluZuBUUZid5gOiw6+5JbmqH+jT98YnOeaotWnGFJkfIIO4z/k2mMgpHQvnJtDJgc Pv4yGx/6fEB7C0zThQfVUo2tSOOoSWlBl1KWt348hcPSEdvzz+3KjordSp4ORyb7C+MK 3xzkrrtMxe72o0r0nYWC1jfCr0cGHZcpEzIMmj0VdbXuHtz1IPC6chiwExXiEuvbZqaj MbGA== X-Forwarded-Encrypted: i=1; AJvYcCWUvqrFcYQyTbvycsllPfzguRh0/hEPG8o1Om/j/XRGnTUQW8w9h9c/+zUPkuyDEdFqrKXmFs5LPL1b5ts=@vger.kernel.org X-Gm-Message-State: AOJu0YwGjStPkOI7XpY2C3Y+BEyAdwy30EDa84UP0xSJ+/Tphsus8LlV 5qDngmpSFKonrsc9Tb+M2dKXWWrWsys/xdB18ebz2LE5FpBX1/zleA6cs2m0g5YR041Zww/kE76 h0zfCdg== X-Google-Smtp-Source: AGHT+IFBo0WplPY5u0KSXjidUMV7aHm6r7XcZJoSM+fjgBwnWdxloP3RVTRtYLfmNJD2vikuitPsOYqh8Bzj X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a05:690c:3349:b0:6ee:3f39:493e with SMTP id 00721157ae682-6f99a877225mr2402777b3.5.1739206275113; Mon, 10 Feb 2025 08:51:15 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:02 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 1/7] perf syscalltble: Remove syscall_table.h From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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 --- 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.48.1.502.g6dc24dfdaf-goog From nobody Tue Dec 16 22:03:26 2025 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 4EFFF2586E8 for ; Mon, 10 Feb 2025 16:51: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=1739206280; cv=none; b=oPAICh1pHtaqgH3+E0O05e6fFhJcfaMWUkzPQNJ7ZKKbXMTpWFNJFqBLFWp44x2x+R2GxUn0O7j3jnQGobMbin46wet22zB4/+mMHp+UB9YCnc577OjVQUnESfKHiJ5nkbs27v0E9fEFYTO0kH2R81d1k14QDLBpmNS8b9oHJFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206280; c=relaxed/simple; bh=vBmJCZL7FXsM0wRzCKWC2iRINIEE9GUub1rN+Mj/lmY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ELoccEqA0Km4bG1NG3v9ZgT68Ck/BtPmlc13MgQapKNjrDBzGfr8IB5qbA6WtJN7MbejHILHhOjOhc35np3UwqHcGpElvhwRZugf8WuIuNxx2cWTorjWhrk3PIglEgq9e1Gxy2GnF+8/u9kvS+tuakflyrN7L4IOOklc7bsfmKE= 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=DrLRcy2z; 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="DrLRcy2z" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6f788a1de55so55880257b3.3 for ; Mon, 10 Feb 2025 08:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206277; x=1739811077; 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=5md5y4kHWywDKqwaR/ocaNjWZAyfwfKfaOG+9xgz6mE=; b=DrLRcy2zLkDLrK8o7xcgbXgn3hDobU76rOnRDvylekDM5saH+kgaxTfOH4c6+96gmX RXES5ZF8fPpxhU9UAi4EiuDCLOZkVayc/ljjucy5JjmK/escY+2qBxx0jZl5/Xwr8qNk PoWqe7zriF1cKp1Rys6X2H0yBkA31fODw+T4Rid/zlIviy+Ol32qJwGAQifckxiFQ8yW jdrX2YGX1yFZwlvwFqoRqXjd4wRS1GxE/b+W1EGr4xewF3yt7Xi7tlWEbsaqgIw4qvZz Us3ABvcaRX2yUfVMrtWcMQZKv1IzKeeado27GJVVHnWR7UmNwiLmpWpX5W3KXRgcmas8 W41g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206277; x=1739811077; 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=5md5y4kHWywDKqwaR/ocaNjWZAyfwfKfaOG+9xgz6mE=; b=Ot+8W2ttYMp9n2ADgr8Eu+2Vy2qvXn/ZEm3hhk1S7P++YsCAJxqGO6zD2L1qKXzmYx qsr5jm31qCRMyp4cCBxyOvQOi6ihksYNmZFhNRBv+a7e/Whx6COGCBL6fqUXX9jPRRJ0 geoLJbTx4ZKguDWIG0NnJ3p2CwRS3waowbSk/zLe5NNLAcXbFHW4QYoxMCLCuTyMAZqB 4z3lVuP5I3k7ULQXkyTXXCwlfHwX/ztYN+73gKCsCUnlgQl9120j3eL1litfAu4j+FAD 20GbqLI2AiNxO8vUFQvCo6ribbNo+8Bj+pdECRI0x104wG+FajM/RylQ+lGQ0fQwz6rs 0MIA== X-Forwarded-Encrypted: i=1; AJvYcCVOLgid6s9VpL25pI7jB0IwVuG9ICR5USVmigEr7Fi9IJRrj9Dr0dPls0i+VqjueycX1PUk9OdPnEGZfiI=@vger.kernel.org X-Gm-Message-State: AOJu0YznvRz4DNU6rU8JkEiO1qqM9MsBftxv2fOpSN675eSYLexzGnLg cbHCeqiNa8/mT7DJm12CkVIRuDr6J+shqSSDmuRXOBTvwbe1EsrSPizrF7j8b3CsPl67n2KrY0p N48B9gw== X-Google-Smtp-Source: AGHT+IEctidZZGy2xrMOAka52OzT6VEqV73LuA8n5euEih3QgASystKFMe/Dy+uuqdyMVNSNzQD4j97QzRuA X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a05:690c:2f12:b0:6f9:a023:5e17 with SMTP id 00721157ae682-6f9b29e7837mr1238577b3.5.1739206277309; Mon, 10 Feb 2025 08:51:17 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:03 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 2/7] perf trace: Reorganize syscalls From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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 Tested-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 178 +++++++++++++++++++++++++------------ 1 file changed, 119 insertions(+), 59 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 06356217adeb..916a51df236b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -66,6 +66,7 @@ #include "rb_resort.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 @@ -143,7 +145,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, @@ -1445,22 +1450,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; @@ -2066,22 +2086,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; @@ -2104,15 +2123,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; @@ -2401,13 +2421,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) { @@ -2432,28 +2506,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 { @@ -2600,14 +2666,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) @@ -2619,7 +2677,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) @@ -2693,7 +2751,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; @@ -2768,7 +2826,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) @@ -3121,7 +3179,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); @@ -3626,7 +3684,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; @@ -3637,20 +3695,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; @@ -3748,7 +3806,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 @@ -3898,7 +3956,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 @@ -4663,7 +4721,11 @@ static size_t thread__dump_stats(struct thread_trace= *ttrace, pct =3D avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /=3D NSEC_PER_MSEC; =20 - sc =3D &trace->syscalls.table[syscall_stats_entry->syscall]; + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, EM_HOST, + syscall_stats_entry->syscall); + 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, syscall_stats_entry->msecs, min, avg); @@ -5071,12 +5133,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.48.1.502.g6dc24dfdaf-goog From nobody Tue Dec 16 22:03:26 2025 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 9005B156C6A for ; Mon, 10 Feb 2025 16:51:20 +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=1739206283; cv=none; b=EGXcjr6yi+PjayZL0t8Da4Q36Pf2AA7tF4BAlcQDT8wqKlOaHdYW0GBGh1k0BOYvRAllPUu2xJGVf7SA9E0WOxbK0KyeYcDX7J7BXHYOKIkgyAmAivKwUVG/pQ2dSNTtZu8qa1dXbcp4Q6iE7Gj4/JRoL4QSLBldHC9AYbP/QGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206283; c=relaxed/simple; bh=rd2xl+VqepYLfai0cIVaTOfUSiuJ2xhRuj3y7jt9BpE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=D6T5GXuhxZrZXAojxxatMcdwW6oFV2GjC0PPgTUsnqXUH5S+yA7c/iF4iViQVmxYTYnahePv3Nlo6A2Dt44V1iJqikUfDUV3tvr/8ZkaqSYhu/NTSKSuyu95WWZ0/UTPQNLpaFbS5g/27J7vO9cks27dZJ5rf3VNYA+9VZElzxU= 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=azspfj2j; 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="azspfj2j" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e54da6701d2so6736686276.0 for ; Mon, 10 Feb 2025 08:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206279; x=1739811079; 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=9h/yMPNxJ4Dirf+M7B0REafcFvaa/2PNfGfSX0zrZkw=; b=azspfj2jb/3bMuwDDFzKw3bvpc00tZewm+EAH2sIoh5Gg+2cVEd8ZRI6njTfcwKmuF HP2OmkW/H6J1mqH4ZUv/LPYOMt+HxYgaf0UZhMdASsx0s6DW0jrXLriNmRhyQCMYu+5w UWdYWu6Z/sig14yf/q0+sX0GjXpy99QsppRhHKQthYMhAzkSQxLLob/05+008OcALv1p YsgKLYiA61+jtq/bWDkcPHz5ycIa4EEx9XfUFrvBpsLNO+xjqCpr90xwnqKVw5QbS6ms ZebkTn48kY3R0W1xkBG7HnvlBPNYgYCfkWXgemCbwNAKJpSja2mSqD65eXDkf4ciGl2G P+Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206279; x=1739811079; 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=9h/yMPNxJ4Dirf+M7B0REafcFvaa/2PNfGfSX0zrZkw=; b=MwI96gLY4U36DtEEpYO/Gw34RW+dkSIrIrVNTborNNCSPZVTEbvgb6CVTvzsWhIWcc I/muCZzJOJUh2JUPkbA6ye1+xom7ent6NKoKZXQ/wRMvlu1ekKR/uWKqw0IpONcBYf19 IdyKn8LOaIke0bNAJPYuDOLif4QOWJbja83RuBHKjRAGtXQbhYVBRo46UAILeC1gL7Mw BkX3yOXPlVcid45Gs6KvrYhIyX6mHtGasenRl+3sgZY3ggEe6zEOzixncTR3Zdd6p9ao ZVL6ZAEcrSSxsz6SYIoOlCAVQ7kGw+QgdTXErxH+kRuDcfNhLsfqW1Swa+SSU/Gu+0FH j1YA== X-Forwarded-Encrypted: i=1; AJvYcCWcyte5g+He9klmhYcjIAYXVGuCGUCtboAFBsgxAsmFMm7Djl2Bh1+d5D/NX3uwekwjfY6JJnyK3dDq/Ko=@vger.kernel.org X-Gm-Message-State: AOJu0YzbZ35zl9BcRKOmjf1cTzTJNRv97EswdzSmfBc4aswczH8XY8kA 6s8v41mwz0DLglD/e6mKvV5WjvGj+cQELPLaj3vpIfHRvPKe1L5XPfxuDMAJ8QAdFamiBNU9vVx f07/8IQ== X-Google-Smtp-Source: AGHT+IF0cWKfHfiMJWCLwswec5kBGcjOBH7dDK9R4qBQHOWcqMOx0lvM6NoT4jpT5Alw2D7KInU31HpXrU+I X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a25:ad64:0:b0:e5b:3241:79f7 with SMTP id 3f1490d57ef6-e5b4617d708mr109721276.3.1739206279481; Mon, 10 Feb 2025 08:51:19 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:04 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 3/7] perf syscalltbl: Remove struct syscalltbl From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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 Tested-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 88 +++++++++++++----------- tools/perf/scripts/syscalltbl.sh | 36 ++++------ tools/perf/util/syscalltbl.c | 113 ++++++++++--------------------- tools/perf/util/syscalltbl.h | 22 ++---- 4 files changed, 103 insertions(+), 156 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 916a51df236b..4b77c2ab3dba 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -143,7 +143,6 @@ struct syscall_fmt { =20 struct trace { struct perf_tool tool; - struct syscalltbl *sctbl; struct { /** Sorted sycall numbers used by the trace. */ struct syscall *table; @@ -2100,7 +2099,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; @@ -2200,10 +2199,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 @@ -2223,7 +2226,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) { @@ -2677,6 +2680,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 @@ -2751,6 +2755,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; @@ -2826,6 +2831,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 @@ -3179,6 +3185,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) { @@ -3682,9 +3689,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; @@ -3693,22 +3700,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; @@ -3804,9 +3811,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 @@ -3890,7 +3897,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); @@ -3898,27 +3905,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); @@ -3954,9 +3961,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 @@ -4393,8 +4400,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) { @@ -4419,7 +4431,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) @@ -4692,8 +4705,7 @@ DEFINE_RESORT_RB(syscall_stats, a->msecs > b->msecs, entry->msecs =3D stats ? (u64)stats->stats.n * (avg_stats(&stats->stats= ) / NSEC_PER_MSEC) : 0; } =20 -static size_t thread__dump_stats(struct thread_trace *ttrace, - struct trace *trace, FILE *fp) +static size_t thread__dump_stats(struct thread_trace *ttrace, struct trace= *trace, int e_machine, FILE *fp) { size_t printed =3D 0; struct syscall *sc; @@ -4721,7 +4733,7 @@ static size_t thread__dump_stats(struct thread_trace = *ttrace, 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, + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, e_machine, syscall_stats_entry->syscall); if (!sc) continue; @@ -4771,7 +4783,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; } @@ -5003,8 +5016,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; } @@ -5140,7 +5154,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 @@ -5286,9 +5299,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.48.1.502.g6dc24dfdaf-goog From nobody Tue Dec 16 22:03:26 2025 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 8289424FBFF for ; Mon, 10 Feb 2025 16:51:22 +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=1739206285; cv=none; b=KqKQusGQlEbb6zukMQgSuJtcQc3AEVpM0i21NU4M5RgWMflkj1+ntbJsi1h8q2B4oflEFBGEnp2UhA1e1cVm4eM5ebTaKL6zCfAMR5iW+27FFbAsV6cIupbEFfQK878pwJJueb8dMN24BR4FOStkeWLCcyVEjDWOMGdbUROOaDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206285; c=relaxed/simple; bh=4jJWJDtMCnrzBvN47taOc3afqbteyTK3Pqrtk6HWFCY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Zg/PWH5JtUQubuM8dFr8uNfBbitjXGqVQItBjGJkAwWksdElBKUrbSoAj+nw78Bq5c9Yp+qg4nxX18I+6TaTEsze72jyI8cYWB4RWdlVWAdLky+YqqKg8mrGme01V+y5mE3NhszBa6VskcwhL5y/CrMS34OfahT616Q3m4Txlik= 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=neepJnG0; 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="neepJnG0" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e5b48736dcfso4358755276.1 for ; Mon, 10 Feb 2025 08:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206281; x=1739811081; 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=DOWoU7qgMcrx0PEujTJ/F53Hw/GeBX58jEXQSbUwztY=; b=neepJnG0rqm3iZrlPKCxdq2w8xS6/opnM3R6Y2/TwZ3VK2bFHeMAVkS5gpsfq/HeAn YzFrVp9AXIbeHQfFDTLT9nYelLvoWcb+CNw9ssamFZnX4W6/+xBaFk+IKeAI/j194p9N mM4nHVzkYWSUhtrpU7ZX5p5Z5yCtzbyPBmjL5P8SxKiGKQdmGwzge/TP2NMAyO0ad5w0 Tkjp6+e6GqzcbVtYpCkEhlDaKKtbybCz43ysR7SzuSfOa2ddoZj3EcO9HFOOyqLdTQpv I8nrnVR7dbdR7HVcbcrR/1wj59TqtwIkNb9Md0ex3vpEX6xvxgL/YwKq9w/fOZAjC6EF 9aRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206281; x=1739811081; 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=DOWoU7qgMcrx0PEujTJ/F53Hw/GeBX58jEXQSbUwztY=; b=qO/jFo3hmFjHgsrxM1fm4KmSiNCZIdjY13GWbUDycRb8ldU+u7YO0Mv4LAuVEd+yoe OSK6zPGgqTS40w27Ix2ygyLeDrHx5NeYzkgWq/YLcLpWi1hv/PGiTIOcBtMyVzARsDV4 wNMK4sh1/UvjDBBIJpmdcDAasiJdniwTOH+RvCttjozkWuUJIXdZJCgJt2p+EaL4j6qo vCD1yXPrXP8jFT5L8/vIam34Kt3I6XWdBpGU5xZUtyPx5zcLAcLh3m8wszS3X/8YyadC i7zM5XaJQK8EOM1X4Fa82FF+NfSlsELSjNT+XSsh6Eel0UTj6utrptr5Mj5c8mdXgSwH 9R2A== X-Forwarded-Encrypted: i=1; AJvYcCXkUASut0KnQCvVrL7qtPaiX5JSX1C4MzdxtyeCOVXlpoQyDK+Xc84jKaJ+DqqDxw1uuQd3bcCYhkCTy+k=@vger.kernel.org X-Gm-Message-State: AOJu0Yxwf3pBrzcektkahRbFdpa5UWr3oejit2SFmStBeI3XdXTR6pkm jd75mXor7iCDgR2lvQWInwLpxwP7ieSiiWJt5mgy42D3iHOIaQxzKvdJiHyx0LkJCIRVso++t7n uQen2sg== X-Google-Smtp-Source: AGHT+IFF/Ei8DFWaLTT38bXuIF9MJCLxN/gIEWqvnKjcrk4LdcKqilSNLNsC8d1WBEJmJ3zFfXtLVVIJodmc X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a05:6902:1827:b0:e5b:38f0:5ea2 with SMTP id 3f1490d57ef6-e5b462c6cb5mr113668276.8.1739206281426; Mon, 10 Feb 2025 08:51:21 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:05 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 4/7] perf thread: Add support for reading the e_machine type for a thread From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: Howard Chu Reviewed-by: Charlie Jenkins Tested-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 41 ++++++++++++++++--------------- tools/perf/util/thread.c | 50 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/thread.h | 14 ++++++++++- 3 files changed, 85 insertions(+), 20 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 4b77c2ab3dba..1ae609555018 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2678,16 +2678,17 @@ 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->output); if (ttrace =3D=3D NULL) goto out_put; @@ -2756,16 +2757,18 @@ static int trace__fprintf_sys_enter(struct trace *t= race, struct evsel *evsel, 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->output); /* * We need to get ttrace just to make sure it is there when syscall__scnp= rintf_args() @@ -2830,15 +2833,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->output); if (ttrace =3D=3D NULL) goto out_put; @@ -3185,8 +3188,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); @@ -4764,6 +4767,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) @@ -4783,8 +4787,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..a07446a280ed 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,52 @@ 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; +} + +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. */ + } + 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.48.1.502.g6dc24dfdaf-goog From nobody Tue Dec 16 22:03:26 2025 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 617A224FBFA for ; Mon, 10 Feb 2025 16:51:25 +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=1739206287; cv=none; b=HsnUQXk9LU46XfevMuGUYuw8GtUC45+Jxo0B7K2Fl3S08acIWWT4BiDHpQzcQCZwaIjTvd1MvDVCrqqzYKkh/nzXFHUoHRtqlmstSZIhOk1HT4fToFES3lyed02ObYmbePjOu+ezt+z0e3MjAKCCmwT+sx206xfVGM7+dMtPu9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206287; c=relaxed/simple; bh=heWBVzZw04pRgynqCm0Cq6lw144TlemYb9z9aoJrcJQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FXexgXC5KaxmhvBC4y29BwMLNFLLfGcnYTxAOtWrLhgqP6Yyh5qre4Qi3Q2oFLkn++q7qF/nB8698DLNrWJGfttbfX1CAq3oegYw+LjfYuvGWwJkYSYCcJ4uvRkoUjs4MyzoR1cg3KciBG8B5pr2ddfd14NIJthekfTbCP4XNHw= 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=tWp0gugn; 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="tWp0gugn" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e572cd106f7so6772581276.3 for ; Mon, 10 Feb 2025 08:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206284; x=1739811084; 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=jIs5NMLsgVSO7Ab7WLnlygcAPfFo1lRY3u+BJlw/ocU=; b=tWp0gugnfbqaTof3JayGyHpcuRfmthWLZR1BdueBZSpR/WZeZE4nknEAqePEqcaJSY wc8evqTgBA5+xpBMAKD6AOJ+qIGiGHzHcZitMYh7XnzU/mLdInNv1Ffh23sJTkwAO1de SuL08lN2i4dK8nWS1QeJojDWgiwCdmZ2Xu4+Fuv2NABjKR7vPoH9E1sR9wAzq3xQAAxj dgD+/Ubg9WPk2Ii05TAaypG1hjVUzwjYyI7X67IlS/cvsVKZvP7HoDpyHzHN/yQNoF1Z OQJW5HFWcdCajYEEdOPf/CsMaW0mipKiJD12n68r18+j78Ez9yvAhC+iXnxYpci8tlYL +Qdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206284; x=1739811084; 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=jIs5NMLsgVSO7Ab7WLnlygcAPfFo1lRY3u+BJlw/ocU=; b=Mqv0ZKBe+RqYVfYD0jbdjtj/uUIQT8M9vil/2R9xRs2wqCqFTR8Jcc7VZ2bOwpkia5 ydnq1303NPCuVQWFVzXSugaDnBrkhwlVeMQIPukvHThl0ckhyeOpiBxEYANxw9Yw+xav 5iAPB2u+nUal60KWZsPIUYRu8VKPtMNCPtkDFYA4FugiXAq3638z/NCFjiw0UcnUKpCo DXBGAs89cNJ+wFj1hQ+F46sB03/jQhWo0e4OJDhdSfcOmk4+i6si7YbVSlEA2MITSzUY OxPtrykVMBO4JjbQtdQHKb41fG1+5fJfjJ1wp7e2hcLrlKbWvLguhubOVxOtActuV7zc AFZw== X-Forwarded-Encrypted: i=1; AJvYcCXvF2ql9fD/NwQUUf2EK7drEMjzB/6VJOEatV/70sj0OIcXQpxs+JKx8yiN1iIon6xDNZK0CqDgtzENop0=@vger.kernel.org X-Gm-Message-State: AOJu0YwTuZKj6mKcuVB7RnC6Hbqgax4fkb6HKYp2MtabyhYFWIxXFQa6 fu/K7aVeVtwFijwh/u9WHW7CHfcd5jGQlHPsdRVakmDDvfNiXegA3cMwKLAN+1NfX3/VDND9nu0 wZPoKXg== X-Google-Smtp-Source: AGHT+IF2pqV0g3K5a0u57y4vudVfN5MsTKJPI871Q7AvG+ejnliDH5oO9Uq5Ualat6SF3gms08TWefJUj0QZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a25:5f0e:0:b0:e5b:12df:4e08 with SMTP id 3f1490d57ef6-e5b46063273mr103290276.0.1739206283618; Mon, 10 Feb 2025 08:51:23 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:06 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 5/7] perf trace beauty: Add syscalltbl.sh generating all system call tables From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu --- 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 55d6ce9ea52f..793e702f9aaf 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..635924dc5f59 --- /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] +# +# NR syscall number +# ABI ABI name +# NAME syscall name +# NATIVE native entry point (optional) +# COMPAT compat entry point (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" <; Mon, 10 Feb 2025 16:51:27 +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=1739206290; cv=none; b=mcWR2/cVq86MA4tAq6O9ejde5fLmFoiQgs/Q7k9fi1cUniSGG89bKX94qHYoqeXtd/azvDxMtCGg4cZrdW/UX6RAA7Nys/SKWtxuLdMv1Hv22JkGKIxq3dZ+0Z+Uz9w+jstb+1OV2XjJ9u9HXuZk0mNxDFgjJqLnVXjROH5nW6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206290; c=relaxed/simple; bh=GdTZkYvK8iYq3lgixNgbkqLaIu/eBrnU+KNubgoF+8E=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=J3aEt5eQcclSzA+UCTL1NpbQEIOsLlrawFCQTTtw3ER6ADnzPaGGeQ5HcIK/uvNWQNNP1XNnNaS5XhWVWnnMNpPuKLJxi/pcFOBcoPzs/gdhuDH67IY/evg0z1TrTiwR93STZWCOdyBak3FI3sfgbE8mOfeCgI4Q/63v7P6Vapo= 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=rEYdRYWc; 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="rEYdRYWc" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e5798866415so5650667276.1 for ; Mon, 10 Feb 2025 08:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206286; x=1739811086; 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=cHZk9QJkCVx2MAUg+NiMOlXRVA2mMMZIpSayEvNziYs=; b=rEYdRYWcBSS5Ly6I9ah1cmTKsUb0z4YXpH65QfmLtEDJKDGZKbXbyDZCPY7j7GZWct zz24N5pbW1cVwOJrXsUaLi6SbKCXE9oSdQWCCBN4rbKxJ8fWh9E7TeBLA1H4o2WJsAwq 8fPCULFVKKvNFxQxJMQ7yVdc1t1883ZTNZPuJB3LcwmiL88UHdnwP/JF+PkQE/Bf3t6l SrlXuiVCLwPl7ZoAGsaQ0ZIDD83brSdrXvvdttWuJ96SwmhrZ7YHSrrbrFc8FxzC0v1U X3BE839EAqWaH0kFDPiKo/5rwUjQUS1Q2xZZ7zD3yvKcZNRAVlYUTMRPdx72DMqy3BkD Nu2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206286; x=1739811086; 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=cHZk9QJkCVx2MAUg+NiMOlXRVA2mMMZIpSayEvNziYs=; b=urplZ1q4aCprgDGoM9xd/jrpg/rG5cQtXKJ326tGo9+txIW8Al+Dm6evuhpbFpvvHC 8oNoJ1Pzt7fBvSvGX1e10CGOf5mQYxl8pOOMmHzmMdi37a3jfJE5ylxXFKEeRGx2vwX3 699SWJDIBcJDgFgqKd0QYGBDG7XuST6FziLT8arXWEcIwQqolL6i1/WMUiVR9RGoGhrV 8+whE+nxzCEvBcxHeXgA8rfKmhxvIuROLNzL7mcqp/TLjg9M9SjgNeNsya6aCGJWmAYk XxaNA48s58e1vdy85fO1WSRwziVcqAOOeyUlDR2RMtkCADpPtdvZ2W3wW4KbWecKEsY+ I8BQ== X-Forwarded-Encrypted: i=1; AJvYcCWd0oEQsiEO/R4E0RYd0dY5xtgn3SMcPUdwYb759WniCW0f8h6FcuHt6LX1qsKhRph3qMxEskvV6vzLe7Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzKQeKHurUChpsNB+rwt8pGvqNlhdKJvf8cJb9j/NpYXwYU/9nO vgoAfLrjYZufifmLpW15ao1XxLhO9GbuOp8NpjusN7uqh6j/OpVDLKMu2y/rPptb+C7TMrAXG1g bdulR/Q== X-Google-Smtp-Source: AGHT+IEfkmVO7KHqhXgeOUlT/jGvE3tyf+z8IVFUZ31wfmVLxFdT4+2f+pJuEDpGZS4x7jimPZhod+DT8Ca/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a25:ba8e:0:b0:e57:fb93:606 with SMTP id 3f1490d57ef6-e5b46068c3bmr111973276.0.1739206286596; Mon, 10 Feb 2025 08:51:26 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:07 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 6/7] perf syscalltbl: Use lookup table containing multiple architectures From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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 --- 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.48.1.502.g6dc24dfdaf-goog From nobody Tue Dec 16 22:03:26 2025 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 AA506255E42 for ; Mon, 10 Feb 2025 16:51: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=1739206292; cv=none; b=hdA7X0RA9RIJrOZQspS0nvbZVvqc4Q/hunWSX/UyeCxnRGGGP5jNCq5gJ5JftIdYK9wz+rkybiP+JxoITITnArZHm6wdiBkxM2rB0XlJglcEKed5Thz6ShSj2SQaIOFWn8sKcr0vtet7ZX8u5lWHOJbfud4dj7ugXt9nbTnULaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739206292; c=relaxed/simple; bh=Wh6NyOGBaJBvCkKxkKE52iGFp5Fp+z8Dx7t/YdqvjFQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=eFH+T6N5FxvnHPDYxHunqfrtjacmz8QSmOcPvi5Z9nEL4ZMuxyCbfEpd/xHE6GfUdYbE605oqkmw/dFG6/f6yrLFnR1gUrvtA8tYCQ1loDQLxyLNirmD9L8REMAXpKfrzGE7/h1Q42LWk6XJKl+Yy46RFOF9WLVeIGtSNObchbs= 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=nnfRRvzn; 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="nnfRRvzn" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e5b26541351so5985475276.2 for ; Mon, 10 Feb 2025 08:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739206288; x=1739811088; 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=/qbAeqzqFuK9ccZYjyEtk2/tBbmWNu+lXtnlO1Us84o=; b=nnfRRvzn2ZZvFw+XSF0xG1wRxEoan5ZYkg3NZKFSeaSgX2+xHPq7d05piavHsZmnjz fRiNwSSe8UkBuF0vrezMdPKPkGtqF14F4ehI+RGwO3K6Zr2RcI6OXffvR2to9NhjVgu5 Jnc92F+m6vDkape1F7/LdqQaJ/e9HiKeyoexWA5KnBuRRDu2AnT/2od8j4LnoYdkWYrY 6TvGXUeDgqc12rf4i2X3M9OkoD0NH4+KvzW8GE3dUE/k9qqR9Do6hASmDR7KbbgdgnSb UTtSyt1uHgzi4pV5z6rAxYt1XIoB86zb7/0j28e0W4RkhRNfC3P0ig6iao4n/I62bhX4 F/vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739206288; x=1739811088; 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=/qbAeqzqFuK9ccZYjyEtk2/tBbmWNu+lXtnlO1Us84o=; b=JJb24kZfqgWkES6GDg8AIHhGlZCVq4HOLL6yxnlOGRwmDHqzioRIAU5xdzn1YQ4UnC /NLEEuYTf4fIlNGqGW1303Y0Iq46ajuQt88JNXqEUmtbd4wnSaMB/FiPJrTsrpARO5n6 vRjc/8OBe4qUO8GDinGiiMtoFU76aHQDjY0fTx3Zp/4G+vAg5sB6PT6Xz+DfTzoVowzQ 9TbeMijRG0fjfDBcn2I/pzwPEG1i/d/NmSDC0tnXVqAj02ZOjy+emfHlXeKKOoOQlL8q 8IBeNDFAUQUFW8cO9w6dsCHCtKgVYxI0q7WgIWpxepJKWOATqxiXBu4iEZHPxfaY33CE zOFw== X-Forwarded-Encrypted: i=1; AJvYcCW5DAhd6C15pI0SYXXb1VB9eqVoW1GD5T6lixzvZGOjwoC7kTrU9BctmIRmC5/x2egtuQ8I5vj2/aCmIOE=@vger.kernel.org X-Gm-Message-State: AOJu0YyAj4ijE5N5vfA3nRLL4A+wpo0/Tp8cR0z3Yv4w6csMTQhBIewt dIryAXVaqefNLuK7hZCKWFUoTqto7MfmyQN97lNpBSWu3zHOjVu0zWw2ybbODABA0pq0DH8Xu3P UM47GqA== X-Google-Smtp-Source: AGHT+IH9FVvvr22m2kfb1GzzDu2WuLJtHfs+stVHlt1+J7P61lRRX4KaORgj3A6+Fcm6vF3ZhKIzvj5oaOz9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c64e:af58:30d4:168d]) (user=irogers job=sendgmr) by 2002:a25:2d04:0:b0:e5b:3ada:41dd with SMTP id 3f1490d57ef6-e5d93c7ece2mr1824276.3.1739206288496; Mon, 10 Feb 2025 08:51:28 -0800 (PST) Date: Mon, 10 Feb 2025 08:51:08 -0800 In-Reply-To: <20250210165108.95894-1-irogers@google.com> Message-Id: <20250210165108.95894-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: <20250210165108.95894-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Subject: [PATCH v2 7/7] perf build: Remove Makefile.syscalls From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Arnd Bergmann , 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 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 --- 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 793e702f9aaf..62176d685445 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.48.1.502.g6dc24dfdaf-goog