Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Mar 2003 00:27:29 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= <des@ofug.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: Checksum/copy
Message-ID:  <20030329235643.H11074@gamplex.bde.org>
In-Reply-To: <xzp3cl61hxs.fsf@flood.ping.uio.no>
References:  <Pine.BSF.4.21.0303260956250.27748-100000@root.org> <20030327232742.GA80113@wantadilla.lemis.com> <20030328073513.GA20464@cirb503493.alcatel.com.au> <xzp3cl61hxs.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sat, 29 Mar 2003, Dag-Erling [iso-8859-1] Smørgrav wrote:

> 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.

I'm sorry I started this.  My original reply was about why even larger
micro-optimizations are dubious.

> (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

Er, they can't be identical.  pmap_zero_page_area() handles partial
pages.  i686_pagezero() was only used for the special case where the
partial page is actually the whole page.

> 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.

There is very little wrong with its order.

% 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

The microoptimization of making bzero a function pointer wasn't such a
good idea.  The main problem with undoing it is that this breaks binary
compatibility.

% +void	pagecopy(const void *from, void *to);
% +void	pagezero(void *buf);

I'd prefer not to have more interfaces to combinatorially explode.
The versions of these in the patch are only generic, so using these
interfaces instead of bcopy() and bzero() bypasses non-generic
versions of the latter.

%
%  void	*memcpy(void *to, const void *from, size_t len);

The declarations of page*() are disordered ('p' > 'm').

% 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
% ...
% @@ -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);

See above about this bug.

% 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

The definitions of page*() are disordered ('p' > 'c').

% 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);

This file was mostly sorted and consistently formatted.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030329235643.H11074>