sched/debug: Add new tracepoints to track PELT at rq level
authorQais Yousef <qais.yousef@arm.com>
Tue, 4 Jun 2019 11:14:56 +0000 (12:14 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 24 Jun 2019 17:23:41 +0000 (19:23 +0200)
The new tracepoints allow tracking PELT signals at rq level for all
scheduling classes + irq.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavankumar Kondeti <pkondeti@codeaurora.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Perret <quentin.perret@arm.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Uwe Kleine-Konig <u.kleine-koenig@pengutronix.de>
Link: https://lkml.kernel.org/r/20190604111459.2862-4-qais.yousef@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/trace/events/sched.h
kernel/sched/fair.c
kernel/sched/pelt.c

index c8c7c7efb4875d81823ca6d562f35ba22ec314a7..520b89d384ecb44dcc2b334d4fc8b31eeb7a21ce 100644 (file)
@@ -594,6 +594,29 @@ TRACE_EVENT(sched_wake_idle_without_ipi,
 
        TP_printk("cpu=%d", __entry->cpu)
 );
+
+/*
+ * Following tracepoints are not exported in tracefs and provide hooking
+ * mechanisms only for testing and debugging purposes.
+ *
+ * Postfixed with _tp to make them easily identifiable in the code.
+ */
+DECLARE_TRACE(pelt_cfs_tp,
+       TP_PROTO(struct cfs_rq *cfs_rq),
+       TP_ARGS(cfs_rq));
+
+DECLARE_TRACE(pelt_rt_tp,
+       TP_PROTO(struct rq *rq),
+       TP_ARGS(rq));
+
+DECLARE_TRACE(pelt_dl_tp,
+       TP_PROTO(struct rq *rq),
+       TP_ARGS(rq));
+
+DECLARE_TRACE(pelt_irq_tp,
+       TP_PROTO(struct rq *rq),
+       TP_ARGS(rq));
+
 #endif /* _TRACE_SCHED_H */
 
 /* This part must be outside protection */
index 461c3e9a67b2612eb681c8932f4fa27815220caf..e883d7e17e3643afeb5ce8a5c2c7b7827e6fdd62 100644 (file)
@@ -3347,6 +3347,8 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)
        update_tg_cfs_util(cfs_rq, se, gcfs_rq);
        update_tg_cfs_runnable(cfs_rq, se, gcfs_rq);
 
+       trace_pelt_cfs_tp(cfs_rq);
+
        return 1;
 }
 
@@ -3499,6 +3501,8 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
        add_tg_cfs_propagate(cfs_rq, se->avg.load_sum);
 
        cfs_rq_util_change(cfs_rq, flags);
+
+       trace_pelt_cfs_tp(cfs_rq);
 }
 
 /**
@@ -3518,6 +3522,8 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
        add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum);
 
        cfs_rq_util_change(cfs_rq, 0);
+
+       trace_pelt_cfs_tp(cfs_rq);
 }
 
 /*
index 42ea66b07b1d6c45a733bd168ecd062af9e929fd..4e961b55b5ea5deca0676ee606691f5b5357b03a 100644 (file)
@@ -28,6 +28,8 @@
 #include "sched.h"
 #include "pelt.h"
 
+#include <trace/events/sched.h>
+
 /*
  * Approximate:
  *   val * y^n,    where y^32 ~= 0.5 (~1 scheduling period)
@@ -292,6 +294,7 @@ int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq)
                                cfs_rq->curr != NULL)) {
 
                ___update_load_avg(&cfs_rq->avg, 1, 1);
+               trace_pelt_cfs_tp(cfs_rq);
                return 1;
        }
 
@@ -317,6 +320,7 @@ int update_rt_rq_load_avg(u64 now, struct rq *rq, int running)
                                running)) {
 
                ___update_load_avg(&rq->avg_rt, 1, 1);
+               trace_pelt_rt_tp(rq);
                return 1;
        }
 
@@ -340,6 +344,7 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running)
                                running)) {
 
                ___update_load_avg(&rq->avg_dl, 1, 1);
+               trace_pelt_dl_tp(rq);
                return 1;
        }
 
@@ -388,8 +393,10 @@ int update_irq_load_avg(struct rq *rq, u64 running)
                                1,
                                1);
 
-       if (ret)
+       if (ret) {
                ___update_load_avg(&rq->avg_irq, 1, 1);
+               trace_pelt_irq_tp(rq);
+       }
 
        return ret;
 }