NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/50638: Extreme slowness on loading gzipped kernels on oldCPUs



The following reply was made to PR bin/50638; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%britannica.bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/50638: Extreme slowness on loading gzipped kernels on oldCPUs
Date: Mon, 11 Jan 2016 19:58:44 +0100

 --zhXaljGHf11kAtnf
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Mon, Jan 11, 2016 at 11:40:01AM +0000, Manuel Bouyer wrote:
 > The following reply was made to PR bin/50638; it has been noted by GNATS.
 > 
 > From: Manuel Bouyer <bouyer%antioche.eu.org@localhost>
 > To: gnats-bugs%NetBSD.org@localhost
 > Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, tsutsui%ceres.dti.ne.jp@localhost
 > Subject: Re: bin/50638: Extreme slowness on loading gzipped kernels on oldCPUs
 > Date: Mon, 11 Jan 2016 12:36:11 +0100
 > 
 >  On Mon, Jan 11, 2016 at 10:50:01AM +0000, Izumi Tsutsui wrote:
 >  >  [...]
 >  >  On i386 and amd64, gzipped kernels are not used at all.
 >  
 >  that's not true. I use gzipped kernels and modules for tftp boot
 
 It's even better. The install ISO image uses gzipped kernels and also
 clearly shows that CRC32 verification is done. Ah well, let's not bother
 anymore. Attached is a working patch that needed 2min of work and
 slightly more time to test...
 
 Joerg
 
 --zhXaljGHf11kAtnf
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="cread.c.diff"
 
 Index: cread.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/src/sys/lib/libsa/cread.c,v
 retrieving revision 1.27
 diff -u -p -r1.27 cread.c
 --- cread.c	25 Jul 2015 07:06:11 -0000	1.27
 +++ cread.c	11 Jan 2016 18:55:47 -0000
 @@ -93,26 +93,32 @@ void	zmemcpy(unsigned char *, unsigned c
   * a 4-bit table and at least 8K smaller than the libkern version.
   */
  #ifndef ETHER_CRC_POLY_LE
 -#define ETHER_CRC_POLY_LE	0xedb88320
 +#define ETHER_CRC_POLY_LE	0xedb88320U
  #endif
  uint32_t
 -crc32(uint32_t crc, const uint8_t *const buf, size_t len)
 +crc32(uint32_t crc, const uint8_t *buf, size_t len)
  {
 -	uint32_t c, carry;
 -	size_t i, j;
 +	static volatile int crc_tbl_inited = 0;
 +	static uint32_t crc_tbl[256];
  
 -	crc = 0xffffffffU ^ crc;
 -	for (i = 0; i < len; i++) {
 -		c = buf[i];
 -		for (j = 0; j < 8; j++) {
 -			carry = ((crc & 0x01) ? 1 : 0) ^ (c & 0x01);
 -			crc >>= 1;
 -			c >>= 1;
 -			if (carry) {
 -				crc = (crc ^ ETHER_CRC_POLY_LE);
 +	if (!crc_tbl_inited) {
 +		uint32_t crc2, b, i;
 +		for (b = 0; b < 256; ++b) {
 +			crc2 = b;
 +			for (i = 8; i > 0; --i) {
 +				if (crc2 & 1)
 +					crc2 = (crc2 >> 1) ^ ETHER_CRC_POLY_LE;
 +				else    
 +					crc2 = (crc2 >> 1);
  			}
 +			crc_tbl[b] = crc2;
  		}
 +		crc_tbl_inited = 1;
  	}
 +
 +	crc = crc ^ 0xffffffffU;
 +	while (len--)
 +		crc = crc_tbl[(crc ^ *buf++) & 0xff] ^ (crc >> 8);
  	return (crc ^ 0xffffffffU);
  }
  
 
 --zhXaljGHf11kAtnf--
 


Home | Main Index | Thread Index | Old Index