Re: [PATCH] add likely around access_ok for uaccess

From: Manfred Spraul
Date: Wed Sep 17 2003 - 11:58:24 EST


Pavel Machek wrote:

Hi!



while trying to figure out why sysv msg is around 30% slower than pipes for data transfers I noticed that gcc's autodetection (3.2.2) guesses the "if(access_ok())" tests in uaccess.h wrong and puts the error memset into the direct path and the copy out of line.

The attached patch adds likely to the tests - any objections? What about the archs except i386?


How much speedup did you gain?


How much can it hurt?



The change is obviously okay, I just wanted to know... If it gains 30%
on sysv messages.. that would be pretty big surprise.

No.
I didn't benchmark it at all. I'd expect one or two cycles.
The 30% difference are due to misaligned buffers: The sysvmsg ABI uses
struct msgbuf {
unsigned long type;
char data[];
};
msgbuf was aligned, thus data on an not 8-byte aligned address. Thus the "rep;movsl" microcode fastpath didn't kick in, and that caused the 30-50% slowdown.
After manually misaligning the msgbuf structure, and properly aligning the kernel buffers, the performance of sysvmsg is now identical to pipes: Around 4 k cycles for a one-byte ping-pong, and around 10k cycles for 4 kB ping-pong, with a Celeron mobile 1.13 GHz.

I haven't decided yet if a patch to align the kernel buffers is a good thing or not - it only helps my benchmark, I'm not aware of a real-world app that uses sysvmsg for bulk data transfers.

--
Manfred

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/