From 01dd80df3487bd23bf14b26889fb2b1e021c6949 Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Tue, 26 Nov 2019 14:38:12 +0000 Subject: [PATCH] module/sched: Fix get_capacities() on !SCHED_DEBUG kernels While reading the DT-provided capacity values (exposed in sysfs) is sufficient, get_capacities() also unconditionally fetches data from the sched_domain procfs, which is only populated on kernels compiled with CONFIG_SCHED_DEBUG. Tweak the logic to only call get_sd_info() if it is both possible and required. --- devlib/module/sched.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/devlib/module/sched.py b/devlib/module/sched.py index 8fad08a..8ec8c9c 100644 --- a/devlib/module/sched.py +++ b/devlib/module/sched.py @@ -469,12 +469,26 @@ class SchedModule(Module): cpus = self.target.list_online_cpus() capacities = {} - sd_info = self.get_sd_info() for cpu in cpus: if self.has_dmips_capacity(cpu): capacities[cpu] = self.get_dmips_capacity(cpu) - elif self.has_em(cpu, sd_info.cpus[cpu]): + + missing_cpus = set(cpus).difference(capacities.keys()) + if not missing_cpus: + return capacities + + if not SchedProcFSData.available(self.target): + if default != None: + capacities.update({cpu : default for cpu in missing_cpus}) + return capacities + else: + raise RuntimeError( + 'No capacity data for cpus {}'.format(sorted(missing_cpus))) + + sd_info = self.get_sd_info() + for cpu in missing_cpus: + if self.has_em(cpu, sd_info.cpus[cpu]): capacities[cpu] = self.get_em_capacity(cpu, sd_info.cpus[cpu]) else: if default != None: