On Wed, Nov 21, 2012 at 12:36 AM, Andre Oppermann <an...@freebsd.org> wrote:
> On 21.11.2012 09:04, Luigi Rizzo wrote: > >> On Tue, Nov 20, 2012 at 11:32 PM, Andre Oppermann <an...@freebsd.org> >> wrote: >> >>> ... >> >> very cool. this seems similar to NAPI. >> > > I've heard about NAPI but haven't looked at it. So I'm not sure how it > have a look at some of the intel nic drivers in linux, they are very similar to the bsd ones so you can easily compare. NAPI is basically the same thing that you describe, there is no special logic and the only kernel support is (i believe) some device independent code that probably you'll end up writing too after the first 2-3 drivers, to avoid boring replications. works internally. In this case no special logic or kernel API support > is required. Every driver can be converted and immediately use it. > > > The only adjustment i'd suggest to your scheme, if possible, is to add >> some control (as it existed in the old polling architecture) to make sure >> that userspace is not starved by the ithreads and other kernel tasks >> (otherwise you can have livelock, as it happens with NAPI). >> I am afraid that simple priorities do not work, you either need some >> kind of fair scheduler, or put some hard limit on the cpu fraction used >> by the kernel tasks when there are userspace processes around. >> > > That's the quantum stuff I talked about. When the ithread has used up > its CPU quantum it gives up the CPU but schedules itself again at the > same time. Also contrary to its name the ithread does not run in > interrupt context but as a normal kernel thread with elevated priority. > it is the elevated priority that worries me, because it has potential to preempt userspace and cause livelock. Again, lacking a proper fair process scheduler, i think the only reliable way is to try and track the (approximate) cpu cycles consumed overall by the various ithreads over, say, the current tick, and once you go above the threshold drop the priority of those threads just above IDLEPRI. Then when the next tick arrives you raise the priorities again. Compared to when i did polling in 2000 (when i wanted to support the i486 soekris), now we can probably assume that a cheap timecounter is available on all architectures (even ARM and MIPS should have some tsc-like thing, right ?) and the cycles used vs cycles per tick can be accounted with a relatively fine grain. cheers luigi _______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"