void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
+static inline int divide_rounding_upwards(int dividend, int divisor)
+{
+ return (dividend + (divisor - 1)) / (divisor ?: 1);
+}
+
void qos_distribution_proportional(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
{
const double proportion = (double) qos->max_throughput / (metrics_get_total(qos->log_metrics) ?: 1);
{
/* round upwards so that it's never 0, to give all clients a chance
* to log at least something (so a developer can tell it's alive) */
- const int equal_limit_for_everybody = (qos->max_throughput + (count - 1)) / count;
+ const int equal_limit_for_everybody = divide_rounding_upwards(qos->max_throughput, count);
for (int i = 0; i < count; ++i)
infos[i].count = equal_limit_for_everybody;