Checksum/copy

Bruce Evans bde at zeta.org.au
Sat Mar 29 05:27:46 PST 2003


On Sat, 29 Mar 2003, Dag-Erling [iso-8859-1] Sm=F8rgrav 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
% =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% RCS file: /home/ncvs/src/sys/sys/systm.h,v
% retrieving revision 1.191
% diff -u -r1.191 systm.h
% --- sys/sys/systm.h=0924 Mar 2003 21:15:35 -0000=091.191
% +++ sys/sys/systm.h=0929 Mar 2003 12:10:28 -0000
% @@ -171,12 +171,9 @@
%
%  void=09bcopy(const void *from, void *to, size_t len);
%  void=09ovbcopy(const void *from, void *to, size_t len);
% -
% -#ifdef __i386__
% -extern void=09(*bzero)(void *buf, size_t len);
% -#else
%  void=09bzero(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=09pagecopy(const void *from, void *to);
% +void=09pagezero(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=09*memcpy(void *to, const void *from, size_t len);

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

% Index: sys/i386/i386/pmap.c
% =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% 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=0925 Mar 2003 00:07:02 -0000=091.398
% +++ sys/i386/i386/pmap.c=0929 Mar 2003 11:59:36 -0000
% ...
% @@ -2789,12 +2784,7 @@
%  #endif
%  =09invlpg((u_int)CADDR2);
%  #endif
% -#if defined(I686_CPU)
% -=09if (cpu_class =3D=3D CPUCLASS_686 && off =3D=3D 0 && size =3D=3D PAGE=
_SIZE)
   =09                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
% -=09=09i686_pagezero(CADDR2);
% -=09else
% -#endif
% -=09=09bzero((char *)CADDR2 + off, size);
% +=09pagezero(CADDR2);

See above about this bug.

% Index: sys/i386/i386/support.s
% =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% 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=0922 Sep 2002 04:45:20 -0000=091.93
% +++ sys/i386/i386/support.s=0929 Mar 2003 12:08:54 -0000
% @@ -48,9 +48,15 @@
%  =09.globl=09bcopy_vector
%  bcopy_vector:
%  =09.long=09generic_bcopy
% -=09.globl=09bzero
% -bzero:
% +=09.globl=09bzero_vector
% +bzero_vector:
%  =09.long=09generic_bzero
% +=09.globl=09pagecopy_vector
% +pagecopy_vector:
% +=09.long=09generic_pagecopy
% +=09.globl=09pagezero_vector
% +pagezero_vector:
% +=09.long=09generic_pagezero
%  =09.globl=09copyin_vector
%  copyin_vector:
%  =09.long=09generic_copyin

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

% Index: sys/i386/include/md_var.h
% =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% 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=0925 Mar 2003 00:07:03 -0000=091.60
% +++ sys/i386/include/md_var.h=0929 Mar 2003 12:11:08 -0000
% @@ -36,12 +36,17 @@
%   * Miscellaneous machine-dependent declarations.
%   */
%
% +extern void=09(*bcopy_vector)(const void *from, void *to, size_t len);
% +extern=09void=09(*ovbcopy_vector)(const void *from, void *to, size_t len=
);
% +extern void=09(*bzero_vector)(void *buf, size_t len);
% +extern void=09(*pagecopy_vector)(const void *from, void *to);
% +extern void=09(*pagezero_vector)(void *buf);
% +extern=09int=09(*copyin_vector)(const void *udaddr, void *kaddr, size_t =
len);
% +extern=09int=09(*copyout_vector)(const void *kaddr, void *udaddr, size_t=
 len);

This file was mostly sorted and consistently formatted.

Bruce


More information about the cvs-src mailing list