2023-01-19 16:09:36

by Phil Auld

[permalink] [raw]
Subject: [RESEND PATCH] 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 <[email protected]>.

Signed-off-by: Phil Auld <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra (Intel) <[email protected]>
Cc: Srikar Dronamraju <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: Vishal Chourasia <[email protected]>
Cc: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
---

Resending due to typo in lkml address... sorry about that.

kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 1637b65ba07a..2378a30738ec 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = {

__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 int sched_debug_open(struct inode *inode, struct file *filp)
@@ -303,7 +342,7 @@ static __init int sched_init_debug(void)
debugfs_sched = debugfs_create_dir("sched", NULL);

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
debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
#endif
@@ -345,7 +384,6 @@ late_initcall(sched_init_debug);
#ifdef CONFIG_SMP

static cpumask_var_t sd_sysctl_cpus;
-static struct dentry *sd_dentry;

static int sd_flags_show(struct seq_file *m, void *v)
{
@@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
if (!debugfs_sched)
return;

+ if (!sched_debug_verbose)
+ return;
+
if (!cpumask_available(sd_sysctl_cpus)) {
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
return;
cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
}

- if (!sd_dentry)
+ if (!sd_dentry) {
sd_dentry = debugfs_create_dir("domains", debugfs_sched);

+ /* rebuild sd_sysclt_cpus if empty since it gets cleared below */
+ if (cpumask_first(sd_sysctl_cpus) >= nr_cpu_ids)
+ cpumask_copy(sd_sysctl_cpus, cpu_online_mask);
+ }
+
for_each_cpu(cpu, sd_sysctl_cpus) {
struct sched_domain *sd;
struct dentry *d_cpu;
--
2.31.1


2023-01-19 16:42:43

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [RESEND PATCH] sched/debug: Put sched/domains files under the verbose flag

On Thu, Jan 19, 2023 at 10:07:58AM -0500, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---
>
> Resending due to typo in lkml address... sorry about that.

Reviewed-by: Greg Kroah-Hartman <[email protected]>

2023-01-20 16:10:48

by Valentin Schneider

[permalink] [raw]
Subject: Re: [RESEND PATCH] sched/debug: Put sched/domains files under the verbose flag

On 19/01/23 10:07, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/

Small nits below, other than that:

Reviewed-by: Valentin Schneider <[email protected]>

> @@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
> if (!debugfs_sched)
> return;
>
> + if (!sched_debug_verbose)
> + return;
> +
> if (!cpumask_available(sd_sysctl_cpus)) {
> if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
> return;
> cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
> }
>
> - if (!sd_dentry)
> + if (!sd_dentry) {
> sd_dentry = debugfs_create_dir("domains", debugfs_sched);
>
> + /* rebuild sd_sysclt_cpus if empty since it gets cleared below */
^^^^^^^^^^^^^^
Nit: sd_sysctl_cpus

> + if (cpumask_first(sd_sysctl_cpus) >= nr_cpu_ids)

Use cpumask_empty() instead?

> + cpumask_copy(sd_sysctl_cpus, cpu_online_mask);
> + }
> +
> for_each_cpu(cpu, sd_sysctl_cpus) {
> struct sched_domain *sd;
> struct dentry *d_cpu;
> --
> 2.31.1

2023-01-20 16:16:40

by Phil Auld

[permalink] [raw]
Subject: Re: [RESEND PATCH] sched/debug: Put sched/domains files under the verbose flag

On Fri, Jan 20, 2023 at 03:52:55PM +0000 Valentin Schneider wrote:
> On 19/01/23 10:07, Phil Auld wrote:
> > 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 <[email protected]>.
> >
> > Signed-off-by: Phil Auld <[email protected]>
> > Cc: Michael Ellerman <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
> > Cc: Ingo Molnar <[email protected]>
> > Cc: Peter Zijlstra (Intel) <[email protected]>
> > Cc: Srikar Dronamraju <[email protected]>
> > Cc: Valentin Schneider <[email protected]>
> > Cc: Vishal Chourasia <[email protected]>
> > Cc: Vincent Guittot <[email protected]>
> > Link: https://lore.kernel.org/all/[email protected]/
>
> Small nits below, other than that:
>
> Reviewed-by: Valentin Schneider <[email protected]>
>
> > @@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
> > if (!debugfs_sched)
> > return;
> >
> > + if (!sched_debug_verbose)
> > + return;
> > +
> > if (!cpumask_available(sd_sysctl_cpus)) {
> > if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
> > return;
> > cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
> > }
> >
> > - if (!sd_dentry)
> > + if (!sd_dentry) {
> > sd_dentry = debugfs_create_dir("domains", debugfs_sched);
> >
> > + /* rebuild sd_sysclt_cpus if empty since it gets cleared below */
> ^^^^^^^^^^^^^^
> Nit: sd_sysctl_cpus
>
> > + if (cpumask_first(sd_sysctl_cpus) >= nr_cpu_ids)
>
> Use cpumask_empty() instead?

Heh, I didn't find that when I looked somehow :) Yes, that's what this check
is doing. I'll fix these in a quick v2.


Thanks!


Cheers,
Phil



>
> > + cpumask_copy(sd_sysctl_cpus, cpu_online_mask);
> > + }
> > +
> > for_each_cpu(cpu, sd_sysctl_cpus) {
> > struct sched_domain *sd;
> > struct dentry *d_cpu;
> > --
> > 2.31.1
>

--

2023-01-20 16:57:56

by Phil Auld

[permalink] [raw]
Subject: [PATCH v2] 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 <[email protected]>.

Signed-off-by: Phil Auld <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra (Intel) <[email protected]>
Cc: Srikar Dronamraju <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: Vishal Chourasia <[email protected]>
Cc: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
---

v2: fix comment typo and use cpumask_empty()

kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 1637b65ba07a..0b2340a79b65 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = {

__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 int sched_debug_open(struct inode *inode, struct file *filp)
@@ -303,7 +342,7 @@ static __init int sched_init_debug(void)
debugfs_sched = debugfs_create_dir("sched", NULL);

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
debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
#endif
@@ -345,7 +384,6 @@ late_initcall(sched_init_debug);
#ifdef CONFIG_SMP

static cpumask_var_t sd_sysctl_cpus;
-static struct dentry *sd_dentry;

static int sd_flags_show(struct seq_file *m, void *v)
{
@@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
if (!debugfs_sched)
return;

+ if (!sched_debug_verbose)
+ return;
+
if (!cpumask_available(sd_sysctl_cpus)) {
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
return;
cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
}

- if (!sd_dentry)
+ if (!sd_dentry) {
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) {
struct sched_domain *sd;
struct dentry *d_cpu;
--
2.31.1

2023-01-21 08:06:11

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] sched/debug: Put sched/domains files under the verbose flag

On Fri, Jan 20, 2023 at 11:33:30AM -0500, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---
>
> v2: fix comment typo and use cpumask_empty()

Acked-by: Greg Kroah-Hartman <[email protected]>

2023-01-27 15:02:41

by Valentin Schneider

[permalink] [raw]
Subject: Re: [PATCH v2] sched/debug: Put sched/domains files under the verbose flag

On 20/01/23 11:33, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/

Reviewed-by: Valentin Schneider <[email protected]>


2023-01-30 14:55:14

by Srikar Dronamraju

[permalink] [raw]
Subject: Re: [PATCH v2] sched/debug: Put sched/domains files under the verbose flag

* Phil Auld <[email protected]> [2023-01-20 11:33:30]:

> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---
>
Looks good to me.

Reviewed-by: Srikar Dronamraju <[email protected]>

--
Thanks and Regards
Srikar Dronamraju

2023-02-08 13:29:57

by Phil Auld

[permalink] [raw]
Subject: Re: [PATCH v2] sched/debug: Put sched/domains files under the verbose flag

Hi Ingo, Peter,

On Fri, Jan 20, 2023 at 11:33:30AM -0500 Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---

Thoughts on this one?


Thanks,
Phil


>
> v2: fix comment typo and use cpumask_empty()
>
> kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 49 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 1637b65ba07a..0b2340a79b65 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = {
>
> __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 int sched_debug_open(struct inode *inode, struct file *filp)
> @@ -303,7 +342,7 @@ static __init int sched_init_debug(void)
> debugfs_sched = debugfs_create_dir("sched", NULL);
>
> 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
> debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
> #endif
> @@ -345,7 +384,6 @@ late_initcall(sched_init_debug);
> #ifdef CONFIG_SMP
>
> static cpumask_var_t sd_sysctl_cpus;
> -static struct dentry *sd_dentry;
>
> static int sd_flags_show(struct seq_file *m, void *v)
> {
> @@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
> if (!debugfs_sched)
> return;
>
> + if (!sched_debug_verbose)
> + return;
> +
> if (!cpumask_available(sd_sysctl_cpus)) {
> if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
> return;
> cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
> }
>
> - if (!sd_dentry)
> + if (!sd_dentry) {
> 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) {
> struct sched_domain *sd;
> struct dentry *d_cpu;
> --
> 2.31.1
>

--


2023-02-15 06:04:16

by Vishal Chourasia

[permalink] [raw]
Subject: Re: [PATCH v2] sched/debug: Put sched/domains files under the verbose flag

On Fri, Jan 20, 2023 at 11:33:30AM -0500, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---
>
> v2: fix comment typo and use cpumask_empty()
>
> kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 49 insertions(+), 3 deletions(-)

Thanks for the Patch.

Tested-by: Vishal Chourasia <[email protected]>

Base Tag : v6.2-rc8
Patch : [V2] sched/debug: Put sched/domains files under the verbose flag


# time ppc64_cpu --smt=off | When kernel is built
| with the patch, time to
real 17m54.246s | smt=off is 17m54s.
user 0m0.013s |
sys 0m4.661s |

System Configuration:

Architecture : ppc64le
CPUS : 1600
Machine : Power10
Thread per core : 8
Sockets : 15

- debug files are not created for the case where kernel command line string
lacks sched_verbose parameter.
- When sched_verbose is passed as kernel commandline parameter, kernel exports
/sys/kernel/debug/sched/verbose file which controls creation of the debug
files.
+ setting Y/N to this file enables/disables creation of debug files during CPU
hotplug operation.

Below is the table listing time taken to perform smt=off operation under
different settings.

+--------------------------+---------------+---------+------------+
| kernel | sched_verbose | verbose | time |
+--------------------------+---------------+---------+------------+
| 6.2.0-rc8-patch-applied+ | YES | N | 16m58.196s |
| 6.2.0-rc8-patch-applied+ | YES | Y | 33m21.774s |
| 6.2.0-rc8-patch-applied+ | NO | NA | 17m54.246s |
| 6.2.0-rc8 | NO | NA | 30m11.344s |
+--------------------------+---------------+---------+------------+

-- vishal.c


Attachments:
(No filename) (2.88 kB)
signature.asc (488.00 B)
Download all attachments

2023-03-03 18:40:13

by Phil Auld

[permalink] [raw]
Subject: [RESEND PATCH v2] 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 <[email protected]>.

Signed-off-by: Phil Auld <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Valentin Schneider <[email protected]>
Reviewed-by: Srikar Dronamraju <[email protected]>
Tested-by: Vishal Chourasia <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra (Intel) <[email protected]>
Cc: Srikar Dronamraju <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: Vishal Chourasia <[email protected]>
Cc: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
---

v2: fix comment typo and use cpumask_empty()

kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 1637b65ba07a..0b2340a79b65 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -280,6 +280,45 @@ static const struct file_operations sched_dynamic_fops = {

__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 int sched_debug_open(struct inode *inode, struct file *filp)
@@ -303,7 +342,7 @@ static __init int sched_init_debug(void)
debugfs_sched = debugfs_create_dir("sched", NULL);

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
debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
#endif
@@ -345,7 +384,6 @@ late_initcall(sched_init_debug);
#ifdef CONFIG_SMP

static cpumask_var_t sd_sysctl_cpus;
-static struct dentry *sd_dentry;

static int sd_flags_show(struct seq_file *m, void *v)
{
@@ -402,15 +440,23 @@ void update_sched_domain_debugfs(void)
if (!debugfs_sched)
return;

+ if (!sched_debug_verbose)
+ return;
+
if (!cpumask_available(sd_sysctl_cpus)) {
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
return;
cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
}

- if (!sd_dentry)
+ if (!sd_dentry) {
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) {
struct sched_domain *sd;
struct dentry *d_cpu;
--
2.31.1


2023-03-09 14:47:51

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [RESEND PATCH v2] sched/debug: Put sched/domains files under the verbose flag

On Fri, Mar 03, 2023 at 01:37:54PM -0500, Phil Auld wrote:
> 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 <[email protected]>.
>
> Signed-off-by: Phil Auld <[email protected]>
> Acked-by: Greg Kroah-Hartman <[email protected]>
> Reviewed-by: Valentin Schneider <[email protected]>
> Reviewed-by: Srikar Dronamraju <[email protected]>
> Tested-by: Vishal Chourasia <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra (Intel) <[email protected]>
> Cc: Srikar Dronamraju <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: Vishal Chourasia <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> ---
>
> v2: fix comment typo and use cpumask_empty()
>
> kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 49 insertions(+), 3 deletions(-)

As no one has picked this up yet, and it is really a debugfs issue, I'll
queue this up in the driver-core tree (which takes debugfs changes) for
6.4-rc1 unless someone screams.

thanks,

greg k-h

2023-03-09 17:50:14

by Phil Auld

[permalink] [raw]
Subject: Re: [RESEND PATCH v2] sched/debug: Put sched/domains files under the verbose flag

On Thu, Mar 09, 2023 at 03:44:45PM +0100 Greg KH wrote:
> On Fri, Mar 03, 2023 at 01:37:54PM -0500, Phil Auld wrote:
> > 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 <[email protected]>.
> >
> > Signed-off-by: Phil Auld <[email protected]>
> > Acked-by: Greg Kroah-Hartman <[email protected]>
> > Reviewed-by: Valentin Schneider <[email protected]>
> > Reviewed-by: Srikar Dronamraju <[email protected]>
> > Tested-by: Vishal Chourasia <[email protected]>
> > Cc: Michael Ellerman <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
> > Cc: Ingo Molnar <[email protected]>
> > Cc: Peter Zijlstra (Intel) <[email protected]>
> > Cc: Srikar Dronamraju <[email protected]>
> > Cc: Valentin Schneider <[email protected]>
> > Cc: Vishal Chourasia <[email protected]>
> > Cc: Vincent Guittot <[email protected]>
> > Link: https://lore.kernel.org/all/[email protected]/
> > ---
> >
> > v2: fix comment typo and use cpumask_empty()
> >
> > kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++---
> > 1 file changed, 49 insertions(+), 3 deletions(-)
>
> As no one has picked this up yet, and it is really a debugfs issue, I'll
> queue this up in the driver-core tree (which takes debugfs changes) for
> 6.4-rc1 unless someone screams.
>

Thanks Greg!


> thanks,
>
> greg k-h
>

--