Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncore perf #519

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions profiles/throughput-intel-uncore-balanced-performance/tuned.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# tuned configuration
#

[main]
summary=Broadly applicable tuning that provides excellent performance across a variety of common server workloads with lower uncore power
include=throughput-performance

[cpu]
uncore_max_delta_mhz=200
61 changes: 60 additions & 1 deletion tuned/plugins/plugin_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ class CPULatencyPlugin(hotplug.Plugin):
pm_qos_resume_latency_us=100
----
Allows any C-state with a resume latency less than value.
[cpu]
uncore_max_delta_mhz=0
----
Limit the maximum uncore frequency that hardware will use. This value is in
Mega Hertz units. This value specifies an offset from the default uncore maximum
frequency. For example, the value of 200 means that maximum uncore frequency
will be capped to the default uncore maximum frequency minus 200 MHz.
"""

def __init__(self, *args, **kwargs):
Expand All @@ -198,6 +205,7 @@ def __init__(self, *args, **kwargs):
self._has_intel_pstate = False
self._has_pm_qos_resume_latency_us = None

self._uncore_max_delta_mhz_save = None
self._min_perf_pct_save = None
self._max_perf_pct_save = None
self._no_turbo_save = None
Expand Down Expand Up @@ -228,6 +236,7 @@ def _get_config_options(self):
"governor" : None,
"sampling_down_factor" : None,
"energy_perf_bias" : None,
"uncore_max_delta_mhz" : None,
"min_perf_pct" : None,
"max_perf_pct" : None,
"no_turbo" : None,
Expand Down Expand Up @@ -359,6 +368,10 @@ def _instance_apply_static(self, instance):
if not instance._first_instance:
return

uncore_max_delta_mhz = self._variables.expand(
instance.options["uncore_max_delta_mhz"])
if uncore_max_delta_mhz is not None:
self._set_uncore_max_delta_mhz(uncore_max_delta_mhz)
force_latency_value = self._variables.expand(
instance.options["force_latency"])
if force_latency_value is not None:
Expand All @@ -380,7 +393,13 @@ def _instance_apply_static(self, instance):
def _instance_unapply_static(self, instance, full_rollback = False):
super(CPULatencyPlugin, self)._instance_unapply_static(instance, full_rollback)

if instance._first_instance and self._has_intel_pstate:
if not instance._first_instance:
return

if self._uncore_max_delta_mhz_save is not None:
self._unset_uncore_max_delta_mhz()

if self._has_intel_pstate:
self._set_intel_pstate_attr("min_perf_pct", self._min_perf_pct_save)
self._set_intel_pstate_attr("max_perf_pct", self._max_perf_pct_save)
self._set_intel_pstate_attr("no_turbo", self._no_turbo_save)
Expand Down Expand Up @@ -408,6 +427,46 @@ def _str2int(self, s):
except (ValueError, TypeError):
return None

def _get_uncore_data(self):
out, files = dict(), ['initial_max_freq_khz', 'max_freq_khz']
dir = '/sys/devices/system/cpu/intel_uncore_frequency'
for dirname, dirnames, filenames in os.walk(dir):
pkg, ignore = dict(), False
for file in files:
if file not in filenames:
ignore = True
break
fpath = os.path.join(dirname, file)
data = self._cmd.read_file(fpath, err_ret=None, no_error=True)
try:
value = int(data.strip())
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException'

Except block directly handles BaseException.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in the next version, once issue with the general direction regarding profile is clear.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I assume from this that the "int" call has its own baseexception that I'm overriding. Not sure what the problem is with that but I can replace this with a simple "if re.match('[0-9]+', data.strip()):". That try/catch is just there in case the sysfs file returns garbage (e.g. anything other than a decimal integer). If it happens I ignore its package and move on like it doesn't exist.

ignore = True
break
pkg[file] = {'path': fpath, 'value': value}
if not ignore:
out[os.path.basename(dirname)] = pkg
return out

def _set_uncore_max_delta_mhz(self, delta):
self._uncore_max_delta_mhz_save = self._get_uncore_data()
for n in self._uncore_max_delta_mhz_save:
pkg = self._uncore_max_delta_mhz_save[n]
ival = pkg['initial_max_freq_khz']['value']
nval = ival - (int(delta) * 1000)
file = pkg['max_freq_khz']['path']
self._cmd.write_to_file(file, nval)
log.info('Set uncore_max_delta_mhz = %s for %s' % (delta, n))

def _unset_uncore_max_delta_mhz(self):
for n in self._uncore_max_delta_mhz_save:
pkg = self._uncore_max_delta_mhz_save[n]
file = pkg['max_freq_khz']['path']
value = pkg['max_freq_khz']['value']
if os.path.exists(file):
self._cmd.write_to_file(file, value)
log.info('Unset uncore_max_delta_mhz for %s' % n)

def _read_cstates_latency(self):
self.cstates_latency = {}
for d in os.listdir(cpuidle_states_path):
Expand Down