Commit 462dbc91 authored by Paolo Valente's avatar Paolo Valente Committed by David S. Miller
Browse files

pkt_sched: QFQ Plus: fair-queueing service at DRR cost

This patch turns QFQ into QFQ+, a variant of QFQ that provides the
following two benefits: 1) QFQ+ is faster than QFQ, 2) differently
from QFQ, QFQ+ correctly schedules also non-leaves classes in a
hierarchical setting. A detailed description of QFQ+, plus a
performance comparison with DRR and QFQ, can be found in [1].

[1] P. Valente, "Reducing the Execution Time of Fair-Queueing Schedulers"
http://algo.ing.unimo.it/people/paolo/agg-sched/agg-sched.pdf



Signed-off-by: default avatarPaolo Valente <paolo.valente@unimore.it>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 351f33d9
/*
* net/sched/sch_qfq.c Quick Fair Queueing Scheduler.
* net/sched/sch_qfq.c Quick Fair Queueing Plus Scheduler.
*
* Copyright (c) 2009 Fabio Checconi, Luigi Rizzo, and Paolo Valente.
* Copyright (c) 2012 Paolo Valente.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -19,12 +20,18 @@
#include <net/pkt_cls.h>
/* Quick Fair Queueing
===================
/* Quick Fair Queueing Plus
========================
Sources:
Fabio Checconi, Luigi Rizzo, and Paolo Valente: "QFQ: Efficient
[1] Paolo Valente,
"Reducing the Execution Time of Fair-Queueing Schedulers."
http://algo.ing.unimo.it/people/paolo/agg-sched/agg-sched.pdf
Sources for QFQ:
[2] Fabio Checconi, Luigi Rizzo, and Paolo Valente: "QFQ: Efficient
Packet Scheduling with Tight Bandwidth Distribution Guarantees."
See also:
......@@ -33,6 +40,20 @@
/*
QFQ+ divides classes into aggregates of at most MAX_AGG_CLASSES
classes. Each aggregate is timestamped with a virtual start time S
and a virtual finish time F, and scheduled according to its
timestamps. S and F are computed as a function of a system virtual
time function V. The classes within each aggregate are instead
scheduled with DRR.
To speed up operations, QFQ+ divides also aggregates into a limited
number of groups. Which group a class belongs to depends on the
ratio between the maximum packet length for the class and the weight
of the class. Groups have their own S and F. In the end, QFQ+
schedules groups, then aggregates within groups, then classes within
aggregates. See [1] and [2] for a full description.
Virtual time computations.
S, F and V are all computed in fixed point arithmetic with
......@@ -76,27 +97,28 @@
#define QFQ_MAX_SLOTS 32
/*
* Shifts used for class<->group mapping. We allow class weights that are
* in the range [1, 2^MAX_WSHIFT], and we try to map each class i to the
* Shifts used for aggregate<->group mapping. We allow class weights that are
* in the range [1, 2^MAX_WSHIFT], and we try to map each aggregate i to the
* group with the smallest index that can support the L_i / r_i configured
* for the class.
* for the classes in the aggregate.
*
* grp->index is the index of the group; and grp->slot_shift
* is the shift for the corresponding (scaled) sigma_i.
*/
#define QFQ_MAX_INDEX 24
#define QFQ_MAX_WSHIFT 12
#define QFQ_MAX_WSHIFT 10
#define QFQ_MAX_WEIGHT (1<<QFQ_MAX_WSHIFT)
#define QFQ_MAX_WSUM (16*QFQ_MAX_WEIGHT)
#define QFQ_MAX_WEIGHT (1<<QFQ_MAX_WSHIFT) /* see qfq_slot_insert */
#define QFQ_MAX_WSUM (64*QFQ_MAX_WEIGHT)
#define FRAC_BITS 30 /* fixed point arithmetic */
#define ONE_FP (1UL << FRAC_BITS)
#define IWSUM (ONE_FP/QFQ_MAX_WSUM)
#define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */
#define QFQ_MIN_SLOT_SHIFT (FRAC_BITS + QFQ_MTU_SHIFT - QFQ_MAX_INDEX)
#define QFQ_MIN_LMAX 256 /* min possible lmax for a class */
#define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */
#define QFQ_MAX_AGG_CLASSES 8 /* max num classes per aggregate allowed */
/*
* Possible group states. These values are used as indexes for the bitmaps
......@@ -106,6 +128,8 @@ enum qfq_state { ER, IR, EB, IB, QFQ_MAX_STATE };
struct qfq_group;
struct qfq_aggregate;
struct qfq_class {
struct Qdisc_class_common common;
......@@ -116,7 +140,12 @@ struct qfq_class {
struct gnet_stats_queue qstats;
struct gnet_stats_rate_est rate_est;
struct Qdisc *qdisc;
struct list_head alist; /* Link for active-classes list. */
struct qfq_aggregate *agg; /* Parent aggregate. */
int deficit; /* DRR deficit counter. */
};
struct qfq_aggregate {
struct hlist_node next; /* Link for the slot list. */
u64 S, F; /* flow timestamps (exact) */
......@@ -127,8 +156,18 @@ struct qfq_class {
struct qfq_group *grp;
/* these are copied from the flowset. */
u32 inv_w; /* ONE_FP/weight */
u32 lmax; /* Max packet size for this flow. */
u32 class_weight; /* Weight of each class in this aggregate. */
/* Max pkt size for the classes in this aggregate, DRR quantum. */
int lmax;
u32 inv_w; /* ONE_FP/(sum of weights of classes in aggr.). */
u32 budgetmax; /* Max budget for this aggregate. */
u32 initial_budget, budget; /* Initial and current budget. */
int num_classes; /* Number of classes in this aggr. */
struct list_head active; /* DRR queue of active classes. */
struct hlist_node nonfull_next; /* See nonfull_aggs in qfq_sched. */
};
struct qfq_group {
......@@ -138,7 +177,7 @@ struct qfq_group {
unsigned int front; /* Index of the front slot. */
unsigned long full_slots; /* non-empty slots */
/* Array of RR lists of active classes. */
/* Array of RR lists of active aggregates. */
struct hlist_head slots[QFQ_MAX_SLOTS];
};
......@@ -146,13 +185,28 @@ struct qfq_sched {
struct tcf_proto *filter_list;
struct Qdisc_class_hash clhash;
u64 V; /* Precise virtual time. */
u32 wsum; /* weight sum */
u64 oldV, V; /* Precise virtual times. */
struct qfq_aggregate *in_serv_agg; /* Aggregate being served. */
u32 num_active_agg; /* Num. of active aggregates */
u32 wsum; /* weight sum */
unsigned long bitmaps[QFQ_MAX_STATE]; /* Group bitmaps. */
struct qfq_group groups[QFQ_MAX_INDEX + 1]; /* The groups. */
u32 min_slot_shift; /* Index of the group-0 bit in the bitmaps. */
u32 max_agg_classes; /* Max number of classes per aggr. */
struct hlist_head nonfull_aggs; /* Aggs with room for more classes. */
};
/*
* Possible reasons why the timestamps of an aggregate are updated
* enqueue: the aggregate switches from idle to active and must scheduled
* for service
* requeue: the aggregate finishes its budget, so it stops being served and
* must be rescheduled for service
*/
enum update_reason {enqueue, requeue};
static struct qfq_class *qfq_find_class(struct Qdisc *sch, u32 classid)
{
struct qfq_sched *q = qdisc_priv(sch);
......@@ -182,18 +236,18 @@ static const struct nla_policy qfq_policy[TCA_QFQ_MAX + 1] = {
* index = log_2(maxlen/weight) but we need to apply the scaling.
* This is used only once at flow creation.
*/
static int qfq_calc_index(u32 inv_w, unsigned int maxlen)
static int qfq_calc_index(u32 inv_w, unsigned int maxlen, u32 min_slot_shift)
{
u64 slot_size = (u64)maxlen * inv_w;
unsigned long size_map;
int index = 0;
size_map = slot_size >> QFQ_MIN_SLOT_SHIFT;
size_map = slot_size >> min_slot_shift;
if (!size_map)
goto out;
index = __fls(size_map) + 1; /* basically a log_2 */
index -= !(slot_size - (1ULL << (index + QFQ_MIN_SLOT_SHIFT - 1)));
index -= !(slot_size - (1ULL << (index + min_slot_shift - 1)));
if (index < 0)
index = 0;
......@@ -204,66 +258,150 @@ static int qfq_calc_index(u32 inv_w, unsigned int maxlen)
return index;
}
/* Length of the next packet (0 if the queue is empty). */
static unsigned int qdisc_peek_len(struct Qdisc *sch)
static void qfq_deactivate_agg(struct qfq_sched *, struct qfq_aggregate *);
static void qfq_activate_agg(struct qfq_sched *, struct qfq_aggregate *,
enum update_reason);
static void qfq_init_agg(struct qfq_sched *q, struct qfq_aggregate *agg,
u32 lmax, u32 weight)
{
struct sk_buff *skb;
INIT_LIST_HEAD(&agg->active);
hlist_add_head(&agg->nonfull_next, &q->nonfull_aggs);
agg->lmax = lmax;
agg->class_weight = weight;
}
static struct qfq_aggregate *qfq_find_agg(struct qfq_sched *q,
u32 lmax, u32 weight)
{
struct qfq_aggregate *agg;
struct hlist_node *n;
hlist_for_each_entry(agg, n, &q->nonfull_aggs, nonfull_next)
if (agg->lmax == lmax && agg->class_weight == weight)
return agg;
return NULL;
}
skb = sch->ops->peek(sch);
return skb ? qdisc_pkt_len(skb) : 0;
/* Update aggregate as a function of the new number of classes. */
static void qfq_update_agg(struct qfq_sched *q, struct qfq_aggregate *agg,
int new_num_classes)
{
u32 new_agg_weight;
if (new_num_classes == q->max_agg_classes)
hlist_del_init(&agg->nonfull_next);
if (agg->num_classes > new_num_classes &&
new_num_classes == q->max_agg_classes - 1) /* agg no more full */
hlist_add_head(&agg->nonfull_next, &q->nonfull_aggs);
agg->budgetmax = new_num_classes * agg->lmax;
new_agg_weight = agg->class_weight * new_num_classes;
agg->inv_w = ONE_FP/new_agg_weight;
if (agg->grp == NULL) {
int i = qfq_calc_index(agg->inv_w, agg->budgetmax,
q->min_slot_shift);
agg->grp = &q->groups[i];
}
q->wsum +=
(int) agg->class_weight * (new_num_classes - agg->num_classes);
agg->num_classes = new_num_classes;
}
/* Add class to aggregate. */
static void qfq_add_to_agg(struct qfq_sched *q,
struct qfq_aggregate *agg,
struct qfq_class *cl)
{
cl->agg = agg;
qfq_update_agg(q, agg, agg->num_classes+1);
if (cl->qdisc->q.qlen > 0) { /* adding an active class */
list_add_tail(&cl->alist, &agg->active);
if (list_first_entry(&agg->active, struct qfq_class, alist) ==
cl && q->in_serv_agg != agg) /* agg was inactive */
qfq_activate_agg(q, agg, enqueue); /* schedule agg */
}
}
static void qfq_deactivate_class(struct qfq_sched *, struct qfq_class *);
static void qfq_activate_class(struct qfq_sched *q, struct qfq_class *cl,
unsigned int len);
static struct qfq_aggregate *qfq_choose_next_agg(struct qfq_sched *);
static void qfq_update_class_params(struct qfq_sched *q, struct qfq_class *cl,
u32 lmax, u32 inv_w, int delta_w)
static void qfq_destroy_agg(struct qfq_sched *q, struct qfq_aggregate *agg)
{
int i;
if (!hlist_unhashed(&agg->nonfull_next))
hlist_del_init(&agg->nonfull_next);
if (q->in_serv_agg == agg)
q->in_serv_agg = qfq_choose_next_agg(q);
kfree(agg);
}
/* update qfq-specific data */
cl->lmax = lmax;
cl->inv_w = inv_w;
i = qfq_calc_index(cl->inv_w, cl->lmax);
/* Deschedule class from within its parent aggregate. */
static void qfq_deactivate_class(struct qfq_sched *q, struct qfq_class *cl)
{
struct qfq_aggregate *agg = cl->agg;
cl->grp = &q->groups[i];
q->wsum += delta_w;
list_del(&cl->alist); /* remove from RR queue of the aggregate */
if (list_empty(&agg->active)) /* agg is now inactive */
qfq_deactivate_agg(q, agg);
}
static void qfq_update_reactivate_class(struct qfq_sched *q,
struct qfq_class *cl,
u32 inv_w, u32 lmax, int delta_w)
/* Remove class from its parent aggregate. */
static void qfq_rm_from_agg(struct qfq_sched *q, struct qfq_class *cl)
{
bool need_reactivation = false;
int i = qfq_calc_index(inv_w, lmax);
struct qfq_aggregate *agg = cl->agg;
if (&q->groups[i] != cl->grp && cl->qdisc->q.qlen > 0) {
/*
* shift cl->F back, to not charge the
* class for the not-yet-served head
* packet
*/
cl->F = cl->S;
/* remove class from its slot in the old group */
qfq_deactivate_class(q, cl);
need_reactivation = true;
cl->agg = NULL;
if (agg->num_classes == 1) { /* agg being emptied, destroy it */
qfq_destroy_agg(q, agg);
return;
}
qfq_update_agg(q, agg, agg->num_classes-1);
}
qfq_update_class_params(q, cl, lmax, inv_w, delta_w);
/* Deschedule class and remove it from its parent aggregate. */
static void qfq_deact_rm_from_agg(struct qfq_sched *q, struct qfq_class *cl)
{
if (cl->qdisc->q.qlen > 0) /* class is active */
qfq_deactivate_class(q, cl);
if (need_reactivation) /* activate in new group */
qfq_activate_class(q, cl, qdisc_peek_len(cl->qdisc));
qfq_rm_from_agg(q, cl);
}
/* Move class to a new aggregate, matching the new class weight and/or lmax */
static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight,
u32 lmax)
{
struct qfq_sched *q = qdisc_priv(sch);
struct qfq_aggregate *new_agg = qfq_find_agg(q, lmax, weight);
if (new_agg == NULL) { /* create new aggregate */
new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC);
if (new_agg == NULL)
return -ENOBUFS;
qfq_init_agg(q, new_agg, lmax, weight);
}
qfq_deact_rm_from_agg(q, cl);
qfq_add_to_agg(q, new_agg, cl);
return 0;
}
static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
struct nlattr **tca, unsigned long *arg)
{
struct qfq_sched *q = qdisc_priv(sch);
struct qfq_class *cl = (struct qfq_class *)*arg;
bool existing = false;
struct nlattr *tb[TCA_QFQ_MAX + 1];
struct qfq_aggregate *new_agg = NULL;
u32 weight, lmax, inv_w;
int err;
int delta_w;
......@@ -286,15 +424,6 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
} else
weight = 1;
inv_w = ONE_FP / weight;
weight = ONE_FP / inv_w;
delta_w = weight - (cl ? ONE_FP / cl->inv_w : 0);
if (q->wsum + delta_w > QFQ_MAX_WSUM) {
pr_notice("qfq: total weight out of range (%u + %u)\n",
delta_w, q->wsum);
return -EINVAL;
}
if (tb[TCA_QFQ_LMAX]) {
lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) {
......@@ -304,7 +433,23 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
} else
lmax = psched_mtu(qdisc_dev(sch));
if (cl != NULL) {
inv_w = ONE_FP / weight;
weight = ONE_FP / inv_w;
if (cl != NULL &&
lmax == cl->agg->lmax &&
weight == cl->agg->class_weight)
return 0; /* nothing to change */
delta_w = weight - (cl ? cl->agg->class_weight : 0);
if (q->wsum + delta_w > QFQ_MAX_WSUM) {
pr_notice("qfq: total weight out of range (%d + %u)\n",
delta_w, q->wsum);
return -EINVAL;
}
if (cl != NULL) { /* modify existing class */
if (tca[TCA_RATE]) {
err = gen_replace_estimator(&cl->bstats, &cl->rate_est,
qdisc_root_sleeping_lock(sch),
......@@ -312,25 +457,18 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
if (err)
return err;
}
if (lmax == cl->lmax && inv_w == cl->inv_w)
return 0; /* nothing to update */
sch_tree_lock(sch);
qfq_update_reactivate_class(q, cl, inv_w, lmax, delta_w);
sch_tree_unlock(sch);
return 0;
existing = true;
goto set_change_agg;
}
/* create and init new class */
cl = kzalloc(sizeof(struct qfq_class), GFP_KERNEL);
if (cl == NULL)
return -ENOBUFS;
cl->refcnt = 1;
cl->common.classid = classid;
qfq_update_class_params(q, cl, lmax, inv_w, delta_w);
cl->deficit = lmax;
cl->qdisc = qdisc_create_dflt(sch->dev_queue,
&pfifo_qdisc_ops, classid);
......@@ -341,11 +479,8 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
err = gen_new_estimator(&cl->bstats, &cl->rate_est,
qdisc_root_sleeping_lock(sch),
tca[TCA_RATE]);
if (err) {
qdisc_destroy(cl->qdisc);
kfree(cl);
return err;
}
if (err)
goto destroy_class;
}
sch_tree_lock(sch);
......@@ -354,19 +489,39 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
qdisc_class_hash_grow(sch, &q->clhash);
set_change_agg:
sch_tree_lock(sch);
new_agg = qfq_find_agg(q, lmax, weight);
if (new_agg == NULL) { /* create new aggregate */
sch_tree_unlock(sch);
new_agg = kzalloc(sizeof(*new_agg), GFP_KERNEL);
if (new_agg == NULL) {
err = -ENOBUFS;
gen_kill_estimator(&cl->bstats, &cl->rate_est);
goto destroy_class;
}
sch_tree_lock(sch);
qfq_init_agg(q, new_agg, lmax, weight);
}
if (existing)
qfq_deact_rm_from_agg(q, cl);
qfq_add_to_agg(q, new_agg, cl);
sch_tree_unlock(sch);
*arg = (unsigned long)cl;
return 0;
destroy_class:
qdisc_destroy(cl->qdisc);
kfree(cl);
return err;
}
static void qfq_destroy_class(struct Qdisc *sch, struct qfq_class *cl)
{
struct qfq_sched *q = qdisc_priv(sch);
if (cl->inv_w) {
q->wsum -= ONE_FP / cl->inv_w;
cl->inv_w = 0;
}
qfq_rm_from_agg(q, cl);
gen_kill_estimator(&cl->bstats, &cl->rate_est);
qdisc_destroy(cl->qdisc);
kfree(cl);
......@@ -481,8 +636,8 @@ static int qfq_dump_class(struct Qdisc *sch, unsigned long arg,
nest = nla_nest_start(skb, TCA_OPTIONS);
if (nest == NULL)
goto nla_put_failure;
if (nla_put_u32(skb, TCA_QFQ_WEIGHT, ONE_FP/cl->inv_w) ||
nla_put_u32(skb, TCA_QFQ_LMAX, cl->lmax))
if (nla_put_u32(skb, TCA_QFQ_WEIGHT, cl->agg->class_weight) ||
nla_put_u32(skb, TCA_QFQ_LMAX, cl->agg->lmax))
goto nla_put_failure;
return nla_nest_end(skb, nest);
......@@ -500,8 +655,8 @@ static int qfq_dump_class_stats(struct Qdisc *sch, unsigned long arg,
memset(&xstats, 0, sizeof(xstats));
cl->qdisc->qstats.qlen = cl->qdisc->q.qlen;
xstats.weight = ONE_FP/cl->inv_w;
xstats.lmax = cl->lmax;
xstats.weight = cl->agg->class_weight;
xstats.lmax = cl->agg->lmax;
if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
gnet_stats_copy_rate_est(d, &cl->bstats, &cl->rate_est) < 0 ||
......@@ -652,16 +807,16 @@ static void qfq_unblock_groups(struct qfq_sched *q, int index, u64 old_F)
* perhaps
*
old_V ^= q->V;
old_V >>= QFQ_MIN_SLOT_SHIFT;
old_V >>= q->min_slot_shift;
if (old_V) {
...
}
*
*/
static void qfq_make_eligible(struct qfq_sched *q, u64 old_V)
static void qfq_make_eligible(struct qfq_sched *q)
{
unsigned long vslot = q->V >> QFQ_MIN_SLOT_SHIFT;
unsigned long old_vslot = old_V >> QFQ_MIN_SLOT_SHIFT;
unsigned long vslot = q->V >> q->min_slot_shift;
unsigned long old_vslot = q->oldV >> q->min_slot_shift;
if (vslot != old_vslot) {
unsigned long mask = (1UL << fls(vslot ^ old_vslot)) - 1;
......@@ -672,34 +827,38 @@ static void qfq_make_eligible(struct qfq_sched *q, u64 old_V)
/*
* If the weight and lmax (max_pkt_size) of the classes do not change,
* then QFQ guarantees that the slot index is never higher than
* 2 + ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) * (QFQ_MAX_WEIGHT/QFQ_MAX_WSUM).
* The index of the slot in which the aggregate is to be inserted must
* not be higher than QFQ_MAX_SLOTS-2. There is a '-2' and not a '-1'
* because the start time of the group may be moved backward by one
* slot after the aggregate has been inserted, and this would cause
* non-empty slots to be right-shifted by one position.
*
* With the current values of the above constants, the index is
* then guaranteed to never be higher than 2 + 256 * (1 / 16) = 18.
* If the weight and lmax (max_pkt_size) of the classes do not change,
* then QFQ+ does meet the above contraint according to the current
* values of its parameters. In fact, if the weight and lmax of the
* classes do not change, then, from the theory, QFQ+ guarantees that
* the slot index is never higher than
* 2 + QFQ_MAX_AGG_CLASSES * ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) *
* (QFQ_MAX_WEIGHT/QFQ_MAX_WSUM) = 2 + 8 * 128 * (1 / 64) = 18
*
* When the weight of a class is increased or the lmax of the class is
* decreased, a new class with smaller slot size may happen to be
* activated. The activation of this class should be properly delayed
* to when the service of the class has finished in the ideal system
* tracked by QFQ. If the activation of the class is not delayed to
* this reference time instant, then this class may be unjustly served
* before other classes waiting for service. This may cause
* (unfrequently) the above bound to the slot index to be violated for
* some of these unlucky classes.
* decreased, a new aggregate with smaller slot size than the original
* parent aggregate of the class may happen to be activated. The
* activation of this aggregate should be properly delayed to when the
* service of the class has finished in the ideal system tracked by
* QFQ+. If the activation of the aggregate is not delayed to this
* reference time instant, then this aggregate may be unjustly served
* before other aggregates waiting for service. This may cause the
* above bound to the slot index to be violated for some of these
* unlucky aggregates.
*
* Instead of delaying the activation of the new class, which is quite
* complex, the following inaccurate but simple solution is used: if
* the slot index is higher than QFQ_MAX_SLOTS-2, then the timestamps
* of the class are shifted backward so as to let the slot index
* become equal to QFQ_MAX_SLOTS-2. This threshold is used because, if
* the slot index is above it, then the data structure implementing
* the bucket list either gets immediately corrupted or may get
* corrupted on a possible next packet arrival that causes the start
* time of the group to be shifted backward.
* Instead of delaying the activation of the new aggregate, which is
* quite complex, the following inaccurate but simple solution is used:
* if the slot index is higher than QFQ_MAX_SLOTS-2, then the
* timestamps of the aggregate are shifted backward so as to let the
* slot index become equal to QFQ_MAX_SLOTS-2.
*/
static void qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl,
static void qfq_slot_insert(struct qfq_group *grp, struct qfq_aggregate *agg,
u64 roundedS)
{
u64 slot = (roundedS - grp->S) >> grp->slot_shift;
......@@ -708,22 +867,22 @@ static void qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl,
if (unlikely(slot > QFQ_MAX_SLOTS - 2)) {
u64 deltaS = roundedS - grp->S -
((u64)(QFQ_MAX_SLOTS - 2)<<grp->slot_shift);
cl->S -= deltaS;
cl->F -= deltaS;
agg->S -= deltaS;
agg->F -= deltaS;
slot = QFQ_MAX_SLOTS - 2;
}
i = (grp->front + slot) % QFQ_MAX_SLOTS;
hlist_add_head(&cl->next, &grp->slots[i]);
hlist_add_head(&agg->next, &grp->slots[i]);
__set_bit(slot, &grp->full_slots);
}
/* Maybe introduce hlist_first_entry?? */