Skip to content

Commit

Permalink
[processor] handle msr module loading via predicate
Browse files Browse the repository at this point in the history
The cpupower and turbostat applications are not installed by default on
most environments, but where it is, it will load the `msr` module when
running this commends. Adding the predicate will solve this.

Closes: #3610
Related: #3624, SET-622

Signed-off-by: Arif Ali <arif.ali@canonical.com>
  • Loading branch information
arif-ali authored and TurboTurtle committed Apr 26, 2024
1 parent 9529386 commit 7f11033
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions sos/report/plugins/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, IndependentPlugin
from sos.report.plugins import Plugin, IndependentPlugin, SoSPredicate
from sos.policies.distros.ubuntu import UbuntuPolicy


class Processor(Plugin, IndependentPlugin):
Expand All @@ -18,6 +19,8 @@ class Processor(Plugin, IndependentPlugin):
files = ('/proc/cpuinfo',)
packages = ('cpufreq-utils', 'cpuid')

cpu_kmods = []

def setup(self):

cpupath = '/sys/devices/system/cpu'
Expand Down Expand Up @@ -48,15 +51,24 @@ def setup(self):
self.add_cmd_output([
"lscpu",
"lscpu -ae",
"cpupower frequency-info",
"cpupower info",
"cpupower idle-info",
"cpufreq-info",
"cpuid",
"cpuid -r",
"turbostat --debug sleep 10"
], cmd_as_tag=True)

if (isinstance(self.policy, UbuntuPolicy) and
self.policy.dist_version() == 24.04):
self.cpu_kmods = ['msr']

cpupower_pred = SoSPredicate(self, kmods=self.cpu_kmods)

self.add_cmd_output([
"cpupower frequency-info",
"cpupower info",
"cpupower idle-info",
"turbostat --debug sleep 10",
], cmd_as_tag=True, pred=cpupower_pred)

if '86' in self.policy.get_arch():
self.add_cmd_output("x86info -a")

Expand Down

0 comments on commit 7f11033

Please sign in to comment.