Date: Mon, 17 Feb 1997 01:04:24 +1100 From: Bruce Evans <bde@zeta.org.au> To: ache@nagual.ru, peter@spinner.dialix.com Cc: bde@zeta.org.au, 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 Message-ID: <199702161404.BAA20251@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>I don't understand why rounding is even needed here (maybe to make less 32-bit rounding is better for bzero, copyout, etc, and doesn't cost more storage. 256-bit rounding avoids slow startup but isn't space-efficient since we're allocating 6 times that. Anyway, I think it would be better to use an auto buffer for small allocations even p_selbits has been allocated. This would have better locality. Most applications wouldn't need a malloced buffer. Half of implementation: fd_mask selbits[6 * OLD_FD_SETSIZE / NFDBITS]; ... ni = bits_to_copyin(); /* multiple of NFDBITS */ if (ni <= OLD_FD_SETSIZE) use_selbits(); else use_malloced_bits(); >*** 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 >+ Change to something like (2048 / 6) = 341. Now that's an odd size :-). >--- 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); >+ } 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. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702161404.BAA20251>