From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8642 invoked by alias); 14 Sep 2003 17:44:05 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 8626 invoked from network); 14 Sep 2003 17:44:05 -0000 Received: from unknown (HELO mta05-svc.ntlworld.com) (62.253.162.45) by sources.redhat.com with SMTP; 14 Sep 2003 17:44:05 -0000 Received: from kc.cam.armlinux.org ([81.96.69.239]) by mta05-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with ESMTP id <20030914174404.RDU10571.mta05-svc.ntlworld.com@kc.cam.armlinux.org> for ; Sun, 14 Sep 2003 18:44:04 +0100 Received: from localhost ([127.0.0.1]) by kc.cam.armlinux.org with esmtp (Exim 3.36 #1 (Debian)) id 19yauq-0004Q1-00 for ; Sun, 14 Sep 2003 18:44:04 +0100 Subject: arm mmap improvements From: Philip Blundell To: libc-hacker@sources.redhat.com Content-Type: multipart/mixed; boundary="=-SZazfqs6Uty31NVZyndA" Message-Id: <1063561443.16945.6.camel@kc.cam.armlinux.org> Mime-Version: 1.0 Date: Sun, 14 Sep 2003 17:44:00 -0000 X-SW-Source: 2003-09/txt/msg00052.txt.bz2 --=-SZazfqs6Uty31NVZyndA Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 95 This patch contains a couple of performance improvements for mmap() and mmap64() on arm. p. --=-SZazfqs6Uty31NVZyndA Content-Disposition: attachment; filename=mmap.diff Content-Type: text/plain; name=mmap.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 3974 2003-09-14 Philip Blundell * sysdeps/unix/sysv/linux/arm/mmap.S: Use sys_mmap2 if it's known to be available. * sysdeps/unix/sysv/linux/arm/mmap2.S: Optimise code a little. Index: sysdeps/unix/sysv/linux/arm/mmap.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/arm/mmap.S,v retrieving revision 1.5 diff -u -r1.5 mmap.S --- sysdeps/unix/sysv/linux/arm/mmap.S 6 Jul 2001 04:56:13 -0000 1.5 +++ sysdeps/unix/sysv/linux/arm/mmap.S 14 Sep 2003 17:18:27 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,11 +17,47 @@ 02111-1307 USA. */ #include +#include + +#define EINVAL 22 .text ENTRY (__mmap) +# ifdef __ASSUME_MMAP2_SYSCALL + /* This code is actually a couple of cycles slower than the + sys_mmap version below, so it might seem like a loss. But the + code path inside the kernel is sufficiently much shorter to + make it a net gain to use mmap2 when it's known to be + available. */ + + /* shuffle args */ + str r5, [sp, #-4]! + ldr r5, [sp, #8] + str r4, [sp, #-4]! + ldr r4, [sp, #8] + + /* convert offset to pages */ + movs ip, r5, lsl #20 + bne .Linval + mov r5, r5, lsr #12 + + /* do the syscall */ + swi SYS_ify (mmap2) + + /* restore registers */ +2: + ldr r4, [sp], #4 + ldr r5, [sp], #4 + + cmn r0, $4096 + RETINSTR(movcc, pc, lr) + b PLTJMP(syscall_error) +.Linval: + mov r0, #-EINVAL + b 2b +# else /* Because we can only get five args through the syscall interface, and mmap() takes six, we need to build a parameter block and pass its address instead. The 386 port does a similar trick. */ @@ -49,6 +85,7 @@ cmn r0, $4096 RETINSTR(movcc, pc, lr) b PLTJMP(syscall_error); +#endif PSEUDO_END (__mmap) Index: sysdeps/unix/sysv/linux/arm/mmap64.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/arm/mmap64.S,v retrieving revision 1.5 diff -u -r1.5 mmap64.S --- sysdeps/unix/sysv/linux/arm/mmap64.S 27 Mar 2003 02:45:46 -0000 1.5 +++ sysdeps/unix/sysv/linux/arm/mmap64.S 14 Sep 2003 17:18:27 -0000 @@ -27,38 +27,44 @@ .text ENTRY (__mmap64) #ifdef __NR_mmap2 - stmfd sp!, {r4, r5, lr} - ldr r5, [sp, $16] - ldr r4, [sp, $12] - movs ip, r5, lsl $20 @ check that offset is page-aligned + ldr ip, [sp, $4] @ offset low part + str r5, [sp, #-4]! + ldr r5, [sp, $12] @ offset high part + str r4, [sp, #-4]! + movs r4, ip, lsl $20 @ check that offset is page-aligned + mov ip, ip, lsr $12 + moveqs r4, r5, lsr $12 @ check for overflow bne .Linval - ldr ip, [sp, $20] - mov r5, r5, lsr $12 - orr r5, r5, ip, lsl $20 @ compose page offset - movs ip, ip, lsr $12 - bne .Linval @ check for overflow + ldr r4, [sp, $8] @ load fd + orr r5, ip, r5, lsl $20 @ compose page offset mov ip, r0 swi SYS_ify (mmap2) cmn r0, $4096 - LOADREGS(ccfd, sp!, {r4, r5, pc}) # ifdef __ASSUME_MMAP2_SYSCALL - ldmfd sp!, {r4, r5, lr} + ldr r4, [sp], #4 + ldr r5, [sp], #4 + RETINSTR(movcc, pc, lr) b PLTJMP(syscall_error) # else + ldrcc r4, [sp], #4 + ldrcc r5, [sp], #4 + RETINSTR(movcc, pc, lr) cmn r0, $ENOSYS - ldmnefd sp!, {r4, r5, lr} - bne PLTJMP(syscall_error) + bne .Lerror /* The current kernel does not support mmap2. Fall back to plain mmap if the offset is small enough. */ - ldr r5, [sp, $20] + ldr r5, [sp, $16] mov r0, ip @ first arg was clobbered teq r5, $0 - ldmeqfd sp!, {r4, r5, lr} + ldreq r4, [sp], #4 + ldreq r5, [sp], #4 beq PLTJMP(__mmap) # endif .Linval: mov r0, $-EINVAL - ldmfd sp!, {r4, r5, lr} +.Lerror: + ldr r4, [sp], #4 + ldr r5, [sp], #4 b PLTJMP(syscall_error) #else /* The kernel headers do not support mmap2. Fall back to plain --=-SZazfqs6Uty31NVZyndA--