1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

cpufreq: Add iter_domains method

It's common to want to do an operation on cpufreq that affects all
CPUs, but doing so explicitly for all CPUs can be unnecessarily slow
when it only needs to be done once for each cpufreq policy.

Add a method to abstract the pattern of iteration.
This commit is contained in:
Brendan Jackman 2017-05-17 10:43:34 +01:00
parent 69a83d4128
commit dc32fa9704

View File

@ -421,3 +421,14 @@ class CpufreqModule(Module):
sysfile = '/sys/devices/system/cpu/{}/cpufreq/affected_cpus'.format(cpu)
return [int(c) for c in self.target.read_value(sysfile).split()]
def iter_domains(self):
"""
Iterate over the frequency domains in the system
"""
cpus = set(range(self.target.number_of_cpus))
while cpus:
cpu = iter(cpus).next()
domain = self.target.cpufreq.get_domain_cpus(cpu)
yield domain
cpus = cpus.difference(domain)