[core/sched/cbs] Move and update CBS params definitions

The CBS params and related macros are placed at the beginning of the source
since they are required also by following code.

This patch adds also properly defined scaling factors to support fixed
point floating number calculus. Each integer which requires a certain
decimal precision is declared at the top by specifying the number of
decimal bits.

Finally, the CBS params are accessed using a pointer to simplify the code.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Better organize CBS specific code

The code which touch CBS specific data structures (i.e. SE and RQ) has been
moved into methods which operates just on that specialized data.
The external scheduler API just operate on global data structures and
resolve the CBS specific ones to be passed to the internal methods.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Load Management - Add data and support functions

This patch adds a set of RQ and SE specific data as well as supporting
macros/functions to keep track of loads used to allocated round quotas.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Cosmetics

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add entry points

The CBS controller will operate in three main points:
1. SE entering CPU
2. SE exiting CPU
3. New round start
These three entry points are hooked into the CBS internal API and they will
host the code in charge to tune and monitor controller specific metrics.
Specifically:
1. tune_cbs_burst: setup the next burst time to be assigned to a SE, once
the SE has been selected to enter the CPU;
2. monitor_cbs_burst: collects metrics related to the SE which are used to
update its status for the next run;
3. tune_cbs_round: setup the next scheduling round based on metrics collected
during the execution of the SE of the previous round.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add requoting support

Each time a SE enter/exit the RQ, the CPU time quota each SE is eligible to
get must be updated. Such a quota depends on the SE weight and the overall
RQ weight.

NOTE: the new quota should be operative starting from the next round

A couple of flags has been added to the RQ to track the need to requote while
the actual requoting is a two step operation:
1. at next round start, requoting base (i.e. 1/weight(RQ)) is cached
and the requoting flags properly udpated;
2. at each next burst of this round the actual SE quota is updated based
on previously cached requoting base value.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add round tuning support

This adds the core to compute the round time correction and corresponding
next round time. This code is part of the tune_cbs_round CBS controller API
which is called at the beginning of a new round.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add burst tuning support

Each time a SE is entering the CPU, the assigned burst interval is assigned
by this method based on the controller defined round time and burst error.
This code is part of the tune_cbs_burst CBS controller API which is called
for each SE right before to assign it the CPU.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add burst monitoring support

Once a SE is removed from the CPU, its effective burst time is cached and
the round time updated. These values are required for the tuning of the
next round. This code is part of the monitor_cbs_burst CBS controller API
which is called for each SE right after they leave the CPU.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add saturation support

This adds saturation control on burst assignments. At the beginning of each
round all SE are assumed to be saturated. Once a SE is actually scheduled
for execution and the burst interval computed the saturation condition
verified and eventually reset.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add reinitialization support

This adds the controller reinitialization code which is triggered each time
the RQ status change (e.g. SE enter/exit or prio change). A controller flag
is used to track the reinitialization condition, which is reset at each new
round if during the paste one there was not a reinitialization event.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: add safety check for fixed point overflows

To avoid fixed point float arithmetic overflow, the current implementation
is limited on the number of TASK_RUNNING SE in the RQ.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>
[core/sched/cbs] Controller: round time clamping

The round time should be clamped to avoid fixed point arithmetics overflow.

Signed-off-by: Patrick Bellasi <derkling@gmail.com>