Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1323471

[RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to show current bandwidths

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to show current bandwidths
Date 2016-02-01 21:40 +0100
Message-ID <qXtqq-8iB-13@gated-at.bofh.it> (permalink)
References <qXtgK-8eB-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC][PATCH 0/4] sched: Display deadline bandwidth and other SCHED_DEBUG clean up Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 21:30 +0100
  [RFC][PATCH 1/4] sched: Move sched_feature file setup into debug.c Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 21:40 +0100
  [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to show current bandwidths Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 21:40 +0100
    Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Peter Zijlstra <peterz@infradead.org> - 2016-02-01 23:20 +0100
      Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 23:40 +0100
        Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Peter Zijlstra <peterz@infradead.org> - 2016-02-01 23:50 +0100
          Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Ingo Molnar <mingo@kernel.org> - 2016-02-03 11:20 +0100
            Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Steven Rostedt <rostedt@goodmis.org> - 2016-02-03 14:30 +0100
    Re: [RFC][PATCH 4/4] sched: Add debugfs/sched/deadline_bw file to  show current bandwidths Peter Zijlstra <peterz@infradead.org> - 2016-02-01 23:20 +0100
  [RFC][PATCH 2/4] sched: Move sched_domain_sysctl to debug.c Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 21:40 +0100
  [RFC][PATCH 3/4] sched: Move sched_domain_debug into debug.c Steven Rostedt <rostedt@goodmis.org> - 2016-02-01 21:40 +0100

csiph-web