mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-08 04:51:53 +01:00
pylint fixes
This commit is contained in:
@@ -61,7 +61,7 @@ class Module(object):
|
||||
self.logger = logging.getLogger(self.name)
|
||||
|
||||
|
||||
class HardRestModule(Module): # pylint: disable=R0921
|
||||
class HardRestModule(Module):
|
||||
|
||||
kind = 'hard_reset'
|
||||
|
||||
@@ -69,7 +69,7 @@ class HardRestModule(Module): # pylint: disable=R0921
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class BootModule(Module): # pylint: disable=R0921
|
||||
class BootModule(Module):
|
||||
|
||||
kind = 'boot'
|
||||
|
||||
|
@@ -125,4 +125,3 @@ def get_mapping(base_dir, partition_file):
|
||||
HostError('file {} was not found in the bundle or was misplaced'.format(pair[1]))
|
||||
mapping[pair[0]] = image_path
|
||||
return mapping
|
||||
|
||||
|
@@ -60,150 +60,150 @@ class BigLittleModule(Module):
|
||||
|
||||
def list_bigs_frequencies(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.list_frequencies(bigs_online[0])
|
||||
|
||||
def list_bigs_governors(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.list_governors(bigs_online[0])
|
||||
|
||||
def list_bigs_governor_tunables(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.list_governor_tunables(bigs_online[0])
|
||||
|
||||
def list_littles_frequencies(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.list_frequencies(littles_online[0])
|
||||
|
||||
def list_littles_governors(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.list_governors(littles_online[0])
|
||||
|
||||
def list_littles_governor_tunables(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.list_governor_tunables(littles_online[0])
|
||||
|
||||
def get_bigs_governor(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.get_governor(bigs_online[0])
|
||||
|
||||
def get_bigs_governor_tunables(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.get_governor_tunables(bigs_online[0])
|
||||
|
||||
def get_bigs_frequency(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.get_frequency(bigs_online[0])
|
||||
|
||||
def get_bigs_min_frequency(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.get_min_frequency(bigs_online[0])
|
||||
|
||||
def get_bigs_max_frequency(self):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
return self.target.cpufreq.get_max_frequency(bigs_online[0])
|
||||
|
||||
def get_littles_governor(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.get_governor(littles_online[0])
|
||||
|
||||
def get_littles_governor_tunables(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.get_governor_tunables(littles_online[0])
|
||||
|
||||
def get_littles_frequency(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.get_frequency(littles_online[0])
|
||||
|
||||
def get_littles_min_frequency(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.get_min_frequency(littles_online[0])
|
||||
|
||||
def get_littles_max_frequency(self):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
return self.target.cpufreq.get_max_frequency(littles_online[0])
|
||||
|
||||
def set_bigs_governor(self, governor, **kwargs):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
self.target.cpufreq.set_governor(bigs_online[0], governor, **kwargs)
|
||||
else:
|
||||
raise ValueError("All bigs appear to be offline")
|
||||
|
||||
def set_bigs_governor_tunables(self, governor, **kwargs):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
self.target.cpufreq.set_governor_tunables(bigs_online[0], governor, **kwargs)
|
||||
else:
|
||||
raise ValueError("All bigs appear to be offline")
|
||||
|
||||
def set_bigs_frequency(self, frequency, exact=True):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
self.target.cpufreq.set_frequency(bigs_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All bigs appear to be offline")
|
||||
|
||||
def set_bigs_min_frequency(self, frequency, exact=True):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
self.target.cpufreq.set_min_frequency(bigs_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All bigs appear to be offline")
|
||||
|
||||
def set_bigs_max_frequency(self, frequency, exact=True):
|
||||
bigs_online = self.bigs_online
|
||||
if len(bigs_online) > 0:
|
||||
if bigs_online:
|
||||
self.target.cpufreq.set_max_frequency(bigs_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All bigs appear to be offline")
|
||||
|
||||
def set_littles_governor(self, governor, **kwargs):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
self.target.cpufreq.set_governor(littles_online[0], governor, **kwargs)
|
||||
else:
|
||||
raise ValueError("All littles appear to be offline")
|
||||
|
||||
def set_littles_governor_tunables(self, governor, **kwargs):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
self.target.cpufreq.set_governor_tunables(littles_online[0], governor, **kwargs)
|
||||
else:
|
||||
raise ValueError("All littles appear to be offline")
|
||||
|
||||
def set_littles_frequency(self, frequency, exact=True):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
self.target.cpufreq.set_frequency(littles_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All littles appear to be offline")
|
||||
|
||||
def set_littles_min_frequency(self, frequency, exact=True):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
self.target.cpufreq.set_min_frequency(littles_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All littles appear to be offline")
|
||||
|
||||
def set_littles_max_frequency(self, frequency, exact=True):
|
||||
littles_online = self.littles_online
|
||||
if len(littles_online) > 0:
|
||||
if littles_online:
|
||||
self.target.cpufreq.set_max_frequency(littles_online[0], frequency, exact)
|
||||
else:
|
||||
raise ValueError("All littles appear to be offline")
|
||||
|
@@ -121,18 +121,20 @@ class Controller(object):
|
||||
cgroups.append(cg)
|
||||
return cgroups
|
||||
|
||||
def move_tasks(self, source, dest, exclude=[]):
|
||||
def move_tasks(self, source, dest, exclude=None):
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
try:
|
||||
srcg = self._cgroups[source]
|
||||
dstg = self._cgroups[dest]
|
||||
except KeyError as e:
|
||||
raise ValueError('Unkown group: {}'.format(e))
|
||||
output = self.target._execute_util(
|
||||
raise ValueError('Unknown group: {}'.format(e))
|
||||
self.target._execute_util( # pylint: disable=protected-access
|
||||
'cgroups_tasks_move {} {} \'{}\''.format(
|
||||
srcg.directory, dstg.directory, exclude),
|
||||
as_root=True)
|
||||
|
||||
def move_all_tasks_to(self, dest, exclude=[]):
|
||||
def move_all_tasks_to(self, dest, exclude=None):
|
||||
"""
|
||||
Move all the tasks to the specified CGroup
|
||||
|
||||
@@ -145,8 +147,10 @@ class Controller(object):
|
||||
tasks.
|
||||
|
||||
:param exclude: list of commands to keep in the root CGroup
|
||||
:type exlude: list(str)
|
||||
:type exclude: list(str)
|
||||
"""
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
|
||||
if isinstance(exclude, str):
|
||||
exclude = [exclude]
|
||||
@@ -169,6 +173,7 @@ class Controller(object):
|
||||
if cgroup != dest:
|
||||
self.move_tasks(cgroup, dest, grep_filters)
|
||||
|
||||
# pylint: disable=too-many-locals
|
||||
def tasks(self, cgroup,
|
||||
filter_tid='',
|
||||
filter_tname='',
|
||||
@@ -203,8 +208,8 @@ class Controller(object):
|
||||
try:
|
||||
cg = self._cgroups[cgroup]
|
||||
except KeyError as e:
|
||||
raise ValueError('Unkown group: {}'.format(e))
|
||||
output = self.target._execute_util(
|
||||
raise ValueError('Unknown group: {}'.format(e))
|
||||
output = self.target._execute_util( # pylint: disable=protected-access
|
||||
'cgroups_tasks_in {}'.format(cg.directory),
|
||||
as_root=True)
|
||||
entries = output.splitlines()
|
||||
@@ -234,7 +239,7 @@ class Controller(object):
|
||||
try:
|
||||
cg = self._cgroups[cgroup]
|
||||
except KeyError as e:
|
||||
raise ValueError('Unkown group: {}'.format(e))
|
||||
raise ValueError('Unknown group: {}'.format(e))
|
||||
output = self.target.execute(
|
||||
'{} wc -l {}/tasks'.format(
|
||||
self.target.busybox, cg.directory),
|
||||
@@ -286,7 +291,7 @@ class CGroup(object):
|
||||
self.controller.kind)
|
||||
logging.debug(' %s',
|
||||
self.directory)
|
||||
output = self.target._execute_util(
|
||||
output = self.target._execute_util( # pylint: disable=protected-access
|
||||
'cgroups_get_attributes {} {}'.format(
|
||||
self.directory, self.controller.kind),
|
||||
as_root=True)
|
||||
@@ -302,7 +307,7 @@ class CGroup(object):
|
||||
if isiterable(attrs[idx]):
|
||||
attrs[idx] = list_to_ranges(attrs[idx])
|
||||
# Build attribute path
|
||||
if self.controller._noprefix:
|
||||
if self.controller._noprefix: # pylint: disable=protected-access
|
||||
attr_name = '{}'.format(idx)
|
||||
else:
|
||||
attr_name = '{}.{}'.format(self.controller.kind, idx)
|
||||
@@ -363,7 +368,7 @@ class CgroupsModule(Module):
|
||||
|
||||
# Get the list of the available controllers
|
||||
subsys = self.list_subsystems()
|
||||
if len(subsys) == 0:
|
||||
if subsys:
|
||||
self.logger.warning('No CGroups controller available')
|
||||
return
|
||||
|
||||
@@ -444,11 +449,11 @@ class CgroupsModule(Module):
|
||||
A regexps of tasks names can be used to defined tasks which should not
|
||||
be moved.
|
||||
"""
|
||||
return self.target._execute_util(
|
||||
return self.target._execute_util( # pylint: disable=protected-access
|
||||
'cgroups_tasks_move {} {} {}'.format(srcg, dstg, exclude),
|
||||
as_root=True)
|
||||
|
||||
def isolate(self, cpus, exclude=[]):
|
||||
def isolate(self, cpus, exclude=None):
|
||||
"""
|
||||
Remove all userspace tasks from specified CPUs.
|
||||
|
||||
@@ -465,6 +470,8 @@ class CgroupsModule(Module):
|
||||
sandbox is the CGroup of sandboxed CPUs
|
||||
isolated is the CGroup of isolated CPUs
|
||||
"""
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
all_cpus = set(range(self.target.number_of_cpus))
|
||||
sbox_cpus = list(all_cpus - set(cpus))
|
||||
isol_cpus = list(all_cpus - set(sbox_cpus))
|
||||
@@ -483,7 +490,7 @@ class CgroupsModule(Module):
|
||||
|
||||
return sbox_cg, isol_cg
|
||||
|
||||
def freeze(self, exclude=[], thaw=False):
|
||||
def freeze(self, exclude=None, thaw=False):
|
||||
"""
|
||||
Freeze all user-space tasks but the specified ones
|
||||
|
||||
@@ -501,6 +508,9 @@ class CgroupsModule(Module):
|
||||
:type thaw: bool
|
||||
"""
|
||||
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
|
||||
# Create Freezer CGroup
|
||||
freezer = self.controller('freezer')
|
||||
if freezer is None:
|
||||
@@ -509,7 +519,8 @@ class CgroupsModule(Module):
|
||||
cmd = 'cgroups_freezer_set_state {{}} {}'.format(freezer_cg.directory)
|
||||
|
||||
if thaw:
|
||||
# Restart froozen tasks
|
||||
# Restart frozen tasks
|
||||
# pylint: disable=protected-access
|
||||
freezer.target._execute_util(cmd.format('THAWED'), as_root=True)
|
||||
# Remove all tasks from freezer
|
||||
freezer.move_all_tasks_to('/')
|
||||
@@ -522,7 +533,7 @@ class CgroupsModule(Module):
|
||||
tasks = freezer.tasks('/')
|
||||
|
||||
# Freeze all tasks
|
||||
# pylint: disable=protected-access
|
||||
freezer.target._execute_util(cmd.format('FROZEN'), as_root=True)
|
||||
|
||||
return tasks
|
||||
|
||||
|
@@ -37,12 +37,14 @@ class MbedFanActiveCoolingModule(Module):
|
||||
with open_serial_connection(timeout=self.timeout,
|
||||
port=self.port,
|
||||
baudrate=self.baud) as target:
|
||||
# pylint: disable=no-member
|
||||
target.sendline('motor_{}_1'.format(self.fan_pin))
|
||||
|
||||
def stop(self):
|
||||
with open_serial_connection(timeout=self.timeout,
|
||||
port=self.port,
|
||||
baudrate=self.baud) as target:
|
||||
# pylint: disable=no-member
|
||||
target.sendline('motor_{}_0'.format(self.fan_pin))
|
||||
|
||||
|
||||
|
@@ -200,7 +200,7 @@ class CpufreqModule(Module):
|
||||
could not be found.
|
||||
"""
|
||||
freqs = self.list_frequencies(cpu)
|
||||
return freqs and max(freqs) or None
|
||||
return max(freqs) if freqs else None
|
||||
|
||||
@memoized
|
||||
def get_min_available_frequency(self, cpu):
|
||||
@@ -209,7 +209,7 @@ class CpufreqModule(Module):
|
||||
could not be found.
|
||||
"""
|
||||
freqs = self.list_frequencies(cpu)
|
||||
return freqs and min(freqs) or None
|
||||
return min(freqs) if freqs else None
|
||||
|
||||
def get_min_frequency(self, cpu):
|
||||
"""
|
||||
@@ -380,6 +380,7 @@ class CpufreqModule(Module):
|
||||
"""
|
||||
Set the specified (minimum) frequency for all the (online) CPUs
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
return self.target._execute_util(
|
||||
'cpufreq_set_all_frequencies {}'.format(freq),
|
||||
as_root=True)
|
||||
@@ -388,6 +389,7 @@ class CpufreqModule(Module):
|
||||
"""
|
||||
Get the current frequency for all the (online) CPUs
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
output = self.target._execute_util(
|
||||
'cpufreq_get_all_frequencies', as_root=True)
|
||||
frequencies = {}
|
||||
@@ -403,6 +405,7 @@ class CpufreqModule(Module):
|
||||
Set the specified governor for all the (online) CPUs
|
||||
"""
|
||||
try:
|
||||
# pylint: disable=protected-access
|
||||
return self.target._execute_util(
|
||||
'cpufreq_set_all_governors {}'.format(governor),
|
||||
as_root=True)
|
||||
@@ -421,6 +424,7 @@ class CpufreqModule(Module):
|
||||
"""
|
||||
Get the current governor for all the (online) CPUs
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
output = self.target._execute_util(
|
||||
'cpufreq_get_all_governors', as_root=True)
|
||||
governors = {}
|
||||
@@ -435,6 +439,7 @@ class CpufreqModule(Module):
|
||||
"""
|
||||
Report current frequencies on trace file
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
return self.target._execute_util('cpufreq_trace_all_frequencies', as_root=True)
|
||||
|
||||
def get_affected_cpus(self, cpu):
|
||||
@@ -478,7 +483,7 @@ class CpufreqModule(Module):
|
||||
"""
|
||||
cpus = set(range(self.target.number_of_cpus))
|
||||
while cpus:
|
||||
cpu = next(iter(cpus))
|
||||
cpu = next(iter(cpus)) # pylint: disable=stop-iteration-return
|
||||
domain = self.target.cpufreq.get_related_cpus(cpu)
|
||||
yield domain
|
||||
cpus = cpus.difference(domain)
|
||||
|
@@ -16,7 +16,6 @@
|
||||
from past.builtins import basestring
|
||||
|
||||
from devlib.module import Module
|
||||
from devlib.utils.misc import memoized
|
||||
from devlib.utils.types import integer, boolean
|
||||
|
||||
|
||||
@@ -51,6 +50,7 @@ class CpuidleState(object):
|
||||
self.desc = desc
|
||||
self.power = power
|
||||
self.latency = latency
|
||||
self.residency = residency
|
||||
self.id = self.target.path.basename(self.path)
|
||||
self.cpu = self.target.path.basename(self.target.path.dirname(path))
|
||||
|
||||
@@ -166,7 +166,8 @@ class Cpuidle(Module):
|
||||
"""
|
||||
Momentarily wake each CPU. Ensures cpu_idle events in trace file.
|
||||
"""
|
||||
output = self.target._execute_util('cpuidle_wake_all_cpus')
|
||||
# pylint: disable=protected-access
|
||||
self.target._execute_util('cpuidle_wake_all_cpus')
|
||||
|
||||
def get_driver(self):
|
||||
return self.target.read_value(self.target.path.join(self.root_path, 'current_driver'))
|
||||
|
@@ -200,7 +200,7 @@ class DevfreqModule(Module):
|
||||
Set the specified governor for all the (available) devices
|
||||
"""
|
||||
try:
|
||||
return self.target._execute_util(
|
||||
return self.target._execute_util( # pylint: disable=protected-access
|
||||
'devfreq_set_all_governors {}'.format(governor), as_root=True)
|
||||
except TargetError as e:
|
||||
if ("echo: I/O error" in str(e) or
|
||||
@@ -217,7 +217,7 @@ class DevfreqModule(Module):
|
||||
"""
|
||||
Get the current governor for all the (online) CPUs
|
||||
"""
|
||||
output = self.target._execute_util(
|
||||
output = self.target._execute_util( # pylint: disable=protected-access
|
||||
'devfreq_get_all_governors', as_root=True)
|
||||
governors = {}
|
||||
for x in output.splitlines():
|
||||
@@ -241,7 +241,7 @@ class DevfreqModule(Module):
|
||||
"""
|
||||
Set the specified (minimum) frequency for all the (available) devices
|
||||
"""
|
||||
return self.target._execute_util(
|
||||
return self.target._execute_util( # pylint: disable=protected-access
|
||||
'devfreq_set_all_frequencies {}'.format(freq),
|
||||
as_root=True)
|
||||
|
||||
@@ -249,7 +249,7 @@ class DevfreqModule(Module):
|
||||
"""
|
||||
Get the current frequency for all the (available) devices
|
||||
"""
|
||||
output = self.target._execute_util(
|
||||
output = self.target._execute_util( # pylint: disable=protected-access
|
||||
'devfreq_get_all_frequencies', as_root=True)
|
||||
frequencies = {}
|
||||
for x in output.splitlines():
|
||||
@@ -258,4 +258,3 @@ class DevfreqModule(Module):
|
||||
break
|
||||
frequencies[kv[0]] = kv[1]
|
||||
return frequencies
|
||||
|
||||
|
@@ -14,16 +14,13 @@
|
||||
|
||||
import re
|
||||
import sys
|
||||
import logging
|
||||
import os.path
|
||||
from collections import defaultdict
|
||||
|
||||
import devlib
|
||||
from devlib.exception import TargetError
|
||||
from devlib.exception import TargetError, HostError
|
||||
from devlib.module import Module
|
||||
from devlib.platform import Platform
|
||||
from devlib.platform.gem5 import Gem5SimulationPlatform
|
||||
from devlib.utils.gem5 import iter_statistics_dump, GEM5STATS_ROI_NUMBER, GEM5STATS_DUMP_TAIL
|
||||
from devlib.utils.gem5 import iter_statistics_dump, GEM5STATS_ROI_NUMBER
|
||||
|
||||
|
||||
class Gem5ROI:
|
||||
@@ -39,7 +36,7 @@ class Gem5ROI:
|
||||
self.target.execute('m5 roistart {}'.format(self.number))
|
||||
self.running = True
|
||||
return True
|
||||
|
||||
|
||||
def stop(self):
|
||||
if not self.running:
|
||||
return False
|
||||
@@ -49,7 +46,7 @@ class Gem5ROI:
|
||||
|
||||
class Gem5StatsModule(Module):
|
||||
'''
|
||||
Module controlling Region of Interest (ROIs) markers, satistics dump
|
||||
Module controlling Region of Interest (ROIs) markers, satistics dump
|
||||
frequency and parsing statistics log file when using gem5 platforms.
|
||||
|
||||
ROIs are identified by user-defined labels and need to be booked prior to
|
||||
@@ -91,7 +88,7 @@ class Gem5StatsModule(Module):
|
||||
raise KeyError('Incorrect ROI label: {}'.format(label))
|
||||
if not self.rois[label].start():
|
||||
raise TargetError('ROI {} was already running'.format(label))
|
||||
|
||||
|
||||
def roi_end(self, label):
|
||||
if label not in self.rois:
|
||||
raise KeyError('Incorrect ROI label: {}'.format(label))
|
||||
@@ -105,7 +102,7 @@ class Gem5StatsModule(Module):
|
||||
msg = 'Delay ({}) and period ({}) for periodic dumps must be positive'
|
||||
raise ValueError(msg.format(delay_ns, period_ns))
|
||||
self.target.execute('m5 dumpresetstats {} {}'.format(delay_ns, period_ns))
|
||||
|
||||
|
||||
def match(self, keys, rois_labels, base_dump=0):
|
||||
'''
|
||||
Extract specific values from the statistics log file of gem5
|
||||
@@ -116,49 +113,49 @@ class Gem5StatsModule(Module):
|
||||
keys.
|
||||
:type keys: list
|
||||
|
||||
:param rois_labels: list of ROIs labels. ``match()`` returns the
|
||||
:param rois_labels: list of ROIs labels. ``match()`` returns the
|
||||
values of the specified fields only during dumps spanned by at
|
||||
least one of these ROIs.
|
||||
:type rois_label: list
|
||||
|
||||
:param base_dump: dump number from which ``match()`` should operate. By
|
||||
specifying a non-zero dump number, one can virtually truncate
|
||||
:param base_dump: dump number from which ``match()`` should operate. By
|
||||
specifying a non-zero dump number, one can virtually truncate
|
||||
the head of the stats file and ignore all dumps before a specific
|
||||
instant. The value of ``base_dump`` will typically (but not
|
||||
instant. The value of ``base_dump`` will typically (but not
|
||||
necessarily) be the result of a previous call to ``next_dump_no``.
|
||||
Default value is 0.
|
||||
:type base_dump: int
|
||||
|
||||
:returns: a dict indexed by key parameters containing a dict indexed by
|
||||
ROI labels containing an in-order list of records for the key under
|
||||
consideration during the active intervals of the ROI.
|
||||
|
||||
consideration during the active intervals of the ROI.
|
||||
|
||||
Example of return value:
|
||||
* Result of match(['sim_'],['roi_1']):
|
||||
{
|
||||
'sim_inst':
|
||||
'sim_inst':
|
||||
{
|
||||
'roi_1': [265300176, 267975881]
|
||||
}
|
||||
'sim_ops':
|
||||
'sim_ops':
|
||||
{
|
||||
'roi_1': [324395787, 327699419]
|
||||
}
|
||||
'sim_seconds':
|
||||
'sim_seconds':
|
||||
{
|
||||
'roi_1': [0.199960, 0.199897]
|
||||
}
|
||||
'sim_freq':
|
||||
'sim_freq':
|
||||
{
|
||||
'roi_1': [1000000000000, 1000000000000]
|
||||
}
|
||||
'sim_ticks':
|
||||
'sim_ticks':
|
||||
{
|
||||
'roi_1': [199960234227, 199896897330]
|
||||
}
|
||||
}
|
||||
'''
|
||||
records = defaultdict(lambda : defaultdict(list))
|
||||
records = defaultdict(lambda: defaultdict(list))
|
||||
for record, active_rois in self.match_iter(keys, rois_labels, base_dump):
|
||||
for key in record:
|
||||
for roi_label in active_rois:
|
||||
@@ -178,15 +175,15 @@ class Gem5StatsModule(Module):
|
||||
|
||||
Example of return value:
|
||||
* Result of match_iter(['sim_'],['roi_1', 'roi_2']).next()
|
||||
(
|
||||
{
|
||||
(
|
||||
{
|
||||
'sim_inst': 265300176,
|
||||
'sim_ops': 324395787,
|
||||
'sim_seconds': 0.199960,
|
||||
'sim_seconds': 0.199960,
|
||||
'sim_freq': 1000000000000,
|
||||
'sim_ticks': 199960234227,
|
||||
},
|
||||
[ 'roi_1 ' ]
|
||||
[ 'roi_1 ' ]
|
||||
)
|
||||
'''
|
||||
for label in rois_labels:
|
||||
@@ -195,11 +192,11 @@ class Gem5StatsModule(Module):
|
||||
if self.rois[label].running:
|
||||
self.logger.warning('Trying to match records in statistics file'
|
||||
' while ROI {} is running'.format(label))
|
||||
|
||||
|
||||
# Construct one large regex that concatenates all keys because
|
||||
# matching one large expression is more efficient than several smaller
|
||||
all_keys_re = re.compile('|'.join(keys))
|
||||
|
||||
|
||||
def roi_active(roi_label, dump):
|
||||
roi = self.rois[roi_label]
|
||||
return (roi.field in dump) and (int(dump[roi.field]) == 1)
|
||||
@@ -215,8 +212,8 @@ class Gem5StatsModule(Module):
|
||||
def next_dump_no(self):
|
||||
'''
|
||||
Returns the number of the next dump to be written to the stats file.
|
||||
|
||||
For example, if next_dump_no is called while there are 5 (0 to 4) full
|
||||
|
||||
For example, if next_dump_no is called while there are 5 (0 to 4) full
|
||||
dumps in the stats file, it will return 5. This will be usefull to know
|
||||
from which dump one should match() in the future to get only data from
|
||||
now on.
|
||||
@@ -224,7 +221,7 @@ class Gem5StatsModule(Module):
|
||||
with open(self._stats_file_path, 'r') as stats_file:
|
||||
# _goto_dump reach EOF and returns the total number of dumps + 1
|
||||
return self._goto_dump(stats_file, sys.maxsize)
|
||||
|
||||
|
||||
def _goto_dump(self, stats_file, target_dump):
|
||||
if target_dump < 0:
|
||||
raise HostError('Cannot go to dump {}'.format(target_dump))
|
||||
@@ -238,12 +235,12 @@ class Gem5StatsModule(Module):
|
||||
curr_dump = max(prev_dumps)
|
||||
curr_pos = self._dump_pos_cache[curr_dump]
|
||||
stats_file.seek(curr_pos)
|
||||
|
||||
|
||||
# And iterate until target_dump
|
||||
dump_iterator = iter_statistics_dump(stats_file)
|
||||
while curr_dump < target_dump:
|
||||
try:
|
||||
dump = next(dump_iterator)
|
||||
next(dump_iterator)
|
||||
except StopIteration:
|
||||
break
|
||||
# End of passed dump is beginning og next one
|
||||
@@ -251,4 +248,3 @@ class Gem5StatsModule(Module):
|
||||
curr_dump += 1
|
||||
self._dump_pos_cache[curr_dump] = curr_pos
|
||||
return curr_dump
|
||||
|
||||
|
@@ -28,7 +28,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import re
|
||||
import json
|
||||
from devlib.module import Module
|
||||
from devlib.exception import TargetError
|
||||
from devlib.utils.misc import memoized
|
||||
@@ -57,7 +56,7 @@ class GpufreqModule(Module):
|
||||
|
||||
def set_governor(self, governor):
|
||||
if governor not in self.governors:
|
||||
raise TargetError('Governor {} not supported for gpu {}'.format(governor, cpu))
|
||||
raise TargetError('Governor {} not supported for gpu'.format(governor))
|
||||
self.target.write_value("/sys/kernel/gpu/gpu_governor", governor)
|
||||
|
||||
def get_frequencies(self):
|
||||
@@ -85,6 +84,6 @@ class GpufreqModule(Module):
|
||||
Returns the model name reported by the GPU.
|
||||
"""
|
||||
try:
|
||||
return self.target.read_value("/sys/kernel/gpu/gpu_model")
|
||||
except:
|
||||
return "unknown"
|
||||
return self.target.read_value("/sys/kernel/gpu/gpu_model")
|
||||
except: # pylint: disable=bare-except
|
||||
return "unknown"
|
||||
|
@@ -36,7 +36,7 @@ class HotplugModule(Module):
|
||||
return target.path.join(cls.base_path, cpu, 'online')
|
||||
|
||||
def online_all(self):
|
||||
self.target._execute_util('hotplug_online_all',
|
||||
self.target._execute_util('hotplug_online_all', # pylint: disable=protected-access
|
||||
as_root=self.target.is_rooted)
|
||||
|
||||
def online(self, *args):
|
||||
@@ -53,4 +53,3 @@ class HotplugModule(Module):
|
||||
return
|
||||
value = 1 if online else 0
|
||||
self.target.write_value(path, value)
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
import os
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
@@ -147,4 +146,3 @@ class HwmonModule(Module):
|
||||
self.logger.debug('Adding device {}'.format(name))
|
||||
device = HwmonDevice(self.target, path, name, fields)
|
||||
self.devices.append(device)
|
||||
|
||||
|
@@ -30,11 +30,11 @@
|
||||
import logging
|
||||
import re
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
from devlib.module import Module
|
||||
from devlib.utils.misc import memoized
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
|
||||
class SchedProcFSNode(object):
|
||||
"""
|
||||
@@ -156,6 +156,7 @@ class SchedDomain(SchedProcFSNode):
|
||||
"""
|
||||
Represents a sched domain as seen through procfs
|
||||
"""
|
||||
# pylint: disable=bad-whitespace
|
||||
# Domain flags obtained from include/linux/sched/topology.h on v4.17
|
||||
# https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux/+/v4.17/include/linux/sched/topology.h#20
|
||||
SD_LOAD_BALANCE = 0x0001 # Do load balancing on this domain.
|
||||
|
@@ -209,6 +209,7 @@ class VexpressUefiShellBoot(VexpressBootModule):
|
||||
|
||||
name = 'vexpress-uefi-shell'
|
||||
|
||||
# pylint: disable=keyword-arg-before-vararg
|
||||
def __init__(self, target, uefi_entry='^Shell$',
|
||||
efi_shell_prompt='Shell>',
|
||||
image='kernel', bootargs=None,
|
||||
@@ -239,6 +240,7 @@ class VexpressUBoot(VexpressBootModule):
|
||||
|
||||
name = 'vexpress-u-boot'
|
||||
|
||||
# pylint: disable=keyword-arg-before-vararg
|
||||
def __init__(self, target, env=None,
|
||||
*args, **kwargs):
|
||||
super(VexpressUBoot, self).__init__(target, *args, **kwargs)
|
||||
@@ -260,6 +262,7 @@ class VexpressBootmon(VexpressBootModule):
|
||||
|
||||
name = 'vexpress-bootmon'
|
||||
|
||||
# pylint: disable=keyword-arg-before-vararg
|
||||
def __init__(self, target,
|
||||
image, fdt, initrd, bootargs,
|
||||
uses_bootscript=False,
|
||||
@@ -282,11 +285,11 @@ class VexpressBootmon(VexpressBootModule):
|
||||
with open_serial_connection(port=self.port,
|
||||
baudrate=self.baudrate,
|
||||
timeout=self.timeout,
|
||||
init_dtr=0) as tty:
|
||||
write_characters(tty, 'fl linux fdt {}'.format(self.fdt))
|
||||
write_characters(tty, 'fl linux initrd {}'.format(self.initrd))
|
||||
write_characters(tty, 'fl linux boot {} {}'.format(self.image,
|
||||
self.bootargs))
|
||||
init_dtr=0) as tty_conn:
|
||||
write_characters(tty_conn, 'fl linux fdt {}'.format(self.fdt))
|
||||
write_characters(tty_conn, 'fl linux initrd {}'.format(self.initrd))
|
||||
write_characters(tty_conn, 'fl linux boot {} {}'.format(self.image,
|
||||
self.bootargs))
|
||||
|
||||
|
||||
class VersatileExpressFlashModule(FlashModule):
|
||||
@@ -328,9 +331,10 @@ class VersatileExpressFlashModule(FlashModule):
|
||||
baudrate=self.target.platform.baudrate,
|
||||
timeout=self.timeout,
|
||||
init_dtr=0) as tty:
|
||||
# pylint: disable=no-member
|
||||
i = tty.expect([self.mcc_prompt, AUTOSTART_MESSAGE, OLD_AUTOSTART_MESSAGE])
|
||||
if i:
|
||||
tty.sendline('')
|
||||
tty.sendline('') # pylint: disable=no-member
|
||||
wait_for_vemsd(self.vemsd_mount, tty, self.mcc_prompt, self.short_delay)
|
||||
try:
|
||||
if image_bundle:
|
||||
@@ -387,4 +391,3 @@ def wait_for_vemsd(vemsd_mount, tty, mcc_prompt=DEFAULT_MCC_PROMPT, short_delay=
|
||||
if os.path.exists(path):
|
||||
return
|
||||
raise TargetError('Could not mount {}'.format(vemsd_mount))
|
||||
|
||||
|
Reference in New Issue
Block a user