����JFIF��`�`�����Viewing File: /lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_uncore.cpython-39.pyc
a

���h��@sjddlmZddlTddlZddlmZddlZddlZej	�
�Ze�ZdZ
dZdZGdd�dej�ZdS)	�)�hotplug)�*�N)�commandsz//sys/devices/system/cpu/intel_uncore_frequency/c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Zdd�Zdd�Z
dd�Zeddd�dd��Zed�d$dd��Zeddd�dd ��Zed�d%d!d"��Zd#S)&�UncorePlugina�
	An Intel-specific plug-in for limiting the maximum and minimum uncore frequency.

	The options [option]`max_freq_khz`, [option]`min_freq_khz` correspond to
	`sysfs` files exposed by Intel uncore frequency driver. Their values can be
	specified in kHz or as a percentage of their configurable range.

	.Limiting maximum uncore frequency
	====
	----
	[uncore10]
	type=uncore
	devices=uncore10
	max_freq_khz=4000000

	[uncore_all]
	type=uncore
	max_freq_khz=90%
	----
	Using this options *TuneD* will limit maximum frequency of all uncore units
	on the Intel system to 90% of the allowable range. Except uncore10 which
	maximum frequency limit will be set to 4 GHz.
	====
	cCs�d|_t�|_t�|_d|_zt�t�}Wnty>YdS0t	�
|d�}t|�dkrbd|_|}|D]}|j�|�qft
�dt|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.9/site-packages/tuned/plugins/plugin_uncore.py�
_init_devices+szUncorePlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning�r�instancerrr�_instance_initAszUncorePlugin._instance_initcCsdS)Nrrrrr�_instance_cleanupEszUncorePlugin._instance_cleanupcCs2t|d|}t�|�}t|�dkr.t|�SdS)N�/r)r
�cmdZ	read_filer�int)r�dev_dir�file�
sysfs_file�valuerrr�_getHs

zUncorePlugin._getcCs(t|d|}t�|d|�r$|SdS)Nrz%u)r
rZ
write_to_file)rrr r"r!rrr�_setOszUncorePlugin._setc	Csdz4|�|d�}|�|d�}|�|d�}|�|d�}Wn"ttfyVt�d�YdS0||||fS)N�initial_max_freq_khz�initial_min_freq_khz�max_freq_khz�min_freq_khz�$fail to read uncore frequency values)r#r�IOErrorr�error)r�devicer%r&r'r(rrr�_get_allUs
zUncorePlugin._get_allcCs
ddd�S)N)r'r(r)�clsrrr�_get_config_options`s�z UncorePlugin._get_config_optionsc
Cs�zt|�}Wn"ty.t�d|�YdS0|�|�}|durFdS|\}}}}	|tkr�||	krzt�d|||	f�dS||kr�t�d|||f�|}nN|tkr�||kr�t�d|||f�dS||kr�t�d|||f�|}ndS|S)N�value '%s' is not integerz/%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�
ValueErrorrr+r-�IS_MAX�info�IS_MIN)
rr,�
min_or_maxr"Zfreq_khz�valuesr%r&r'r(rrr�_validate_khz_valuegs2
z UncorePlugin._validate_khz_valuecCsVzt|�}Wn"ty.t�d|�YdS0|dks@|dkrRt�d|�dS|S)Nr0r�dz/percent value '%s' is not within [0..100] range)rr1rr+)rr"�pctrrr�_validate_percent_value�sz$UncorePlugin._validate_percent_valuec
Cs�t|t�rn|ddkrn|�|�d��}|dur2dS|�|�}|durHdS|\}}}}|t|||d�}	n|}	|�|||	�S)N����%r8)�
isinstancerr:�rstripr-rr7)
rr,r5r"r9r6r%r&�_Zkhzrrr�_validate_value�s
zUncorePlugin._validate_valuer'T)Z
per_devicecCsB|�|t|�}|durdS|r"|St�d||f�|�|d|�S)Nz%s: set max_freq_khz %dr')r@r2rrr$)rr"r,r�sim�remover'rrr�_set_max_freq_khz�szUncorePlugin._set_max_freq_khzFc	Cs^|rtj�t�sdSz|�|d�}Wn"ttfyFt�d�YdS0t�	d||f�|S)Nr'r)z%s: get max_freq_khz %d�
r�path�isdirr
r#rr*rr+r)rr,r�ignore_missingr'rrr�_get_max_freq_khz�s
zUncorePlugin._get_max_freq_khzr(cCsB|�|t|�}|durdS|r"|St�d||f�|�|d|�S)Nz%s: set min_freq_khz %dr()r@r4rrr$)rr"r,rrArBr(rrr�_set_min_freq_khz�szUncorePlugin._set_min_freq_khzc	Cs^|rtj�t�sdSz|�|d�}Wn"ttfyFt�d�YdS0t�	d||f�|S)Nr(r)z%s: get min_freq_khz %drD)rr,rrGr(rrr�_get_min_freq_khz�s
zUncorePlugin._get_min_freq_khzN)F)F)�__name__�
__module__�__qualname__�__doc__rrrr#r$r-�classmethodr/r7r:r@Zcommand_setrCZcommand_getrHrIrJrrrrrs(
#




r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrrrZlogs�getrrr
r4r2ZPluginrrrrr�<module>s

Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����