Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Feb 1997 16:04:02 +0300 (MSK)
From:      =?KOI8-R?B?4c7E0sXKIP7F0s7P1w==?= <ache@nagual.ru>
To:        Peter Wemm <peter@spinner.dialix.com>
Cc:        Mike Pritchard <mpp@freefall.freebsd.org>, Bruce Evans <bde@zeta.org.au>, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/sys types.h 
Message-ID:  <Pine.BSF.3.95q.970216152728.392A-100000@nagual.ru>
In-Reply-To: <199702160821.QAA24233@spinner.DIALix.COM>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Feb 1997, Peter Wemm wrote:

> poll... 

Well lets fix select for now and take poll as next step. 

> Also, bzero(6*FD_SETSIZE...) etc can probably be fixed without too much 
> pain for select() if somebody's prepared to get blood on their hands.  The 
> incoming bits do not appear to need to be zeroed (copyin overwrites it 
> with a rounded up to byte boundary and counts the bits that it's scanning 
> in selscan), and only the number of bytes that are going to be copyout'ed 
> need to be zeroed.

I don't understand why rounding is even needed here (maybe to make less
overhead for p_selbits_size increasing?), but we can always
round to 256 boundary by defining FD_ROUNDSIZE=256 in sys_generic.c

> 	if (ni > 8) {	/* 64 bits - arbitary guess at tradeoff */
> 		/*
> 		 * Clear the entire return-to-user buffer space
> 		 */
> 		bzero (p->p_selbits + (i + 3) * p->p_selbits_size,
				      ^^^^^^ just 3	
> 			p->p_selbits_size * 3);

I agree about this one too and include it the patch.

Here is the patch variant for review:

*** sys_generic.c.orig	Tue Jan 14 23:11:28 1997
--- sys_generic.c	Sun Feb 16 16:00:48 1997
***************
*** 508,513 ****
--- 508,515 ----
  	return (error);
  }
  
+ #define FD_ROUNDSIZE 256
+ 
  static int	nselcoll;
  int	selwait;
  
***************
*** 539,545 ****
  		uap->nd = p->p_fd->fd_nfiles;   /* forgiving; slightly wrong */
  
  	/* The amount of space we need to allocate */
! 	ni = howmany(roundup2 (uap->nd, FD_SETSIZE), NFDBITS) *
  		sizeof(fd_mask);
  
  	if (ni > p->p_selbits_size) {
--- 541,547 ----
  		uap->nd = p->p_fd->fd_nfiles;   /* forgiving; slightly wrong */
  
  	/* The amount of space we need to allocate */
! 	ni = howmany(roundup2 (uap->nd, FD_ROUNDSIZE), NFDBITS) *
  		sizeof(fd_mask);
  
  	if (ni > p->p_selbits_size) {
***************
*** 547,553 ****
  			free (p->p_selbits, M_SELECT);
  
  		while (p->p_selbits_size < ni)
! 			p->p_selbits_size += 32; /* Increase by 256 bits */
  
  		p->p_selbits = malloc(p->p_selbits_size * 6, M_SELECT,
  			M_WAITOK);
--- 549,557 ----
  			free (p->p_selbits, M_SELECT);
  
  		while (p->p_selbits_size < ni)
! 			p->p_selbits_size +=
! 				howmany(FD_ROUNDSIZE, NFDBITS) *
! 				sizeof(fd_mask);
  
  		p->p_selbits = malloc(p->p_selbits_size * 6, M_SELECT,
  			M_WAITOK);
***************
*** 558,571 ****
  			p->p_selbits_size);
  	}
  
- 	/*
- 	 * This buffer is usually very small therefore it's probably faster
- 	 * to just zero it, rather than calculate what needs to be zeroed.
- 	 */
- 	bzero (p->p_selbits, p->p_selbits_size * 6);
- 
  	/* The amount of space we need to copyin/copyout */
  	ni = howmany(uap->nd, NFDBITS) * sizeof(fd_mask);
  
  #define	getbits(name, x) \
  	if (uap->name && \
--- 562,580 ----
  			p->p_selbits_size);
  	}
  
  	/* The amount of space we need to copyin/copyout */
  	ni = howmany(uap->nd, NFDBITS) * sizeof(fd_mask);
+ 
+ 	if (ni > 8) {   /* 64 bits - arbitary guess at tradeoff */
+ 		/*
+ 		 * Clear the entire return-to-user buffer space
+ 		 */
+ 		bzero (p->p_selbits + 3 * p->p_selbits_size,
+ 			p->p_selbits_size * 3);
+ 	} else {
+ 		for (i = 0; i < 3; i++)
+ 			bzero(obits[i], ni);
+ 	}
  
  #define	getbits(name, x) \
  	if (uap->name && \



-- 
Andrey A. Chernov
<ache@null.net>
http://www.nagual.ru/~ache/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970216152728.392A-100000>