Skip to contentSkip to conversation

sched: Display deadline bandwidth and other SCHED_DEBUG clean up

RFC PATCH Superseded Steven Rostedt 3 participants 11 messages Feb 1, 2016 – Feb 3, 2016 Scheduler

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Steven Rostedt

author reviewer
#0 lore raw

cover sched: Display deadline bandwidth and other SCHED_DEBUG clean up

I'm starting to play with SCHED_DEADLINE a bit and I'm able to cause a bandwidth "leak". Then I realized there's no way to examine what bandwidths are enabled on which CPUs. I decided to create a debugfs file that would display the deadline bandwidths. I created a debugfs/sched/ directory to place a "deadline_bw" file that displays the bandwidths of the CPUs in the following format:

 # 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

I created the debugfs/sched directory in case there's future scheduling data we would like to add, instead of cluttering up the debugfs root. There's already a sched_features file, but I did not want to move it because other tools may need it in its current location.

Before adding this code, I also realized there was a bit of SCHED_DEBUG code in the kernel/sched/core.c file, and decided to move that to kernel/sched/debug.c to clean the core.c file up a bit. Those patches are mostly orthognal to the deadline_bw file, but decided to group them together here.

Steven Rostedt (Red Hat) (4):
sched: Move sched_feature file setup into debug.c
sched: Move sched_domain_sysctl to debug.c
sched: Move sched_domain_debug into debug.c
sched: Add debugfs/sched/deadline_bw file to show current bandwidths

----

 kernel/sched/core.c  | 434 +------------------------------------------
 kernel/sched/debug.c | 511 +++++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sched/sched.h |  30 +++
 3 files changed, 542 insertions(+), 433 deletions(-)
author reviewer
#1 lore raw

RFC PATCH 1/4 sched: Move sched_feature file setup into debug.c

From: "Steven Rostedt (Red Hat)" <[email protected]>

As sched_feature is only created when SCHED_DEBUG is enabled, and the file debug.c is only compiled when SCHED_DEBUG is enabled, it makes sense to move sched_feature setup into that file and get rid of the #ifdef.

---
 kernel/sched/core.c  | 133 ---------------------------------------------------
 kernel/sched/debug.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 131 insertions(+), 133 deletions(-)
kernel/sched/core.c +0 -133
index 63d3a24e081a..c49e64c4675e 100644
@@ -66,7 +66,6 @@
 #include <linux/pagemap.h>
 #include <linux/hrtimer.h>
 #include <linux/tick.h>
-#include <linux/debugfs.h>
 #include <linux/ctype.h>
 #include <linux/ftrace.h>
 #include <linux/slab.h>
@@ -124,138 +123,6 @@ const_debug unsigned int sysctl_sched_features =
 
 #undef SCHED_FEAT
 
-#ifdef CONFIG_SCHED_DEBUG
-#define SCHED_FEAT(name, enabled)	\
-	#name ,
-
-static const char * const sched_feat_names[] = {
-#include "features.h"
-};
-
-#undef SCHED_FEAT
-
-static int sched_feat_show(struct seq_file *m, void *v)
-{
-	int i;
-
-	for (i = 0; i < __SCHED_FEAT_NR; i++) {
-		if (!(sysctl_sched_features & (1UL << i)))
-			seq_puts(m, "NO_");
-		seq_printf(m, "%s ", sched_feat_names[i]);
-	}
-	seq_puts(m, "\n");
-
-	return 0;
-}
-
-#ifdef HAVE_JUMP_LABEL
-
-#define jump_label_key__true  STATIC_KEY_INIT_TRUE
-#define jump_label_key__false STATIC_KEY_INIT_FALSE
-
-#define SCHED_FEAT(name, enabled)	\
-	jump_label_key__##enabled ,
-
-struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
-#include "features.h"
-};
-
-#undef SCHED_FEAT
-
-static void sched_feat_disable(int i)
-{
-	static_key_disable(&sched_feat_keys[i]);
-}
-
-static void sched_feat_enable(int i)
-{
-	static_key_enable(&sched_feat_keys[i]);
-}
-#else
-static void sched_feat_disable(int i) { };
-static void sched_feat_enable(int i) { };
-#endif /* HAVE_JUMP_LABEL */
-
-static int sched_feat_set(char *cmp)
-{
-	int i;
-	int neg = 0;
-
-	if (strncmp(cmp, "NO_", 3) == 0) {
-		neg = 1;
-		cmp += 3;
-	}
-
-	for (i = 0; i < __SCHED_FEAT_NR; i++) {
-		if (strcmp(cmp, sched_feat_names[i]) == 0) {
-			if (neg) {
-				sysctl_sched_features &= ~(1UL << i);
-				sched_feat_disable(i);
-			} else {
-				sysctl_sched_features |= (1UL << i);
-				sched_feat_enable(i);
-			}
-			break;
-		}
-	}
-
-	return i;
-}
-
-static ssize_t
-sched_feat_write(struct file *filp, const char __user *ubuf,
-		size_t cnt, loff_t *ppos)
-{
-	char buf[64];
-	char *cmp;
-	int i;
-	struct inode *inode;
-
-	if (cnt > 63)
-		cnt = 63;
-
-	if (copy_from_user(&buf, ubuf, cnt))
-		return -EFAULT;
-
-	buf[cnt] = 0;
-	cmp = strstrip(buf);
-
-	/* Ensure the static_key remains in a consistent state */
-	inode = file_inode(filp);
-	inode_lock(inode);
-	i = sched_feat_set(cmp);
-	inode_unlock(inode);
-	if (i == __SCHED_FEAT_NR)
-		return -EINVAL;
-
-	*ppos += cnt;
-
-	return cnt;
-}
-
-static int sched_feat_open(struct inode *inode, struct file *filp)
-{
-	return single_open(filp, sched_feat_show, NULL);
-}
-
-static const struct file_operations sched_feat_fops = {
-	.open		= sched_feat_open,
-	.write		= sched_feat_write,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
-
-static __init int sched_init_debug(void)
-{
-	debugfs_create_file("sched_features", 0644, NULL, NULL,
-			&sched_feat_fops);
-
-	return 0;
-}
-late_initcall(sched_init_debug);
-#endif /* CONFIG_SCHED_DEBUG */
-
 /*
  * Number of tasks to iterate in a single balance run.
  * Limited because this is done with IRQs disabled.
kernel/sched/debug.c +131 -0

143 lines not on this page · raw message

Signature · 1 line
2.6.4
author reviewer
#2 lore raw

RFC PATCH 2/4 sched: Move sched_domain_sysctl to debug.c

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The sched_domain_sysctl setup is only enabled when SCHED_DEBUG is configured. As debug.c is only compiled when SCHED_DEBUG is configured as well, move the setup of sched_domain_sysctl into that file.

Note, the (un)register_sched_domain_sysctl() functions had to be changed from static to allow access to them from core.c.

---
 kernel/sched/core.c  | 178 ---------------------------------------------------
 kernel/sched/debug.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sched/sched.h |  13 ++++
 3 files changed, 186 insertions(+), 178 deletions(-)
kernel/sched/core.c +0 -178
index c49e64c4675e..9c6d976d94f0 100644
@@ -70,7 +70,6 @@
 #include <linux/ftrace.h>
 #include <linux/slab.h>
 #include <linux/init_task.h>
-#include <linux/binfmts.h>
 #include <linux/context_tracking.h>
 #include <linux/compiler.h>
 
@@ -5272,183 +5271,6 @@ static void migrate_tasks(struct rq *dead_rq)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
-
-static struct ctl_table sd_ctl_dir[] = {
-	{
-		.procname	= "sched_domain",
-		.mode		= 0555,
-	},
-	{}
-};
-
-static struct ctl_table sd_ctl_root[] = {
-	{
-		.procname	= "kernel",
-		.mode		= 0555,
-		.child		= sd_ctl_dir,
-	},
-	{}
-};
-
-static struct ctl_table *sd_alloc_ctl_entry(int n)
-{
-	struct ctl_table *entry =
-		kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
-
-	return entry;
-}
-
-static void sd_free_ctl_entry(struct ctl_table **tablep)
-{
-	struct ctl_table *entry;
-
-	/*
-	 * In the intermediate directories, both the child directory and
-	 * procname are dynamically allocated and could fail but the mode
-	 * will always be set. In the lowest directory the names are
-	 * static strings and all have proc handlers.
-	 */
-	for (entry = *tablep; entry->mode; entry++) {
-		if (entry->child)
-			sd_free_ctl_entry(&entry->child);
-		if (entry->proc_handler == NULL)
-			kfree(entry->procname);
-	}
-
-	kfree(*tablep);
-	*tablep = NULL;
-}
-
-static int min_load_idx = 0;
-static int max_load_idx = CPU_LOAD_IDX_MAX-1;
-
-static void
-set_table_entry(struct ctl_table *entry,
-		const char *procname, void *data, int maxlen,
-		umode_t mode, proc_handler *proc_handler,
-		bool load_idx)
-{
-	entry->procname = procname;
-	entry->data = data;
-	entry->maxlen = maxlen;
-	entry->mode = mode;
-	entry->proc_handler = proc_handler;
-
-	if (load_idx) {
-		entry->extra1 = &min_load_idx;
-		entry->extra2 = &max_load_idx;
-	}
-}
-
-static struct ctl_table *
-sd_alloc_ctl_domain_table(struct sched_domain *sd)
-{
-	struct ctl_table *table = sd_alloc_ctl_entry(14);
-
-	if (table == NULL)
-		return NULL;
-
-	set_table_entry(&table[0], "min_interval", &sd->min_interval,
-		sizeof(long), 0644, proc_doulongvec_minmax, false);
-	set_table_entry(&table[1], "max_interval", &sd->max_interval,
-		sizeof(long), 0644, proc_doulongvec_minmax, false);
-	set_table_entry(&table[2], "busy_idx", &sd->busy_idx,
-		sizeof(int), 0644, proc_dointvec_minmax, true);
-	set_table_entry(&table[3], "idle_idx", &sd->idle_idx,
-		sizeof(int), 0644, proc_dointvec_minmax, true);
-	set_table_entry(&table[4], "newidle_idx", &sd->newidle_idx,
-		sizeof(int), 0644, proc_dointvec_minmax, true);
-	set_table_entry(&table[5], "wake_idx", &sd->wake_idx,
-		sizeof(int), 0644, proc_dointvec_minmax, true);
-	set_table_entry(&table[6], "forkexec_idx", &sd->forkexec_idx,
-		sizeof(int), 0644, proc_dointvec_minmax, true);
-	set_table_entry(&table[7], "busy_factor", &sd->busy_factor,
-		sizeof(int), 0644, proc_dointvec_minmax, false);
-	set_table_entry(&table[8], "imbalance_pct", &sd->imbalance_pct,
-		sizeof(int), 0644, proc_dointvec_minmax, false);
-	set_table_entry(&table[9], "cache_nice_tries",
-		&sd->cache_nice_tries,
-		sizeof(int), 0644, proc_dointvec_minmax, false);
-	set_table_entry(&table[10], "flags", &sd->flags,
-		sizeof(int), 0644, proc_dointvec_minmax, false);
-	set_table_entry(&table[11], "max_newidle_lb_cost",
-		&sd->max_newidle_lb_cost,
-		sizeof(long), 0644, proc_doulongvec_minmax, false);
-	set_table_entry(&table[12], "name", sd->name,
-		CORENAME_MAX_SIZE, 0444, proc_dostring, false);
-	/* &table[13] is terminator */
-
-	return table;
-}
-
-static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
-{
-	struct ctl_table *entry, *table;
-	struct sched_domain *sd;
-	int domain_num = 0, i;
-	char buf[32];
-
-	for_each_domain(cpu, sd)
-		domain_num++;
-	entry = table = sd_alloc_ctl_entry(domain_num + 1);
-	if (table == NULL)
-		return NULL;
-
-	i = 0;
-	for_each_domain(cpu, sd) {
-		snprintf(buf, 32, "domain%d", i);
-		entry->procname = kstrdup(buf, GFP_KERNEL);
-		entry->mode = 0555;
-		entry->child = sd_alloc_ctl_domain_table(sd);
-		entry++;
-		i++;
-	}
-	return table;
-}
-
-static struct ctl_table_header *sd_sysctl_header;
-static void register_sched_domain_sysctl(void)
-{
-	int i, cpu_num = num_possible_cpus();
-	struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
-	char buf[32];
-
-	WARN_ON(sd_ctl_dir[0].child);
-	sd_ctl_dir[0].child = entry;
-
-	if (entry == NULL)
-		return;
-
-	for_each_possible_cpu(i) {
-		snprintf(buf, 32, "cpu%d", i);
-		entry->procname = kstrdup(buf, GFP_KERNEL);
-		entry->mode = 0555;
-		entry->child = sd_alloc_ctl_cpu_table(i);
-		entry++;
-	}
-
-	WARN_ON(sd_sysctl_header);
-	sd_sysctl_header = register_sysctl_table(sd_ctl_root);
-}
-
-/* may be called multiple times per register */
-static void unregister_sched_domain_sysctl(void)
-{
-	unregister_sysctl_table(sd_sysctl_header);
-	sd_sysctl_header = NULL;
-	if (sd_ctl_dir[0].child)
-		sd_free_ctl_entry(&sd_ctl_dir[0].child);
-}
-#else
-static void register_sched_domain_sysctl(void)
-{
-}
-static void unregister_sched_domain_sysctl(void)
-{
-}
-#endif /* CONFIG_SCHED_DEBUG && CONFIG_SYSCTL */
-
 static void set_rq_online(struct rq *rq)
 {
 	if (!rq->online) {
kernel/sched/debug.c +173 -0

179 lines not on this page · raw message

kernel/sched/sched.h +13 -0
index 10f16374df7f..b146f5298cb1 100644
@@ -3,6 +3,7 @@
 #include <linux/sched/sysctl.h>
 #include <linux/sched/rt.h>
 #include <linux/sched/deadline.h>
+#include <linux/binfmts.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
 #include <linux/stop_machine.h>
@@ -909,6 +910,18 @@ static inline unsigned int group_first_cpu(struct sched_group *group)
 
 extern int group_balance_cpu(struct sched_group *sg);
 
+#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
+void register_sched_domain_sysctl(void);
+void unregister_sched_domain_sysctl(void);
+#else
+static inline void register_sched_domain_sysctl(void)
+{
+}
+static inline void unregister_sched_domain_sysctl(void)
+{
+}
+#endif
+
 #else
 
 static inline void sched_ttwu_pending(void) { }
Signature · 1 line
2.6.4
author reviewer
#3 lore raw

RFC PATCH 3/4 sched: Move sched_domain_debug into debug.c

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The sched_domain_debug code only gets compiled if SCHED_DEBUG is configured, and debug.c only gets compiled if SCHED_DEBUG is also configured. Move the code into debug.c and remove the #ifdefs in core.c. Some functions and variables need to not be static anymore, but everything is still local within the kernel/sched directory.

---
 kernel/sched/core.c  | 123 +--------------------------------------------------
 kernel/sched/debug.c | 107 ++++++++++++++++++++++++++++++++++++++++++++
 kernel/sched/sched.h |  17 +++++++
 3 files changed, 125 insertions(+), 122 deletions(-)
kernel/sched/core.c +1 -122
index 9c6d976d94f0..d0810e997db3 100644
@@ -5431,128 +5431,7 @@ static int __init migration_init(void)
 }
 early_initcall(migration_init);
 
-static cpumask_var_t sched_domains_tmpmask; /* sched_domains_mutex */
-
-#ifdef CONFIG_SCHED_DEBUG
-
-static __read_mostly int sched_debug_enabled;
-
-static int __init sched_debug_setup(char *str)
-{
-	sched_debug_enabled = 1;
-
-	return 0;
-}
-early_param("sched_debug", sched_debug_setup);
-
-static inline bool sched_debug(void)
-{
-	return sched_debug_enabled;
-}
-
-static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
-				  struct cpumask *groupmask)
-{
-	struct sched_group *group = sd->groups;
-
-	cpumask_clear(groupmask);
-
-	printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
-
-	if (!(sd->flags & SD_LOAD_BALANCE)) {
-		printk("does not load-balance\n");
-		if (sd->parent)
-			printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain"
-					" has parent");
-		return -1;
-	}
-
-	printk(KERN_CONT "span %*pbl level %s\n",
-	       cpumask_pr_args(sched_domain_span(sd)), sd->name);
-
-	if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
-		printk(KERN_ERR "ERROR: domain->span does not contain "
-				"CPU%d\n", cpu);
-	}
-	if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) {
-		printk(KERN_ERR "ERROR: domain->groups does not contain"
-				" CPU%d\n", cpu);
-	}
-
-	printk(KERN_DEBUG "%*s groups:", level + 1, "");
-	do {
-		if (!group) {
-			printk("\n");
-			printk(KERN_ERR "ERROR: group is NULL\n");
-			break;
-		}
-
-		if (!cpumask_weight(sched_group_cpus(group))) {
-			printk(KERN_CONT "\n");
-			printk(KERN_ERR "ERROR: empty group\n");
-			break;
-		}
-
-		if (!(sd->flags & SD_OVERLAP) &&
-		    cpumask_intersects(groupmask, sched_group_cpus(group))) {
-			printk(KERN_CONT "\n");
-			printk(KERN_ERR "ERROR: repeated CPUs\n");
-			break;
-		}
-
-		cpumask_or(groupmask, groupmask, sched_group_cpus(group));
-
-		printk(KERN_CONT " %*pbl",
-		       cpumask_pr_args(sched_group_cpus(group)));
-		if (group->sgc->capacity != SCHED_CAPACITY_SCALE) {
-			printk(KERN_CONT " (cpu_capacity = %d)",
-				group->sgc->capacity);
-		}
-
-		group = group->next;
-	} while (group != sd->groups);
-	printk(KERN_CONT "\n");
-
-	if (!cpumask_equal(sched_domain_span(sd), groupmask))
-		printk(KERN_ERR "ERROR: groups don't span domain->span\n");
-
-	if (sd->parent &&
-	    !cpumask_subset(groupmask, sched_domain_span(sd->parent)))
-		printk(KERN_ERR "ERROR: parent span is not a superset "
-			"of domain->span\n");
-	return 0;
-}
-
-static void sched_domain_debug(struct sched_domain *sd, int cpu)
-{
-	int level = 0;
-
-	if (!sched_debug_enabled)
-		return;
-
-	if (!sd) {
-		printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu);
-		return;
-	}
-
-	printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu);
-
-	for (;;) {
-		if (sched_domain_debug_one(sd, cpu, level, sched_domains_tmpmask))
-			break;
-		level++;
-		sd = sd->parent;
-		if (!sd)
-			break;
-	}
-}
-#else /* !CONFIG_SCHED_DEBUG */
-# define sched_domain_debug(sd, cpu) do { } while (0)
-static inline bool sched_debug(void)
-{
-	return false;
-}
-#endif /* CONFIG_SCHED_DEBUG */
+cpumask_var_t sched_domains_tmpmask; /* sched_domains_mutex */
 
 static int sd_degenerate(struct sched_domain *sd)
 {
kernel/sched/debug.c +107 -0

113 lines not on this page · raw message

kernel/sched/sched.h +17 -0
index b146f5298cb1..bfa2dd97fe0b 100644
@@ -922,6 +922,23 @@ static inline void unregister_sched_domain_sysctl(void)
 }
 #endif
 
+extern cpumask_var_t sched_domains_tmpmask; /* sched_domains_mutex */
+
+#ifdef CONFIG_SCHED_DEBUG
+extern int sched_debug_enabled;
+void sched_domain_debug(struct sched_domain *sd, int cpu);
+static inline bool sched_debug(void)
+{
+	return sched_debug_enabled;
+}
+#else
+# define sched_domain_debug(sd, cpu) do { } while (0)
+static inline bool sched_debug(void)
+{
+	return false;
+}
+#endif
+
 #else
 
 static inline void sched_ttwu_pending(void) { }
Signature · 1 line
2.6.4
author reviewer
#4 lore raw

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

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

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
---
 kernel/sched/debug.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
kernel/sched/debug.c +100 -0
index 68838495624f..a6ce364ba9b9 100644
@@ -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 */
Signature · 1 line
2.6.4
maintainer
#5 lore raw

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

Quoted 22 lines · Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

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]:
Quoted 8 lines
    bw:       996147
    total_bw: 0
  CPU[6]:
    bw:       996147
    total_bw: 0
  CPU[7]:
    bw:       996147
    total_bw: 0

Why not add this to print_dl_rq() ?

author reviewer
#6 lore raw

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

Quoted 32 lines · On Mon, 1 Feb 2016 23:17:20 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 22 lines · Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

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]:
Quoted 8 lines
    bw:       996147
    total_bw: 0
  CPU[6]:
    bw:       996147
    total_bw: 0
  CPU[7]:
    bw:       996147
    total_bw: 0  
Quoted 1 line

Why not add this to print_dl_rq() ?

Because I didn't see that ;-)

That could work, although, Damn there's a lot of info there already. I'll play with that.

Regardless of this final patch, what do you think of the first three? I can send them as a separate series, just to get more of the SCHED_DEBUG code into debug.c.

-- Steve

maintainer
#7 lore raw

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

Quoted 3 lines · Steven Rostedt

Regardless of this final patch, what do you think of the first three? I can send them as a separate series, just to get more of the SCHED_DEBUG code into debug.c.

The first two looked ok, the third I had a vague niggle it might be part of something bigger and tearing it up like this might make it harder.

Other than that, I didn't really look at them for more than a few seconds. I'll give them more of a look tomorrow.

#8 lore raw

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

Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Steven Rostedt

Regardless of this final patch, what do you think of the first three? I can send them as a separate series, just to get more of the SCHED_DEBUG code into debug.c.

The first two looked ok, the third I had a vague niggle it might be part of something bigger and tearing it up like this might make it harder.

Yeah, so the purpose of kernel/sched/debug.c is mostly meant as a filesystem interface to display various internal scheduler details. It mostly deals with /proc/sched_debug details: hence the name.

Note that 'sched domain debugging' does not fit into that cleanly, because it also does sanity checking of the sched-domains data. So I'm not sure we want to do patch #3 that moves sched-domain debugging to debug.c.

So debug.c is named in a bit too generic fashion, attracting such patches.

Thanks,

Ingo

author reviewer
#9 lore raw

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

Quoted 10 lines · On Wed, 3 Feb 2016 11:12:09 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Steven Rostedt

Regardless of this final patch, what do you think of the first three? I can send them as a separate series, just to get more of the SCHED_DEBUG code into debug.c.

The first two looked ok, the third I had a vague niggle it might be part of something bigger and tearing it up like this might make it harder.

Actually, I originally had plans to display the entire root domain here, but decided against that.

Quoted 11 lines

Yeah, so the purpose of kernel/sched/debug.c is mostly meant as a filesystem interface to display various internal scheduler details. It mostly deals with /proc/sched_debug details: hence the name.

Note that 'sched domain debugging' does not fit into that cleanly, because it also does sanity checking of the sched-domains data. So I'm not sure we want to do patch #3 that moves sched-domain debugging to debug.c.

So debug.c is named in a bit too generic fashion, attracting such patches.

It was actually more the #ifdef SCHED_DEBUG that attracted the patches. The debug.c file is compiled on SCHED_DEBUG, thus it appeared natural to have parts in core.c just moved into that file instead of having all the #ifdef SCHED_DEBUG in it.

-- Steve

maintainer
#10 lore raw

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

In reply to Steven Rostedt

kernel/sched/debug.c void proc_sched_set_task(struct task_struct *p) · line 1087

Quoted 11 lines · Steven Rostedt
kernel/sched/debug.c +11 -0
+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())

And that wants to be: nr_cpu_ids, imagine the bitmap having holes in.

Quoted 6 lines
kernel/sched/debug.c +6 -0
+		cpu = 0;
+	else
+		cpu++;
+
+	return (void *)cpu;
+}