]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net_sched: add tracepoints for qdisc_reset() and qdisc_destroy()
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 27 May 2020 04:35:24 +0000 (21:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 22:05:49 +0000 (15:05 -0700)
Add two tracepoints for qdisc_reset() and qdisc_destroy() to track
qdisc resetting and destroying.

Sample output:

  tc-756   [000] ...3   138.355662: qdisc_reset: dev=ens3 kind=pfifo_fast parent=ffff:ffff handle=0:0
  tc-756   [000] ...1   138.355720: qdisc_reset: dev=ens3 kind=pfifo_fast parent=ffff:ffff handle=0:0
  tc-756   [000] ...1   138.355867: qdisc_reset: dev=ens3 kind=pfifo_fast parent=ffff:ffff handle=0:0
  tc-756   [000] ...1   138.355930: qdisc_destroy: dev=ens3 kind=pfifo_fast parent=ffff:ffff handle=0:0
  tc-757   [000] ...2   143.073780: qdisc_reset: dev=ens3 kind=fq_codel parent=ffff:ffff handle=8001:0
  tc-757   [000] ...1   143.073878: qdisc_reset: dev=ens3 kind=fq_codel parent=ffff:ffff handle=8001:0
  tc-757   [000] ...1   143.074114: qdisc_reset: dev=ens3 kind=fq_codel parent=ffff:ffff handle=8001:0
  tc-757   [000] ...1   143.074228: qdisc_destroy: dev=ens3 kind=fq_codel parent=ffff:ffff handle=8001:0

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_generic.c

index 0d1a9ebf55ba4415537a345867948a4d34b536c6..2b948801afa33f48fd1183983b4d211f04656564 100644 (file)
@@ -8,6 +8,8 @@
 #include <linux/netdevice.h>
 #include <linux/tracepoint.h>
 #include <linux/ftrace.h>
+#include <linux/pkt_sched.h>
+#include <net/sch_generic.h>
 
 TRACE_EVENT(qdisc_dequeue,
 
@@ -44,6 +46,56 @@ TRACE_EVENT(qdisc_dequeue,
                  __entry->txq_state, __entry->packets, __entry->skbaddr )
 );
 
+TRACE_EVENT(qdisc_reset,
+
+       TP_PROTO(struct Qdisc *q),
+
+       TP_ARGS(q),
+
+       TP_STRUCT__entry(
+               __string(       dev,            qdisc_dev(q)    )
+               __string(       kind,           q->ops->id      )
+               __field(        u32,            parent          )
+               __field(        u32,            handle          )
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev, qdisc_dev(q));
+               __assign_str(kind, q->ops->id);
+               __entry->parent = q->parent;
+               __entry->handle = q->handle;
+       ),
+
+       TP_printk("dev=%s kind=%s parent=%x:%x handle=%x:%x", __get_str(dev),
+                 __get_str(kind), TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent),
+                 TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle))
+);
+
+TRACE_EVENT(qdisc_destroy,
+
+       TP_PROTO(struct Qdisc *q),
+
+       TP_ARGS(q),
+
+       TP_STRUCT__entry(
+               __string(       dev,            qdisc_dev(q)    )
+               __string(       kind,           q->ops->id      )
+               __field(        u32,            parent          )
+               __field(        u32,            handle          )
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev, qdisc_dev(q));
+               __assign_str(kind, q->ops->id);
+               __entry->parent = q->parent;
+               __entry->handle = q->handle;
+       ),
+
+       TP_printk("dev=%s kind=%s parent=%x:%x handle=%x:%x", __get_str(dev),
+                 __get_str(kind), TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent),
+                 TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle))
+);
+
 #endif /* _TRACE_QDISC_H */
 
 /* This part must be outside protection */
index 7a0b06001e488f03a770f4b9d36a732c02de8ee2..abaa446ed01a6d7a21276bdd3f528ea2c0aeec16 100644 (file)
@@ -911,6 +911,8 @@ void qdisc_reset(struct Qdisc *qdisc)
        const struct Qdisc_ops *ops = qdisc->ops;
        struct sk_buff *skb, *tmp;
 
+       trace_qdisc_reset(qdisc);
+
        if (ops->reset)
                ops->reset(qdisc);
 
@@ -965,6 +967,8 @@ static void qdisc_destroy(struct Qdisc *qdisc)
        module_put(ops->owner);
        dev_put(qdisc_dev(qdisc));
 
+       trace_qdisc_destroy(qdisc);
+
        call_rcu(&qdisc->rcu, qdisc_free_cb);
 }