top.py: rewrite to make it easier to add and configure columns

top.py was written with a hard-coded set of columns, and adding new columns
was messy and caused a lot of code repetition. Worse, the code for the "-s"
option allowing to turn off a subset of the columns was ugly, and we could
hardly ever expand it to more combinations of columns or even controlling
the appearance or disappearance of individual columns.

So this patch rewrites most of top.py in a cleaner way. We now start with a
definition of all supported columns, each defined by a "source" field from the
REST api (e.g., "cpu_ms", "name", etc.), and various transformations on it.
Then, according to the command-line arguments we select a list of columns.
Finally we have code to render any selected set of columns.

This patch also adds two new options to top.py:

'-i' (--idle) shows the idle threads as normal threads (idle0, idle1, ...)
instead of summarizing the idle percentage on top. This is useful if you
want to see more statistics on the idle thread - such as the number of
switches, the average microseconds ran at each switch, etc.

'-p' (--period) allows changing the number of seconds to wait between
refreshes. E.g, "-p 10" refreshes every 10 seconds, and "-p 0.5"
refreshes every half a second. Remember that the rates shown (e.g.,
"switches/second") are always scaled per second - regardless of the
refresh period.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: fix formatting of per-CPU time ranges

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

It uses sched_wait, sched_wait_ret and sched_wake tracepoint samples
to calculate wakeup latency for each wake up event.

Example:

$ trace wakeup-latency
THREAD             THREAD-NAME     CPU         TIMESTAMP[s]    WAKEUP[ms]  WAIT[ms] BACKTRACE
0xffff800001b9b040 balancer2         2          5.450296508      0.005352    10.064
0xffff800001b9b040 balancer2         2          5.460325089      0.004435    10.024
0xffff800001b9b040 balancer2         2          5.521223741      0.006707    10.031
0xffff800007dfc050 >>java.so         2          5.526478430      0.004586    50.018
0xffff800001b9b040 balancer2         2          5.531256612      0.005243    10.021
0xffff800001b9b040 balancer2         2          5.541294190      0.007497    10.028
0xffff800001b9b040 balancer2         2          5.551348229      0.006181    10.038
0xffff80000a021050 >>>>>java.so      2          5.558015355      0.005727   100.047
0xffff800001b9b040 balancer2         2          5.561364355      0.005475    10.012
0xffff80000aa18050 >>>>>java.so      1          5.565284278      0.001366     0.040
0xffff800007e02050 >>>>java.so       3          5.565286537      0.001098     0.003
0xffff800007e02050 >>>>java.so       3          5.565413877      0.012507     0.118
0xffff80000abbe050 >>>>>java.so      2          5.565419369      0.001764     0.014
0xffff80000abbe050 >>>>>java.so      2          5.565566115      0.060521     0.137

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: add sched_load() tracepoint

It records the CPU load when runqueue size changes, on wakeups or
reschedule.

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

Prints the per-CPU load based on sched_load tracepoint.

For example:

$ trace cpu-load
 5.791242759           3
 5.791243882           2
 5.791262612           0
 5.791269467           0       1
 5.791270651           0       1
 5.791305531           0       3
 5.791306129           0       2
 5.791316507           0   0   0
 5.791388241           0   0   0   1
 5.791388999           0   0   0   1
 5.792139203           0   0   0   3
 5.792140146           0   0   0   2

$ trace cpu-load -c 4
 5.791388241           0   0   0   1
 5.791388999           0   0   0   1
 5.792139203           0   0   0   3
 5.792140146           0   0   0   2

$ trace cpu-load -f csv
 5.791242759,3
 5.791243882,2
 5.791262612,0
 5.791269467,0,,1
 5.791270651,0,,1
 5.791305531,0,,3
 5.791306129,0,,2
 5.791316507,0,0,0
 5.791388241,0,0,0,1

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
upload_manifest.py: fix python3 support

In python3, octal constants like 0777 are not supported. The form
0o777 must be used instead, and it also works on python2.

Noticed when running upload_manifest.py using python3.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
musl: bring in crypt functions

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: dtb: get the base address of pl011 from dtb

and reuse the early console for the full console class,
or we will lose the base address setting.

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