rteval: Construct a 'model name' on architectures that don't have one
PATCH v2 2/5 rteval: Construct a 'model name' on architectures that don't have one
This is based on an idea from Punit Agrawal <[email protected]>
On architectures that lack 'model name' in /proc/cpuinfo create 'model name' Unknown when creating the per core dictionaries in cpuinfo
For arm, we can construct the 'model name' from the 'CPU implementer'
'CPU architecture'
'CPU variant'
'CPU part'
'CPU revision'
--- rteval/misc.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
rteval/misc.py +21 -0
@@ -77,6 +77,27 @@ def cpuinfo(): info[core] = {} continue info[core][key] = val + + for (core, pcdict) in info.items(): + if not 'model name' in pcdict: + # On Arm CPU implementer is present + # Construct the model_name from the following fields + if 'CPU implementer' in pcdict: + model_name = [pcdict.get('CPU implementer')] + model_name.append(pcdict.get('CPU architecture')) + model_name.append(pcdict.get('CPU variant')) + model_name.append(pcdict.get('CPU part')) + model_name.append(pcdict.get('CPU revision', '')) + + # If a list item is None, remove it + model_name = [name for name in model_name if name] + + # Convert the model_name list into a string + model_name = " ".join(model_name) + pcdict['model name'] = model_name + else: + pcdict['model name'] = 'Unknown' + return info if __name__ == "__main__":
Signature · 1 line
2.31.1
Hi John,
Quoted 28 lines · John Kacur
This is based on an idea from Punit Agrawal <[email protected]>
On architectures that lack 'model name' in
/proc/cpuinfocreate 'model name' Unknown when creating the per core dictionaries in cpuinfoFor arm, we can construct the 'model name' from the 'CPU implementer'
'CPU architecture'
'CPU variant'
'CPU part'
'CPU revision'Suggested-by Punit Agrawal <[email protected]>Signed-off-by John Kacur <[email protected]>--- rteval/misc.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)rteval/misc.py +1
-0@@ -77,6 +77,27 @@ def cpuinfo(): info[core] = {} continue info[core][key] = val +
rteval/misc.py def cpuinfo(): · line 90
Quoted 10 lines
rteval/misc.py +10
-0+ for (core, pcdict) in info.items(): + if not 'model name' in pcdict: + # On Arm CPU implementer is present + # Construct the model_name from the following fields + if 'CPU implementer' in pcdict: + model_name = [pcdict.get('CPU implementer')] + model_name.append(pcdict.get('CPU architecture')) + model_name.append(pcdict.get('CPU variant')) + model_name.append(pcdict.get('CPU part')) + model_name.append(pcdict.get('CPU revision', ''))
Is there a reason to use an empty default for "CPU revision" but not for the other components? Maybe a left-over from original patch.
rteval/misc.py def cpuinfo(): · line 103
Quoted 13 lines
rteval/misc.py +10
-0+ + # If a list item is None, remove it + model_name = [name for name in model_name if name] + + # Convert the model_name list into a string + model_name = " ".join(model_name) + pcdict['model name'] = model_name + else: + pcdict['model name'] = 'Unknown' + return info if __name__ == "__main__":
With the above comment addressed, fwiw -
Thanks,
Punit
Quoted 37 lines · Punit Agrawal
Hi John,
Quoted 33 lines · John Kacur
This is based on an idea from Punit Agrawal <[email protected]>
On architectures that lack 'model name' in
/proc/cpuinfocreate 'model name' Unknown when creating the per core dictionaries in cpuinfoFor arm, we can construct the 'model name' from the 'CPU implementer'
'CPU architecture'
'CPU variant'
'CPU part'
'CPU revision'Suggested-by Punit Agrawal <[email protected]>Signed-off-by John Kacur <[email protected]>--- rteval/misc.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)rteval/misc.py +6
-0@@ -77,6 +77,27 @@ def cpuinfo(): info[core] = {} continue info[core][key] = val + + for (core, pcdict) in info.items(): + if not 'model name' in pcdict: + # On Arm CPU implementer is present + # Construct the model_name from the following fields + if 'CPU implementer' in pcdict:
Quoted 8 lines
rteval/misc.py def cpuinfo(): · line 90
Quoted 5 lines
rteval/misc.py +5
-0+ model_name = [pcdict.get('CPU implementer')] + model_name.append(pcdict.get('CPU architecture')) + model_name.append(pcdict.get('CPU variant')) + model_name.append(pcdict.get('CPU part')) + model_name.append(pcdict.get('CPU revision', ''))Is there a reason to use an empty default for "CPU revision" but not for the other components? Maybe a left-over from original patch.
Not sure of the origin of that typo, but thanks for catching it, removing.
Quoted 23 lines
Quoted 4 lines
rteval/misc.py +3
-0+ + # If a list item is None, remove it + model_name = [name for name in model_name if name]rteval/misc.py def cpuinfo(): · line 103
Quoted 10 lines
rteval/misc.py +7
-0+ + # Convert the model_name list into a string + model_name = " ".join(model_name) + pcdict['model name'] = model_name + else: + pcdict['model name'] = 'Unknown' + return info if __name__ == "__main__":With the above comment addressed, fwiw -
Reviewed-by Punit Agrawal <[email protected]>Tested-by Punit Agrawal <[email protected]>Thanks,
Punit