Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: xiangxia.m.yue@gmail.com
To: xiyou.wangcong@gmail.com, jhs@mojatatu.com
Cc: netdev@vger.kernel.org, Tonghao Zhang <xiangxia.m.yue@gmail.com>
Subject: [net-next 2/2] qdisc: add tracepoint qdisc:qdisc_requeue for requeued SKBs
Date: Sun, 11 Jul 2021 13:00:07 +0800	[thread overview]
Message-ID: <20210711050007.1200-2-xiangxia.m.yue@gmail.com> (raw)
In-Reply-To: <20210711050007.1200-1-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

The main purpose of this tracepoint is to monitor what,
how many and why packets were requeued. The txq_state can
be used for determining the reason for packets requeued.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 include/trace/events/qdisc.h | 32 ++++++++++++++++++++++++++++++++
 net/sched/sch_generic.c      |  8 +++++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/include/trace/events/qdisc.h b/include/trace/events/qdisc.h
index b0e76237bb74..c6187a8fc103 100644
--- a/include/trace/events/qdisc.h
+++ b/include/trace/events/qdisc.h
@@ -78,6 +78,38 @@ TRACE_EVENT(qdisc_dequeue,
 		  __entry->txq_state, __entry->packets, __entry->skbaddr )
 );
 
+TRACE_EVENT(qdisc_requeue,
+
+	TP_PROTO(struct sk_buff *skb, struct Qdisc *qdisc,
+		 const struct netdev_queue *txq),
+
+	TP_ARGS(skb, qdisc, txq),
+
+	TP_STRUCT__entry(
+		__field(	struct Qdisc *,		qdisc	)
+		__field(const	struct netdev_queue *,	txq	)
+		__field(	void *,			skbaddr	)
+		__field(	int,			ifindex	)
+		__field(	u32,			handle	)
+		__field(	u32,			parent	)
+		__field(	unsigned long,		txq_state)
+	),
+
+	TP_fast_assign(
+		__entry->qdisc		= qdisc;
+		__entry->txq		= txq;
+		__entry->skbaddr	= skb;
+		__entry->ifindex	= txq->dev ? txq->dev->ifindex : 0;
+		__entry->handle		= qdisc->handle;
+		__entry->parent		= qdisc->parent;
+		__entry->txq_state	= txq->state;
+	),
+
+	TP_printk("requeue ifindex=%d qdisc handle=0x%X parent=0x%X txq_state=0x%lX skbaddr=%p",
+		  __entry->ifindex, __entry->handle, __entry->parent,
+		  __entry->txq_state, __entry->skbaddr)
+);
+
 TRACE_EVENT(qdisc_reset,
 
 	TP_PROTO(struct Qdisc *q),
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 75605075178f..0701d1e9d221 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -137,7 +137,8 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc *q,
 		spin_unlock(lock);
 }
 
-static inline void dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
+static inline void dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q,
+				   struct netdev_queue *txq)
 {
 	spinlock_t *lock = NULL;
 
@@ -149,6 +150,7 @@ static inline void dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
 	while (skb) {
 		struct sk_buff *next = skb->next;
 
+		trace_qdisc_requeue(skb, q, txq);
 		__skb_queue_tail(&q->gso_skb, skb);
 
 		/* it's still part of the queue */
@@ -325,7 +327,7 @@ bool sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
 		if (root_lock)
 			spin_lock(root_lock);
 
-		dev_requeue_skb(skb, q);
+		dev_requeue_skb(skb, q, txq);
 		return false;
 	}
 #endif
@@ -353,7 +355,7 @@ bool sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
 			net_warn_ratelimited("BUG %s code %d qlen %d\n",
 					     dev->name, ret, q->q.qlen);
 
-		dev_requeue_skb(skb, q);
+		dev_requeue_skb(skb, q, txq);
 		return false;
 	}
 
-- 
2.27.0


  reply	other threads:[~2021-07-11  5:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11  5:00 [net-next 1/2] qdisc: add tracepoint qdisc:qdisc_enqueue for enqueued SKBs xiangxia.m.yue
2021-07-11  5:00 ` xiangxia.m.yue [this message]
2021-07-12  3:51   ` [net-next 2/2] qdisc: add tracepoint qdisc:qdisc_requeue for requeued SKBs Cong Wang
2021-07-12  4:17     ` Tonghao Zhang
2021-07-13  2:06       ` Tonghao Zhang
2021-07-15  4:24         ` Cong Wang
2021-07-11 18:24 ` [net-next 1/2] qdisc: add tracepoint qdisc:qdisc_enqueue for enqueued SKBs Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210711050007.1200-2-xiangxia.m.yue@gmail.com \
    --to=xiangxia.m.yue@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    --subject='Re: [net-next 2/2] qdisc: add tracepoint qdisc:qdisc_requeue for requeued SKBs' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).