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

module/sched: Fix/simplify procfs packing behaviour

Back when I first wrote this I tried to make something smart that
would automatically detect which procfs entries to pack into a
mapping, the condition to do so being "the entry ends with a
digit and there is another entry with the same name but a different
digit".

I wrongly assumed this would always work for the sched_domain entries,
but it's possible to have a domain with a single group and thus a
single "group0" entry.

Since we know which entries we want to pack, let's hard-code these and
be less smart about it.
This commit is contained in:
Valentin Schneider 2019-03-18 16:21:50 +00:00 committed by Marc Bonnici
parent d76c2d63fe
commit be8b87d559

View File

@ -52,6 +52,12 @@ class SchedProcFSNode(object):
_re_procfs_node = re.compile(r"(?P<name>.*\D)(?P<digits>\d+)$")
PACKABLE_ENTRIES = [
"cpu",
"domain",
"group"
]
@staticmethod
def _ends_with_digits(node):
if not isinstance(node, basestring):
@ -71,18 +77,19 @@ class SchedProcFSNode(object):
"""
:returns: The name of the procfs node
"""
return re.search(SchedProcFSNode._re_procfs_node, node).group("name")
match = re.search(SchedProcFSNode._re_procfs_node, node)
if match:
return match.group("name")
@staticmethod
def _packable(node, entries):
return node
@classmethod
def _packable(cls, node):
"""
:returns: Whether it makes sense to pack a node into a common entry
"""
return (SchedProcFSNode._ends_with_digits(node) and
any([SchedProcFSNode._ends_with_digits(x) and
SchedProcFSNode._node_digits(x) != SchedProcFSNode._node_digits(node) and
SchedProcFSNode._node_name(x) == SchedProcFSNode._node_name(node)
for x in entries]))
SchedProcFSNode._node_name(node) in cls.PACKABLE_ENTRIES)
@staticmethod
def _build_directory(node_name, node_data):
@ -119,7 +126,7 @@ class SchedProcFSNode(object):
# Find which entries can be packed into a common entry
packables = {
node : SchedProcFSNode._node_name(node) + "s"
for node in list(nodes.keys()) if SchedProcFSNode._packable(node, list(nodes.keys()))
for node in list(nodes.keys()) if SchedProcFSNode._packable(node)
}
self._dyn_attrs = {}