[RFC 0/2] allow to inline generic entry

Sven Schnelle
2023-05-16T13:56:13Z

Hi,

i looked into the syscall performance on s390 with the latest
kernel. For that reason i wrote a small syscall test program,
which just calls getpid() in a loop:

#include <stdio.h>
#include <time.h>
#include <bsd/sys/time.h>
#include <unistd.h>
static const double nsec_per_sec = 1000000000;

int main(int argc, char **argv)
{
struct timespec start, end, res;
double diff;
int i;
(void)argc;
(void)argv;

clock_gettime(CLOCK_REALTIME, &start);
for (i = 0; i < 150000000; i++) {
volatile int a = getpid();
(void)a;
}

clock_gettime(CLOCK_REALTIME, &end);
timespecsub(&end, &start, &res);
diff = ((double)res.tv_sec * nsec_per_sec + (double)res.tv_nsec) / nsec_per_sec;
printf("%f\n", diff);
return 0;
}

Analyzing performance data i see some overhead in the generic entry C
functions, which are not inlined because they are defined in
kernel/entry/common.c. Moving them to include/linux/entry-common.h
gives me the following runtime for the loop above:

with entry common code inlined: 12.8s
not inlined: 13.8s

While i prefer to have C functions in C files instead of header files,
7% performance gain is quite a lot, so i wonder what people think about
moving them to header files. I made this a small patchset for reference,
if there is interest in merging that i'll clean it up and submit it.

Any thoughts?

Sven Schnelle (2):
entry: move the exit path to header files
entry: move the enter path to header files

include/linux/entry-common.h | 305 ++++++++++++++++++++++++++++++++++-
kernel/entry/common.c | 281 --------------------------------
2 files changed, 297 insertions(+), 289 deletions(-)

--
2.39.2