net: fix poll() abort on net channels

While the net channel poller list (a vector<pollreq>) is managed via rcu,
do_poll() modifies the pollreq without protection when it clears
pollreq::_poll_thread.  This can cause net_channel::wake_pollers() to wake
a null thread.

Fix by converting pollreq::_poll_thread to a sched::thread_handle (which has
internal rcu protection).

Seen running wrk against a static tomcat page (the home page).

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
balloon: protect against ill-sized moves

Carl noticed that it is legal for a java program (think for instance, somebody
using JNI), to move stuff manually from the middle of the balloon. In that case,
we would have a move that is smaller than the size of the object. We haven't put
much tought on how to handle this case - if at all. But it is certainly better
to fault there than to have a silent weird behaviour.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests/misc-lfring.cc: Delete the test for ring_mpsc.

We are about to kill ring_mpsc - delete the corresponding tests.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ring_spsc/mpsc: Fix pop() method failing after the ring index wraps around

- Fixed ring_spsc: "empty" check should be "_beg == _end" and not "_beg >= _end".
- Deleted ring_mpsc since it's not currently used anywhere.

Fixes #225.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: added a test verifying the fix for issue #225

Running 'make check' after the fix:
...
TEST tst-ring-spsc-wraparound.so OK  (8.817 s)
...

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
balloon: remove obsolete assert

I am currently being able to trigger this assert. It comes from the old days
before we found the opportunistic copying bug. Right now, it *is* possible to
have the balloons list to be empty, and still some old VMAs lying around.

Just remove the assertion.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
move malloc pools to mempool.cc

No reason to expose it in the headers.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: fix command help
trace: fix prof -h

Currently it fails with:

Traceback (most rTraceback (most recent call last):
  File "scripts/trace.py", line 433, in <module>
    args = parser.parse_args()
...
  File "/usr/lib/python2.7/argparse.py", line 601, in _expand_help
    return self._get_help_string(action) % params
ValueError: incomplete format
run.py: add --trace option

This option enables given tracepoint from the very beginning.
run.py: add --trace-wait switch
run.py: add --trace-backtrace option
trace: make 'prof' show all trace samples by default
trace: auto-paginate output using less
trace: use .tracefile by default
Introduce sampling profiler
stash