Skip to content

Commit 86bd446

Browse files
w1ldptrdavem330
authored andcommitted
net: sched: rename qdisc_destroy() to qdisc_put()
Current implementation of qdisc_destroy() decrements Qdisc reference counter and only actually destroy Qdisc if reference counter value reached zero. Rename qdisc_destroy() to qdisc_put() in order for it to better describe the way in which this function currently implemented and used. Extract code that deallocates Qdisc into new private qdisc_destroy() function. It is intended to be shared between regular qdisc_put() and its unlocked version that is introduced in next patch in this series. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6f99528 commit 86bd446

File tree

20 files changed

+47
-42
lines changed

20 files changed

+47
-42
lines changed

include/net/sch_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void dev_deactivate_many(struct list_head *head);
554554
struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
555555
struct Qdisc *qdisc);
556556
void qdisc_reset(struct Qdisc *qdisc);
557-
void qdisc_destroy(struct Qdisc *qdisc);
557+
void qdisc_put(struct Qdisc *qdisc);
558558
void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, unsigned int n,
559559
unsigned int len);
560560
struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,

net/sched/sch_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ static void notify_and_destroy(struct net *net, struct sk_buff *skb,
920920
qdisc_notify(net, skb, n, clid, old, new);
921921

922922
if (old)
923-
qdisc_destroy(old);
923+
qdisc_put(old);
924924
}
925925

926926
/* Graft qdisc "new" to class "classid" of qdisc "parent" or
@@ -973,7 +973,7 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
973973
qdisc_refcount_inc(new);
974974

975975
if (!ingress)
976-
qdisc_destroy(old);
976+
qdisc_put(old);
977977
}
978978

979979
skip:
@@ -1561,7 +1561,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
15611561
err = qdisc_graft(dev, p, skb, n, clid, q, NULL, extack);
15621562
if (err) {
15631563
if (q)
1564-
qdisc_destroy(q);
1564+
qdisc_put(q);
15651565
return err;
15661566
}
15671567

net/sched/sch_atm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
150150
pr_debug("atm_tc_put: destroying\n");
151151
list_del_init(&flow->list);
152152
pr_debug("atm_tc_put: qdisc %p\n", flow->q);
153-
qdisc_destroy(flow->q);
153+
qdisc_put(flow->q);
154154
tcf_block_put(flow->block);
155155
if (flow->sock) {
156156
pr_debug("atm_tc_put: f_count %ld\n",

net/sched/sch_cbq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ static void cbq_destroy_class(struct Qdisc *sch, struct cbq_class *cl)
14181418
WARN_ON(cl->filters);
14191419

14201420
tcf_block_put(cl->block);
1421-
qdisc_destroy(cl->q);
1421+
qdisc_put(cl->q);
14221422
qdisc_put_rtab(cl->R_tab);
14231423
gen_kill_estimator(&cl->rate_est);
14241424
if (cl != &q->link)

net/sched/sch_cbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static void cbs_destroy(struct Qdisc *sch)
379379
cbs_disable_offload(dev, q);
380380

381381
if (q->qdisc)
382-
qdisc_destroy(q->qdisc);
382+
qdisc_put(q->qdisc);
383383
}
384384

385385
static int cbs_dump(struct Qdisc *sch, struct sk_buff *skb)

net/sched/sch_drr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
134134
tca[TCA_RATE]);
135135
if (err) {
136136
NL_SET_ERR_MSG(extack, "Failed to replace estimator");
137-
qdisc_destroy(cl->qdisc);
137+
qdisc_put(cl->qdisc);
138138
kfree(cl);
139139
return err;
140140
}
@@ -153,7 +153,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
153153
static void drr_destroy_class(struct Qdisc *sch, struct drr_class *cl)
154154
{
155155
gen_kill_estimator(&cl->rate_est);
156-
qdisc_destroy(cl->qdisc);
156+
qdisc_put(cl->qdisc);
157157
kfree(cl);
158158
}
159159

net/sched/sch_dsmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void dsmark_destroy(struct Qdisc *sch)
412412
pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
413413

414414
tcf_block_put(p->block);
415-
qdisc_destroy(p->q);
415+
qdisc_put(p->q);
416416
if (p->mv != p->embedded)
417417
kfree(p->mv);
418418
}

net/sched/sch_fifo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
177177
if (q) {
178178
err = fifo_set_limit(q, limit);
179179
if (err < 0) {
180-
qdisc_destroy(q);
180+
qdisc_put(q);
181181
q = NULL;
182182
}
183183
}

net/sched/sch_generic.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
901901
if (!ops->init || ops->init(sch, NULL, extack) == 0)
902902
return sch;
903903

904-
qdisc_destroy(sch);
904+
qdisc_put(sch);
905905
return NULL;
906906
}
907907
EXPORT_SYMBOL(qdisc_create_dflt);
@@ -941,15 +941,11 @@ void qdisc_free(struct Qdisc *qdisc)
941941
kfree((char *) qdisc - qdisc->padded);
942942
}
943943

944-
void qdisc_destroy(struct Qdisc *qdisc)
944+
static void qdisc_destroy(struct Qdisc *qdisc)
945945
{
946946
const struct Qdisc_ops *ops = qdisc->ops;
947947
struct sk_buff *skb, *tmp;
948948

949-
if (qdisc->flags & TCQ_F_BUILTIN ||
950-
!refcount_dec_and_test(&qdisc->refcnt))
951-
return;
952-
953949
#ifdef CONFIG_NET_SCHED
954950
qdisc_hash_del(qdisc);
955951

@@ -976,7 +972,16 @@ void qdisc_destroy(struct Qdisc *qdisc)
976972

977973
qdisc_free(qdisc);
978974
}
979-
EXPORT_SYMBOL(qdisc_destroy);
975+
976+
void qdisc_put(struct Qdisc *qdisc)
977+
{
978+
if (qdisc->flags & TCQ_F_BUILTIN ||
979+
!refcount_dec_and_test(&qdisc->refcnt))
980+
return;
981+
982+
qdisc_destroy(qdisc);
983+
}
984+
EXPORT_SYMBOL(qdisc_put);
980985

981986
/* Attach toplevel qdisc to device queue. */
982987
struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
@@ -1270,7 +1275,7 @@ static void shutdown_scheduler_queue(struct net_device *dev,
12701275
rcu_assign_pointer(dev_queue->qdisc, qdisc_default);
12711276
dev_queue->qdisc_sleeping = qdisc_default;
12721277

1273-
qdisc_destroy(qdisc);
1278+
qdisc_put(qdisc);
12741279
}
12751280
}
12761281

@@ -1279,7 +1284,7 @@ void dev_shutdown(struct net_device *dev)
12791284
netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc);
12801285
if (dev_ingress_queue(dev))
12811286
shutdown_scheduler_queue(dev, dev_ingress_queue(dev), &noop_qdisc);
1282-
qdisc_destroy(dev->qdisc);
1287+
qdisc_put(dev->qdisc);
12831288
dev->qdisc = &noop_qdisc;
12841289

12851290
WARN_ON(timer_pending(&dev->watchdog_timer));

net/sched/sch_hfsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ hfsc_destroy_class(struct Qdisc *sch, struct hfsc_class *cl)
10921092
struct hfsc_sched *q = qdisc_priv(sch);
10931093

10941094
tcf_block_put(cl->block);
1095-
qdisc_destroy(cl->qdisc);
1095+
qdisc_put(cl->qdisc);
10961096
gen_kill_estimator(&cl->rate_est);
10971097
if (cl != &q->root)
10981098
kfree(cl);

0 commit comments

Comments
 (0)