* [PATCH] sched/debug: Don't update sched_domain debug directories before sched_debug_init()
@ 2021-05-18 13:07 Valentin Schneider
2021-06-25 10:04 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Valentin Schneider @ 2021-05-18 13:07 UTC (permalink / raw
To: linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Vincent Guittot, Dietmar Eggemann,
Ionela Voinescu
Since CPU capacity asymmetry can stem purely from maximum frequency
differences (e.g. Pixel 1), a rebuild of the scheduler topology can be
issued upon loading cpufreq, see:
arch_topology.c::init_cpu_capacity_callback()
Turns out that if this rebuild happens *before* sched_debug_init() is
run (which is a late initcall), we end up messing up the sched_domain debug
directory: passing a NULL parent to debugfs_create_dir() ends up creating
the directory at the debugfs root, which in this case creates
/sys/kernel/debug/domains (instead of /sys/kernel/debug/sched/domains).
This currently doesn't happen on asymmetric systems which use cpufreq-scpi
or cpufreq-dt drivers, as those are loaded via
deferred_probe_initcall() (it is also a late initcall, but appears to be
ordered *after* sched_debug_init()).
Ionela has been working on detecting maximum frequency asymmetry via ACPI,
and that actually happens via a *device* initcall, thus before
sched_debug_init(), and causes the aforementionned debugfs mayhem.
One option would be to punt sched_debug_init() down to
fs_initcall_sync(). Preventing update_sched_domain_debugfs() from running
before sched_debug_init() appears to be the safer option.
Link: http://lore.kernel.org/r/20210514095339.12979-1-ionela.voinescu@arm.com
Fixes: 3b87f136f8fc ("sched,debug: Convert sysctl sched_domains to debugfs")
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
---
kernel/sched/debug.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 3bdee5fd7d29..6b5d6c7612fd 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -388,6 +388,13 @@ void update_sched_domain_debugfs(void)
{
int cpu, i;
+ /*
+ * This can unfortunately be invoked before sched_debug_init() creates
+ * the debug directory. Don't touch sd_sysctl_cpus until then.
+ */
+ if (!debugfs_sched)
+ return;
+
if (!cpumask_available(sd_sysctl_cpus)) {
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
return;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched/debug: Don't update sched_domain debug directories before sched_debug_init()
2021-05-18 13:07 [PATCH] sched/debug: Don't update sched_domain debug directories before sched_debug_init() Valentin Schneider
@ 2021-06-25 10:04 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2021-06-25 10:04 UTC (permalink / raw
To: Valentin Schneider
Cc: linux-kernel, Ingo Molnar, Vincent Guittot, Dietmar Eggemann,
Ionela Voinescu
On Tue, May 18, 2021 at 02:07:25PM +0100, Valentin Schneider wrote:
> Since CPU capacity asymmetry can stem purely from maximum frequency
> differences (e.g. Pixel 1), a rebuild of the scheduler topology can be
> issued upon loading cpufreq, see:
>
> arch_topology.c::init_cpu_capacity_callback()
>
> Turns out that if this rebuild happens *before* sched_debug_init() is
> run (which is a late initcall), we end up messing up the sched_domain debug
> directory: passing a NULL parent to debugfs_create_dir() ends up creating
> the directory at the debugfs root, which in this case creates
> /sys/kernel/debug/domains (instead of /sys/kernel/debug/sched/domains).
>
> This currently doesn't happen on asymmetric systems which use cpufreq-scpi
> or cpufreq-dt drivers, as those are loaded via
> deferred_probe_initcall() (it is also a late initcall, but appears to be
> ordered *after* sched_debug_init()).
>
> Ionela has been working on detecting maximum frequency asymmetry via ACPI,
> and that actually happens via a *device* initcall, thus before
> sched_debug_init(), and causes the aforementionned debugfs mayhem.
>
> One option would be to punt sched_debug_init() down to
> fs_initcall_sync(). Preventing update_sched_domain_debugfs() from running
> before sched_debug_init() appears to be the safer option.
>
> Link: http://lore.kernel.org/r/20210514095339.12979-1-ionela.voinescu@arm.com
> Fixes: 3b87f136f8fc ("sched,debug: Convert sysctl sched_domains to debugfs")
> Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-25 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-18 13:07 [PATCH] sched/debug: Don't update sched_domain debug directories before sched_debug_init() Valentin Schneider
2021-06-25 10:04 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).