Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Nov 2012 00:53:18 -0800
From:      Luigi Rizzo <rizzo@iet.unipi.it>
To:        Andre Oppermann <andre@freebsd.org>
Cc:        Barney Cordoba <barney_cordoba@yahoo.com>, Adrian Chadd <adrian@freebsd.org>, khatfield@socllc.net, "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>, Jim Thompson <jim@netgate.com>, Alfred Perlstein <bright@mu.org>
Subject:   Re: FreeBSD boxes as a 'router'...
Message-ID:  <CA%2BhQ2%2Bh8HHeO7xgjVJ0eZPtoOgYGbn-h3NWRSkYo6X8wh_hTmQ@mail.gmail.com>
In-Reply-To: <50AC92A0.2000406@freebsd.org>
References:  <1353448328.76219.YahooMailClassic@web121602.mail.ne1.yahoo.com> <E1F4816E-676C-4630-9FA1-817F737D007D@netgate.com> <50AC08EC.8070107@mu.org> <832757660.33924.1353460119408@238ae4dab3b4454b88aea4d9f7c372c1.nuevasync.com> <CAJ-Vmok8Ybdi%2BY8ZguMTKC7%2BF5=OxVDog27i4UgY-s3MCZkGcQ@mail.gmail.com> <250266404.35502.1353464214924@238ae4dab3b4454b88aea4d9f7c372c1.nuevasync.com> <50AC8393.3060001@freebsd.org> <CA%2BhQ2%2BiBLi%2B3_GAVBfiTMmiZPnqGRomXYABawPct4n7-Nrq2Ew@mail.gmail.com> <50AC92A0.2000406@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Nov 21, 2012 at 12:36 AM, Andre Oppermann <andre@freebsd.org> wrote:

> On 21.11.2012 09:04, Luigi Rizzo wrote:
>
>> On Tue, Nov 20, 2012 at 11:32 PM, Andre Oppermann <andre@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BhQ2%2Bh8HHeO7xgjVJ0eZPtoOgYGbn-h3NWRSkYo6X8wh_hTmQ>