HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_cpu.cpython-39.opt-1.pyc
a

,�g�v�@s�ddlmZddlTddlZddlmZddlmZddl	Z	ddl
Z
ddlZddl
Z
ddlZddl
Z
ej��ZdZGdd�dej�ZdS)	�)�hotplug)�*�N)�commandsz$/sys/devices/system/cpu/cpu0/cpuidlecs^eZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zd d!�Zd"d#�Zd$d%�Z�fd&d'�Zejf�fd(d)�	Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zdvd5d6�Z dwd7d8�Z!dxd9d:�Z"d;d<�Z#d=d>�Z$e%d?d@dA�dBdC��Z&e'd?�dydDdE��Z(dzdGdH�Z)e%dId@dJdK�dLdM��Z*e'dI�d{dNdO��Z+dPdQ�Z,dRdS�Z-d|dTdU�Z.dVdW�Z/e%dXd@dA�dYdZ��Z0d[d\�Z1d]d^�Z2d_d`�Z3e'dX�d}dadb��Z4dcdd�Z5dedf�Z6e%dgd@dA�dhdi��Z7e'dg�d~djdk��Z8e%dld@dA�dmdn��Z9e'dl�ddodp��Z:e%dqd@dA�drds��Z;e'dq�d�dtdu��Z<�Z=S)��CPULatencyPlugina
	Sets the CPU governor to the value specified by the [option]`governor`
	option and dynamically changes the Power Management Quality of
	Service (PM QoS) CPU Direct Memory Access (DMA) latency according
	to the CPU load.
	
	`governor`:::
	The [option]`governor` option of the 'cpu' plug-in supports specifying
	CPU governors. Multiple governors are separated using '|'. The '|'
	character is meant to represent a logical 'or' operator. Note that the
	same syntax is used for the [option]`energy_perf_bias` option. *TuneD*
	will set the first governor that is available on the system.
	+
	.Specifying a CPU governor
	====
	----
	[cpu]
	governor=ondemand|powersave
	----

	*TuneD* will set the 'ondemand'
	governor, if it is available. If it is not available, but the 'powersave'
	governor is available, 'powersave' will be set. If neither of them are
	available, the governor will not be changed.
	====
	
	`sampling_down_factor`:::
	The sampling rate determines how frequently the governor checks
	to tune the CPU. The [option]`sampling_down_factor` is a tunable
	that multiplies the sampling rate when the CPU is at its highest
	clock frequency thereby delaying load evaluation and improving
	performance. Allowed values for sampling_down_factor are 1 to 100000.
	+
	.The recommended setting for jitter reduction
	====
	----
	[cpu]
	sampling_down_factor = 100
	----
	====
	
	`energy_perf_bias`:::
	[option]`energy_perf_bias` supports managing energy
	vs. performance policy via x86 Model Specific Registers using the
	`x86_energy_perf_policy` tool. Multiple alternative Energy Performance
	Bias (EPB) values are supported. The alternative values are separated
	using the '|' character. The following EPB values are supported
	starting with kernel 4.13: "performance", "balance-performance",
	"normal", "balance-power" and "power". On newer processors is value
	writen straight to file (see rhbz#2095829)
	+
	.Specifying alternative Energy Performance Bias values
	====
	----
	[cpu]
	energy_perf_bias=powersave|power
	----
	
	*TuneD* will try to set EPB to 'powersave'. If that fails, it will
	try to set it to 'power'.
	====
	
	`energy_performance_preference`:::
	[option]`energy_performance_preference` supports managing energy
	vs. performance hints on newer Intel and AMD processors with active P-State
	CPU scaling drivers (intel_pstate or amd-pstate). Multiple alternative
	Energy Performance Preferences (EPP) values are supported. The alternative
	values are separated using the '|' character. Available values can be found
	in `energy_performance_available_preferences` file in `CPUFreq` policy
	directory in `sysfs`.
	in
	+
	.Specifying alternative Energy Performance Hints values
	====
	----
	[cpu]
	energy_performance_preference=balance_power|power
	----
	
	*TuneD* will try to set EPP to 'balance_power'. If that fails, it will
	try to set it to 'power'.
	====
	
	`latency_low, latency_high, load_threshold`:::
	+
	If the CPU load is lower than the value specified by
	the [option]`load_threshold` option, the latency is set to the value
	specified either by the [option]`latency_high` option or by the
	[option]`latency_low` option.

	`force_latency`:::
	You can also force the latency to a specific value and prevent it from
	dynamically changing further. To do so, set the [option]`force_latency`
	option to the required latency value.
	+
	The maximum latency value can be specified in several ways:
	+
	--
	* by a numerical value in microseconds (for example, `force_latency=10`)
	* as the kernel CPU idle level ID of the maximum C-state allowed
	  (for example, force_latency = cstate.id:1)
	* as a case sensitive name of the maximum C-state allowed
	  (for example, force_latency = cstate.name:C1)
	* by using 'None' as a fallback value to prevent errors when alternative
	  C-state IDs/names do not exist. When 'None' is used in the alternatives
	  pipeline, all the alternatives that follow 'None' are ignored.
	--
	+
	It is also possible to specify multiple fallback values separated by '|' as
	the C-state names and/or IDs may not be available on some systems.
	+
	.Specifying fallback C-state values
	====
	----
	[cpu]
	force_latency=cstate.name:C6|cstate.id:4|10
	----
	This configuration tries to obtain and set the latency of C-state named C6.
	If the C-state C6 does not exist, kernel CPU idle level ID 4 (state4) latency
	is searched for in sysfs. Finally, if the state4 directory in sysfs is not found,
	the last latency fallback value is `10` us. The value is encoded and written into
	the kernel's PM QoS file `/dev/cpu_dma_latency`.
	====
	+
	.Specifying fallback C-state values using 'None'.
	====
	----
	[cpu]
	force_latency=cstate.name:XYZ|None
	----
	In this case, if C-state with the name `XYZ` does not exist,
	no latency value will be written into the
	kernel's PM QoS file, and no errors will be reported due to the
	presence of 'None'.
	====
	
	`min_perf_pct, max_perf_pct, no_turbo`:::
	These options set the internals of the Intel P-State driver exposed via the kernel's
	`sysfs` interface.
	+
	.Adjusting the configuration of the Intel P-State driver
	====
	----
	[cpu]
	min_perf_pct=100
	----
	Limit the minimum P-State that will be requested by the driver. It states
	it as a percentage of the max (non-turbo) performance level.
	====

	`pm_qos_resume_latency_us`:::
	This option allow to set specific latency for all cpus or specific ones.
	+
	.Configuring resume latency
	====
	----
	[cpu]
	pm_qos_resume_latency_us=n/a
	----
	Special value that disables C-states completely.
	----
	[cpu]
	pm_qos_resume_latency_us=0
	----
	Allows all C-states.
	----
	[cpu]
	pm_qos_resume_latency_us=100
	----
	Allows any C-state with a resume latency less than 100.
	====

	`boost`:::
	The [option]`boost` option allows the CPU to boost above nominal
	frequencies for shorts periods of time.
	+
	.Allowing CPU boost
	====
	----
	[cpu]
	boost=1
	----
	====
	cs|tt|�j|i|��d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_i|_t�|_d|_dS)NT�x86_64F)�superr�__init__�_has_pm_qos�_archZ_is_x86�	_is_intel�_is_amd�_has_hwp_epp� _has_energy_perf_policy_and_bias�_has_intel_pstate�_has_amd_pstate�_has_pm_qos_resume_latency_us�_min_perf_pct_save�_max_perf_pct_save�_no_turbo_save�_governors_mapr�_cmd�_flags)�self�args�kwargs��	__class__��</usr/lib/python3.9/site-packages/tuned/plugins/plugin_cpu.pyr	�s"zCPULatencyPlugin.__init__cCs:d|_t�|_|j�d�D]}|j�|j�qt�|_dS)NT�cpu)Z_devices_supported�setZ
_free_devices�_hardware_inventoryZget_devices�addZsys_nameZ_assigned_devices�r�devicerrr�
_init_devices�s
zCPULatencyPlugin._init_devicescs�fdd�|D�S)Ncsg|]}�j�d|��qS)r )r"Z
get_device)�.0�x�rrr�
<listcomp>��z8CPULatencyPlugin._get_device_objects.<locals>.<listcomp>r)rZdevicesrr)r�_get_device_objects�sz$CPULatencyPlugin._get_device_objectscCs dddddddddddddd�
S)Ng�������?�di�)
�load_threshold�latency_low�latency_high�
force_latency�governor�sampling_down_factor�energy_perf_bias�min_perf_pct�max_perf_pct�no_turbo�pm_qos_resume_latency_us�energy_performance_preference�boostrr)rrr�_get_config_options�s�z$CPULatencyPlugin._get_config_optionscCs�gd�}t��|_|j|vrnt��}|j�d�}|dkr@d|_n|dksP|dkrXd|_nd|_t	�
d|�nt	�
d|j�tj|�
�v|_|jr�|js�|��|��|jr�|��dS)	N)rZi686Zi585Zi486Zi386Z	vendor_idZGenuineIntelTZAuthenticAMDZHygonGenuinez$We are running on an x86 %s platformzWe are running on %s (non x86))�platform�machiner�procfs�cpuinfo�tags�getrr
�log�info�constsZCFG_CPU_EPP_FLAG�_get_cpuinfo_flagsr�"_check_energy_perf_policy_and_bias�_check_intel_pstate�_check_amd_pstate)rZintel_archsr Zvendorrrr�_check_archs&

zCPULatencyPlugin._check_archcCs\d}|jjddgtj|gd�\}}|dkr:|dkr:d|_n|dkrNt�d�n
t�d	�d
S)z_Check for EPB via x86_energy_perf_policy, warn if the tool is not available or EPB unsupported.r�x86_energy_perf_policy�-r)Z	no_errorsr�Tzgunable to run x86_energy_perf_policy tool, ignoring CPU energy performance bias, is the tool installed?zXyour CPU doesn't support MSR_IA32_ENERGY_PERF_BIAS, ignoring CPU energy performance biasN)r�execute�errno�ENOENTrrB�warning)rZretcode_unsupported�retcode�outrrrrF#sz3CPULatencyPlugin._check_energy_perf_policy_and_biascCs"tj�d�|_|jrt�d�dS)Nz$/sys/devices/system/cpu/intel_pstatezintel_pstate detected)�os�path�existsrrBrCr)rrrrG1sz$CPULatencyPlugin._check_intel_pstatecCs"tj�d�|_|jrt�d�dS)Nz"/sys/devices/system/cpu/amd_pstatezamd-pstate detected)rSrTrUrrBrCr)rrrrH6sz"CPULatencyPlugin._check_amd_pstatecCs$|jdurt��j�dg�|_|jS)N�flags)rr>r?r@rAr)rrrrE;s
z#CPULatencyPlugin._get_cpuinfo_flagscCs t|�}|j�t|��dd��S)Nr rL)�strrZ
is_cpu_online�replace)rr%�sdrrr�_is_cpu_online@szCPULatencyPlugin._is_cpu_onlinecCstj�d|�S)N�3/sys/devices/system/cpu/%s/cpufreq/scaling_governor)rSrTrUr$rrr�_cpu_has_scaling_governorDsz*CPULatencyPlugin._cpu_has_scaling_governorcCs<|�|�st�d|�dS|�|�s8t�d|�dSdS)Nz'%s' is not online, skippingFz.there is no scaling governor fo '%s', skippingT)rZrB�debugr\r$rrr�_check_cpu_can_change_governorGs

z/CPULatencyPlugin._check_cpu_can_change_governorcCs�d|_d|_d|_t|j���d|kr�d|_zt�t	j
tj�|_Wn(t
ylt�dt	j
�d|_Yn0d|_|jddur�|jddur�d|_|��nd|_t�d|j�zt|j�d|_Wnty�d|_Yn0dS)NTFrz-Unable to open '%s', disabling PM_QoS controlr1r8zILatency settings from non-first CPU plugin instance '%s' will be ignored.)Z_has_static_tuningZ_has_dynamic_tuning�
_load_monitor�listZ
_instances�values�_first_instancerS�openrDZPATH_CPU_DMA_LATENCY�O_WRONLY�_cpu_latency_fd�OSErrorrBrCr
�_latency�optionsrI�nameZassigned_devices�
_first_device�
IndexError�r�instancerrr�_instance_initPs(
zCPULatencyPlugin._instance_initcCs4|jr0|jrt�|j�|jdur0|j�|j�dS�N)rbr
rS�closerer_�_monitors_repository�deleterlrrr�_instance_cleanupls

z"CPULatencyPlugin._instance_cleanupcs*tt|��|�|jr&|j�dd�|_dS)N�load)rr�_instance_init_dynamicrbrqZcreater_rlrrrrussz'CPULatencyPlugin._instance_init_dynamiccCs|j�d|d���S)N�'/sys/devices/system/cpu/intel_pstate/%s)r�	read_file�strip)r�attrrrr�_get_intel_pstate_attrxsz'CPULatencyPlugin._get_intel_pstate_attrcCs"|dur|jjd||dd�dS)NrvT)�ignore_same)r�
write_to_file)rry�valrrr�_set_intel_pstate_attr{sz'CPULatencyPlugin._set_intel_pstate_attrcCs&|durdS|�|�}|�||�|Sro)rzr~)rry�value�vrrr�_getset_intel_pstate_attrs

z*CPULatencyPlugin._getset_intel_pstate_attrcs�tt|��|�|jsdS|j�|jd�}|dur>|�|�|jr�|j�|jd�}|�	d|�|_
|j�|jd�}|�	d|�|_|j�
|j�|jd��}|�	d|�|_dS)Nr1r5r6r7)rr�_instance_apply_staticrbZ
_variables�expandrh�_set_latencyrr�rrrZget_boolr)rrmZforce_latency_valueZ	new_valuerrrr��s6�
������z'CPULatencyPlugin._instance_apply_staticcsLtt|��||�|jrH|jrH|�d|j�|�d|j�|�d|j�dS)Nr5r6r7)	rr�_instance_unapply_staticrbrr~rrr)rrmZrollbackrrrr��s
z)CPULatencyPlugin._instance_unapply_staticcCs|�||�dSro)�_instance_update_dynamic�rrmr%rrr�_instance_apply_dynamic�sz(CPULatencyPlugin._instance_apply_dynamiccCsP||jkrdS|j��d}||jdkr<|�|jd�n|�|jd�dS)N�systemr.r0r/)rjr_Zget_loadrhr�)rrmr%rtrrrr��s
z)CPULatencyPlugin._instance_update_dynamiccCsdSrorr�rrr�_instance_unapply_dynamic�sz*CPULatencyPlugin._instance_unapply_dynamicc	Cs(z
t|�WSttfy"YdS0dSro)�int�
ValueError�	TypeError�r�srrr�_str2int�s
zCPULatencyPlugin._str2intcCs�i|_t�t�D]l}td|}|jj|dddd�}|jj|dddd�}|dur|dur|�|�}|dur||j|��<qdS)Nz/%s/riT�Zerr_ret�no_error�latency)�cstates_latencyrS�listdir�cpuidle_states_pathrrwr�rx)r�dZcstate_pathrir�rrr�_read_cstates_latency�s
z&CPULatencyPlugin._read_cstates_latencyFcCsht�d|�|jdur*t�d�|��|j�|d�}|rR|dkrRt�d�dSt�dt|��|S)Nz)getting latency for cstate with name '%s'zreading cstates latency tabler�"skipping latency 0 as set by paramz!cstate name mapped to latency: %s)rBr]r�r�rArW)rri�no_zeror�rrr�_get_latency_by_cstate_name�s


z,CPULatencyPlugin._get_latency_by_cstate_namecCs�t�dt|��|�|�}|dur2t�d�dStdd|}|�|jj|ddd��}|rt|dkrtt�d�dSt�d	t|��|S)
Nz'getting latency for cstate with ID '%s'zcstate ID is invalidz/%s/latencyzstate%dTr�rr�zcstate ID mapped to latency: %s)rBr]rWr�r�rrw)rZlidr�Zlatency_pathr�rrr�_get_latency_by_cstate_id�s


z*CPULatencyPlugin._get_latency_by_cstate_idc	Cs^d|_t|��d�}t�d||f�|D�](}zt|�}t�d|�Wn�t�yD|dd�dkr�|j|dd�dd�}n�|dd	�d
kr�|�|d	d��}n�|dd�dkr�|j|dd�dd�}nr|dd
�dkr�|�|d
d��}nN|dv�rt�d�YdS|�r*|dk�r*t�d�nt�dt|��d}Yn0|dur*�qVq*|dfS)N�|z#parsing latency '%s', allow_na '%s'z+parsed directly specified latency value: %dr�zcstate.id_no_zero:T)r��
z
cstate.id:�zcstate.name_no_zero:�zcstate.name:)Znone�Nonezlatency 'none' specified)NT�n/azlatency 'n/a' specifiedzinvalid latency specified: '%s'F)	r�rW�splitrBr]r�r�r�r�)rr��allow_naZ	latenciesrrr�_parse_latency�s6




zCPULatencyPlugin._parse_latencycCsn|�|�\}}|sj|jrj|dur2t�d�d|_n8|j|krjt�d|�t�d|�}t�	|j
|�||_dS)Nztunable to evaluate latency value (probably wrong settings in the 'cpu' section of current profile), disabling PM QoSFzsetting new cpu latency %d�i)r�r
rB�errorrgrC�struct�packrS�writere)rr��skipZlatency_binrrrr�s


zCPULatencyPlugin._set_latencycCs|j�d|�����S)Nz>/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors)rrwrxr�r$rrr�_get_available_governors
sz)CPULatencyPlugin._get_available_governorsr2T)�
per_devicecCs�|�|�sdSt|�}|�d�}dd�|D�}|D] }t|�dkr2t�d�dSq2|�|�}|D]b}||vr�|s�t�d||f�|jj	d|||r�t
jgndd	d
�q�qb|sbt�d||f�qbt�
dd
�|��d}|S)Nr�cSsg|]}|���qSr)rx)r'r2rrrr*r+z2CPULatencyPlugin._set_governor.<locals>.<listcomp>rz.The 'governor' option contains an empty value.z!setting governor '%s' on cpu '%s'r[FT�r�r{z7Ignoring governor '%s' on cpu '%s', it is not supportedz.None of the scaling governors is supported: %sz, )r^rWr��lenrBr�r�rCrr|rNrOr]rP�join)rZ	governorsr%rm�sim�remover2Zavailable_governorsrrr�
_set_governors>



�����zCPULatencyPlugin._set_governorcCsTd}|�|�sdS|jjd||d���}t|�dkr:|}|durPt�d|�|S)Nr[�r�rz*could not get current governor on cpu '%s')r^rrwrxr�rBr�)rr%rm�ignore_missingr2�datarrr�
_get_governor-s
zCPULatencyPlugin._get_governor�ondemandcCsd|S)Nz7/sys/devices/system/cpu/cpufreq/%s/sampling_down_factorr)rr2rrr�_sampling_down_factor_path;sz+CPULatencyPlugin._sampling_down_factor_pathr3r�)r��priorityc	Cs�d}||jvr|j��d|j|<|�||�}|durHt�d|�dS|t|j���vr�||j|<|�|�}tj	�
|�s�t�d||f�dSt|�}|s�t�d||f�|j
j|||r�tjgndd�|S)NzIignoring sampling_down_factor setting for CPU '%s', cannot match governorzTignoring sampling_down_factor setting for CPU '%s', governor '%s' doesn't support itz6setting sampling_down_factor to '%s' for governor '%s'Fr�)r�clearr�rBr]r`rar�rSrTrUrWrCrr|rNrO)	rr3r%rmr�r�r}r2rTrrr�_set_sampling_down_factor>s&




z*CPULatencyPlugin._set_sampling_down_factorcCsF|j|||d�}|durdS|�|�}tj�|�s6dS|j�|���S)N)r�)r�r�rSrTrUrrwrx)rr%rmr�r2rTrrr�_get_sampling_down_factorYs
z*CPULatencyPlugin._get_sampling_down_factorcCs*|jjdd|t|�gdd�\}}}||fS)NrJ�-cT)Z
return_err)rrMrW)r�cpu_idrrQrR�err_msgrrr�_try_set_energy_perf_biascs��z*CPULatencyPlugin._try_set_energy_perf_biascCsd|S)Nz./sys/devices/system/cpu/cpufreq/policy%s/boostr�rr�rrr�_pstate_boost_pathlsz#CPULatencyPlugin._pstate_boost_pathcCsd||rdndfS)Nz>/sys/devices/system/cpu/cpufreq/policy%s/energy_performance_%sZavailable_preferencesZ
preferencer)rr�Z	availablerrr�_pstate_preference_pathosz(CPULatencyPlugin._pstate_preference_pathcCsd|S)Nz4/sys/devices/system/cpu/cpu%s/power/energy_perf_biasrr�rrr�_energy_perf_bias_pathrsz'CPULatencyPlugin._energy_perf_bias_pathr4cCsx|�|�st�d|�dS|�d�}|�d�}|jr�|�|�}tj�	|�r�|s�|D]B}	|	�
�}	|jj||	|rvt
jgnddd�rTt�d|	|f�q�qTt�d|�t|�St�d	|�dSn�|j�rp|�sh|D]�}	|	�
�}	t�d
|	|f�|�||	�\}
}|
dk�r&t�d|	|f��qhq�|
dk�rFt�d|��qhq�t�d
|	|f�q�t�d|�t|�SdSdS)N�%s is not online, skippingr r�FTr�z5energy_perf_bias successfully set to '%s' on cpu '%s'zPFailed to set energy_perf_bias on cpu '%s'. Is the value in the profile correct?zXFailed to set energy_perf_bias on cpu '%s' because energy_perf_bias file does not exist.z2Trying to set energy_perf_bias to '%s' on cpu '%s'rz"Failed to set energy_perf_bias: %szHCould not set energy_perf_bias to '%s' on cpu '%s', trying another value)rZrBr]�lstripr�rr�rSrTrUrxrr|rNrOrCr�rWrr�)rr4r%rmr�r�r��vals�energy_perf_bias_pathr}rQr�rrr�_set_energy_perf_biasusl




������
�
���z&CPULatencyPlugin._set_energy_perf_biasc
Csnzt|�}Wn\tyh}zDzt|d�}Wn(tyR}z|}WYd}~n
d}~00WYd}~n
d}~00|S)N�)r�r�)rr�r��errr�_try_parse_num�s0zCPULatencyPlugin._try_parse_numcCsdddd��|�|�|�S)N�performance�normalZ	powersave)r���rAr�r�rrr�_energy_perf_policy_to_human�sz-CPULatencyPlugin._energy_perf_policy_to_humancCsdddddd��|�|�|�S)Nr�zbalance-performancer�z
balance-powerZpower)r�r��r�r�r�rrr�_energy_perf_policy_to_human_v2�s�
�z0CPULatencyPlugin._energy_perf_policy_to_human_v2cCs�d}|�|�s t�d|�dS|�d�}|jrZ|�|�}tj�|�r�|�	|j
�|��}nz|jr�|j
�
dd|dg�\}}|dkr�|��D]J}	|	��}
t|
�dkr�|�|
d�}q�q�t|
�d	kr�|�	|
d�}q�q�|S)
Nr�r rJr�rKr�r�)rZrBr]r�rr�rSrTrUr�rrwrrM�
splitlinesr�r�r�)rr%rmr�r4r�r�rQ�lines�line�lrrr�_get_energy_perf_bias�s*


z&CPULatencyPlugin._get_energy_perf_biascCsd|S)Nz9/sys/devices/system/cpu/%s/power/pm_qos_resume_latency_usrr$rrr�_pm_qos_resume_latency_us_path�sz/CPULatencyPlugin._pm_qos_resume_latency_us_pathcCs4|jdur.tj�|�|��|_|js.t�d�|jS)NzGOption 'pm_qos_resume_latency_us' is not supported on current hardware.)rrSrTrUr�rBrCr$rrr�_check_pm_qos_resume_latency_us�s


z0CPULatencyPlugin._check_pm_qos_resume_latency_usr8cCs�|�|�st�d|�dS|j|dd�\}}|s<|�|�s@dS|dusX|dkrn|dkrnt�d||f�dS|s�|jj|�|�||r�t	j
gndd�|S)	Nr�T)r�r�rz<Invalid pm_qos_resume_latency_us specified: '%s', cpu: '%s'.Fr�)rZrBr]r�r�rPrr|r�rNrO)rr8r%rmr�r�r�r�rrr�_set_pm_qos_resume_latency_us�s
�z.CPULatencyPlugin._set_pm_qos_resume_latency_uscCsD|�|�st�d|�dS|�|�s*dS|jj|�|�|d���S)Nr�r�)rZrBr]r�rrwr�rx)rr%rmr�rrr�_get_pm_qos_resume_latency_us�s

z.CPULatencyPlugin._get_pm_qos_resume_latency_usr:cCs�|�|�st�d|�dS|�d�}tj�|�|��r�|s�|dksL|dkr�|jj	|�|�||rht
jgnddd�t�d||f�nt�
d	|�t|�St�d
�dS)Nr�r �0�1FTr�z%Setting boost value '%s' for cpu '%s'zEFailed to set boost on cpu '%s'. Is the value in the profile correct?�9boost file missing, which can happen on pre 6.11 kernels.)rZrBr]r�rSrTrUr�rr|rNrOrCr�rW)rr:r%rmr�r�r�rrr�
_set_boosts

�
zCPULatencyPlugin._set_boostcCs\|�|�st�d|�dS|�d�}tj�|�|��rN|j�	|�|���
�St�d�dS)Nr�r r�)rZrBr]r�rSrTrUr�rrwrx�rr%rmr�r�rrr�
_get_boosts


zCPULatencyPlugin._get_boostr9c	Cs4|�|�st�d|�dS|�d�}tj�|�|d���r&|�d�}|�st	|j
�|�|d�����}|D]�}	z,t|	�}	d|	ko�dkn}
t
|	�}	Wnty�|	|v}
Yn0|
r�|j
j|�|�|	|r�tjgnddd�t�d	|	|f��qqlt�d
|	|f�qlt�d|�t
|�St�d�dS)
Nr�r Tr�r�Fr�z=Setting energy_performance_preference value '%s' for cpu '%s'zAenergy_performance_preference value '%s' unavailable for cpu '%s'z]Failed to set energy_performance_preference on cpu '%s'. Is the value in the profile correct?�yenergy_performance_available_preferences file missing, which can happen if the system is booted without a P-state driver.)rZrBr]r�rSrTrUr�r�r!rrwr�rWr�r|rNrOrCrPr�)rr9r%rmr�r�r�r�Z
avail_valsr}Zvalidrrr�"_set_energy_performance_preferences8


��
z3CPULatencyPlugin._set_energy_performance_preferencecCs^|�|�st�d|�dS|�d�}tj�|�|d��rP|j�	|�|���
�St�d�dS)Nr�r Tr�)rZrBr]r�rSrTrUr�rrwrxr�rrr�"_get_energy_performance_preference?s


z3CPULatencyPlugin._get_energy_performance_preference)F)F)F)F)r�)F)F)F)F)F)F)>�__name__�
__module__�__qualname__�__doc__r	r&r,�classmethodr;rIrFrGrHrErZr\r^rnrsrurzr~r�r�rDZ
ROLLBACK_SOFTr�r�r�r�r�r�r�r�r�r�r�Zcommand_setr�Zcommand_getr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrrrrs�:	
#	






		


7





r)rLrZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrZtuned.constsrDrSrNr�r<r>ZlogsrArBr�ZPluginrrrrr�<module>s