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