From owner-cvs-sys Sun Feb 16 14:58:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA03455 for cvs-sys-outgoing; Sun, 16 Feb 1997 14:58:04 -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 OAA03444; Sun, 16 Feb 1997 14:57:55 -0800 (PST) Received: by sovcom.kiae.su id AA18982 (5.65.kiae-1 ); Mon, 17 Feb 1997 01:38:35 +0300 Received: by sovcom.KIAE.su (UUMAIL/2.0); Mon, 17 Feb 97 01:38:35 +0300 Received: (from ache@localhost) by nagual.ru (8.8.5/8.8.5) id BAA00738; Mon, 17 Feb 1997 01:37:40 +0300 (MSK) Date: Mon, 17 Feb 1997 01:37:35 +0300 (MSK) From: =?KOI8-R?B?4c7E0sXKIP7F0s7P1w==?= To: Bruce Evans Cc: peter@spinner.dialix.com, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org, mpp@freefall.freebsd.org Subject: Re: cvs commit: src/sys/sys types.h In-Reply-To: <199702161404.BAA20251@godzilla.zeta.org.au> 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 Mon, 17 Feb 1997, Bruce Evans wrote: > >+ #define FD_ROUNDSIZE 256 > >+ > > Change to something like (2048 / 6) = 341. Now that's an odd size :-). I change it (see update patch below) but still not understand why 2048 is here. p_selbits_size increasing constant will be 44 in this case, is it good value for you too? > Don't use this except possibly for very large ni together with unusual > combinations of fds. Put 3 contiguous copyout buffers first (readfds, > writefds, exexptfds), then 3 copyin buffers, and bzero 1*ni, 2*ni or > 3*ni bits as necessary (exceptfds is usually NULL so the bzero doesn't > need to cover it). The old code got this wrong mainly by spacing the > buffers with separation p->p_selbits_size instead of ni. I try to implement what you say, see the patch below: *** sys_generic.c.orig Tue Jan 14 23:11:28 1997 --- sys_generic.c Mon Feb 17 01:33:11 1997 *************** *** 508,513 **** --- 508,515 ---- return (error); } + #define FD_ROUNDSIZE (2048 / (3 + 3)) + 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,571 **** 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); } - for (i = 0; i < 3; i++) { - ibits[i] = (fd_mask *)(p->p_selbits + i * p->p_selbits_size); - obits[i] = (fd_mask *)(p->p_selbits + (i + 3) * - 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 && \ --- 549,579 ---- 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); } /* The amount of space we need to copyin/copyout */ ni = howmany(uap->nd, NFDBITS) * sizeof(fd_mask); + + for (i = 0; i < 3; i++) { + obits[i] = (fd_mask *)(p->p_selbits + i * ni); + ibits[i] = (fd_mask *)(p->p_selbits + (i + 3) * ni); + } + if (uap->ex) + i = 3; + else if (uap->ou) + i = 2; + else if (uap->in) + i = 1; + else + i = 0; + if (i) + bzero(p->p_selbits, i * ni); #define getbits(name, x) \ if (uap->name && \ -- Andrey A. Chernov http://www.nagual.ru/~ache/