~madcoder/pwqr.git
10 years agoimplement poll and read
Pierre Habouzit [Sun, 15 Jan 2012 09:31:44 +0000 (10:31 +0100)]
implement poll and read

No matter if we implement some other kind of dirty notification mechanism,
it feels right to have pwqr pollable for overcommit.

Documentation:
- drop the "in kernel unpark" method, it sucks
- migrate to using non blocking "read" for the probing method.
- document the pollability and how read works in the pwqr_create "manpage".

lib:
- implement epoll_create with flags. It requires a kernel supporting
  O_NONBLOCK/O_CLOEXEC flags to open(), I've been too lazy to implement
  the emulation yet.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agodo not forbid other processes to use the pwqr fd.
Pierre Habouzit [Sun, 15 Jan 2012 08:03:38 +0000 (09:03 +0100)]
do not forbid other processes to use the pwqr fd.

Actually it could even make sense, to have stuff running in the background
and wanting to be accounted in the overall load of this process group (for
example some kind of snapshot procedure that would be forke()d in the
background).

Plus this restriction was kind of un-kernelish.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agoPrepare code to plug the overcommit notification.
Pierre Habouzit [Sun, 15 Jan 2012 07:51:17 +0000 (08:51 +0100)]
Prepare code to plug the overcommit notification.

Let the pwqr_sb have a state (instead of yes/no "dead" flag) being among:
- DEAD
- NONE (normal)
- UC (undercommit)
- OC (overcommit).

In the last two modes a timer is fired.

In the UC case, if the timer fires, we unpark a thread (if any, and if no
overcommit unpark is pending) as before.

In the OC case for now we do nothing.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agocheck the `addr` argument for PWQ_WAIT is aligned to an integer.
Pierre Habouzit [Sat, 14 Jan 2012 21:28:39 +0000 (22:28 +0100)]
check the `addr` argument for PWQ_WAIT is aligned to an integer.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agofix asciidoc
Pierre Habouzit [Sat, 14 Jan 2012 20:46:23 +0000 (21:46 +0100)]
fix asciidoc

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agorework the quarantine: it doesn't really need to be accounted.
Pierre Habouzit [Sat, 14 Jan 2012 20:36:45 +0000 (21:36 +0100)]
rework the quarantine: it doesn't really need to be accounted.

The notion of quarantine is purely virtual and we only care about it at
WAKE time. It significantly simplifies the fastpath of our code, namely
__pwqr_sb_update_state.

Also allow the WAKE command to directly unpark threads if that fits with
the concurrency level. I don't really expect userland to really use that,
but it doesn't break anything and makes sense.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agoImplement the reluctancy to unpark threads.
Pierre Habouzit [Sat, 14 Jan 2012 20:01:47 +0000 (21:01 +0100)]
Implement the reluctancy to unpark threads.

This means that a pool needs to undercommit for 0.1s before we allow it to
grow its number of in-pool threads.

Document the last todo: how to reduce the pool when we're overcommiting.
Right now we only pray that userland will put some threads to WAIT. But
frankly it's less than ideal. With the repulsion to start a new thread we
hope though that the overcommit will never ever grow out of proportion for
now.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agotypo
Pierre Habouzit [Sat, 14 Jan 2012 19:19:46 +0000 (20:19 +0100)]
typo

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agoWrite some nice documentation about the design and APIs.
Pierre Habouzit [Sat, 14 Jan 2012 18:22:49 +0000 (19:22 +0100)]
Write some nice documentation about the design and APIs.

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
10 years agoPthread Workqueue Regulator (pwqr) initial commit.
Pierre Habouzit [Fri, 16 Dec 2011 15:24:24 +0000 (16:24 +0100)]
Pthread Workqueue Regulator (pwqr) initial commit.

This contains an alpha/beta quality kernel proof-of-concept driver, plus
some code concepts to wrap the syscall in lib/libpwqr.c

Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>