msleep() an load average

From: Eibach, Dirk
Date: Wed May 04 2011 - 08:44:18 EST



LDD Chapter 7 says "In general, if you can tolerate longer delays than
requested, you should use schedule_timeout, msleep or ssleep.".

Following this rule, my kernel thread does:
while(1) msleep(1000);

Seconds later userspace guys start whining: "Your driver is evil,
loadavg is 1 and we did not even start our fancy application".

I say: "No, my code is perfectly fine, I followed LDD to the letter."

So the userspace guys head back to their cave, only to return after 5
hours of googling: "Hey, we know what you are doing. Your kernel thread
does uninterruptible sleeps. Wikipedia says, this means you are probably
waiting for disk activity."

Since I don't like having those whining userspace guys around I change
my code, reluctantly:
while(1) msleep_interruptible(1000);

Seconds later they say: "All hail great kernel hacker! You fixed it in
no time."

I appreciate their admiration, but still there are doubts in my mind: Is
this code really any better? Is the loadavg metric broken beyond repair?
Should I really avoid msleep, just to stop those userspace guys from
whining?
The truth must be out there ...

Cheers
Dirk


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/