[CORE] vmm_manager: Determine host CPU for new VCPUs using from load balancer

We should use help from load balancer for determing host CPU for new VCPU.

This will provide a chance to load balancing algo to reduce number of
balancing interations by assigining most apporpriate host CPU for a
newly created VCPU.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_loadbal: Create load balancing thread instead of orphan VCPU

This patch makes use of vmm_threads API in vmm_loadbal instead of
Orphan VCPU APIs for better readablity. This also shows our inclination
to use vmm_threads API over Orphan VCPU APIs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_scheduler: Implement host CPU idleness stats gathering

Knowing the CPU utilization or CPU idleness of each host CPU is
very important to know the efficiency of hypervisor and also
useful for in implementing load balancing algos hence this patch
extends vmm_scheduler to track host CPU idleness.

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Extend "host cpu info" command to show CPU utilization

We have vmm_scheduler APIs available to track host CPU idleness (or
utilization) hence we extend "host cpu info" command to show
utilization of each host CPU.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_loadbal: Provide priority as argument to vmm_loadbal_good_hcpu()

Knowing the intended priority can be very useful in implementing
good_hcpu() callback of load balancing algo hence add this as argument
to vmm_loadbal_good_hcpu() API.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_scheduler: Add vmm_scheduler_ready_count() API

This patch adds vmm_scheduler_ready_count() API to determine
number of ready VCPUs with given priority on particular
host CPU.

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Show active vcpu count per host CPU in "host cpu info" command

Showing active vcpu count per host CPU in "host cpu info" can be
very useful in getting an idea of overall distribution of VCPUs
on host CPUs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Show vcpu affinity in "vcpu list" command

Knowing the VCPU affinity from managment terminal can be very
useful to Xvisor users.

This patch replaces "Device Path" column with "Affinity" column
in output of "vcpu list" and related commands.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_manager: Improve vmm_manager_vcpu_set_affinity() API

Currently, the vmm_manager_vcpu_set_affinity() API only tries to
ensure current vcpu->hcpu is set in new vcpu affinity mask. This
does not cover all cases because it can happen that current
vcpu->hcpu is not set new vcpu affinity mask but old vcpu affinity
mask and new vcpu affinity mask overlap.

The only constraint that needs to be ensured is that old vcpu
affinity mask overlaps with new vcpu affinity mask. If current
vcpu->hcpu is not set in new vcpu affinity mask then we change
the vcpu->hcpu such that it is set in both old affinity mask
and new affinity mask.

This patch improves vmm_manager_vcpu_set_affinity() as-per above
description.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_loadbal: Minor improvement to loadalgo start callback

The start() callback of loadalgo can fail hence start() callback
should return error code. This patch update start() callback
prototype and its usage in vmm_loadbal.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_loadbal: Don't do balancing if only one host CPU is online

This patch does a pretty obvious optimization for SMP host having
only host CPU online.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_loadbal: Improve crude load balancer

This patch improves our existing crude load balancer making it
more sensible and also keeping the simplicity.

The improved crude load balancer is very simple and lazy. It will
balance VCPUs based on host CPU utilization. It does not consider
the VCPU nature (i.e. IO-bound or CPU-bound) and rather treats all
ready VCPUs equally when balancing. For newly created VCPUs, it
will try to provide host CPU with least number of READY, RUNNING,
and PAUSED VCPUs.

Folks aiming at developing their own application-centric or HW-centric
load balancer can use the updated crude load balancer as reference.

Signed-off-by: Anup Patel <anup@brainfault.org>