shrinker: export to C

Export the shrinker interface to C users.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: fix trace list-timed

Broken by commit 1e53a52f6664b0c53a3d867386565511efeae25a.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: unify timed trace extraction

The algorithm was duplicated between 'prof-wait','prof-lock' and 'list
timed','summary --timed'. This change unifies all paths.

As a side effect, mutex_lock_wait/mutex_lock_wake pair is now
recognized as timed sample and appears in 'summary --timed' and
'trace list-timed'

This refactoring will also make it easy to declare timed samples which
are correlated by data rather than calling thread.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: introduce 'prof-timed' command

This command shows a duration profile like 'prof-wait' or 'prof-lock'
but is more generic, it can work with any timed traces.

'trace prof-wait' is equivalent of 'trace prof-timed -t sched_wait'
'trace prof-lock' is equivalent of 'trace prof-timed -t mutex_lock_wait'

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: increase coverage of trace.py

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: make timed-trace recognition handle discontinuous streams properly

This change aims to reduce the likelihood of running into issue
merged stream may not be. If samples cross CPUs and the CPU of the
second sample has its earliest sample after the first sample, we
ignore that pair as the second sample has a high chance of belonging
to other pair.

This change does not solve the problem completly because there may be
a situation when sample which was recorded on another CPU was
discarded and the next sample will be again on the first CPU.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
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>