From owner-cvs-all@FreeBSD.ORG Sat Mar 29 04:22:13 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22C2B37B401; Sat, 29 Mar 2003 04:22:13 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id A900143FA3; Sat, 29 Mar 2003 04:22:09 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 1DAFA5308; Sat, 29 Mar 2003 13:22:08 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Peter Jeremy From: des@ofug.org (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Sat, 29 Mar 2003 13:22:07 +0100 In-Reply-To: <20030328073513.GA20464@cirb503493.alcatel.com.au> (Peter Jeremy's message of "Fri, 28 Mar 2003 18:35:14 +1100") Message-ID: User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: <20030327180247.D1825@gamplex.bde.org> <20030327232742.GA80113@wantadilla.lemis.com> <20030328161552.L5953@gamplex.bde.org> <20030328073513.GA20464@cirb503493.alcatel.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" cc: src-committers@freebsd.org cc: Bruce Evans cc: Nate Lawson cc: Greg 'groggy' Lehey cc: cvs-src@freebsd.org cc: Mike Silbersack cc: cvs-all@freebsd.org Subject: Re: Checksum/copy X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Mar 2003 12:22:16 -0000 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Peter Jeremy writes: > Finally, how many different bcopy/bzero variants to we want? A > "page-size" variant has the advantage of not having to worry about > alignment or remaining-bytes issues but doubles the number of > bzero/bcopy variants we need to maintain. Likewise, different > variants optimised for different feature sets of different CPUs > in different families could very rapidly get out of hand. I've attached an untested patch that sets up the infrastructure for processor-specific pagezero() and pagecopy() on i386. At the very least, it helps avoid some of the #ifdef spaghetti in pmap.c, and it should also result in a slight speedup for page zeroing and copying. (the patch builds, but I haven't booted it) Note that this patch makes pmap_zero_page_area() identical to pmap_zero_page() on i386 - this was already the case for i686-class CPUs since they use i686_pagezero() for pmap_zero_page_area(). This could turn out to be a pessimization on older CPUs with smaller amounts of cache, but I don't think pmap_zero_page_area() is used a lot, so it's probably not noticeable. On a different note, support.s is a bloody mess. Once the dust has settled, I'd like to go through it and reorder its contents a little. DES --=20 Dag-Erling Sm=F8rgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=page.diff Index: sys/sys/systm.h =================================================================== RCS file: /home/ncvs/src/sys/sys/systm.h,v retrieving revision 1.191 diff -u -r1.191 systm.h --- sys/sys/systm.h 24 Mar 2003 21:15:35 -0000 1.191 +++ sys/sys/systm.h 29 Mar 2003 12:10:28 -0000 @@ -171,12 +171,9 @@ void bcopy(const void *from, void *to, size_t len); void ovbcopy(const void *from, void *to, size_t len); - -#ifdef __i386__ -extern void (*bzero)(void *buf, size_t len); -#else void bzero(void *buf, size_t len); -#endif +void pagecopy(const void *from, void *to); +void pagezero(void *buf); void *memcpy(void *to, const void *from, size_t len); Index: sys/vm/vm_zeroidle.c =================================================================== RCS file: /home/ncvs/src/sys/vm/vm_zeroidle.c,v retrieving revision 1.18 diff -u -r1.18 vm_zeroidle.c --- sys/vm/vm_zeroidle.c 12 Oct 2002 05:32:24 -0000 1.18 +++ sys/vm/vm_zeroidle.c 29 Mar 2003 11:15:28 -0000 @@ -143,10 +143,10 @@ } } -static struct proc *pagezero; +static struct proc *pagezero_proc; static struct kproc_desc pagezero_kp = { "pagezero", vm_pagezero, - &pagezero + &pagezero_proc }; SYSINIT(pagezero, SI_SUB_KTHREAD_VM, SI_ORDER_ANY, kproc_start, &pagezero_kp) Index: sys/i386/i386/identcpu.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/identcpu.c,v retrieving revision 1.119 diff -u -r1.119 identcpu.c --- sys/i386/i386/identcpu.c 18 Mar 2003 08:45:22 -0000 1.119 +++ sys/i386/i386/identcpu.c 29 Mar 2003 12:07:25 -0000 @@ -563,7 +563,7 @@ #if defined(I486_CPU) case CPUCLASS_486: printf("486"); - bzero = i486_bzero; + bzero_vector = i486_bzero; break; #endif #if defined(I586_CPU) @@ -580,6 +580,7 @@ (intmax_t)(tsc_freq + 4999) / 1000000, (u_int)((tsc_freq + 4999) / 10000) % 100); printf("686"); + pagezero_vector = i686_pagezero; break; #endif default: Index: sys/i386/i386/pmap.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/pmap.c,v retrieving revision 1.398 diff -u -r1.398 pmap.c --- sys/i386/i386/pmap.c 25 Mar 2003 00:07:02 -0000 1.398 +++ sys/i386/i386/pmap.c 29 Mar 2003 11:59:36 -0000 @@ -2754,12 +2754,7 @@ #endif invlpg((u_int)CADDR2); #endif -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686) - i686_pagezero(CADDR2); - else -#endif - bzero(CADDR2, PAGE_SIZE); + pagezero(CADDR2); #ifdef SMP curthread->td_switchin = NULL; #endif @@ -2789,12 +2784,7 @@ #endif invlpg((u_int)CADDR2); #endif -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) - i686_pagezero(CADDR2); - else -#endif - bzero((char *)CADDR2 + off, size); + pagezero(CADDR2); #ifdef SMP curthread->td_switchin = NULL; #endif @@ -2823,12 +2813,7 @@ #endif invlpg((u_int)CADDR3); #endif -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686) - i686_pagezero(CADDR3); - else -#endif - bzero(CADDR3, PAGE_SIZE); + pagezero(CADDR3); #ifdef SMP curthread->td_switchin = NULL; #endif @@ -2861,7 +2846,7 @@ invlpg((u_int)CADDR1); invlpg((u_int)CADDR2); #endif - bcopy(CADDR1, CADDR2, PAGE_SIZE); + pagecopy(CADDR1, CADDR2); #ifdef SMP curthread->td_switchin = NULL; #endif Index: sys/i386/i386/support.s =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/support.s,v retrieving revision 1.93 diff -u -r1.93 support.s --- sys/i386/i386/support.s 22 Sep 2002 04:45:20 -0000 1.93 +++ sys/i386/i386/support.s 29 Mar 2003 12:08:54 -0000 @@ -48,9 +48,15 @@ .globl bcopy_vector bcopy_vector: .long generic_bcopy - .globl bzero -bzero: + .globl bzero_vector +bzero_vector: .long generic_bzero + .globl pagecopy_vector +pagecopy_vector: + .long generic_pagecopy + .globl pagezero_vector +pagezero_vector: + .long generic_pagezero .globl copyin_vector copyin_vector: .long generic_copyin @@ -73,6 +79,10 @@ * void bzero(void *buf, u_int len) */ +ENTRY(bzero) + MEXITCOUNT + jmp *bzero_vector + ENTRY(generic_bzero) pushl %edi movl 8(%esp),%edi @@ -349,6 +359,39 @@ ret #endif /* I586_CPU && defined(DEV_NPX) */ +ENTRY(pagecopy) + MEXITCOUNT + jmp *pagecopy_vector + +ENTRY(generic_pagecopy) + pushl %esi + pushl %edi + movl 8(%esp),%esi + movl 12(%esp),%edi + movl $1024,%ecx + xorl %eax,%eax + cld + rep + movsl + popl %edi + popl %esi + ret + +ENTRY(pagezero) + MEXITCOUNT + jmp *pagezero_vector + +ENTRY(generic_pagezero) + pushl %edi + movl 8(%esp),%edi + movl $1024,%ecx + xorl %eax,%eax + cld + rep + stosl + popl %edi + ret + ENTRY(i686_pagezero) pushl %edi pushl %ebx @@ -361,7 +404,7 @@ 1: xorl %eax, %eax repe - scasl + scasl jnz 2f popl %ebx Index: sys/i386/include/md_var.h =================================================================== RCS file: /home/ncvs/src/sys/i386/include/md_var.h,v retrieving revision 1.60 diff -u -r1.60 md_var.h --- sys/i386/include/md_var.h 25 Mar 2003 00:07:03 -0000 1.60 +++ sys/i386/include/md_var.h 29 Mar 2003 12:11:08 -0000 @@ -36,12 +36,17 @@ * Miscellaneous machine-dependent declarations. */ +extern void (*bcopy_vector)(const void *from, void *to, size_t len); +extern void (*ovbcopy_vector)(const void *from, void *to, size_t len); +extern void (*bzero_vector)(void *buf, size_t len); +extern void (*pagecopy_vector)(const void *from, void *to); +extern void (*pagezero_vector)(void *buf); +extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len); +extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len); + extern long Maxmem; extern u_int atdevbase; /* offset in virtual memory of ISA io mem */ -extern void (*bcopy_vector)(const void *from, void *to, size_t len); extern int busdma_swi_pending; -extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len); -extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len); extern u_int cpu_exthigh; extern u_int cpu_feature; extern u_int cpu_fxsr; @@ -56,7 +61,6 @@ extern int need_pre_dma_flush; extern int need_post_dma_flush; #endif -extern void (*ovbcopy_vector)(const void *from, void *to, size_t len); extern char sigcode[]; extern int szsigcode; #ifdef COMPAT_FREEBSD4 --=-=-=--