From nobody Thu Dec 18 23:23:18 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 A5C07215162 for ; Wed, 19 Feb 2025 18:57:13 +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=1739991436; cv=none; b=p59PurFHNGoS/SFtoB2QW/FB5/CmTJc2PF0YNLUOQqu2MyXr8BhjfjbXg7WmlTQotgsTcNmZefoCVFpVjHSaUbLG5D2UK2+fCY4DiBhH16YM0t38PUt5TPq0KWlyB/9iuiLlsbm8WOCAOUHGDIqkwC4ZUmwwRTC0742GjJ7SlBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991436; c=relaxed/simple; bh=DA56kgNouuSPwqZwswLZuEndFxCcYpk0qdRwCUnBzVg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Qwk3gP3ww4hvnYnKiyBQtc792Hn3pU5AUdnSFFr448g63hBNQ0/1tlCW2WVOpeS7G08U2+RWMhrzsD29GUGRwqK2i4FzQP7saWigPqc5Tkn8JLBpDIgaRIO6pqQCd6o6s8pgXVz/VtPkuL5Dq/ffI4bwU+B4Tg/VBX7Ah/1pnps= 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=OpnG1JWC; 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="OpnG1JWC" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e5740c858beso193280276.2 for ; Wed, 19 Feb 2025 10:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991432; x=1740596232; 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=s0bsoJDMKnAUZGWEn4OupAOH97fr8b6W+Og+QQZpJxU=; b=OpnG1JWCeakPfVchZtXm/gTokvohgE9FvHzyiHOEaTlvUDPRYr0bl0RKPWygNz3x4y 526fSgQj25TOAtJUaoH//XccClUlMf/CvJYXJscOsY337r6ClRLT39KY8IzEO5qErzDp wxdpd0M8gWAGfh+Mnqd5Qx8rKTv/hsxxu8p3YqXS6vW+ftS5aAjiSGg6zT3+0tCQdscj 4Qrpiee0BvqRaHUulga986C1ZgYRumIzszLy8lDwgV/2a0vMtO66fiMAHk3FY/dPUtC7 ujatJArJ97yVMcbHuwn5Bvp9Z79eXPUNNl2GlI1qu3o5uah51/3nBRpCetEQo0PDbpdD Tp1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991432; x=1740596232; 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=s0bsoJDMKnAUZGWEn4OupAOH97fr8b6W+Og+QQZpJxU=; b=IFmMxCoGFzgbghhKUXlT2ozJJbepvSnOmZhEc8ZZbB3KjTeicU1AvObSxPXYN7czPS 91OG4PerESHc3t0YNt4j93v8fqPRWqmlWstblW55l5nBF7wKIx6Q7LutrZn9zyfsFSeq irax/L2KvzLhoIEZa66tPKJOxt13AocCnsMBRU61Nca1ng+fsNNyxMMGgLdeqGVewwrh 2O1bdX8V3W0GQkmE8knh8wKeeEV+BtQcFEsOV9zP1GNCEtAbh1IyWAun0dnxwUIfFM5n rsznZGILhq5gMYZKsmI67URBy/rcyaQ4+gZn7zV/g+NeWsoN1fjeDQ1or9MAivD1cdl4 klxg== X-Forwarded-Encrypted: i=1; AJvYcCWTiskT89nEk0MlFZ3w0NIndBpFi75pNMDk7JU4lqwVrVOBU5+UIY4I7U8iXMcOalSF67YepF9TWoJgE4w=@vger.kernel.org X-Gm-Message-State: AOJu0YwbO/H3JsdB4B2e+/6tLijoka4/TE6TCJ0HKY3eocz6YuGTyN/d VhRQrjgRW92YufLpY6hh/29Mu1lEpNdhGalR7jvHJqgSaA3p8dTyNWrWYJHeE64WJFnEXFNaOCh c46XPGA== X-Google-Smtp-Source: AGHT+IGF51usFsQ9FNTzFoNRGh8XS+OYeljEd0FsqywFcj/FC4LqivZ9CcaSZ05HEZ2iLxCAbI37MGEuie6a X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a25:aa45:0:b0:e5d:bc8e:cc92 with SMTP id 3f1490d57ef6-e5dc91e9bafmr201196276.4.1739991432389; Wed, 19 Feb 2025 10:57:12 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:50 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 1/8] perf syscalltble: Remove syscall_table.h From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The definition of "static const char *const syscalltbl[] =3D {" is done in a generated syscalls_32.h or syscalls_64.h that is architecture dependent. In order to include the appropriate file a syscall_table.h is found via the perf include path and it includes the syscalls_32.h or syscalls_64.h as appropriate. To support having multiple syscall tables, one for 32-bit and one for 64-bit, or for different architectures, an include path cannot be used. Remove syscall_table.h because of this and inline what it does into syscalltbl.c. For architectures without a syscall_table.h this will cause a failure to include either syscalls_32.h or syscalls_64.h rather than a failure to include syscall_table.h. For architectures that only included one or other, the behavior matches BITS_PER_LONG as previously done on architectures supporting both syscalls_32.h and syscalls_64.h. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- 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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 20B1721518E for ; Wed, 19 Feb 2025 18:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991439; cv=none; b=roK+z40aUEpF5PQOmG4AX4gW+WzCFICbSMLjzM5OzUMr9zJUkWIk9/aLNlipj3fgfw3XQucvXJpUWjV35o0T7gT05cHV2vdgqcx32KwSyZ1MKieV7/u0CfCbDfoVN6Cab9c5W/vo5wAIRvRk06fx8urjoKvy3kJk3zGPKdQFgyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991439; c=relaxed/simple; bh=TCgqmhfXYewTfdfE5eGGWEMMxbZ3unWH7SsyKg+4rhU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DG3+AbOrxFy4oy8vOiNB3gD47+Pp9ZcTa96UMtf7T/HvBKRl86DmFq87Ip2GN5PJyr5agFMTTJfvX3+FqBB/EUQ7nabW4GYSlFQJxDwX/oRffevzEzZXuIliw/muWLD7N8iep2myoH2+oFS9spj9WqVAN5DR62Ot0JDiOha4p3A= 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=c2xni/dj; 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="c2xni/dj" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e5789a8458eso241881276.2 for ; Wed, 19 Feb 2025 10:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991435; x=1740596235; 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=UhKzWnab12XMxWTCYlOFUttaizbC7pr5Fhq5T8U2Rac=; b=c2xni/djB+3ylUlQYJ44Lk26g0Ym7Ax4SZ+UNHUaix6V/f0Z5TH98xMAcv/h5oXS3q s4WsS7P2fPT5BU6jybMV5DNJvKweDzhedBYq1cf2jLSLWKbFFheU71O05IeoA3zc8VZW WHYfqES3OS8N+yiiLb+QH9pLEcQvSwfuZ5gdlEx63B6u5iD0BKTbNFxWdRAnRIo8XDzW B6FZQlQuiNaqUIvkdUecAdBWFheALRvnLRowMFq97huIaMcQoG/QrXU7jOsl14NJgBpq gRbq4bojuBbwadbQSkN4syvNxjvCvfvAekW6BN9YjNAEnqbq6SPoMDzVRMaTFGhDQUbc bJkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991435; x=1740596235; 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=UhKzWnab12XMxWTCYlOFUttaizbC7pr5Fhq5T8U2Rac=; b=v/6dp59EoBuubo62cHzcRozBXUf2Qebsln7dvRF5ClAiWnOj7dq6tpOqwGVugFArZo GH/N8q76ziF8AkwW7TM/ItOPvGNiUCHDoFHFMdkBXIxYDq474FyNGov70lCzx52Par2V K+J7HNUPFXil6iZ/vwF5jwt2FqG//KFnD0zWDU3HZuzOtQ4pVjXNYGU+en+naKx9LEwM T2lTVAMgrnqF2RrARdrp0ruBiNUdmhePwoHjdD8VIhyLkaMClfX8ZCDy5gL98hbLw/Oi LZhVBKLcGNapozlNIIsXf+WZMDw/2T4f7IaFgSWX6c8AVMRkYQwl5hmo9iS6OxG9bjqL jSfA== X-Forwarded-Encrypted: i=1; AJvYcCWh0aquK0SoeXKEcAqTLV46ffv2gCmWBNpQwiT9MJwExsiEaHqqBim2bfEwx1Pj6DCyVsOMyJMJjW/u4Po=@vger.kernel.org X-Gm-Message-State: AOJu0YzLaE77Y/LLoFyUB6jlxk6czZd7p/uflWQplJFKyD9bkqFcvPS4 pPStUYOrX+Haj0V9mAr3C7MYgbX716tHpfXsxOPs9+7iX83LZWq27xAInJx58rgrhJZmkSXj13J TzgOXqQ== X-Google-Smtp-Source: AGHT+IGXwvYLp2kQzjITAGDJrXA0LX3POwHlCA5JvOVaoVS7n1r0R/Yw+oVM26kgofXtKfVPeA2TfRdlWuI/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a05:6902:2987:b0:e5b:20df:8adb with SMTP id 3f1490d57ef6-e5dc932b130mr194569276.9.1739991434785; Wed, 19 Feb 2025 10:57:14 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:51 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 2/8] perf trace: Reorganize syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Identify struct syscall information in the syscalls table by a machine type and syscall number, not just system call number. Having the machine type means that 32-bit system calls can be differentiated from 64-bit ones on a machine capable of both. Having a table for all machine types and all system call numbers would be too large, so maintain a sorted array of system calls as they are encountered. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 177 ++++++++++++++++++++++++------------- 1 file changed, 118 insertions(+), 59 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f55a8a6481f2..eb3551fb0e7b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -66,6 +66,7 @@ #include "syscalltbl.h" #include "../perf.h" #include "trace_augment.h" +#include "dwarf-regs.h" =20 #include #include @@ -86,6 +87,7 @@ =20 #include #include +#include =20 #ifdef HAVE_LIBTRACEEVENT #include @@ -149,7 +151,10 @@ struct trace { struct perf_tool tool; struct syscalltbl *sctbl; struct { + /** Sorted sycall numbers used by the trace. */ struct syscall *table; + /** Size of table. */ + size_t table_size; struct { struct evsel *sys_enter, *sys_exit, @@ -1454,22 +1459,37 @@ static const struct syscall_fmt *syscall_fmt__find_= by_alias(const char *alias) return __syscall_fmt__find_by_alias(syscall_fmts, nmemb, alias); } =20 -/* - * is_exit: is this "exit" or "exit_group"? - * is_open: is this "open" or "openat"? To associate the fd returned in sy= s_exit with the pathname in sys_enter. - * args_size: sum of the sizes of the syscall arguments, anything after th= at is augmented stuff: pathname for openat, etc. - * nonexistent: Just a hole in the syscall table, syscall id not allocated +/** + * struct syscall */ struct syscall { + /** @e_machine: The ELF machine associated with the entry. */ + int e_machine; + /** @id: id value from the tracepoint, the system call number. */ + int id; struct tep_event *tp_format; int nr_args; + /** + * @args_size: sum of the sizes of the syscall arguments, anything + * after that is augmented stuff: pathname for openat, etc. + */ + int args_size; struct { struct bpf_program *sys_enter, *sys_exit; } bpf_prog; + /** @is_exit: is this "exit" or "exit_group"? */ bool is_exit; + /** + * @is_open: is this "open" or "openat"? To associate the fd returned in + * sys_exit with the pathname in sys_enter. + */ bool is_open; + /** + * @nonexistent: Name lookup failed. Just a hole in the syscall table, + * syscall id not allocated. + */ bool nonexistent; bool use_btf; struct tep_format_field *args; @@ -2107,22 +2127,21 @@ static int syscall__set_arg_fmts(struct syscall *sc) return 0; } =20 -static int trace__read_syscall_info(struct trace *trace, int id) +static int syscall__read_info(struct syscall *sc, struct trace *trace) { char tp_name[128]; - struct syscall *sc; - const char *name =3D syscalltbl__name(trace->sctbl, id); + const char *name; int err; =20 - if (trace->syscalls.table =3D=3D NULL) { - trace->syscalls.table =3D calloc(trace->sctbl->syscalls.max_id + 1, size= of(*sc)); - if (trace->syscalls.table =3D=3D NULL) - return -ENOMEM; - } - sc =3D trace->syscalls.table + id; if (sc->nonexistent) return -EEXIST; =20 + if (sc->name) { + /* Info already read. */ + return 0; + } + + name =3D syscalltbl__name(trace->sctbl, sc->id); if (name =3D=3D NULL) { sc->nonexistent =3D true; return -EEXIST; @@ -2145,15 +2164,16 @@ static int trace__read_syscall_info(struct trace *t= race, int id) */ if (IS_ERR(sc->tp_format)) { sc->nonexistent =3D true; - return PTR_ERR(sc->tp_format); + err =3D PTR_ERR(sc->tp_format); + sc->tp_format =3D NULL; + return err; } =20 /* * The tracepoint format contains __syscall_nr field, so it's one more * than the actual number of syscall arguments. */ - if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? - RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields - 1)) + if (syscall__alloc_arg_fmts(sc, sc->tp_format->format.nr_fields - 1)) return -ENOMEM; =20 sc->args =3D sc->tp_format->format.fields; @@ -2442,13 +2462,67 @@ static size_t syscall__scnprintf_args(struct syscal= l *sc, char *bf, size_t size, return printed; } =20 +static void syscall__init(struct syscall *sc, int e_machine, int id) +{ + memset(sc, 0, sizeof(*sc)); + sc->e_machine =3D e_machine; + sc->id =3D id; +} + +static void syscall__exit(struct syscall *sc) +{ + if (!sc) + return; + + zfree(&sc->arg_fmt); +} + +static int syscall__cmp(const void *va, const void *vb) +{ + const struct syscall *a =3D va, *b =3D vb; + + if (a->e_machine !=3D b->e_machine) + return a->e_machine - b->e_machine; + + return a->id - b->id; +} + +static struct syscall *trace__find_syscall(struct trace *trace, int e_mach= ine, int id) +{ + struct syscall key =3D { + .e_machine =3D e_machine, + .id =3D id, + }; + struct syscall *sc, *tmp; + + sc =3D bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, + sizeof(struct syscall), syscall__cmp); + if (sc) + return sc; + + tmp =3D reallocarray(trace->syscalls.table, trace->syscalls.table_size + = 1, + sizeof(struct syscall)); + if (!tmp) + return NULL; + + trace->syscalls.table =3D tmp; + sc =3D &trace->syscalls.table[trace->syscalls.table_size++]; + syscall__init(sc, e_machine, id); + qsort(trace->syscalls.table, trace->syscalls.table_size, sizeof(struct sy= scall), + syscall__cmp); + sc =3D bsearch(&key, trace->syscalls.table, trace->syscalls.table_size, + sizeof(struct syscall), syscall__cmp); + return sc; +} + typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel, union perf_event *event, struct perf_sample *sample); =20 -static struct syscall *trace__syscall_info(struct trace *trace, - struct evsel *evsel, int id) +static struct syscall *trace__syscall_info(struct trace *trace, struct evs= el *evsel, + int e_machine, int id) { + struct syscall *sc; int err =3D 0; =20 if (id < 0) { @@ -2473,28 +2547,20 @@ static struct syscall *trace__syscall_info(struct t= race *trace, =20 err =3D -EINVAL; =20 - if (id > trace->sctbl->syscalls.max_id) { - goto out_cant_read; - } - - if ((trace->syscalls.table =3D=3D NULL || trace->syscalls.table[id].name = =3D=3D NULL) && - (err =3D trace__read_syscall_info(trace, id)) !=3D 0) - goto out_cant_read; + sc =3D trace__find_syscall(trace, e_machine, id); + if (sc) + err =3D syscall__read_info(sc, trace); =20 - if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) - goto out_cant_read; - - return &trace->syscalls.table[id]; - -out_cant_read: - if (verbose > 0) { + if (err && verbose > 0) { char sbuf[STRERR_BUFSIZE]; - fprintf(trace->output, "Problems reading syscall %d: %d (%s)", id, -err,= str_error_r(-err, sbuf, sizeof(sbuf))); - if (id <=3D trace->sctbl->syscalls.max_id && trace->syscalls.table[id].n= ame !=3D NULL) - fprintf(trace->output, "(%s)", trace->syscalls.table[id].name); + + fprintf(trace->output, "Problems reading syscall %d: %d (%s)", id, -err, + str_error_r(-err, sbuf, sizeof(sbuf))); + if (sc && sc->name) + fprintf(trace->output, "(%s)", sc->name); fputs(" information\n", trace->output); } - return NULL; + return err ? NULL : sc; } =20 struct syscall_stats { @@ -2643,14 +2709,6 @@ static void *syscall__augmented_args(struct syscall = *sc, struct perf_sample *sam return NULL; } =20 -static void syscall__exit(struct syscall *sc) -{ - if (!sc) - return; - - zfree(&sc->arg_fmt); -} - static int trace__sys_enter(struct trace *trace, struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) @@ -2662,7 +2720,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; int augmented_args_size =3D 0; void *augmented_args =3D NULL; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 if (sc =3D=3D NULL) @@ -2736,7 +2794,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args =3D NULL; int augmented_args_size; @@ -2811,7 +2869,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; int alignment =3D trace->args_alignment; - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 if (sc =3D=3D NULL) @@ -3164,7 +3222,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); - struct syscall *sc =3D trace__syscall_info(trace, evsel, id); + struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); =20 if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -3673,7 +3731,7 @@ static struct bpf_program *trace__find_syscall_bpf_pr= og(struct trace *trace, str =20 static void trace__init_syscall_bpf_progs(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); =20 if (sc =3D=3D NULL) return; @@ -3684,20 +3742,20 @@ static void trace__init_syscall_bpf_progs(struct tr= ace *trace, int id) =20 static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(tra= ce->skel->progs.syscall_unaugmented); } =20 static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trac= e->skel->progs.syscall_unaugmented); } =20 static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, u= nsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc =3D trace__syscall_info(trace, NULL, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment =3D false; @@ -3795,7 +3853,7 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace try_to_find_pair: for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int id =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair =3D trace__syscall_info(trace, NULL, id); + struct syscall *pair =3D trace__syscall_info(trace, NULL, EM_HOST, id); struct bpf_program *pair_prog; bool is_candidate =3D false; =20 @@ -3945,7 +4003,7 @@ static int trace__init_syscalls_bpf_prog_array_maps(s= truct trace *trace) */ for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { int key =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc =3D trace__syscall_info(trace, NULL, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); struct bpf_program *pair_prog; int prog_fd; =20 @@ -4760,7 +4818,10 @@ static size_t syscall__dump_stats(struct trace *trac= e, FILE *fp, pct =3D avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /=3D NSEC_PER_MSEC; =20 - sc =3D &trace->syscalls.table[entry->syscall]; + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, EM_HOST, entry->sys= call); + if (!sc) + continue; + printed +=3D fprintf(fp, " %-15s", sc->name); printed +=3D fprintf(fp, " %8" PRIu64 " %6" PRIu64 " %9.3f %9.3f %9.3f", n, stats->nr_failures, entry->msecs, min, avg); @@ -5217,12 +5278,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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 027192153C6 for ; Wed, 19 Feb 2025 18:57:17 +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=1739991440; cv=none; b=SdFUsgO4lXMTGHeFw5Fut84AKwUFv4kO9u8ofL4aW8guck3qHaz/OPnrFFHTn8jAvYxIFSY3FKcFWeTFbBwjrWk9wYMCtGeb88g3xQ9cwunZIOuCiafsJxT2Op6CCkHdUMm4uhHyRMSlDLUvGhKEOYDuH5GYRJ6PUcA9H50NvXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991440; c=relaxed/simple; bh=9O22tmV90PhD/MkSmA2ZFA+Hq340q2NOX11TMalzwyI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ny0xYHJUgLhlUXaEqRtdhLvO0ph7M9qkq4nljs2JlzxN73w3Ai4VtDH+fZZI/S0SUdfeIXZyI6DDZv6RS0aMmDeelGJJwwbWr9CSbnLEhd6EXWimiBFq7Rdg8ddcp3I8h8ziJrIj+YN3382A+ZRvWZ7J3MdzwoY8gvyhXLur9Uc= 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=iBcYNoqX; 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="iBcYNoqX" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6f46ad8a390so1001707b3.1 for ; Wed, 19 Feb 2025 10:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991437; x=1740596237; 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=dd+vR04gllYquum04pJ2ab6UMn0xDK1cmHJnYiAKDVE=; b=iBcYNoqXuwDHewNABDETvDWVNnZsf1a320WDjAOvqIN8Lxl1Ou/9LveFWePTDzTKWJ qLF7qMRDqaw0PlA1hTz6HpGvJwB0ZJRgkUIWaQdsl/DVkLXWmgXLJpDPtU/gGdmfbOOc fcXsnd6KpoN7QV3xnEZ05iTMbVIZfKh+9yDFzDlw9AyFiYSP461j+hhU4oN49pgyit7Y xhBXdT97YBW3URVUaYOFjjQQdcKchw4wi5XLqiZSL53IW7sOof7KG7yqPXUS4n+9G15d nR20Xe2P8A3XNezsGeuR6QvJVP4b6A8Sfk3/6ZorwQlksoTktwperDtk+vzboQSqei+i vaEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991437; x=1740596237; 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=dd+vR04gllYquum04pJ2ab6UMn0xDK1cmHJnYiAKDVE=; b=tFXO65w0Onz/fnjhB+vLOJzgRopqiksUMKxZ17D/4pOA7kn8blrP1fDqG6ubsvCsdz aj8uYYGp3t5ZOdhKcSc+lhdpxlCk6M32/TOTIO/GwtBbJ0p+2g3XoP+zDJfaGxKc0RY5 isG3e2n0jxM601NZJYQdwfouYVi59qvJka3FUcrCouzfIjuvckf3jmgXCRG2BctL3IFl I/JooR7gJrsD5vmdNRhgROTQd2y3M8bBZuJT9uIR7Xt+uB4m956nd2HVvZPfR0f8VEcJ 2I5A7cD5tkNHwcm3sHMo47kvNkeixVB7p8IXf38cexCfLob1BSEFSbtTa4NGP5AAtFil DbtA== X-Forwarded-Encrypted: i=1; AJvYcCWYGLjCQl+jeKOsHR3CtWoWyn98zIRJ4hvdOPX6obiLiEZm7obtfrs/MLMWsFubj3MP5ViRd0rSeeKBWCA=@vger.kernel.org X-Gm-Message-State: AOJu0YzxhoOuEhvaW6n8UCCl7K8/M/YZrtZ8lNBIx8cx5msoP+TvkS4t TIhev1PN6UKeE9QztGhkCLnaMNwfHHG1DkEHVoSrcKmekocryjZ6dk/yIE3UGSlWl/4LTuTVmZH eiV7yEQ== X-Google-Smtp-Source: AGHT+IG8BjrEupOvaUPtTr948/xj1ADFgAE0bp2qDX4ugqIw/zoJ6OVcBh1vGjkCZy0L3XDI98vgCwJxIkSU X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a05:690c:3102:b0:6fb:451d:3409 with SMTP id 00721157ae682-6fb5804f0b1mr2087177b3.0.1739991437065; Wed, 19 Feb 2025 10:57:17 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:52 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 3/8] perf syscalltbl: Remove struct syscalltbl From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The syscalltbl held entries of system call name and number pairs, generated from a native syscalltbl at start up. As there are gaps in the system call number there is a notion of index into the table. Going forward we want the system call table to be identifiable by a machine type, for example, i386 vs x86-64. Change the interface to the syscalltbl so (1) a (currently unused machine type of EM_HOST) is passed (2) the index to syscall number and system call name mapping is computed at build time. Two tables are used for this, an array of system call number to name, an array of system call numbers sorted by the system call name. The sorted array doesn't store strings in part to save memory and relocations. The index notion is carried forward and is an index into the sorted array of system call numbers, the data structures are opaque (held only in syscalltbl.c), and so the number of indices for a machine type is exposed as a new API. The arrays are computed in the syscalltbl.sh script and so no start-up time computation and storage is necessary. Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- tools/perf/builtin-trace.c | 106 +++++++++++++++++------------ tools/perf/scripts/syscalltbl.sh | 36 ++++------ tools/perf/util/syscalltbl.c | 113 ++++++++++--------------------- tools/perf/util/syscalltbl.h | 22 ++---- 4 files changed, 117 insertions(+), 160 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index eb3551fb0e7b..fbf21055cff6 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -149,7 +149,6 @@ enum summary_mode { =20 struct trace { struct perf_tool tool; - struct syscalltbl *sctbl; struct { /** Sorted sycall numbers used by the trace. */ struct syscall *table; @@ -188,6 +187,14 @@ struct trace { pid_t *entries; struct bpf_map *map; } filter_pids; + /* + * TODO: The map is from an ID (aka system call number) to struct + * syscall_stats. If there is >1 e_machine, such as i386 and x86-64 + * processes, then the stats here will gather wrong the statistics for + * the non EM_HOST system calls. A fix would be to add the e_machine + * into the key, but this would make the code inconsistent with the + * per-thread version. + */ struct hashmap *syscall_stats; double duration_filter; double runtime_ms; @@ -2141,7 +2148,7 @@ static int syscall__read_info(struct syscall *sc, str= uct trace *trace) return 0; } =20 - name =3D syscalltbl__name(trace->sctbl, sc->id); + name =3D syscalltbl__name(sc->e_machine, sc->id); if (name =3D=3D NULL) { sc->nonexistent =3D true; return -EEXIST; @@ -2241,10 +2248,14 @@ static int trace__validate_ev_qualifier(struct trac= e *trace) =20 strlist__for_each_entry(pos, trace->ev_qualifier) { const char *sc =3D pos->s; - int id =3D syscalltbl__id(trace->sctbl, sc), match_next =3D -1; + /* + * TODO: Assume more than the validation/warnings are all for + * the same binary type as perf. + */ + int id =3D syscalltbl__id(EM_HOST, sc), match_next =3D -1; =20 if (id < 0) { - id =3D syscalltbl__strglobmatch_first(trace->sctbl, sc, &match_next); + id =3D syscalltbl__strglobmatch_first(EM_HOST, sc, &match_next); if (id >=3D 0) goto matches; =20 @@ -2264,7 +2275,7 @@ static int trace__validate_ev_qualifier(struct trace = *trace) continue; =20 while (1) { - id =3D syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next); + id =3D syscalltbl__strglobmatch_next(EM_HOST, sc, &match_next); if (id < 0) break; if (nr_allocated =3D=3D nr_used) { @@ -2720,6 +2731,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; int augmented_args_size =3D 0; void *augmented_args =3D NULL; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 @@ -2794,6 +2806,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); char msg[1024]; void *args, *augmented_args =3D NULL; @@ -2869,6 +2882,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; int alignment =3D trace->args_alignment; + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); struct thread_trace *ttrace; =20 @@ -3222,6 +3236,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); + /* TODO: get e_machine from thread. */ struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); =20 if (sc) { @@ -3729,9 +3744,9 @@ static struct bpf_program *trace__find_syscall_bpf_pr= og(struct trace *trace, str return trace->skel->progs.syscall_unaugmented; } =20 -static void trace__init_syscall_bpf_progs(struct trace *trace, int id) +static void trace__init_syscall_bpf_progs(struct trace *trace, int e_machi= ne, int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); =20 if (sc =3D=3D NULL) return; @@ -3740,22 +3755,22 @@ static void trace__init_syscall_bpf_progs(struct tr= ace *trace, int id) sc->bpf_prog.sys_exit =3D trace__find_syscall_bpf_prog(trace, sc, sc->fm= t ? sc->fmt->bpf_prog_name.sys_exit : NULL, "exit"); } =20 -static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int id) +static int trace__bpf_prog_sys_enter_fd(struct trace *trace, int e_machine= , int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_enter) : bpf_program__fd(tra= ce->skel->progs.syscall_unaugmented); } =20 -static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) +static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int e_machine,= int id) { - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, id); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, id); return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trac= e->skel->progs.syscall_unaugmented); } =20 -static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int key, u= nsigned int *beauty_array) +static int trace__bpf_sys_enter_beauty_map(struct trace *trace, int e_mach= ine, int key, unsigned int *beauty_array) { struct tep_format_field *field; - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, key); const struct btf_type *bt; char *struct_offset, *tmp, name[32]; bool can_augment =3D false; @@ -3851,9 +3866,9 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace return NULL; =20 try_to_find_pair: - for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int id =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *pair =3D trace__syscall_info(trace, NULL, EM_HOST, id); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(sc->e_machine); i < num= _idx; ++i) { + int id =3D syscalltbl__id_at_idx(sc->e_machine, i); + struct syscall *pair =3D trace__syscall_info(trace, NULL, sc->e_machine,= id); struct bpf_program *pair_prog; bool is_candidate =3D false; =20 @@ -3937,7 +3952,7 @@ static struct bpf_program *trace__find_usable_bpf_pro= g_entry(struct trace *trace return NULL; } =20 -static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) +static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace, i= nt e_machine) { int map_enter_fd =3D bpf_map__fd(trace->skel->maps.syscalls_sys_enter); int map_exit_fd =3D bpf_map__fd(trace->skel->maps.syscalls_sys_exit); @@ -3945,27 +3960,27 @@ static int trace__init_syscalls_bpf_prog_array_maps= (struct trace *trace) int err =3D 0; unsigned int beauty_array[6]; =20 - for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int prog_fd, key =3D syscalltbl__id_at_idx(trace->sctbl, i); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(e_machine); i < num_idx= ; ++i) { + int prog_fd, key =3D syscalltbl__id_at_idx(e_machine, i); =20 if (!trace__syscall_enabled(trace, key)) continue; =20 - trace__init_syscall_bpf_progs(trace, key); + trace__init_syscall_bpf_progs(trace, e_machine, key); =20 // It'll get at least the "!raw_syscalls:unaugmented" - prog_fd =3D trace__bpf_prog_sys_enter_fd(trace, key); + prog_fd =3D trace__bpf_prog_sys_enter_fd(trace, e_machine, key); err =3D bpf_map_update_elem(map_enter_fd, &key, &prog_fd, BPF_ANY); if (err) break; - prog_fd =3D trace__bpf_prog_sys_exit_fd(trace, key); + prog_fd =3D trace__bpf_prog_sys_exit_fd(trace, e_machine, key); err =3D bpf_map_update_elem(map_exit_fd, &key, &prog_fd, BPF_ANY); if (err) break; =20 /* use beauty_map to tell BPF how many bytes to collect, set beauty_map'= s value here */ memset(beauty_array, 0, sizeof(beauty_array)); - err =3D trace__bpf_sys_enter_beauty_map(trace, key, (unsigned int *)beau= ty_array); + err =3D trace__bpf_sys_enter_beauty_map(trace, e_machine, key, (unsigned= int *)beauty_array); if (err) continue; err =3D bpf_map_update_elem(beauty_map_fd, &key, beauty_array, BPF_ANY); @@ -4001,9 +4016,9 @@ static int trace__init_syscalls_bpf_prog_array_maps(s= truct trace *trace) * first and second arg (this one on the raw_syscalls:sys_exit prog * array tail call, then that one will be used. */ - for (int i =3D 0; i < trace->sctbl->syscalls.nr_entries; ++i) { - int key =3D syscalltbl__id_at_idx(trace->sctbl, i); - struct syscall *sc =3D trace__syscall_info(trace, NULL, EM_HOST, key); + for (int i =3D 0, num_idx =3D syscalltbl__num_idx(e_machine); i < num_idx= ; ++i) { + int key =3D syscalltbl__id_at_idx(e_machine, i); + struct syscall *sc =3D trace__syscall_info(trace, NULL, e_machine, key); struct bpf_program *pair_prog; int prog_fd; =20 @@ -4449,8 +4464,13 @@ static int trace__run(struct trace *trace, int argc,= const char **argv) goto out_error_mem; =20 #ifdef HAVE_BPF_SKEL - if (trace->skel && trace->skel->progs.sys_enter) - trace__init_syscalls_bpf_prog_array_maps(trace); + if (trace->skel && trace->skel->progs.sys_enter) { + /* + * TODO: Initialize for all host binary machine types, not just + * those matching the perf binary. + */ + trace__init_syscalls_bpf_prog_array_maps(trace, EM_HOST); + } #endif =20 if (trace->ev_qualifier_ids.nr > 0) { @@ -4475,7 +4495,8 @@ static int trace__run(struct trace *trace, int argc, = const char **argv) * So just disable this beautifier (SCA_FD, SCA_FDAT) when 'close' is * not in use. */ - trace->fd_path_disabled =3D !trace__syscall_enabled(trace, syscalltbl__id= (trace->sctbl, "close")); + /* TODO: support for more than just perf binary machine type close. */ + trace->fd_path_disabled =3D !trace__syscall_enabled(trace, syscalltbl__id= (EM_HOST, "close")); =20 err =3D trace__expand_filters(trace, &evsel); if (err) @@ -4787,7 +4808,7 @@ static struct syscall_entry *syscall__sort_stats(stru= ct hashmap *syscall_stats) return entry; } =20 -static size_t syscall__dump_stats(struct trace *trace, FILE *fp, +static size_t syscall__dump_stats(struct trace *trace, int e_machine, FILE= *fp, struct hashmap *syscall_stats) { size_t printed =3D 0; @@ -4818,7 +4839,7 @@ static size_t syscall__dump_stats(struct trace *trace= , FILE *fp, pct =3D avg ? 100.0 * stddev_stats(&stats->stats) / avg : 0.0; avg /=3D NSEC_PER_MSEC; =20 - sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, EM_HOST, entry->sys= call); + sc =3D trace__syscall_info(trace, /*evsel=3D*/NULL, e_machine, entry->s= yscall); if (!sc) continue; =20 @@ -4845,14 +4866,14 @@ static size_t syscall__dump_stats(struct trace *tra= ce, FILE *fp, } =20 static size_t thread__dump_stats(struct thread_trace *ttrace, - struct trace *trace, FILE *fp) + struct trace *trace, int e_machine, FILE *fp) { - return syscall__dump_stats(trace, fp, ttrace->syscall_stats); + return syscall__dump_stats(trace, e_machine, fp, ttrace->syscall_stats); } =20 -static size_t system__dump_stats(struct trace *trace, FILE *fp) +static size_t system__dump_stats(struct trace *trace, int e_machine, FILE = *fp) { - return syscall__dump_stats(trace, fp, trace->syscall_stats); + return syscall__dump_stats(trace, e_machine, fp, trace->syscall_stats); } =20 static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struc= t trace *trace) @@ -4878,7 +4899,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; } @@ -4939,7 +4961,8 @@ static size_t trace__fprintf_total_summary(struct tra= ce *trace, FILE *fp) else if (fputc('\n', fp) !=3D EOF) ++printed; =20 - printed +=3D system__dump_stats(trace, fp); + /* TODO: get all system e_machines. */ + printed +=3D system__dump_stats(trace, EM_HOST, fp); =20 return printed; } @@ -5131,8 +5154,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; } @@ -5285,7 +5309,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 @@ -5434,9 +5457,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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 517AA21505D for ; Wed, 19 Feb 2025 18:57: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=1739991442; cv=none; b=bisPOlasEIiWhBz/iHaX3Ns6s7kZfvwb1VWrLDAhWEPCjw1zI+4ifaUNMGY5ykT7bowiIrfL3VuQK0eNySWlL4EilPJ+3N0T0zNPavfQElEqJvXycsVAxumrwdjl00w+GKKZiTUyynziVqZTLaEEUduh9jCGaTFk7CZXQJ2f1HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991442; c=relaxed/simple; bh=HX0srdsrcJyujuxVltTOJpCgtzYp3ymOKQwk3LGQ7P0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qY9yGDU3iYCEOZRFaChbsonsBFIg5uD3iTG2zDwcVgjPelhxGN3cpAQnALv8Q0eJrKVWvOON8OUoTNsfmvQ7oVmx6thuFTU773QQic9r0AnCcnJTYLCVIjO+NObYpB7MHRqt+LS/6BQrThtau4Nv/pKmVNatm8bJjqUbVgYEBWw= 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=PiXnVEc3; 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="PiXnVEc3" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e5dbe8309eeso207236276.3 for ; Wed, 19 Feb 2025 10:57:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991439; x=1740596239; 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=kWH/J8feL05TW7MSkGLKxFZ1lLYkRRNINqOHnwtT3tY=; b=PiXnVEc3HPual2+iM1/MgoHWFH9fIBgrCfzg4NBryksKjK1Im+vn7Sn6fcLG5yOfhx pINApHU52kEFCup2usInG+QwY5hrb/BguvkeGzCiU1OPJZviMKltbVNzgxX3Ocskyx46 PE6ENEpFaMGBRuivmsC7FmnoZRy/ZJOZxMQ8o5WCEhGm6Vi3wmH0i6H1W0KPw9SlokBE VbHTQgJVhZjB8fTOWN2MKec70yZgB5tlelaWEu5PRCuxj14EBD2Xyo/ozFGLymXonLzr KmvKjGCg/l2NcIoMf8ocnrnUyH+/dbNB6+0MriZHChm26ZNIJOJRWsVw1divglprk1RG altw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991439; x=1740596239; 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=kWH/J8feL05TW7MSkGLKxFZ1lLYkRRNINqOHnwtT3tY=; b=e9UZRyQuz4+OfOXtBXJld13s1xrvr8YFuMZCOdIFYvM7EKvFI8Df4uVGnCwFVL7Tcu 0+sSwR5UgeYLzmXkvIjLwxe7SkY2zCfK7UE4mQCijHiH3bmnnGtqd2rLCpAQtthThyZy zez+U6xEA8Wrq7ZbzcX9Oq5fWr42wlPExB3rf8TOki0I5TPmB7hMyFAp5EIY3rV/TsTr Qe68c9GjC5QC/kgpAJ3pU1HcuLid82g2NJ6/mljc1d+oet1IrpVi/qygnctAzhmh2Hf1 3QanDIrj2Y+rwJ06JKp1sOqauGRhz62b7g/UhsVTJ10msYuMIs9Jue0ReJTzjo85/eF7 x6DA== X-Forwarded-Encrypted: i=1; AJvYcCXDHgiUdr5V9IN6JLeuIUUBGHh2h2fQN6UTc9MD3klDfcW4xs3xJ1KQS498YmELSKKz90iBQTvCaN22iqs=@vger.kernel.org X-Gm-Message-State: AOJu0YzBdQTIu5sFSmENsLjtFZVX3WbzehtzC4QZWCmK38nVq6Icd7At ErrJEuJDedcV59TISOqQj/aooXXGO+1csUGep0a+zTwHMPpkZE/2DIgNQCVsBwcvIQcT+30l4CN ztno3vQ== X-Google-Smtp-Source: AGHT+IFzltNedNUmnbTjYGbhJ5gshU+KX8waGHsEl1kC2+D01VybaqMjHTRbv6ZYyd1KMbkh3O5NS15WXbnX X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a25:b282:0:b0:e5d:98cd:a44e with SMTP id 3f1490d57ef6-e5dc904b5b8mr214241276.3.1739991439082; Wed, 19 Feb 2025 10:57:19 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:53 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 4/8] perf thread: Add support for reading the e_machine type for a thread From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann 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 --- tools/perf/builtin-trace.c | 43 ++++++++++++++++---------------- tools/perf/util/thread.c | 50 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/thread.h | 14 ++++++++++- 3 files changed, 85 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fbf21055cff6..de6896ebe82b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2729,16 +2729,16 @@ static int trace__sys_enter(struct trace *trace, st= ruct evsel *evsel, int printed =3D 0; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - int augmented_args_size =3D 0; + int augmented_args_size =3D 0, e_machine; void *augmented_args =3D NULL; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; struct thread_trace *ttrace; =20 - if (sc =3D=3D NULL) - return -1; - thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + goto out_put; ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; @@ -2806,17 +2806,18 @@ static int trace__fprintf_sys_enter(struct trace *t= race, struct evsel *evsel, struct thread_trace *ttrace; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + struct syscall *sc; char msg[1024]; void *args, *augmented_args =3D NULL; - int augmented_args_size; + int augmented_args_size, e_machine; size_t printed =3D 0; =20 - if (sc =3D=3D NULL) - return -1; =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + return -1; ttrace =3D thread__trace(thread, trace); /* * We need to get ttrace just to make sure it is there when syscall__scnp= rintf_args() @@ -2881,15 +2882,15 @@ static int trace__sys_exit(struct trace *trace, str= uct evsel *evsel, bool duration_calculated =3D false; struct thread *thread; int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; - int alignment =3D trace->args_alignment; - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + int alignment =3D trace->args_alignment, e_machine; + struct syscall *sc; struct thread_trace *ttrace; =20 - if (sc =3D=3D NULL) - return -1; - thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); + e_machine =3D thread__e_machine(thread, trace->host); + sc =3D trace__syscall_info(trace, evsel, e_machine, id); + if (sc =3D=3D NULL) + goto out_put; ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; @@ -3236,8 +3237,8 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); - /* TODO: get e_machine from thread. */ - struct syscall *sc =3D trace__syscall_info(trace, evsel, EM_HOST, id); + int e_machine =3D thread ? thread__e_machine(thread, trace->host) : EM_H= OST; + struct syscall *sc =3D trace__syscall_info(trace, evsel, e_machine, id); =20 if (sc) { fprintf(trace->output, "%s(", sc->name); @@ -4880,6 +4881,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) @@ -4899,8 +4901,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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 3D964215780 for ; Wed, 19 Feb 2025 18:57:21 +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=1739991444; cv=none; b=siBx31CiHeLkYPi8ipWoDgzHevVJ/SbFVySMVJrNwd3Urzn50pw4uPgUy9kNJqsQ203nQDcQNUKpDb3D1HfUrYxdiTG/s6QtL4DoN+X/j7IRRcLTQgoPUXKkx+I77jui+Ygaw/DlBAE98frlQ8J/g1K2coD6WNNVC7N69UWlqb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991444; c=relaxed/simple; bh=4u0r33GQQwWbugYJk4vJkP/L1mgxHvDxK326EG2PId4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AnTiv2IFfO8nl37ZpvWPWT6mZfG7dRQZ1IUXMNm8hJnox4ems7YPQRA9MlS1x/i3HTz2QDgl5S3WL6Pd0HYqDwr5ZIQvdGduANkDItdG0+vq6ylJkt7SCfbih3G8avmyH4dzonfZ+tdzx3dmX7Yk56W+GoS0Nv2d54hYrlxWIRw= 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=E36wba+4; 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="E36wba+4" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e584f13c56aso218717276.0 for ; Wed, 19 Feb 2025 10:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991441; x=1740596241; 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=B0W/MdbpFPufmvsBpwvPfF6M+6JFCh/wACHxRC0LJnU=; b=E36wba+4yG8aClKZDGORiCyHrJfJCnSf4oelmb5WOxE8UPEi9SZRw5PaSCjDgGHE/n B6RgyUW/zttrR39tuHe1bDIFr5fZrt3nMwiENxgFBS8n65UBTvHogoGkcr20hfjlH66f UmcXw7j9wTbJy2iw4BtI8lo/VBsaGdXTMbweBJ7qQE1Dq3DcQ4X7LxamGQ+bh1J/mcKs nSaTYqSkShLqJuL/zyR/mjVf8Kwfbbh8zIrgLc5v5Zytx9mHM9IwL2VZJyFjlQmSJlwy gt0YHu2IcjkUEm7tjVmhlSboywaLn+AZSW5G40jBBUws13uwVy9Y3EvmJHUqnWKq0y/v SylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991441; x=1740596241; 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=B0W/MdbpFPufmvsBpwvPfF6M+6JFCh/wACHxRC0LJnU=; b=fa0pZ9AOnxbwGkEnOSFHfQkbNNIxY78mI2vOqiG5XiPTLoGJxZcrMmKAWUaj6/XZcC Q6lHKKhTc5yCEbB6F5OqhSuAELqQSWCdhUBPca/XuigJK1Jq9cpB6n/5tJmAPjdMotwm KMxOTv3WFpt3EK03aF6bhk8uBzlb9EQ1KYPY6FHrgaZ4KriQN8KvdPQwVi9qlF5KoYGY kqFDiop6QFVfv7O2PyZOWTLwwvQ89lUIR4v/Qt005zXVvt/qX/LcD0uTZgflRgPBo9+b d4+Xk/WOrb0yImd0Vxn3sZYahC9XFYpIMve1uwZOiYOl77CixLIsdmfqSflkVgi4W3o/ hOvA== X-Forwarded-Encrypted: i=1; AJvYcCXQqtOuHhdduXqhVaTDUPazsFs3mtwYzxD7Kjj3l03Ij03MvpxC3ZhM1yLtelLlK0VOL5bjAqQ2ECihV6U=@vger.kernel.org X-Gm-Message-State: AOJu0YyUE9wWEPSrC3dDkNRb7WkDjtMHtgz2quswAy0peEN1tWYpxBay ERrpCkR5P19ps93SGTD+Q+K300jJqaskKsW2DtkF3SWTres8OkjLXn97KDExKoPo9y8evOsYAEa 4OnxU3A== X-Google-Smtp-Source: AGHT+IEc17EkF855R/mtJ+P/1sruNzGL1Z3jO3GoB7KHZ7Vd8vGmtnbWb/CaP104jKDnUlZAd9eSLolJEScm X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a25:818e:0:b0:e5b:3e69:ecae with SMTP id 3f1490d57ef6-e5dc931927fmr209939276.9.1739991440963; Wed, 19 Feb 2025 10:57:20 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:54 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 5/8] perf trace beauty: Add syscalltbl.sh generating all system call tables From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than generating individual syscall header files generate a single trace/beauty/generated/syscalltbl.c. In a syscalltbls array have references to each architectures tables along with the corresponding e_machine. When the 32-bit or 64-bit table is ambiguous, match the perf binary's type. For ARM32 don't use the arm64 32-bit table which is smaller. EM_NONE is present for is no machine matches. Conditionally compile the tables, only having the appropriate 32 and 64-bit table. If ALL_SYSCALLTBL is defined all tables can be compiled. Add comment for noreturn column suggested by Arnd Bergmann: https://lore.kernel.org/lkml/d47c35dd-9c52-48e7-a00d-135572f11fbb@app.fastm= ail.com/ and added in commit 9142be9e6443 ("x86/syscall: Mark exit[_group] syscall handlers __noreturn"). Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- 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..1199618dc178 --- /dev/null +++ b/tools/perf/trace/beauty/syscalltbl.sh @@ -0,0 +1,274 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Generate all syscall tables. +# +# Each line of the syscall table should have the following format: +# +# NR ABI NAME [NATIVE] [COMPAT [noreturn]] +# +# NR syscall number +# ABI ABI name +# NAME syscall name +# NATIVE native entry point (optional) +# COMPAT compat entry point (optional) +# noreturn system call doesn't return (optional) +set -e + +usage() { + cat >&2 < + + path to kernel tools directory + output header file +EOF + exit 1 +} + +if [ $# -ne 2 ]; then + usage +fi +tools_dir=3D$1 +outfile=3D$2 + +build_tables() { + infile=3D"$1" + outfile=3D"$2" + abis=3D$(echo "($3)" | tr ',' '|') + e_machine=3D"$4" + + if [ ! -f "$infile" ] + then + echo "Missing file $infile" + exit 1 + fi + sorted_table=3D$(mktemp /tmp/syscalltbl.XXXXXX) + grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > "$sorted_table" + + echo "static const char *const syscall_num_to_name_${e_machine}[] =3D {" = >> "$outfile" + # the params are: nr abi name entry compat + # use _ for intentionally unused variables according to SC2034 + while read -r nr _ name _ _; do + echo " [$nr] =3D \"$name\"," >> "$outfile" + done < "$sorted_table" + echo "};" >> "$outfile" + + echo "static const uint16_t syscall_sorted_names_${e_machine}[] =3D {" >>= "$outfile" + + # When sorting by name, add a suffix of 0s upto 20 characters so that + # system calls that differ with a numerical suffix don't sort before + # those without. This default behavior of sort differs from that of + # strcmp used at runtime. Use sed to strip the trailing 0s suffix + # afterwards. + grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | awk '{printf $3; for (i = =3D length($3); i < 20; i++) { printf "0"; }; print " " $1}'| sort | sed 's= /\([a-zA-Z1-9]\+\)0\+ \([0-9]\+\)/\1 \2/' > "$sorted_table" + while read -r name nr; do + echo " $nr, /* $name */" >> "$outfile" + done < "$sorted_table" + echo "};" >> "$outfile" + + rm -f "$sorted_table" +} + +rm -f "$outfile" +cat >> "$outfile" < +#include +#include +#include + +struct syscalltbl { + const char *const *num_to_name; + const uint16_t *sorted_names; + uint16_t e_machine; + uint16_t num_to_name_len; + uint16_t sorted_names_len; +}; + +#if defined(ALL_SYSCALLTBL) || defined(__alpha__) +EOF +build_tables "$tools_dir/perf/arch/alpha/entry/syscalls/syscall.tbl" "$out= file" common,64 EM_ALPHA +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/parisc/entry/syscalls/syscall.tbl" "$ou= tfile" common,64 EM_PARISC +cat >> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/scripts/syscall.tbl" "$outfile" common,64,riscv,r= limit,memfd_secret EM_RISCV +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/perf/arch/sparc/entry/syscalls/syscall.tbl" "$out= file" common,64 EM_SPARC +cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" +build_tables "$tools_dir/scripts/syscall.tbl" "$outfile" common,64 EM_NONE +echo "#endif //__BITS_PER_LONG !=3D 64" >> "$outfile" + +build_outer_table() { + e_machine=3D$1 + outfile=3D"$2" + cat >> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <> "$outfile" <; Wed, 19 Feb 2025 18:57:24 +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=1739991446; cv=none; b=UGCZ/iD7vYD8amZSWGl+hNxiaTuuBkqqlnhXs1JCNhVntWEmkDcL5PLWIa6rcoZBH9Di1WffnOAErvofddYa1ToEpBbiJzOeoDJlCBpgfLl1eOBCsyYZyze9pyRrLFG9ttYHiclkyqODF7E/qpWanzyTnelQhpnPYbQPkvmeobA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991446; c=relaxed/simple; bh=tKVHQOFRR+bT/Upl1u+suPKmUPP9zGjBniig9+y5GB4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=TH36RczJx1IpTHp7Z8Fcq/VN+iZ+PzXbf/IB74xlG/w2bF3hxWJb7T+fLykSw3657/DfVHLv0yq7DpFEjjCYuew/aVYY7w49XlH7XgVaBfstuYE+2TtIRO9nofagPkm1nPG4Ruj249H3Nr3qz+iqDLx1XKmldFg6kLF6qqEuaks= 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=dgioi/HU; 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="dgioi/HU" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fb518ad1e4so1913367b3.1 for ; Wed, 19 Feb 2025 10:57:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991443; x=1740596243; 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=WtE9YMxkX6iJIzxbxQHOso3EIj87gNZ3xHcs11euMqY=; b=dgioi/HU2ITAacseNYq4j8xtQFi+44KS/p1uE7yPR4fQFVOGArjEfwohR46YM9vvBT Dq43dCzLR4e/3iJYHA7uUgc0aYnKD/p5z/acwvqehkn/ylxSn56fwTFBJYJytYdJGSTP q4hmAkhkK2ajLesequmscQ8sE5mpBe39Qs/ouBZEGFWjqYLxy3rZ7K0R/B6Yw08dzwYL n4Tfg5HouhWWdiTHglteTCco9XidkNF7qDA3gyvGC9ppFCgqbubD6i5TskDCRmaF/15h 5qT2NVJ65RqqSLw1Qe5yk68M9OMW4aWh5Q/LMDos8Z1OZD9mW+Tn66LqCD+r5TAxRGeN 6qFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991443; x=1740596243; 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=WtE9YMxkX6iJIzxbxQHOso3EIj87gNZ3xHcs11euMqY=; b=SfbTYAQT/a8rH1fTEurZ8FsXJG+7Al2IA8cn2fch8AeSdsCYF/vI8ISxYnN9OGBpW4 iA/uvOkEViCu4fe0iGIhrlXZmo4sGDJooSWXGWdgjTrOiXm4Q0reh7Oy5h37t7fWhc0Y zFXYM1Ums/VGCWNUVVTgRnmsVkOE38KvQELuKDhTJAMzlcs8jf/vTYdwDrYLTiuANHxS GJh4+2n7ypbkzXB/V/r+6sO/Noy+fXNsvAvPvilVlZYc6s/7+pjmIgxqHM2KGm/4c/0u uXE67Hlpostq4Qmkp4YKWL1RYLNQfxYE9aC1oTCRK7SBM/EtzkeeK2iM8SxjEK740zsM 7ldQ== X-Forwarded-Encrypted: i=1; AJvYcCVvSbsxdtzZ/5ImwIapnpRQ4xSFopry6/fMOEyCXSK11j3ojAcOC3MrT/Kdy9AQpN3KKw7sNMv+4IgH0bs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6OzVC6pYbjcm62v42uuHlgtnyglwq+qgZaubnU4nl/IkYL19F DUg3F6Y0bkY7nhcqmYVhJ9huO596hnIv1cv9U6H8+PuwxI8oo3ZDeo9zGYvSo7osy8Nkc/NcmSF J7ALo4A== X-Google-Smtp-Source: AGHT+IGwwow2WZA60I+8tcofEY/J6CAtOHjSnbRklLDkqBfPvpjpwbRXmZixIwiYWsIaDUxYfy5YvSNpHTlh X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a05:690c:4d8a:b0:6f9:a7d6:45cf with SMTP id 00721157ae682-6fbb794e5c0mr54697b3.4.1739991443313; Wed, 19 Feb 2025 10:57:23 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:55 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 6/8] perf syscalltbl: Use lookup table containing multiple architectures From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch to use the lookup table containing all architectures rather than tables matching the perf binary. This fixes perf trace when executed on a 32-bit i386 binary on an x86-64 machine. Note in the following the system call names of the 32-bit i386 binary as seen by an x86-64 perf. Before: ``` ? ( ): a.out/447296 ... [continued]: munmap()) = =3D 0 0.024 ( 0.001 ms): a.out/447296 recvfrom(ubuf: 0x2, size: 4160585708, = flags: DONTROUTE|CTRUNC|TRUNC|DONTWAIT|EOR|WAITALL|FIN|SYN|CONFIRM|RST|ERRQ= UEUE|NOSIGNAL|WAITFORONE|BATCH|SOCK_DEVMEM|ZEROCOPY|FASTOPEN|CMSG_CLOEXEC|0= x91f80000, addr: 0xe30, addr_len: 0xffce438c) =3D 1475198976 0.042 ( 0.003 ms): a.out/447296 lgetxattr(name: "", value: 0x3, size: = 34) =3D 4160344064 0.054 ( 0.003 ms): a.out/447296 dup2(oldfd: -134422744, newfd: 4) = =3D -1 ENOENT (No such file or directory) 0.060 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct io= vec){.iov_base =3D (void *)0x2e646c2f6374652f,.iov_len =3D (__kernel_size_t= )7307199665335594867,}, vlen: 557056, pos_h: 4160585708) =3D 3 0.074 ( 0.004 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: = 2) =3D 4160237568 0.080 ( 0.001 ms): a.out/447296 lstat(filename: "", statbuf: 0x193f6) = =3D 0 0.089 ( 0.007 ms): a.out/447296 preadv(fd: 4294967196, vec: (struct io= vec){.iov_base =3D (void *)0x3833692f62696c2f,.iov_len =3D (__kernel_size_t= )3276497845987585334,}, vlen: 557056, pos_h: 4160585708) =3D 3 0.097 ( 0.002 ms): a.out/447296 close(fd: 3) = =3D 512 0.103 ( 0.002 ms): a.out/447296 lgetxattr(name: "", value: 0x1, size: = 2050) =3D 4157935616 0.107 ( 0.007 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x5, size: 2066) =3D 4158078976 0.116 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x1, size: 2066) =3D 4159639552 0.121 ( 0.003 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x3, size: 2066) =3D 4160184320 0.129 ( 0.002 ms): a.out/447296 lgetxattr(pathname: "", name: "", valu= e: 0x3, size: 50) =3D 4160196608 0.138 ( 0.001 ms): a.out/447296 lstat(filename: "") = =3D 0 0.145 ( 0.002 ms): a.out/447296 mq_timedreceive(mqdes: 4291706800, u_m= sg_ptr: 0xf7f9ea48, msg_len: 134616640, u_msg_prio: 0xf7fd7fec, u_abs_timeo= ut: (struct __kernel_timespec){.tv_sec =3D (__kernel_time64_t)-578174027777= 317696,.tv_nsec =3D (long long int)4160349376,}) =3D 0 0.148 ( 0.001 ms): a.out/447296 mkdirat(dfd: -134617816, pathname: " = =EF=BF=BD=EF=BF=BD=EF=BF=BD =EF=BF=BD=EF=BF=BD=EF=BF=BD=E2=96=92=EF=BF=BD= =EF=BF=BD=EF=BF=BD=E2=96=92=EF=BF=BD=EF=BF=BD=EF=BF=BD", mode: IFREG|ISUID|= IRUSR|IWGRP|0xf7fd0000) =3D 447296 0.150 ( 0.001 ms): a.out/447296 process_vm_writev(pid: -134617812, lve= c: (struct iovec){.iov_base =3D (void *)0xf7f9e9c8f7f9e4c0,.iov_len =3D (__= kernel_size_t)4160349376,}, liovcnt: 4160588048, rvec: (struct iovec){}, ri= ovcnt: 4160585708, flags: 4291707352) =3D 0 0.197 ( 0.004 ms): a.out/447296 capget(header: 4160184320, dataptr: 81= 92) =3D 0 0.202 ( 0.002 ms): a.out/447296 capget(header: 1448669184, dataptr: 40= 96) =3D 0 0.208 ( 0.002 ms): a.out/447296 capget(header: 4160577536, dataptr: 81= 92) =3D 0 0.220 ( 0.001 ms): a.out/447296 getxattr(pathname: "", name: "c=EF=BF= =BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD", value: 0xf7f77e34, size:= 1) =3D 0 0.228 ( 0.005 ms): a.out/447296 fchmod(fd: -134729728, mode: IRUGO|IWU= GO|IFREG|IFIFO|ISVTX|IXUSR|0x10000) =3D 0 0.240 ( 0.009 ms): a.out/447296 preadv(fd: 4294967196, vec: 0x5658e008= , pos_h: 4160192052) =3D 3 0.250 ( 0.008 ms): a.out/447296 close(fd: 3) = =3D 1436 0.260 ( 0.018 ms): a.out/447296 stat(filename: "", statbuf: 0xffce32ac= ) =3D 1436 0.288 (1000.213 ms): a.out/447296 readlinkat(buf: 0xffce31d4, bufsiz: = 4291703244) =3D 0 ``` After: ``` ? ( ): a.out/442930 ... [continued]: execve()) = =3D 0 0.023 ( 0.002 ms): a.out/442930 brk() = =3D 0x57760000 0.052 ( 0.003 ms): a.out/442930 access(filename: 0xf7f5af28, mode: R) = =3D -1 ENOENT (No such file or directory) 0.059 ( 0.009 ms): a.out/442930 openat(dfd: CWD, filename: "/etc/ld.so= .cache", flags: RDONLY|CLOEXEC|LARGEFILE) =3D 3 0.078 ( 0.001 ms): a.out/442930 close(fd: 3) = =3D 0 0.087 ( 0.007 ms): a.out/442930 openat(dfd: CWD, filename: "/lib/i386-= linux-", flags: RDONLY|CLOEXEC|LARGEFILE) =3D 3 0.095 ( 0.002 ms): a.out/442930 read(fd: 3, buf: = 0xffbdbb70, count: 512) =3D 512 0.135 ( 0.001 ms): a.out/442930 close(fd: 3) = =3D 0 0.148 ( 0.001 ms): a.out/442930 set_tid_address(tidptr: 0xf7f2b528) = =3D 442930 (a.out) 0.150 ( 0.001 ms): a.out/442930 set_robust_list(head: 0xf7f2b52c, len:= 12) =3D 0.196 ( 0.004 ms): a.out/442930 mprotect(start: 0xf7f03000, len: 8192,= prot: READ) =3D 0 0.202 ( 0.002 ms): a.out/442930 mprotect(start: 0x5658e000, len: 4096,= prot: READ) =3D 0 0.207 ( 0.002 ms): a.out/442930 mprotect(start: 0xf7f63000, len: 8192,= prot: READ) =3D 0 0.230 ( 0.005 ms): a.out/442930 munmap(addr: 0xf7f10000, len: 103414) = =3D 0 0.244 ( 0.010 ms): a.out/442930 openat(dfd: CWD, filename: 0x5658d008)= =3D 3 0.255 ( 0.007 ms): a.out/442930 read(fd: 3, buf: = 0xffbdb67c, count: 4096) =3D 1436 0.264 ( 0.018 ms): a.out/442930 write(fd: 1, buf: , count:= 1436) =3D 1436 0.292 (1000.173 ms): a.out/442930 clock_nanosleep(rqtp: { .tv_sec: 178= 66546940376776704, .tv_nsec: 4159878336 }, rmtp: 0xffbdb59c) =3D 0 1000.478 ( ): a.out/442930 exit_group() = =3D ? ``` Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- 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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 3A81E2163AA for ; Wed, 19 Feb 2025 18:57:26 +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=1739991449; cv=none; b=ADxFJc8je/44m98lj2B2ykjIpDmJtIvVuzNu7wH8X+9aFJ2diui9Rt1T8VxBu7zB/BtswKNWgwgj2L/n6EfwChw0zOk61bdLNOoFg7IbLbJO720NhRE8Ru3c590wEQyHds+LAZPFDbJQ10+dho9lKTNEmWfQ/EYsunkaXiz5uOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991449; c=relaxed/simple; bh=2XluTa3KtSGNFLWc8xuwQ16X0LAV9Zuu3yyIDpc0mNY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=O75RA1JJXWBk6NOQ++KP+Hta8uXf1oMMAL/HhmsgU6Z6HSa6KgcaBqe1LYhSeVbbRbRxY5kmVNNbwfRfU4hqgJR5qmVnfF6ttjC4cZsg21CYwV7Gcozz3n0bnnFYNGYyV3PFQMuNU7b/WiAQprziHioCnoHw+jUCdAQpaifaUmU= 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=BCwetQc/; 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="BCwetQc/" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e54cb50c3baso285124276.0 for ; Wed, 19 Feb 2025 10:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991445; x=1740596245; 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=qwnDsjncPSxJCvmfKlXJnCe/CpsM2WyTDG1AtNxJY0I=; b=BCwetQc/LGgEHhFglZD/a9uY1fYAkKbofiMyApzj55O0hu6CPXtvnJIL2uXySxBBUi KMIR0NdHa3CibC6OSzBPLmInm3ZAp5GUGScrvLyk5P7Y5XG6vlyraeisi4PWG1lyGBBc OK6FT5OlMLTH7AcbjyBArhqh+CblT8ZM6rzqT2muI3yvKmBAdRU7tJVcvXRZ+avcrEEw Xubva4NIIx/nM7BrTeloC+KZeLU64w9kvoKZA0ZJ3vLEfrogV0IQ1Mhjgx9Yp6RosTDy +h8ZDzmTMXJVAQdMyUvT0QYMlQdvBwKQI81fyklCq6W+/p3JJwCbOIgD2V9nVnTElzoI yVIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991445; x=1740596245; 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=qwnDsjncPSxJCvmfKlXJnCe/CpsM2WyTDG1AtNxJY0I=; b=V46rPc1PlQQgU0HCfVHQ2aDO4QAU4Z0GI2QvqW2d6M9m2boFBE1eCUUiv+dzMxTtdY Ik4xI+whefJMlEcAZAbIcnGJg+OUnKYfZPOV2/oRu3tVFEoWVT4x3uouRrIJORkOFG5T aihWiriRZFx4WnUTJRJ/xSWTljr0er3fgQJVV3uA6YuF5Zxvw1eoi2X8OIVi1iXUQyEJ SALiheh/oN74GIcOSUdp+IS9RSqQ5G13w2smdwQkugWzWZ3Dq4JkMyhXFRzDBKj5xkjk lFNJKAP/FrW6E38tE5947CGinceohp3iaQD0yRwSpySwL/lB/tkay5VAVg8H8PakbKAd bC/A== X-Forwarded-Encrypted: i=1; AJvYcCWBzdeOiXQXLkx7h++uuiU6qcB8sh/Lt20KrgEfUpoYDIZxuQop0VMpbUoVhg9P6yrTQi8GBrzgmo/XPIY=@vger.kernel.org X-Gm-Message-State: AOJu0YwQoP/ei0r6zcmuK67CmQJqVnQSdq73GwIuUPc/uFUzQ8t++vQE AJFPHkgPn0SMAw8aGfDydd9DdTRgzR2zhModg4VtawdUQBShHZ/g05Zp+NWQPF5qGODd9nqI9fR YGowM3w== X-Google-Smtp-Source: AGHT+IH12AI6JralxaE2bnZolvYPhIJnFHEOOP/4KX84YLRfTlRwQy6tG5H2k3UIp06Yc8vW3+WtnDWhk7Ag X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a5b:1d1:0:b0:e5e:1496:7371 with SMTP id 3f1490d57ef6-e5e18ffbb32mr9390276.0.1739991445199; Wed, 19 Feb 2025 10:57:25 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:56 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-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: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 7/8] perf build: Remove Makefile.syscalls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now a single beauty file is generated and used by all architectures, remove the per-architecture Makefiles, Kbuild files and previous generator script. Note: there was conversation with Charlie Jenkins and they'd written an alternate approach to support multiple architectures: https://lore.kernel.org/all/20250114-perf_syscall_arch_runtime-v1-1-5b304e4= 08e11@rivosinc.com/ It would have been better to have helped Charlie fix their series (my apologies) but they agreed that the approach taken here was likely best for longer term maintainability: https://lore.kernel.org/lkml/Z6Jk_UN9i69QGqUj@ghost/ Signed-off-by: Ian Rogers Reviewed-by: Howard Chu Reviewed-by: Charlie Jenkins --- 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.601.g30ceb7b040-goog From nobody Thu Dec 18 23:23:18 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 A7F9521507D for ; Wed, 19 Feb 2025 18:57:28 +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=1739991450; cv=none; b=HOET35NSzhpySwrHK2RLHlKm8C1NjEOPNjSPMtlk2ySD3szQhK7V4pbwFsLAcePf246gu9BbPV7zveUQoOyDaPjIH8CcXt3TlzV0rOzgziJU/SPClqqyRHuKqs4GOcStEMHyzUvo4r357N9aw2rNLpwYzknUDcFSo+PrrIOj4TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991450; c=relaxed/simple; bh=ly9ScmKJMVA6q31ptFJQo64X6QGUOGrxOWC9a86NvwQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=gcf7azL3qgRjFckDQ7K2xYXPC2Ag7ZRA/MpMd0MRkwbEixaww0c7U98tOV9MGlmnAvOXtbckPY9fdp47vuerNJPVpmswWuxxlxPTdkAx64FwU61ZNmcWno+cvE2svZ68RygR40G+HVMLMJX4m42rE5phTojZuaLnVNJh1pLqz98= 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=DFLC7nez; 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="DFLC7nez" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f6f2db824bso802597b3.3 for ; Wed, 19 Feb 2025 10:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739991447; x=1740596247; 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=XIzMGizCa0TqJAjUgJqlPFZGjy2pOOpFJSWoUD2uhWM=; b=DFLC7nezGn3GhKf2LE07CrPcbk/Qa4uZRlXc/n8BPlTjTU29o4qEzeQhbDiIdARZ1q 67+BYUmsWl+OTs1k+GP8N5h4FYmYr67xiPJPd8kWiybPwun8aJVmWPu2cPB8eZ7xQ7ur gWsFkD6d/HZCbup1AeLSXOi5zBuvXWUJnBp2edyW5Xr3kwnTHG0G800xPts8yCJ1RKj6 gKfKXaFnXspTNV6bgHyGx8w3epIFcFylmu+SmyyBNt2e8HLBUkJOA6hVfMDmFYsgKA6e 7OaXoFroUWGtRGI/fYceCxKDuaoASj6WOUiCMdokfDER3kp2EtatIN4lzdwOrTes7wI9 6niQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739991447; x=1740596247; 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=XIzMGizCa0TqJAjUgJqlPFZGjy2pOOpFJSWoUD2uhWM=; b=qj9Yw0hsBIqTA2jImqwc+S0hnOgZuRRPgMG9++WJ1NJPM2s1x8d+7e+hWqCHko969B i70RcBUKf77/cxIXAvQ5AI6gGgYeJfOkzsDXO85c0Ljurvpavz+ZN0uPhJQ+iWyhSFki yoC+CazNlomdHlN4cI4g4VJDVh0rdFu9BDbhcxH7q5ecrQzMl42JY21rgSWQt2uX3iA6 VeeDhjBRNhHRAOGEwXUCMUlifss8fyCHUksSvORymqptCcqaQiLTkQYnxd4dJXhuk8Ds hN2KAd7VQCSSvOa5PXfKvgHTwpjkq3x7b1cvTRXcFUWhGyxw111cVyu/gZBrz6n4PWaI 6Eyw== X-Forwarded-Encrypted: i=1; AJvYcCXSwns0qtnrg2F5WeSEpv4dFYbQrHPTgbVxOoAvYFGtqu9W+agdT2kEWlBn7wijzaf959F2APkpEGHPzAw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1waF0WlM6kpo7C52FBDHr0jOf/E9gZsx78k44LMndP2RZXE6f 4xW8TKMAu6RjmQ5lTcSUqI6ygmB0h9l/TSRuOliaRG+Q0/pQR2H2ArH3HpJ8ENDzKMV7864/3eT eihBhzw== X-Google-Smtp-Source: AGHT+IHBIqCbWM4vcI984nDuEzZSczl9Bby3fcXaZ7gK0bV5Lnp/HxnIbC0vqnoo+ZtzSlf5EYQ7UBrYNZ0b X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:c57b:86f0:c166:3061]) (user=irogers job=sendgmr) by 2002:a05:690c:2f81:b0:6ea:ecc3:ec61 with SMTP id 00721157ae682-6fb582571c3mr2102467b3.1.1739991447284; Wed, 19 Feb 2025 10:57:27 -0800 (PST) Date: Wed, 19 Feb 2025 10:56:57 -0800 In-Reply-To: <20250219185657.280286-1-irogers@google.com> Message-Id: <20250219185657.280286-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250219185657.280286-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Subject: [PATCH v3 8/8] perf syscalltbl: Mask off ABI type for MIPS system calls From: Ian Rogers To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , guoren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Bibo Mao , Huacai Chen , Catalin Marinas , Jiri Slaby , "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , Howard Chu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Arnd Bergmann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Arnd Bergmann described that MIPS system calls don't necessarily start from 0 as an ABI prefix is applied: https://lore.kernel.org/lkml/8ed7dfb2-1e4d-4aa4-a04b-0397a89365d1@app.fastm= ail.com/ When decoding the "id" (aka system call number) for MIPS ignore values greater-than 1000. Signed-off-by: Ian Rogers --- tools/perf/util/syscalltbl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c index db0d2b81aed1..ace66e69c1bc 100644 --- a/tools/perf/util/syscalltbl.c +++ b/tools/perf/util/syscalltbl.c @@ -46,6 +46,14 @@ const char *syscalltbl__name(int e_machine, int id) { const struct syscalltbl *table =3D find_table(e_machine); =20 + if (e_machine =3D=3D EM_MIPS && id > 1000) { + /* + * MIPS may encode the N32/64/O32 type in the high part of + * syscall number. Mask this off if present. See the values of + * __NR_N32_Linux, __NR_64_Linux, __NR_O32_Linux and __NR_Linux. + */ + id =3D id % 1000; + } if (table && id >=3D 0 && id < table->num_to_name_len) return table->num_to_name[id]; return NULL; --=20 2.48.1.601.g30ceb7b040-goog