Skip to content

Commit f5a7833

Browse files
congwangdavem330
authored andcommitted
net_sched: add a tracepoint for qdisc creation
With this tracepoint, we could know when qdisc's are created, especially those default qdisc's. Sample output: tc-736 [001] ...1 56.230107: qdisc_create: dev=ens3 kind=pfifo parent=1:0 tc-736 [001] ...1 56.230113: qdisc_create: dev=ens3 kind=hfsc parent=ffff:ffff tc-738 [001] ...1 56.256816: qdisc_create: dev=ens3 kind=pfifo parent=1:100 tc-739 [001] ...1 56.267584: qdisc_create: dev=ens3 kind=pfifo parent=1:200 tc-740 [001] ...1 56.279649: qdisc_create: dev=ens3 kind=fq_codel parent=1:100 tc-741 [001] ...1 56.289996: qdisc_create: dev=ens3 kind=pfifo_fast parent=1:200 tc-745 [000] .N.1 111.687483: qdisc_create: dev=ens3 kind=ingress parent=ffff:fff1 Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a34dac0 commit f5a7833

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

include/trace/events/qdisc.h

+23
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,29 @@ TRACE_EVENT(qdisc_destroy,
9696
TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle))
9797
);
9898

99+
TRACE_EVENT(qdisc_create,
100+
101+
TP_PROTO(const struct Qdisc_ops *ops, struct net_device *dev, u32 parent),
102+
103+
TP_ARGS(ops, dev, parent),
104+
105+
TP_STRUCT__entry(
106+
__string( dev, dev->name )
107+
__string( kind, ops->id )
108+
__field( u32, parent )
109+
),
110+
111+
TP_fast_assign(
112+
__assign_str(dev, dev->name);
113+
__assign_str(kind, ops->id);
114+
__entry->parent = parent;
115+
),
116+
117+
TP_printk("dev=%s kind=%s parent=%x:%x",
118+
__get_str(dev), __get_str(kind),
119+
TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent))
120+
);
121+
99122
#endif /* _TRACE_QDISC_H */
100123

101124
/* This part must be outside protection */

net/sched/sch_api.c

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <net/pkt_sched.h>
3333
#include <net/pkt_cls.h>
3434

35+
#include <trace/events/qdisc.h>
36+
3537
/*
3638
3739
Short review.
@@ -1283,6 +1285,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
12831285
}
12841286

12851287
qdisc_hash_add(sch, false);
1288+
trace_qdisc_create(ops, dev, parent);
12861289

12871290
return sch;
12881291

net/sched/sch_generic.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,10 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
896896
}
897897
sch->parent = parentid;
898898

899-
if (!ops->init || ops->init(sch, NULL, extack) == 0)
899+
if (!ops->init || ops->init(sch, NULL, extack) == 0) {
900+
trace_qdisc_create(ops, dev_queue->dev, parentid);
900901
return sch;
902+
}
901903

902904
qdisc_put(sch);
903905
return NULL;

0 commit comments

Comments
 (0)