libc: implement ftime.c

This is an import from musl. It exists in a newer version, but not in the one
we're using. When we update, we can get rid of this one. But that has to be a
concious and coordinated decision.

For now let's bring it in and keep it verbatim.

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>
aarch64: gic: set target mask to zero for the uniproc

in commit ad8466ba18d24c72c96c4d78d173f5042974f5f7 we removed
an abort and changed it to a warning when we cannot read our
own cpu mask target from the GIC, as zero is allowed as a
special case for uniprocessor.
However, we logically still need to set the cpu target mask
to zero in our gic driver state.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Cc: Geyslan G. Bem <geyslan@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: add tracepoint for wakeup IPIs

Add a tracepoint "sched_ipi" for IPIs sent to wake up a thread on a
remote CPU.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: add tracepoint for yield

Add a tracepoint "sched_yield" for sched::thread::yield(), sched_yield()
or pthread_yield() calls, and a second tracepoint "sched_yield_switch"
when the yield operation actually yielded (i.e., there was another
thread in the run queue).

Some sources on the Web suggest that Java uses sched_yield() heavily
and yield's behavior makes a big difference (see issue #482).
However, with this tracepoint, I disproved this conjecture when it
comes to workloads that interest us: For example, in Cassandra,
yield() is rarely used (10 times a second most of the time, 1000 times
a second in rare cases), and when it is used, there is usually no other
thread to yield to and we never see more than a couple of sched_yield_switch
occurances per second. So the implementation of yield() is of no
consequence for Cassandra's performance.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: add tracepoint for rescheduling

Add a tracepoint "sched_sched" for scheduler runs. Note that
scheduler may decide to do nothing (continuing to run the current
thread), so the sched_switch frequency is <= the sched_sched frequency.

Showing the frequency of both sched_sched and sched_switch in one
example workload (Cassandra), I noticed that in about half of the
reschedule calls we decide not to context switch. This suggests it
might be a good idea to optimize this case, to realise as quickly as
possible there is nothing to do. We already try to return quickly,
but maybe we can do this even more quickly.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests:remove unused code in misc-timeslice.cc

The _loop function is no long used here,so remove it.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Haifeng Gao <gaohaifeng.gao@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>