Sleep and Wake up

Mulyadi Santosa mulyadi.santosa at gmail.com
Tue May 3 03:10:10 EDT 2011


Hi Abu...

On Tue, May 3, 2011 at 01:32, Abu Rasheda <rcpilot2010 at gmail.com> wrote:
> I am testing my driver on much faster host processor and facing
> following issues:
>
> My host is too powerful and it can fill up device buffer queue very fast.
>
> I get best performance when I do busy wait, but this is not desirable
> and is bad design.

For me, busy waiting could be the best for your case... in fact, NAPI
sometimes do that too....in most cases.

Actually, devices usually fills the in-RAM buffer with the help of
interrupt(s). So whenever in-device buffer has something new, it
interrupts...then soft irq follows up by copying them to RAM buffe
(circular buffer usually). To make it fast, DMA  or other CPU less
operation kicks in here.

So I think that;s the key...by relying on the interrupts...then you
will know when your buffer is about to be full.

Other than that, I would still say, busy waiting could be your best bet.

PS: here's crazy idea, if you can accept it. Put a guard page, right
at the tail of your buffer,. Make it unwritable even by kernel mode.
Right when you hit it, page fault should kicks in. Then you know
buffer is full. This is inspired by the stack guard..usual method in
user space to reduce buffer overflow risk.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list