Skip to content

Commit 0c8d13a

Browse files
Jakub Kicinskidavem330
authored andcommitted
net: sched: red: delay destroying child qdisc on replace
Move destroying of the old child qdisc outside of the sch_tree_lock() section. This should improve the software qdisc replace but is even more important for offloads. Firstly calling offloads under a spin lock is best avoided. Secondly the destroy event of existing child would have been sent to the offload device before the replace, causing confusion. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: John Hurley <john.hurley@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9da93ec commit 0c8d13a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/sched/sch_red.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ static const struct nla_policy red_policy[TCA_RED_MAX + 1] = {
193193
static int red_change(struct Qdisc *sch, struct nlattr *opt,
194194
struct netlink_ext_ack *extack)
195195
{
196+
struct Qdisc *old_child = NULL, *child = NULL;
196197
struct red_sched_data *q = qdisc_priv(sch);
197198
struct nlattr *tb[TCA_RED_MAX + 1];
198199
struct tc_red_qopt *ctl;
199-
struct Qdisc *child = NULL;
200200
int err;
201201
u32 max_P;
202202

@@ -233,7 +233,7 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt,
233233
if (child) {
234234
qdisc_tree_reduce_backlog(q->qdisc, q->qdisc->q.qlen,
235235
q->qdisc->qstats.backlog);
236-
qdisc_put(q->qdisc);
236+
old_child = q->qdisc;
237237
q->qdisc = child;
238238
}
239239

@@ -252,7 +252,11 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt,
252252
red_start_of_idle_period(&q->vars);
253253

254254
sch_tree_unlock(sch);
255+
255256
red_offload(sch, true);
257+
258+
if (old_child)
259+
qdisc_put(old_child);
256260
return 0;
257261
}
258262

0 commit comments

Comments
 (0)