the slack estimator used unsigned math; however for very short delay it's
possible that by the time you calculate the timeout, it's already passed and
you get a negative time/slack... in an unsigned variable... which then gets
turned into a 100 msec delay rather than zero.
This patch fixes this by using a signed typee in the right places.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
-static unsigned long __estimate_accuracy(struct timespec *tv)
+static long __estimate_accuracy(struct timespec *tv)
int divfactor = 1000;
if (task_nice(current) > 0)
int divfactor = 1000;
if (task_nice(current) > 0)
if (slack > 100 * NSEC_PER_MSEC)
slack = 100 * NSEC_PER_MSEC;
if (slack > 100 * NSEC_PER_MSEC)
slack = 100 * NSEC_PER_MSEC;
+
+ if (slack < 0)
+ slack = 0;
-static unsigned long estimate_accuracy(struct timespec *tv)
+static long estimate_accuracy(struct timespec *tv)
{
unsigned long ret;
struct timespec now;
{
unsigned long ret;
struct timespec now;
+ if (end_time && !timed_out)
slack = estimate_accuracy(end_time);
retval = 0;
slack = estimate_accuracy(end_time);
retval = 0;
+ if (end_time && !timed_out)
slack = estimate_accuracy(end_time);
for (;;) {
slack = estimate_accuracy(end_time);
for (;;) {