From: Qais Yousef <qais.yousef@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
Pavankumar Kondeti <pkondeti@codeaurora.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Uwe Kleine-Konig <u.kleine-koenig@pengutronix.de>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Quentin Perret <quentin.perret@arm.com>,
Qais Yousef <qais.yousef@arm.com>
Subject: [PATCH v2 4/7] sched: Add pelt_rq tracepoint
Date: Fri, 10 May 2019 12:30:10 +0100 [thread overview]
Message-ID: <20190510113013.1193-5-qais.yousef@arm.com> (raw)
In-Reply-To: <20190510113013.1193-1-qais.yousef@arm.com>
The new tracepoint allows tracking PELT signals at rq level for all
scheduling classes.
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---
include/trace/events/sched.h | 9 ++++++
kernel/sched/fair.c | 9 ++++--
kernel/sched/pelt.c | 4 +++
kernel/sched/sched_tracepoints.h | 50 ++++++++++++++++++++++++++++++++
4 files changed, 70 insertions(+), 2 deletions(-)
create mode 100644 kernel/sched/sched_tracepoints.h
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 9a4bdfadab07..50346098e026 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -587,6 +587,15 @@ 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.
+ */
+DECLARE_TRACE(pelt_rq,
+ TP_PROTO(int cpu, const char *path, struct sched_avg *avg),
+ TP_ARGS(cpu, path, avg));
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2b4963bbeab4..34782e37387c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -21,8 +21,7 @@
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
*/
#include "sched.h"
-
-#include <trace/events/sched.h>
+#include "sched_tracepoints.h"
/*
* Targeted preemption latency for CPU-bound tasks:
@@ -3139,6 +3138,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);
+ sched_trace_pelt_cfs_rq(cfs_rq);
+
return 1;
}
@@ -3291,6 +3292,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);
+
+ sched_trace_pelt_cfs_rq(cfs_rq);
}
/**
@@ -3310,6 +3313,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);
+
+ sched_trace_pelt_cfs_rq(cfs_rq);
}
/*
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index befce29bd882..39418e80699f 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -26,6 +26,7 @@
#include <linux/sched.h>
#include "sched.h"
+#include "sched_tracepoints.h"
#include "pelt.h"
/*
@@ -292,6 +293,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);
+ sched_trace_pelt_cfs_rq(cfs_rq);
return 1;
}
@@ -317,6 +319,7 @@ int update_rt_rq_load_avg(u64 now, struct rq *rq, int running)
running)) {
___update_load_avg(&rq->avg_rt, 1, 1);
+ sched_trace_pelt_rt_rq(rq);
return 1;
}
@@ -340,6 +343,7 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running)
running)) {
___update_load_avg(&rq->avg_dl, 1, 1);
+ sched_trace_pelt_dl_rq(rq);
return 1;
}
diff --git a/kernel/sched/sched_tracepoints.h b/kernel/sched/sched_tracepoints.h
new file mode 100644
index 000000000000..5f804629d3b7
--- /dev/null
+++ b/kernel/sched/sched_tracepoints.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Scheduler tracepoints that are probe-able only and aren't exported ABI in
+ * tracefs.
+ */
+#ifndef __SCHED_TRACEPOINTS_H
+#define __SCHED_TRACEPOINTS_H
+
+#include <trace/events/sched.h>
+
+#define SCHED_TP_PATH_LEN 20
+
+
+#ifdef CONFIG_SMP
+static __always_inline void sched_trace_pelt_cfs_rq(struct cfs_rq *cfs_rq)
+{
+ if (trace_pelt_rq_enabled()) {
+ int cpu = cpu_of(rq_of(cfs_rq));
+ char path[SCHED_TP_PATH_LEN];
+
+ cfs_rq_tg_path(cfs_rq, path, SCHED_TP_PATH_LEN);
+ trace_pelt_rq(cpu, path, &cfs_rq->avg);
+ }
+}
+
+static __always_inline void sched_trace_pelt_rt_rq(struct rq *rq)
+{
+ if (trace_pelt_rq_enabled()) {
+ int cpu = cpu_of(rq);
+
+ trace_pelt_rq(cpu, NULL, &rq->avg_rt);
+ }
+}
+
+static __always_inline void sched_trace_pelt_dl_rq(struct rq *rq)
+{
+ if (trace_pelt_rq_enabled()) {
+ int cpu = cpu_of(rq);
+
+ trace_pelt_rq(cpu, NULL, &rq->avg_dl);
+ }
+}
+#else
+static inline void sched_trace_pelt_cfs_rq(struct cfs_rq *cfs_rq) {}
+static inline void sched_trace_pelt_rt_rq(struct rq *rq) {}
+static inline void sched_trace_pelt_dl_rq(struct rq *rq) {}
+#endif /* CONFIG_SMP */
+
+
+#endif /* __SCHED_TRACEPOINTS_H */
--
2.17.1
next prev parent reply other threads:[~2019-05-10 11:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 11:30 [PATCH v2 0/7] Add new tracepoints required for EAS testing Qais Yousef
2019-05-10 11:30 ` [PATCH v2 1/7] sched: autogroup: Make autogroup_path() always available Qais Yousef
2019-05-10 11:30 ` [PATCH v2 2/7] sched: fair: move helper functions into fair.h Qais Yousef
2019-05-10 11:30 ` [PATCH v2 3/7] sched: fair.h: add a new cfs_rq_tg_path() Qais Yousef
2019-05-10 11:30 ` Qais Yousef [this message]
2019-05-13 12:14 ` [PATCH v2 4/7] sched: Add pelt_rq tracepoint Peter Zijlstra
2019-05-13 12:48 ` Qais Yousef
2019-05-13 13:37 ` Dietmar Eggemann
2019-05-10 11:30 ` [PATCH v2 5/7] sched: Add pelt_se tracepoint Qais Yousef
2019-05-10 11:30 ` [PATCH v2 6/7] sched: Add sched_overutilized tracepoint Qais Yousef
2019-05-13 12:08 ` Peter Zijlstra
2019-05-13 12:42 ` Qais Yousef
2019-05-10 11:30 ` [PATCH v2 7/7] sched: export the newly added tracepoints Qais Yousef
2019-05-13 12:28 ` [PATCH v2 0/7] Add new tracepoints required for EAS testing Peter Zijlstra
2019-05-13 13:42 ` Qais Yousef
2019-05-13 15:06 ` Peter Zijlstra
2019-05-13 15:18 ` Qais Yousef
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=20190510113013.1193-5-qais.yousef@arm.com \
--to=qais.yousef@arm.com \
--cc=bigeasy@linutronix.de \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pkondeti@codeaurora.org \
--cc=quentin.perret@arm.com \
--cc=rostedt@goodmis.org \
--cc=u.kleine-koenig@pengutronix.de \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®