Viewing File: /usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/plugin_uncore.cpython-36.pyc

3

�<�es�@sjddlmZddlTddlZddlmZddlZddlZej	j
�Ze�ZdZ
dZdZGdd�dej�ZdS)	�)�hotplug)�*�N)�commandsz//sys/devices/system/cpu/intel_uncore_frequency/c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
dd�Zeddd�dd��Z
ed�ddd��Zeddd�dd��Zed�ddd��ZdS) �UncorePlugina|
	`uncore`::

	`max_freq_khz, min_freq_khz`:::
	Limit the maximum and minumum uncore frequency.

	Those options are Intel specific and correspond directly to `sysfs` files
	exposed by Intel uncore frequency driver.
	====
	----
	[uncore]
	max_freq_khz=4000000
	----
	Using this options *TuneD* will limit maximum frequency of all uncore units
	on the Intel system to 4 GHz.
	====
	cCs�d|_t�|_t�|_d|_ytjt�}Wntk
r>dSXt	j
|d�}t|�dkrbd|_|}x|D]}|jj|�qhWt
jdt|j��dS)NTFzuncore*rzdevices: %s)Z_devices_supported�setZ_assigned_devicesZ
_free_devicesZ_is_tpmi�os�listdir�	SYSFS_DIR�OSError�fnmatch�filter�len�add�log�debug�str)�selfZdevicesZtpmi_devices�d�r�#/usr/lib/python3.6/plugin_uncore.py�
_init_devices$s
zUncorePlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r�instancerrr�_instance_init:szUncorePlugin._instance_initcCsdS)Nr)rrrrr�_instance_cleanup>szUncorePlugin._instance_cleanupcCs2t|d|}tj|�}t|�dkr.t|�SdS)N�/r)r
�cmdZ	read_filer�int)r�dev_dir�file�
sysfs_file�valuerrr�_getAs

zUncorePlugin._getcCs(t|d|}tj|d|�r$|SdS)Nrz%u)r
rZ
write_to_file)rrrr!r rrr�_setHszUncorePlugin._setcCs
ddd�S)N)�max_freq_khz�min_freq_khzr)�clsrrr�_get_config_optionsNsz UncorePlugin._get_config_optionsc	Cs*yt|�}Wn"tk
r.tjd|�dSXy4|j|d�}|j|d�}|j|d�}|j|d�}Wn"ttfk
r�tjd�dSX|tkr�||kr�tjd|||f�dS||kr�tjd|||f�|}nT|t	k�r"||k�r�tjd	|||f�dS||k�r&tjd
|||f�|}ndS|S)Nzvalue '%s' is not integer�initial_max_freq_khz�initial_min_freq_khzr$r%z+fail to read inital uncore frequency valuesz/%s: max_freq_khz %d value below min_freq_khz %dzC%s: max_freq_khz %d value above initial_max_freq_khz - capped to %dz/%s: min_freq_khz %d value above max_freq_khz %dzC%s: min_freq_khz %d value below initial_max_freq_khz - capped to %d)
r�
ValueErrorr�errorr"r�IOError�IS_MAX�info�IS_MIN)	r�deviceZ
min_or_maxr!Zfreq_khzr(r)r$r%rrr�_validate_valueUs:



zUncorePlugin._validate_valuer$T)Z
per_devicecCsB|j|t|�}|dkrdS|r"|Stjd||f�|j|d|�S)Nz%s: set max_freq_khz %dr$)r1r-rrr#)rr!r0�sim�remover$rrr�_set_max_freq_khz|szUncorePlugin._set_max_freq_khzFcCs`|rtjjt�rdSy|j|d�}Wn"ttfk
rHtjd�dSXtj	d||f�|S)Nr$z$fail to read uncore frequency valuesz%s: get max_freq_khz %d)
r�path�isdirr
r"rr,rr+r)rr0�ignore_missingr$rrr�_get_max_freq_khz�s
zUncorePlugin._get_max_freq_khzr%cCsB|j|t|�}|dkrdS|r"|Stjd||f�|j|d|�S)Nz%s: set min_freq_khz %dr%)r1r/rrr#)rr!r0r2r3r%rrr�_set_min_freq_khz�szUncorePlugin._set_min_freq_khzcCs`|rtjjt�rdSy|j|d�}Wn"ttfk
rHtjd�dSXtj	d||f�|S)Nr%z$fail to read uncore frequency valuesz%s: get min_freq_khz %d)
rr5r6r
r"rr,rr+r)rr0r7r%rrr�_get_min_freq_khz�s
zUncorePlugin._get_min_freq_khzN)F)F)�__name__�
__module__�__qualname__�__doc__rrrr"r#�classmethodr'r1Zcommand_setr4Zcommand_getr8r9r:rrrrrs'
r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrrrZlogs�getrrr
r/r-ZPluginrrrrr�<module>s

Back to Directory File Manager
<