netchannels: specialize new and delete operators

While running one of the redis benchmarks, I saw around 23k calls to
malloc_large.  Among those, ~10 - 11k were 2-page sized. I managed to track it
down to the creation of net channels. The problem here is that the net channel
structure is slightly larger than half a page - the maximum size for small
object pools. That will throw all allocations into malloc_large. Besides being
slow, it also wastes a page for every net channel created, since malloc_large
will include an extra page in the beginning of each allocation.

This patch fixes this by overloading the operators new and delete for the
netchannel structure so that we use the more efficient and less wasteful
alloc_page.

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>
debug: allow debug_early to work really early again

an effect of commit 9bbbe9dc is that no output is possible
before prio 'console' initializers have been run.
This change allows to have at least one API available
really early (from boot code and premain).
Document the requirements for the early console class
regarding the write() method.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Fixed include directive

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
add execle() to libc

add symbol to libc for port CRuby

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Reflect add libc/process and code

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Reflect add libc/process

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Add lookup_name_demangled(), which converts addr to demangled symbol name.

lookup_name_demangled() lookups a symbol name, demangle it, then
snprintf onto preallocated buffer.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Use lookup_name_demangled() on abort backtrace.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Add symbol name on dump_registers

Resolve and demangle symbol name of RIP, show it.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Show current RIP and symbol name on sigsegv, by using dump_registers

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libzfs: Add missing files into libzfs build to fix missing symbols

Some functionality from the zfs and zpool commands require some functions
contained in zfs_prop.c and zpool_prop.c. This patch solves this problem
by adding the files as part of the libzfs compilation process.
Currently, OSv fall into the 'failed to lookup symbol' scenario when using
certain parameters from the aforementioned commands, e.g.:
scripts/run.py -e 'zfs.so list osv'

_OPENSOLARIS_SYS_UIO_H_ was added to CFLAGS to fix a confliction where
'struct uio' was being defined twice (Glauber Costa).

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: ensure buffers are initialized when tracepoint is enabled

Tracepoints can be enbaled not only via enable_tracepoint(std::string)
but via tracepoint_base::enable() also. This change also makes the
initialization thread-safe as it may be called from aribtrary thread.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: allow atomic changes of _log_backtrace via tracepoint_base::log_backtrace()

Sampler will need to set and later restore value of this option.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: strip leading unimportant frames from backtrace

First couple of frames always come from trace logging functions. I
think we should not show them because they do not add any information.

There was already a list of function names which should be filtered
out. This is not appropriate in this case because tracing goes through
a function named 'log' which is a pretty generic name and could as
well be an application symbol, so we cannot just filter out all
functions named 'log. This patch adds support for knocking off a
leading sequence of frames form the backtrace which is more accurate
and seems good enough.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: introduce sampling profiler

This introduces a simple timer-based sampling profiler which is
reusing our tracing infrastructure to collect samples.

To enable sampler from run.py run it like this:

 $ scripts/run.py ... --sampler [frequency]

Where 'frequency' is an optional parameter for overriding sampling
frequency. The default is 1000 (ticks per second). The bigger the
frequency the bigger sampling overhead is. Too low values will hurt
profile accuracy.

Ad-hoc sampler enabling is planned. The code already takes that into
account.

To see the profile you need to extract the trace:

 $ trace extract

And then show it like this:

 $ trace prof

All 'prof' options can be applied, for example you can group by CPU:

 $ trace prof -g cpu

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: add sampler enabling/disabling test

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pagecache, zfs: make hole detection logic more efficient

Instead of searching for next data offset in a file before getting ARC
buffer this patch adds dmu_buf_hold_array_sparse() function which is variant
of dmu_buf_hold_array() but it returns an error if requested offset
belongs to a hole. This reduces amount of locks taken and avoids file
syncing that dmu_offset_next() does.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
aarch64: fix build broken by recent changes

fix build for Aarch64 broken by commit 66317807 and b3fa77d3.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader: use early console to display OSV string

and do it early (before the loop around init_array)

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Update mgmt for upload API

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>