From owner-cvs-sys Sun Feb 16 05:22:59 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id FAA04180 for cvs-sys-outgoing; Sun, 16 Feb 1997 05:22:59 -0800 (PST) Received: from sovcom.kiae.su (sovcom.kiae.su [193.125.152.1]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id FAA04120; Sun, 16 Feb 1997 05:21:05 -0800 (PST) Received: by sovcom.kiae.su id AA13904 (5.65.kiae-1 ); Sun, 16 Feb 1997 16:05:34 +0300 Received: by sovcom.KIAE.su (UUMAIL/2.0); Sun, 16 Feb 97 16:05:33 +0300 Received: (from ache@localhost) by nagual.ru (8.8.5/8.8.5) id QAA00485; Sun, 16 Feb 1997 16:04:07 +0300 (MSK) Date: Sun, 16 Feb 1997 16:04:02 +0300 (MSK) From: =?KOI8-R?B?4c7E0sXKIP7F0s7P1w==?= To: Peter Wemm Cc: Mike Pritchard , Bruce Evans , cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org Subject: Re: cvs commit: src/sys/sys types.h In-Reply-To: <199702160821.QAA24233@spinner.DIALix.COM> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-sys@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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 http://www.nagual.ru/~ache/