lib: Make workqueue more conservative about ramping up

* workqueue.c: (work_queue_run) Err more on the side of keeping granularity
  down, by being more conservative about increasing it.
  Also, fix mispelling.
This commit is contained in:
Paul Jakma 2010-01-11 13:55:01 +00:00
parent e276eb8282
commit 3322055b39

View File

@ -341,7 +341,7 @@ work_queue_run (struct thread *thread)
stats: stats:
#define WQ_HYSTERIS_FACTOR 2 #define WQ_HYSTERESIS_FACTOR 4
/* we yielded, check whether granularity should be reduced */ /* we yielded, check whether granularity should be reduced */
if (yielded && (cycles < wq->cycles.granularity)) if (yielded && (cycles < wq->cycles.granularity))
@ -349,17 +349,18 @@ stats:
wq->cycles.granularity = ((cycles > 0) ? cycles wq->cycles.granularity = ((cycles > 0) ? cycles
: WORK_QUEUE_MIN_GRANULARITY); : WORK_QUEUE_MIN_GRANULARITY);
} }
/* otherwise, should granularity increase? */
if (cycles >= (wq->cycles.granularity)) else if (cycles >= (wq->cycles.granularity))
{ {
if (cycles > wq->cycles.best) if (cycles > wq->cycles.best)
wq->cycles.best = cycles; wq->cycles.best = cycles;
/* along with yielded check, provides hysteris for granularity */ /* along with yielded check, provides hysteresis for granularity */
if (cycles > (wq->cycles.granularity * WQ_HYSTERIS_FACTOR * 2)) if (cycles > (wq->cycles.granularity * WQ_HYSTERESIS_FACTOR
wq->cycles.granularity *= WQ_HYSTERIS_FACTOR; /* quick ramp-up */ * WQ_HYSTERESIS_FACTOR))
else if (cycles > (wq->cycles.granularity * WQ_HYSTERIS_FACTOR)) wq->cycles.granularity *= WQ_HYSTERESIS_FACTOR; /* quick ramp-up */
wq->cycles.granularity += WQ_HYSTERIS_FACTOR; else if (cycles > (wq->cycles.granularity * WQ_HYSTERESIS_FACTOR))
wq->cycles.granularity += WQ_HYSTERESIS_FACTOR;
} }
#undef WQ_HYSTERIS_FACTOR #undef WQ_HYSTERIS_FACTOR