Update the lib to include polling on the pwqrfd.
authorPierre Habouzit <pierre.habouzit@intersec.com>
Sun, 15 Jan 2012 12:57:42 +0000 (13:57 +0100)
committerPierre Habouzit <pierre.habouzit@intersec.com>
Sun, 15 Jan 2012 13:11:58 +0000 (14:11 +0100)
commit537958e9f81a6338fa2986ec56938d5a9fbc5166
tree589f8eed5ad3c20e820d71ec461172ff36d6deee
parent866e56c8f10d718c24e812335b107a05218dc339
Update the lib to include polling on the pwqrfd.

This introduces an overcommit_count.  This counter is set by a poller
thread (or an event loop, see pwqr_overcommit_poll_loop.

On the other side, normal jobs consumers check this counter, when non 0
they XCHG it with 0 (to be sure they are alone evaluating the overcommit
ratio), ask the kernel for the current overcommit, substract one, put it
as the new counter and go to be parked.

Of course when going to be parked the threads may actually find overcommit
jobs or similar, then the polling thread will reset the overcommit_count
again in that case and this will start again. In the more common case, the
thread will be parked directly and we hope it'll be enough.

When a thread goes out of PARK mode without signaling an EDQUOT condition,
we forcefully set the overcommit_count to zero.

This should hopefully take care of the downsizing of the pool in case of
overcommit for too long. As a side note, the kernel only signals
overcommit when it's lasting for more than PWQR_OC_DELAY (which is 1/20 of
a second as of this commit), which lets plenty of time for the overcommit
to be reduced in other more "natural" ways.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
lib/libpwqr.c