sch_gred: prefer GFP_KERNEL allocations
In control path, its better to use GFP_KERNEL allocations where
possible.
Before taking qdisc spinlock, we preallocate memory just in case we'll
need it in gred_change_vq()
This is a followup to commit 3f1e6d3fd3
(sch_gred: should not use
GFP_KERNEL while holding a spinlock)
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c607b2ed84
commit
869aa41044
|
@ -380,18 +380,19 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps)
|
||||||
|
|
||||||
static inline int gred_change_vq(struct Qdisc *sch, int dp,
|
static inline int gred_change_vq(struct Qdisc *sch, int dp,
|
||||||
struct tc_gred_qopt *ctl, int prio,
|
struct tc_gred_qopt *ctl, int prio,
|
||||||
u8 *stab, u32 max_P)
|
u8 *stab, u32 max_P,
|
||||||
|
struct gred_sched_data **prealloc)
|
||||||
{
|
{
|
||||||
struct gred_sched *table = qdisc_priv(sch);
|
struct gred_sched *table = qdisc_priv(sch);
|
||||||
struct gred_sched_data *q;
|
struct gred_sched_data *q = table->tab[dp];
|
||||||
|
|
||||||
if (table->tab[dp] == NULL) {
|
if (!q) {
|
||||||
table->tab[dp] = kzalloc(sizeof(*q), GFP_ATOMIC);
|
table->tab[dp] = q = *prealloc;
|
||||||
if (table->tab[dp] == NULL)
|
*prealloc = NULL;
|
||||||
|
if (!q)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = table->tab[dp];
|
|
||||||
q->DP = dp;
|
q->DP = dp;
|
||||||
q->prio = prio;
|
q->prio = prio;
|
||||||
q->limit = ctl->limit;
|
q->limit = ctl->limit;
|
||||||
|
@ -421,6 +422,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
|
||||||
int err, prio = GRED_DEF_PRIO;
|
int err, prio = GRED_DEF_PRIO;
|
||||||
u8 *stab;
|
u8 *stab;
|
||||||
u32 max_P;
|
u32 max_P;
|
||||||
|
struct gred_sched_data *prealloc;
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -460,9 +462,10 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
|
||||||
prio = ctl->prio;
|
prio = ctl->prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
|
||||||
sch_tree_lock(sch);
|
sch_tree_lock(sch);
|
||||||
|
|
||||||
err = gred_change_vq(sch, ctl->DP, ctl, prio, stab, max_P);
|
err = gred_change_vq(sch, ctl->DP, ctl, prio, stab, max_P, &prealloc);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto errout_locked;
|
goto errout_locked;
|
||||||
|
|
||||||
|
@ -476,6 +479,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
|
||||||
|
|
||||||
errout_locked:
|
errout_locked:
|
||||||
sch_tree_unlock(sch);
|
sch_tree_unlock(sch);
|
||||||
|
kfree(prealloc);
|
||||||
errout:
|
errout:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue