linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hp@axis.com>
To: <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Cc: John Garry <john.garry@huawei.com>, Will Deacon <will@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Leo Yan <leo.yan@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Kim Phillips <kim.phillips@arm.com>
Subject: [PATCH] perf arm64: Simplify mksyscalltbl
Date: Mon, 28 Dec 2020 03:41:59 +0100	[thread overview]
Message-ID: <20201228024159.2BB66203B5@pchp3.se.axis.com> (raw)

This patch isn't intended to have any effect on the compiled
code.  It just removes one level of indirection: calling the
*host* compiler to build and then run a program that just
printf:s the numerical entries of the syscall-table.  In other
words, the generated syscalls.c changes from:
	[46] = "ftruncate",
to:
	[__NR3264_ftruncate] = "ftruncate",
The latter is as good as the former to the user of perf, and
this can be done directly by the shell-script.  The syscalls
defined as non-literal values (like "#define __NR_ftruncate
__NR3264_ftruncate") are trivially resolved at compile-time
without namespace-leaking and/or collision for its sole user,
perf/util/syscalltbl.c, that just #includes the generated file.
A future "-mabi=32" support would probably have to handle this
differently, but that is a pre-existing problem not affected by
this simplification.

Calling the *host* compiler only complicates things and
accidentally can get a completely wrong set of files and syscall
numbers, see earlier commits.  Note that the script parameter
hostcc is now unused.

At the time of this patch, powerpc (the origin, see comments),
and also e.g. x86 has moved on, from filtering "gcc -dM -E"
output to reading separate specific text-file, a table of
syscall numbers.  IMHO should arm64 consider adopting this.

Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Kim Phillips <kim.phillips@arm.com>
---
 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
index a7ca48d1e37b..22cdf911dd9a 100755
--- a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
@@ -23,34 +23,17 @@ create_table_from_c()
 {
 	local sc nr last_sc
 
-	create_table_exe=`mktemp ${TMPDIR:-/tmp}/create-table-XXXXXX`
-
-	{
-
-	cat <<-_EoHEADER
-		#include <stdio.h>
-		#include "$input"
-		int main(int argc, char *argv[])
-		{
-	_EoHEADER
-
 	while read sc nr; do
-		printf "%s\n" "	printf(\"\\t[%d] = \\\"$sc\\\",\\n\", __NR_$sc);"
+		printf "%s\n" "	[$nr] = \"$sc\","
 		last_sc=$sc
 	done
 
-	printf "%s\n" "	printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
-	printf "}\n"
-
-	} | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
-
-	$create_table_exe
-
-	rm -f $create_table_exe
+	printf "%s\n" "#define SYSCALLTBL_ARM64_MAX_ID __NR_$last_sc"
 }
 
 create_table()
 {
+	echo "#include \"$input\""
 	echo "static const char *syscalltbl_arm64[] = {"
 	create_table_from_c
 	echo "};"
-- 
2.11.0

brgds, H-P

             reply	other threads:[~2020-12-28  2:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-28  2:41 Hans-Peter Nilsson [this message]
2021-01-05 10:47 ` [PATCH] perf arm64: Simplify mksyscalltbl Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201228024159.2BB66203B5@pchp3.se.axis.com \
    --to=hp@axis.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=kim.phillips@arm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).