modules/lua: fix the build

The assignment to PREFIX env var had no effect on the makefile
variable 'PREFIX', so it resolved to an enpty string. We need to put
it inside eval.

This fixes the build for me:

$ make image=cli
...
make[2]: Entering directory '/home/tgrabiec/src/osv/modules/lua'
PREFIX=/home/tgrabiec/src/osv/modules/lua
cd build/luarocks-2.1.2 && \
    ./configure --prefix=/out --force-config \
    --with-lua-include=/src --lua-version=5.2
Lua interpreter found: /usr/bin/lua5.2...
Lua version detected: 5.2
Looking for Lua... lua5.2 found in $PATH: /usr/bin
Checking Lua includes... lua.h not found (looked in /src, /src/lua/5.2, /src/lua5.2)
You may want to use the flag --with-lua or --with-lua-include. See --help.

configure failed.

Makefile:75: recipe for target 'build/luarocks-2.1.2/Makefile' failed
make[2]: *** [build/luarocks-2.1.2/Makefile] Error 1
make[2]: Leaving directory '/home/tgrabiec/src/osv/modules/lua'

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
gdb: fix padding for short bits str

bits2str() uses the length of bits chars to add paddings when printing
fields. This patch fixes the situation when length of bits chars is
less than len('none').

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
gdb: show offset/path for file mapped vma in 'osv mmap'

Before:
(gdb) osv mmap
0x0000000000000000 0x0000000000000000 [0 kB]           flags=none     perm=none
0x0000100000000000 0x00001000000a4000 [656 kB]         flags=fmF      perm=rx
0x00001000002a3000 0x00001000002a9000 [24 kB]          flags=fmF      perm=rw
0x0000100000400000 0x0000100000415000 [84 kB]          flags=fmF      perm=rx
0x0000100000614000 0x0000100000615000 [4 kB]           flags=fmF      perm=r
0x0000100000615000 0x0000100000616000 [4 kB]           flags=fmF      perm=rw
0x0000200000000000 0x0000200000001000 [4 kB]           flags=p        perm=none
0x0000200000001000 0x0000200000100000 [1020 kB]        flags=p        perm=rw
...

After:
(gdb) osv mmap
0x0000000000000000 0x0000000000000000 [0 kB]           flags=none     perm=none
0x0000100000000000 0x00001000000a4000 [656 kB]         flags=fmF      perm=rx   offset=0x00000000 path=/libhttpserver.so
0x00001000002a3000 0x00001000002a9000 [24 kB]          flags=fmF      perm=rw   offset=0x000a3000 path=/libhttpserver.so
0x0000100000400000 0x0000100000415000 [84 kB]          flags=fmF      perm=rx   offset=0x00000000 path=/usr/lib/libgcc_s.so.1
0x0000100000614000 0x0000100000615000 [4 kB]           flags=fmF      perm=r    offset=0x00014000 path=/usr/lib/libgcc_s.so.1
0x0000100000615000 0x0000100000616000 [4 kB]           flags=fmF      perm=rw   offset=0x00015000 path=/usr/lib/libgcc_s.so.1
0x0000200000000000 0x0000200000001000 [4 kB]           flags=p        perm=none
0x0000200000001000 0x0000200000100000 [1020 kB]        flags=p        perm=rw
...

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Clean up tests/misc-mutex.cc

tests/misc-mutex.cc includes some mutex benchmarks and tests, but was
a big mess and this patch cleans some of the dead code, useless stuff,
and over-verbose output.

The test now includes 4 main parts:

* Measure the size in bytes of the mutual exclusion primitives, spinlock
  and mutex (this comes out to 1 byte and 40 bytes, respectively).

* Measure the single-CPU uncontended lock/unlock cycle, for both mutex
  and spinlock. On my machine this shows about 25ns, and 12ns, respectively.

* Measure the lock/unlock cycle when several threads in a tight loop
  requesting the same lock. We try 2 threads, 4 threads (on 4 cpus),
  and 20 threads on 4 cpus.
  Here the mutex is significantly slower than the spinlock, because the
  spinlock only context-switches when the thread's time slice is over,
  while the mutex context-switches on most lock/unlock cycles, as we
  sleep while waiting for another thread to release the lock.

* Additional correctness tests, less useful as benchmarks.

Reviewed-by: Dor Laor <dor@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
revert "make image=", add new "make modules="

This is a compromise between some people's insistance (see issue #390)
that we shouldn't have modules added by default, and other people's
just-as-vigorous insistance that some modules, like httpserver, are
essential in every image.

What this patch does is to:

  1. return "make image=..." to how it used to be, i.e., only modules
     explicitly listed on this list, and their dependencies, are added
     to the image, and no "default" modules are added.

  2. A new "make modules=..." behaves like "make image=" does before
     this patch, i.e., it builds an image using both the listed modules,
     and the default modules. "make modules=x,-httpserver" will still work,
     if anyone wants to do this.

Internally, what this patch does is to add to the module list syntax a
prefix "!" which signifies we want this list exactly, without defaults.
The "make modules" doesn't add this prefix, while "make image" does
(i.e., "make image=x" is equivalent to "make modules=!x").

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
routecache: Remove debugging printout

This removes the following debuggign printout from OSv boot that was
added in commit c9f3702 ("Route Cache patch #2"):

  routecache.hh: caching route for fea9fea9 ffffff

Reviewed-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
httpserver: document /os/cmdline

Be more explicit about what we are doing

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
release-ec2: introduce AWS region/zone/placement group parameters

These parameters define created AMIs/instances placement,
useful for performance tests where instances locality matter.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Fix SCOPE_LOCK to be usable twice in the same scope.

Asias discovered that if SCOPE_LOCK is used twice in the same block,
it gives a compilation error because the same lock name is used for
both.

The existing code attempted to solve this problem using __COUNTER__,
but did it wrongly... The problem is that the "##" c-preprocessor
operator does concatenation macro expansion, so the literal string
"__COUNTER__" was used, not a numeric counter as we had hoped.
To do this correctly, we need to pass the task to another macro, or
two actually!

A more detailed explanation about the solution:

This macro concatenates the two literal arguments passed to it, and only
then does macro expansion. So naively calling
CONCATENATE2(_SCOPE_LOCK, __COUNTER__) would result in just the string
_SCOPE_LOCK__COUNTER.

Now, CONCATENATE(_SCOPE_LOCK, __COUNTER__) expands to
CONCATENATE2(_SCOPE_LOCK, <actual counter>) and that is now exapnded
again to get the actual behaviour we need.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
async: Remove recursive timer lock

timer_task has an internal mutex lock which protects various timer_task
operations. This patch changes this lock to a reference to an external
lock. This way, instead of doing recursive locking, we can share the lock
with serial_timer_task's mutex lock.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ci
ci
ci
ci
ci
ci
ci
ci
internal mutex for timer_task