scripts: Separate Capstan and VM image building

This separates Capstan and VM image building into two scripts. This is
needed to be able to drop useless VM images like "osv-base" or
"osv-openjdk" that only make sense as Capstan base images, not
standalone VM images that people boot to.

Cc: Tzach Livyatan <tzach@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: fix madvice(MADV_DONTNEED)

Fix madvice(MADV_DONTNEED) to use correct page ops for a VMA. Don't try
to use what we have today on mmaped files.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
rwlock: replace condition variables with waitqueues

Waitqueues fullfil the same role as condition variables, but are much lighter
since they rely on an external mutex, which is already provided by rwlock.

Replacing condvars by waitqueues significantly reduces the size of an rwlock,
and in addition reduces the number of atomic operations in contended cases
significantly.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: Move getpwuid to user.cc

Move getpwuid() and getpwuid_r() to libc/user.cc where OSv user is
defined.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Fix getpwuid_r() to use OSv user info

The "user.home" JVM system property, for example, uses getpwuid() so
make sure it's returning proper values.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mgmt: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
net: don't abort when receive a VLAN frame

bsd/sys/net/if_ethersubr.cc has an assert to check if
incoming frame is a VLAN frame, if so kernel will abort
there, just dropping it may be a bettter choice.

Signed-off-by: Li Yu <raise.sail@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: remove unused count_maps code

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
disable rt lock
no arp lock
core: add handle_incoming_wakeups tracepoints

When you see this in `perf kvm top`:

 20,93%  [guest.kernel]    [g] _ZN5sched3cpu23handle_incoming_wakeupsEv

You may want to know where does it come from. For that you can trace
'handle_incoming_wakeups' tracepoint and display call sites with
`trace prof`:

$ trace prof
(100.00%, #32722) All
 log
 sched::cpu::handle_incoming_wakeups()
 |-- (96.18%, #31472) sched::cpu::do_idle()
 |    sched::cpu::idle()
 |    sched::thread::main()
 |
 \-- (3.82%, #1250) sched::cpu::reschedule_from_interrupt(bool)
      |-- (2.79%, #914) sched::cpu::schedule()
      |    |-- (1.94%, #634) sched::thread::wait()
      |    |    |-- (1.19%, #390) sched::thread::do_wait_until
      |    |    |    |    waiter::wait(sched::timer*) const
      |    |    |    |    condvar::wait(lockfree::mutex*, sched::timer*)
no timer lock
get rid of unnecessary recursive locking
disable routing lock

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: turn _migration_lock_counter into __thread local variable

This way migration-lock can be used unconditionally in memory
allocator which is called very early, before the first thread is
created.
mempool: prevent across-CPU page stealing

This addresses the race which is mentioned in the comment. If the
thread doing add_page() is migrated before the preempt_lock is taken
it may feed the pool with a page coming from different CPU's page
buffer.

The fix is to embrace the body with migration-lock.
mempool: do not take preempt_lock when freeing from different cpu
mempool: remove contention inside unfill_page_buffer()

This change reduces page buffer pressure caused by virtio-net
allocations, showign up as contention inside unfill_page_buffer() and
refill_page_buffer(). The virtio-net subsystem allocates pages on one
CPU which are then scattered across all other CPUs and freed to their
per-CPU buffers. To mitigate that, this change enables caching of
pages used by virtio-net.
poll: special case POLLIN on one file descriptor

OpenJDK's SocketInputStream.read() is calling poll() to support
timeout. The call site looks like this:

 pfd.fd = s;
 pfd.events = POLLIN | POLLERR;
 poll(&pfd, 1, timeout);

Our current implementation of poll() is quite complex because it needs
to handle polling on many files. It also allocates memory in several
places:
 - in poll() due to std::vector
 - in poll_install()
 - in net_channel::add_poller
 - in net_channel::del_poller

poll() on one socket can be greatly simplified and we can avoid memory
allocation completely. This change adds special casing for that. It
reduces allocation rate in half in tomcat benchmark with 256 connections.
test: add test for poll() on a socket