Commit 34320745 authored by Phil Auld's avatar Phil Auld Committed by Greg Kroah-Hartman

sched/debug: Put sched/domains files under the verbose flag

The debug files under sched/domains can take a long time to regenerate,
especially when updates are done one at a time. Move these files under
the sched verbose debug flag. Allow changes to verbose to trigger
generation of the files. This lets a user batch the updates but still
have the information available.  The detailed topology printk messages
are also under verbose.

Discussion that lead to this approach can be found in the link below.

Simplified code to maintain use of debugfs bool routines suggested by
Michael Ellerman <mpe@ellerman.id.au>.
Signed-off-by: default avatarPhil Auld <pauld@redhat.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarValentin Schneider <vschneid@redhat.com>
Reviewed-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Tested-by: default avatarVishal Chourasia <vishalc@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vishal Chourasia <vishalc@linux.vnet.ibm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/all/Y01UWQL2y2r69sBX@li-05afa54c-330e-11b2-a85c-e3f3aa0db1e9.ibm.com/
Link: https://lore.kernel.org/r/20230303183754.3076321-1-pauld@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2bd5c639
...@@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = { ...@@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = {
__read_mostly bool sched_debug_verbose; __read_mostly bool sched_debug_verbose;
#ifdef CONFIG_SMP
static struct dentry *sd_dentry;
static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
ssize_t result;
bool orig;
cpus_read_lock();
mutex_lock(&sched_domains_mutex);
orig = sched_debug_verbose;
result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
if (sched_debug_verbose && !orig)
update_sched_domain_debugfs();
else if (!sched_debug_verbose && orig) {
debugfs_remove(sd_dentry);
sd_dentry = NULL;
}
mutex_unlock(&sched_domains_mutex);
cpus_read_unlock();
return result;
}
#else
#define sched_verbose_write debugfs_write_file_bool
#endif
static const struct file_operations sched_verbose_fops = {
.read = debugfs_read_file_bool,
.write = sched_verbose_write,
.open = simple_open,
.llseek = default_llseek,
};
static const struct seq_operations sched_debug_sops; static const struct seq_operations sched_debug_sops;
static int sched_debug_open(struct inode *inode, struct file *filp) static int sched_debug_open(struct inode *inode, struct file *filp)
...@@ -303,7 +342,7 @@ static __init int sched_init_debug(void) ...@@ -303,7 +342,7 @@ static __init int sched_init_debug(void)
debugfs_sched = debugfs_create_dir("sched", NULL); debugfs_sched = debugfs_create_dir("sched", NULL);
debugfs_create_file("features", 0644, debugfs_sched, NULL, &sched_feat_fops); debugfs_create_file("features", 0644, debugfs_sched, NULL, &sched_feat_fops);
debugfs_create_bool("verbose", 0644, debugfs_sched, &sched_debug_verbose); debugfs_create_file_unsafe("verbose", 0644, debugfs_sched, &sched_debug_verbose, &sched_verbose_fops);
#ifdef CONFIG_PREEMPT_DYNAMIC #ifdef CONFIG_PREEMPT_DYNAMIC
debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops); debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
#endif #endif
...@@ -345,7 +384,6 @@ late_initcall(sched_init_debug); ...@@ -345,7 +384,6 @@ late_initcall(sched_init_debug);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static cpumask_var_t sd_sysctl_cpus; static cpumask_var_t sd_sysctl_cpus;
static struct dentry *sd_dentry;
static int sd_flags_show(struct seq_file *m, void *v) static int sd_flags_show(struct seq_file *m, void *v)
{ {
...@@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void) ...@@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
if (!debugfs_sched) if (!debugfs_sched)
return; return;
if (!sched_debug_verbose)
return;
if (!cpumask_available(sd_sysctl_cpus)) { if (!cpumask_available(sd_sysctl_cpus)) {
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL)) if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
return; return;
cpumask_copy(sd_sysctl_cpus, cpu_possible_mask); cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
} }
if (!sd_dentry) if (!sd_dentry) {
sd_dentry = debugfs_create_dir("domains", debugfs_sched); sd_dentry = debugfs_create_dir("domains", debugfs_sched);
/* rebuild sd_sysctl_cpus if empty since it gets cleared below */
if (cpumask_empty(sd_sysctl_cpus))
cpumask_copy(sd_sysctl_cpus, cpu_online_mask);
}
for_each_cpu(cpu, sd_sysctl_cpus) { for_each_cpu(cpu, sd_sysctl_cpus) {
struct sched_domain *sd; struct sched_domain *sd;
struct dentry *d_cpu; struct dentry *d_cpu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment