]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net_sched: add a tracepoint for qdisc creation
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 27 May 2020 04:35:25 +0000 (21:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 22:05:49 +0000 (15:05 -0700)
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>
include/trace/events/qdisc.h
net/sched/sch_api.c
net/sched/sch_generic.c

index 2b948801afa33f48fd1183983b4d211f04656564..330d32d84485b953944adf2b99e2e627b77dab0a 100644 (file)
@@ -96,6 +96,29 @@ TRACE_EVENT(qdisc_destroy,
                  TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle))
 );
 
+TRACE_EVENT(qdisc_create,
+
+       TP_PROTO(const struct Qdisc_ops *ops, struct net_device *dev, u32 parent),
+
+       TP_ARGS(ops, dev, parent),
+
+       TP_STRUCT__entry(
+               __string(       dev,            dev->name       )
+               __string(       kind,           ops->id         )
+               __field(        u32,            parent          )
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev, dev->name);
+               __assign_str(kind, ops->id);
+               __entry->parent = parent;
+       ),
+
+       TP_printk("dev=%s kind=%s parent=%x:%x",
+                 __get_str(dev), __get_str(kind),
+                 TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent))
+);
+
 #endif /* _TRACE_QDISC_H */
 
 /* This part must be outside protection */
index 0d99df1e764db812f5dfc78a9c54832c0f676f70..9a3449b56bd603ce900fac47ea9f3247e11ba7ef 100644 (file)
@@ -32,6 +32,8 @@
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
 
+#include <trace/events/qdisc.h>
+
 /*
 
    Short review.
@@ -1283,6 +1285,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
        }
 
        qdisc_hash_add(sch, false);
+       trace_qdisc_create(ops, dev, parent);
 
        return sch;
 
index abaa446ed01a6d7a21276bdd3f528ea2c0aeec16..a4271e47f220b38c4ef7bb01058ef486538a1992 100644 (file)
@@ -896,8 +896,10 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
        }
        sch->parent = parentid;
 
-       if (!ops->init || ops->init(sch, NULL, extack) == 0)
+       if (!ops->init || ops->init(sch, NULL, extack) == 0) {
+               trace_qdisc_create(ops, dev_queue->dev, parentid);
                return sch;
+       }
 
        qdisc_put(sch);
        return NULL;