powerpc: Improve 64bit copy_tofrom_user
authorAnton Blanchard <anton@samba.org>
Wed, 10 Feb 2010 14:56:26 +0000 (14:56 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 17 Feb 2010 03:03:16 +0000 (14:03 +1100)
commit789c299ca280f96368c0296b739e89c0bb232f8a
treec14611126d351e6b69cb2db26afd4fbd77b3763f
parent63e6c5b8102af7df7a5e1cebbd865d711645886a
powerpc: Improve 64bit copy_tofrom_user

Here is a patch from Paul Mackerras that improves the ppc64 copy_tofrom_user.
The loop now does 32 bytes at a time and as well as pairing loads and stores.

A quick test case that reads 8kB over and over shows the improvement:

POWER6: 53% faster
POWER7: 51% faster

#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#define BUFSIZE (8 * 1024)
#define ITERATIONS 10000000

int main()
{
char tmpfile[] = "/tmp/copy_to_user_testXXXXXX";
int fd;
char *buf[BUFSIZE];
unsigned long i;

fd = mkstemp(tmpfile);
if (fd < 0) {
perror("open");
exit(1);
}

if (write(fd, buf, BUFSIZE) != BUFSIZE) {
perror("open");
exit(1);
}

for (i = 0; i < 10000000; i++) {
if (pread(fd, buf, BUFSIZE, 0) != BUFSIZE) {
perror("pread");
exit(1);
}
}

unlink(tmpfile);

return 0;
}

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/lib/copyuser_64.S