mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Juri Lelli <juri.lelli@gmail.com>,
	Clark Williams <williams@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to show current bandwidths
Date: Mon, 01 Feb 2016 15:26:28 -0500	[thread overview]
Message-ID: <20160201202742.317361821@goodmis.org> (raw)
In-Reply-To: <20160201202624.079532484@goodmis.org>

[-- Attachment #1: 0004-sched-Add-debugfs-sched-deadline_bw-file-to-show-cur.patch --]
[-- Type: text/plain, Size: 3035 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Add a /sys/kernel/debug/sched directory and place a deadline_bw file there
that shows the current bandwidths of the CPUs for SCHED_DEADLINE tasks.

  # cat /sys/kernel/debug/sched/deadline_bw
  CPU[0]:
    bw:       996147
    total_bw: 0
  CPU[1]:
    bw:       996147
    total_bw: 0
  CPU[2]:
    bw:       996147
    total_bw: 0
  CPU[3]:
    bw:       996147
    total_bw: 0
  CPU[4]:
    bw:       996147
    total_bw: 0
  CPU[5]:
    bw:       996147
    total_bw: 0
  CPU[6]:
    bw:       996147
    total_bw: 0
  CPU[7]:
    bw:       996147
    total_bw: 0

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/sched/debug.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 68838495624f..a6ce364ba9b9 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -1070,3 +1070,103 @@ void proc_sched_set_task(struct task_struct *p)
 	memset(&p->se.statistics, 0, sizeof(p->se.statistics));
 #endif
 }
+
+#ifdef CONFIG_DEBUG_FS
+
+
+static void *dl_next(struct seq_file *m, void *v, loff_t *pos)
+{
+	long cpu = (long)v;
+
+	/* to keep from returning zero, v is always cpu + 1 */
+	cpu--;
+	cpu = cpumask_next(cpu, cpu_possible_mask);
+
+	(*pos)++;
+
+	if (cpu >= num_possible_cpus())
+		cpu = 0;
+	else
+		cpu++;
+
+	return (void *)cpu;
+}
+
+static void *dl_start(struct seq_file *m, loff_t *pos)
+{
+	long cpu = 1;
+	loff_t l = 0;
+
+	for (; cpu && l < *pos; cpu = (long)dl_next(m, (void *)cpu, &l))
+			;
+	return (void *)cpu;
+}
+
+static void dl_stop(struct seq_file *m, void *p)
+{
+}
+
+static int dl_show(struct seq_file *m, void *v)
+{
+	struct rq *rq;
+	long cpu = (long)v;
+	struct dl_bw *dl_bw;
+
+	if (!cpu)
+		return 0;
+
+	/* to keep from returning zero, v is always cpu + 1 */
+	cpu--;
+	rq = cpu_rq(cpu);
+	raw_spin_lock_irq(&rq->lock);
+#ifdef CONFIG_SMP
+	dl_bw = &rq->rd->dl_bw;
+#else
+	dl_bw = &rq->dl.dl_bw;
+#endif
+	seq_printf(m, "CPU[%ld]:\n", cpu);
+	seq_printf(m, "  bw:       %lld\n", dl_bw->bw);
+	seq_printf(m, "  total_bw: %lld\n", dl_bw->total_bw);
+	raw_spin_unlock_irq(&rq->lock);
+
+	return 0;
+}
+
+static const struct seq_operations deadline_bw_seq_ops = {
+	.start		= dl_start,
+	.next		= dl_next,
+	.stop		= dl_stop,
+	.show		= dl_show,
+};
+
+static int deadline_bw_open(struct inode *inode, struct file *file)
+{
+	int ret;
+
+	ret = seq_open(file, &deadline_bw_seq_ops);
+	return ret;
+}
+
+static const struct file_operations deadline_bw_fops = {
+	.open		= deadline_bw_open,
+	.read		= seq_read,
+	.llseek		= no_llseek,
+};
+
+static struct dentry *sched_debugfs;
+
+static __init int sched_init_debugfs(void)
+{
+	sched_debugfs = debugfs_create_dir("sched", NULL);
+
+	if (WARN_ON(!sched_debugfs)) {
+		return 0;
+	}
+
+	debugfs_create_file("deadline_bw", 0444, sched_debugfs, NULL,
+			    &deadline_bw_fops);
+	return 0;
+}
+fs_initcall(sched_init_debugfs);
+
+#endif /*CONFIG_DEBUG_FS */
-- 
2.6.4

  parent reply	other threads:[~2016-02-01 20:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 20:26 [RFC][PATCH 0/4] sched: Display deadline bandwidth and other SCHED_DEBUG clean up Steven Rostedt
2016-02-01 20:26 ` [RFC][PATCH 1/4] sched: Move sched_feature file setup into debug.c Steven Rostedt
2016-02-01 20:26 ` [RFC][PATCH 2/4] sched: Move sched_domain_sysctl to debug.c Steven Rostedt
2016-02-01 20:26 ` [RFC][PATCH 3/4] sched: Move sched_domain_debug into debug.c Steven Rostedt
2016-02-01 20:26 ` Steven Rostedt [this message]
2016-02-01 22:17   ` [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to show current bandwidths Peter Zijlstra
2016-02-01 22:38     ` Steven Rostedt
2016-02-01 22:41       ` Peter Zijlstra
2016-02-03 10:12         ` Ingo Molnar
2016-02-03 13:21           ` Steven Rostedt
2016-02-01 22:18   ` Peter Zijlstra

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=20160201202742.317361821@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /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®