This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH 01/23] all: syscall wrappers: add documentation
- From: Yury Norov <ynorov at caviumnetworks dot com>
- To: Catalin Marinas <catalin dot marinas at arm dot com>
- Cc: David Miller <davem at davemloft dot net>, <arnd at arndb dot de>, <linux-arm-kernel at lists dot infradead dot org>, <linux-kernel at vger dot kernel dot org>, <linux-doc at vger dot kernel dot org>, <linux-arch at vger dot kernel dot org>, <linux-s390 at vger dot kernel dot org>, <libc-alpha at sourceware dot org>, <schwidefsky at de dot ibm dot com>, <heiko dot carstens at de dot ibm dot com>, <pinskia at gmail dot com>, <broonie at kernel dot org>, <joseph at codesourcery dot com>, <christoph dot muellner at theobroma-systems dot com>, <bamvor dot zhangjian at huawei dot com>, <szabolcs dot nagy at arm dot com>, <klimov dot linux at gmail dot com>, <Nathan_Lynch at mentor dot com>, <agraf at suse dot de>, <Prasun dot Kapoor at caviumnetworks dot com>, <kilobyte at angband dot pl>, <geert at linux-m68k dot org>, <philipp dot tomsich at theobroma-systems dot com>
- Date: Wed, 15 Jun 2016 02:08:38 +0300
- Subject: Re: [PATCH 01/23] all: syscall wrappers: add documentation
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=Yuri dot Norov at caviumnetworks dot com;
- References: <6293194 dot tGy03QJ9ME at wuerfel> <20160525 dot 135039 dot 244098606649448826 dot davem at davemloft dot net> <6407614 dot fdv5XFSBue at wuerfel> <20160525 dot 142821 dot 1719403997976778673 dot davem at davemloft dot net> <20160526204819 dot GA10274 at yury-N73SV> <20160526222943 dot GA16729 at MBP dot local>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi Catalin, David, all
> COMPAT_SYSCALL_WRAP2(creat, ...):
> mov w0, w0
> b <sys_creat>
> > > Cost wise, this seems like it all cancels out in the end, but what
> > > do I know?
> > I think you know something, and I also think Heiko and other s390 guys
> > know something as well. So I'd like to listen their arguments here.
> > For me spark64 way is looking reasonable only because it's really simple
> > and takes less coding. I'll try it on some branch and share here what happened.
> The kernel code will definitely look simpler ;). It would be good to see
> if there actually is any performance impact. Even with 16 more cycles on
> syscall entry, would they be lost in the noise? You don't need a full
> implementation, just some dummy mov x0, x0 on the entry path.
I wrote a simple test:
struct timeval start, end;
unsigned long long ut;
for (int i = 1000000; i; i--)
syscall(__NR_getrusage, 100 /* EINVAL */, NULL);
ut = (end.tv_sec - start.tv_sec) * 1000000ULL
+ end.tv_usec - start.tv_usec;
In kernel there's minimal overhead:
diff --git a/kernel/sys.c b/kernel/sys.c
index 89d5be4..003d5ad 100644
@@ -1634,6 +1634,17 @@ COMPAT_SYSCALL_DEFINE2(getrusage, int, who,
struct compat_rusage __user *, ru)
struct rusage r;
+ asm volatile (
+ " mov w0, w0 \n"
+ " mov w1, w1 \n"
+ " mov w2, w2 \n"
+ " mov w3, w3 \n"
+ " mov w4, w4 \n"
+ " mov w5, w5 \n"
+ " mov w6, w6 \n"
+ " mov w7, w7 \n"
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN &&
who != RUSAGE_THREAD)
With MOVs: W/O MOVs:
We have 83 mS vs 81 mS, ~2.6% of performance degradation.
And I can show bigger numbers if I'll use asm svc instead of
syscall() wrapper which increases time as well.
It's definitely more than 0, but not so big anyway. For syscalls
with heavy payload it will be non-measurable. So the choice
is still there. Should we use wrappers and save 2.5% of syscall
performance. Or clear top-halves unconditionally and win in simplicity?
If QEMU is looking non-representative, I can run test on real
hardware, but it takes a time, and I think will end up with similar
Latest kernel with wrappers and library are here:
BTW, notice the change in ABI: syscalls that take stat and statfs
structures now routed to (wrapped) native handlers, after switching
userspace to use 64-bit off_t, ino_t, blkcnt_t, fsblkcnt_t and