From owner-freebsd-net Thu Nov 29 4:26:40 2001 Delivered-To: freebsd-net@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 66B9A37B43C for ; Thu, 29 Nov 2001 04:26:27 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA01501; Thu, 29 Nov 2001 23:26:16 +1100 Date: Thu, 29 Nov 2001 23:26:20 +1100 (EST) From: Bruce Evans X-X-Sender: To: Luigi Rizzo Cc: Subject: Re: Revised polling code for STABLE In-Reply-To: <20011126115704.L88153@iguana.aciri.org> Message-ID: <20011129222256.W1389-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > On Mon, 26 Nov 2001, Luigi Rizzo wrote: > > > [Bcc to -stable in case someone is interested there] > > > > Attached you can find the latest version of the polling code > > for STABLE (which is useful to make boxes much more robust > > to attacks and have much better responsiveness under [over]load). > > ... > Index: sys/i386/i386/swtch.s > =================================================================== > RCS file: /home/xorpc/u2/freebsd/src/sys/i386/i386/swtch.s,v > retrieving revision 1.89.2.4 > diff -u -r1.89.2.4 swtch.s > --- sys/i386/i386/swtch.s 2001/07/26 02:29:10 1.89.2.4 > +++ sys/i386/i386/swtch.s 2001/10/26 21:54:19 > @@ -246,6 +246,17 @@ > call _procrunnable > testl %eax,%eax > CROSSJUMP(jnz, sw1a, jz) > +#ifdef XORP_ETHER_POLLING > + incl _idle_done > + pushl _poll_burst > + call _ether_poll > + addl $4,%esp > + sti > + nop > + cli > + testl %eax, %eax > + jnz idle_loop > +#endif > call _vm_page_zero_idle > testl %eax, %eax > jnz idle_loop This has some serious bugs: (1) ether_poll() is called with interrupts disabled. This breaks fast interrupt handlers. ether_poll() uses splimp() so it is apparently not intended to run with priority higher than splhigh(). (2) The sti/cli stuff belongs in ether_poll(), and the test of the return code of ether_poll() only works because ether_poll() always returns 1. vm_page_zero_idle() and the hlt instruction are never reached and the system spins calling ether_poll() from idle until a process becomes runnable. ether_poll() needs quite different handling than vm_page_zero_idle() since it can reasonably find something to do whenever an interface is up, while vm_page_zero_idle() soon runs out of things to do if it is called a lot. > Index: sys/kern/kern_clock.c It shouldn't be necessary to touch this file. Everything involving "ether" certainly doesn't belong here. Everything related to periodic polling can be done, probably more efficiently, using schedsoft*() or timeout(). E.g., schedsoftnet() arranges for netisrs to be checked for at the next clock interrupt. But this can now be done almost as well (probably better in -current) using an ordinary timeout. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message