Your IP : 18.119.166.141


Current Path : /usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/plugin_cpu.cpython-36.pyc

3

�<�e:n�@s�ddlmZddlTddlZddlmZddljZddl	Z	ddl
Z
ddlZddl
Z
ddlZddl
Z
ejj�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�Zdd�Zd d!�Zd"d#�Z�fd$d%�Zejf�fd&d'�	Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zdmd3d4�Zdnd5d6�Z dod7d8�Z!d9d:�Z"d;d<�Z#e$d=d>d?�d@dA��Z%e&d=�dpdBdC��Z'dqdEdF�Z(e$dGd>dHdI�dJdK��Z)e&dG�drdLdM��Z*dNdO�Z+dsdPdQ�Z,dRdS�Z-e$dTd>d?�dUdV��Z.dWdX�Z/dYdZ�Z0d[d\�Z1e&dT�dtd]d^��Z2d_d`�Z3dadb�Z4e$dcd>d?�ddde��Z5e&dc�dudfdg��Z6e$dhd>d?�didj��Z7e&dh�dvdkdl��Z8�Z9S)w�CPULatencyPlugina�
	`cpu`::
	
	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.
	+    
	For example, with the following profile, *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.
	+
	.Specifying a CPU governor
	====
	----
	[cpu]
	governor=ondemand|powersave
	----
	====
	
	`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
	[option]`force_latency`, 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.
	====
	----
	[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 value.
	csrtt|�j||�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_energy_perf_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.6/plugin_cpu.pyr	�s zCPULatencyPlugin.__init__cCs>d|_t�|_x"|jjd�D]}|jj|j�qWt�|_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|]}�jjd|��qS)r)r Z
get_device)�.0�x)rrr�
<listcomp>�sz8CPULatencyPlugin._get_device_objects.<locals>.<listcomp>r)rZdevicesr)rr�_get_device_objects�sz$CPULatencyPlugin._get_device_objectsc
Csddddddddddddd�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_preferencer)rrrr�_get_config_options�sz$CPULatencyPlugin._get_config_optionscCs�dddddg}tj�|_|j|krttj�}|jjd�}|dkrFd|_n|d	ksV|d
kr^d|_nd|_t	j
d|�nt	j
d|j�|jr�|j�|j�|jr�|j
�dS)
NrZi686Zi585Zi486Zi386Z	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�_check_energy_perf_bias�_check_intel_pstate�_check_amd_pstate)rZintel_archsrZvendorrrr�_check_arch�s"

zCPULatencyPlugin._check_archcCsbd|_d}|jjddgtj|gd�\}}|dkr@|dkr@d|_n|dkrTtjd	�n
tjd
�dS)NFr�x86_energy_perf_policyz-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 bias)rr�execute�errno�ENOENTr<�warning)rZretcode_unsupported�retcode�outrrrr>sz(CPULatencyPlugin._check_energy_perf_biascCs"tjjd�|_|jrtjd�dS)Nz$/sys/devices/system/cpu/intel_pstatezintel_pstate detected)�os�path�existsrr<r=)rrrrr?sz$CPULatencyPlugin._check_intel_pstatecCs"tjjd�|_|jrtjd�dS)Nz"/sys/devices/system/cpu/amd_pstatezamd-pstate detected)rJrKrLrr<r=)rrrrr@#sz"CPULatencyPlugin._check_amd_pstatecCs$|jdkrtj�jjdg�|_|jS)N�flags)rr8r9r:r;)rrrr�_get_cpuinfo_flags(s
z#CPULatencyPlugin._get_cpuinfo_flagscCs t|�}|jjt|�jdd��S)NrrC)�strrZ
is_cpu_online�replace)rr"Zsdrrr�_is_cpu_online-szCPULatencyPlugin._is_cpu_onlinecCstjjd|�S)Nz3/sys/devices/system/cpu/%s/cpufreq/scaling_governor)rJrKrL)rr"rrr�_cpu_has_scaling_governor1sz*CPULatencyPlugin._cpu_has_scaling_governorcCs<|j|�stjd|�dS|j|�s8tjd|�dSdS)Nz'%s' is not online, skippingFz.there is no scaling governor fo '%s', skippingT)rQr<�debugrR)rr"rrr�_check_cpu_can_change_governor4s

z/CPULatencyPlugin._check_cpu_can_change_governorcCs�d|_d|_t|jj��d|kr�d|_ytjtj	tj
�|_Wn*tk
rht
jdtj	�d|_YnXd|_|jddkr�|jddkr�|jjdd�|_d|_nd|_|j�nd|_t
jd|j�yt|j�d|_Wntk
r�d|_YnXdS)	NTFrz-Unable to open '%s', disabling PM_QoS controlr,r3�loadzILatency settings from non-first CPU plugin instance '%s' will be ignored.)Z_has_static_tuningZ_has_dynamic_tuning�listZ
_instances�values�_first_instancerJ�open�constsZPATH_CPU_DMA_LATENCY�O_WRONLY�_cpu_latency_fd�OSErrorr<�errorr
�_latency�options�_monitors_repositoryZcreate�
_load_monitorrAr=�nameZassigned_devices�
_first_device�
IndexError)r�instancerrr�_instance_init=s*
zCPULatencyPlugin._instance_initcCs4|jr0|jrtj|j�|jdk	r0|jj|j�dS)N)rXr
rJ�closer\rbra�delete)rrfrrr�_instance_cleanup[s

z"CPULatencyPlugin._instance_cleanupcCs|jjd|d�j�S)Nz'/sys/devices/system/cpu/intel_pstate/%s)r�	read_file�strip)r�attrrrr�_get_intel_pstate_attrbsz'CPULatencyPlugin._get_intel_pstate_attrcCs|dk	r|jjd||�dS)Nz'/sys/devices/system/cpu/intel_pstate/%s)r�
write_to_file)rrm�valrrr�_set_intel_pstate_attresz'CPULatencyPlugin._set_intel_pstate_attrcCs&|dkrdS|j|�}|j||�|S)N)rnrq)rrm�value�vrrr�_getset_intel_pstate_attris

z*CPULatencyPlugin._getset_intel_pstate_attrcs�tt|�j|�|jsdS|jj|jd�}|dk	r>|j|�|jr�|jj|jd�}|j	d|�|_
|jj|jd�}|j	d|�|_|jj|jd�}|j	d|�|_dS)Nr,r0r1r2)
rr�_instance_apply_staticrXZ
_variables�expandr`�_set_latencyrrtrrr)rrfZforce_latency_valueZ	new_value)rrrrups(


z'CPULatencyPlugin._instance_apply_staticcsLtt|�j||�|jrH|jrH|jd|j�|jd|j�|jd|j�dS)Nr0r1r2)	rr�_instance_unapply_staticrXrrqrrr)rrfZrollback)rrrrx�s
z)CPULatencyPlugin._instance_unapply_staticcCs|j||�dS)N)�_instance_update_dynamic)rrfr"rrr�_instance_apply_dynamic�sz(CPULatencyPlugin._instance_apply_dynamiccCsZ|js
t�||jkrdS|jj�d}||jdkrF|j|jd�n|j|jd�dS)N�systemr)r+r*)rX�AssertionErrorrdrbZget_loadr`rw)rrfr"rUrrrry�s

z)CPULatencyPlugin._instance_update_dynamiccCsdS)Nr)rrfr"rrr�_instance_unapply_dynamic�sz*CPULatencyPlugin._instance_unapply_dynamiccCs&yt|�Sttfk
r dSXdS)N)�int�
ValueError�	TypeError)r�srrr�_str2int�szCPULatencyPlugin._str2intcCs�i|_xztjt�D]l}td|}|jj|dddd�}|jj|dddd�}|dk	r|dk	r|j|�}|dk	r||j|j�<qWdS)Nz/%s/rcT)�err_ret�no_error�latency)�cstates_latencyrJ�listdir�cpuidle_states_pathrrkr�rl)r�dZcstate_pathrcr�rrr�_read_cstates_latency�s
z&CPULatencyPlugin._read_cstates_latencyFcCshtjd|�|jdkr*tjd�|j�|jj|d�}|rR|dkrRtjd�dStjdt|��|S)Nz)getting latency for cstate with name '%s'zreading cstates latency tablerz"skipping latency 0 as set by paramz!cstate name mapped to latency: %s)r<rSr�r�r;rO)rrc�no_zeror�rrr�_get_latency_by_cstate_name�s


z,CPULatencyPlugin._get_latency_by_cstate_namecCs�tjdt|��|j|�}|dkr2tjd�dStdd|}|j|jj|ddd��}|rt|dkrttjd�dStjd	t|��|S)
Nz'getting latency for cstate with ID '%s'zcstate ID is invalidz/%s/latencyzstate%dT)r�r�rz"skipping latency 0 as set by paramzcstate ID mapped to latency: %s)r<rSrOr�r�rrk)rZlidr�Zlatency_pathr�rrr�_get_latency_by_cstate_id�s


z*CPULatencyPlugin._get_latency_by_cstate_idcCs`d|_t|�jd�}tjd||f��x.|D�]$}yt|�}tjd|�W�n�tk
�rH|dd�dkr�|j|dd�dd�}n�|dd	�d
kr�|j|d	d��}n�|dd�dkr�|j|dd�dd�}nn|dd
�dkr�|j|d
d��}nJ|dk�rtjd�dS|�r.|dk�r.tjd�ntjdt|��d}YnX|dk	r.Pq.W|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:�none�Nonezlatency 'none' specifiedzn/azlatency 'n/a' specifiedzinvalid latency specified: '%s'F)r�r�)NT)	r�rO�splitr<rSr~rr�r�)rr��allow_naZ	latenciesrrr�_parse_latency�s6



zCPULatencyPlugin._parse_latencycCsp|j|�\}}|rl|jrl|dkr4tjd�d|_n8|j|krltjd|�tjd|�}tj	|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
r<r^r_r=�struct�packrJ�writer\)rr��skipZlatency_binrrrrw�s

zCPULatencyPlugin._set_latencycCs|jjd|�j�j�S)Nz>/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors)rrkrlr�)rr"rrr�_get_available_governors�sz)CPULatencyPlugin._get_available_governorsr-T)�
per_devicecCs�|j|�sdSt|�}|jd�}dd�|D�}x&|D]}t|�dkr4tjd�dSq4W|j|�}x~|D]^}||kr�|s�tjd||f�|jj	d|||r�t
jgndd	�Pqf|sftjd
||f�qfWtj
ddj|��d}|S)
Nr�cSsg|]}|j��qSr)rl)r$r-rrrr&sz2CPULatencyPlugin._set_governor.<locals>.<listcomp>rz.The 'governor' option contains an empty value.z!setting governor '%s' on cpu '%s'z3/sys/devices/system/cpu/%s/cpufreq/scaling_governorF)r�z7Ignoring governor '%s' on cpu '%s', it is not supportedz.None of the scaling governors is supported: %sz, )rTrOr��lenr<r^r�r=rrorErFrS�warn�join)rZ	governorsr"�sim�remover-Zavailable_governorsrrr�
_set_governor�s2





zCPULatencyPlugin._set_governorcCsTd}|j|�sdS|jjd||d�j�}t|�dkr:|}|dkrPtjd|�|S)Nz3/sys/devices/system/cpu/%s/cpufreq/scaling_governor)r�rz*could not get current governor on cpu '%s')rTrrkrlr�r<r^)rr"�ignore_missingr-�datarrr�
_get_governors
zCPULatencyPlugin._get_governor�ondemandcCsd|S)Nz7/sys/devices/system/cpu/cpufreq/%s/sampling_down_factorr)rr-rrr�_sampling_down_factor_path%sz+CPULatencyPlugin._sampling_down_factor_pathr.r�)r�ZprioritycCs�d}||jkr|jj�d|j|<|j|�}|dkrFtjd|�dS|t|jj��kr�||j|<|j|�}tj	j
|�s�tjd||f�dSt|�}|s�tj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'F)r�)r�clearr�r<rSrVrWr�rJrKrLrOr=rrorErF)rr.r"r�r�rpr-rKrrr�_set_sampling_down_factor(s&





z*CPULatencyPlugin._set_sampling_down_factorcCsD|j||d�}|dkrdS|j|�}tjj|�s4dS|jj|�j�S)N)r�)r�r�rJrKrLrrkrl)rr"r�r-rKrrr�_get_sampling_down_factorCs
z*CPULatencyPlugin._get_sampling_down_factorcCs*|jjdd|t|�gdd�\}}}||fS)NrBz-cT)Z
return_err)rrDrO)r�cpu_idrrrHrI�err_msgrrr�_try_set_energy_perf_biasMsz*CPULatencyPlugin._try_set_energy_perf_biascCsd||rdndfS)Nz>/sys/devices/system/cpu/cpufreq/policy%s/energy_performance_%sZavailable_preferencesZ
preferencer)rr�Z	availablerrr�_pstate_preference_pathVsz(CPULatencyPlugin._pstate_preference_pathcCsd|S)Nz4/sys/devices/system/cpu/cpu%s/power/energy_perf_biasr)rr�rrr�_energy_perf_bias_pathYsz'CPULatencyPlugin._energy_perf_bias_pathr/cCs||j|�stjd|�dS|jd�}|jd�}tj|j�kr�|j|�}t	j
j|�r�|s�xT|D]>}|j�}|j
j|||r�tjgndd�r^tjd||f�Pq^Wtjd|�t|�Stjd|�dSn�|j�rt|�slx�|D]|}|j�}tjd	||f�|j||�\}	}
|	d
k�r,tjd||f�Pq�|	d
k�rHtjd|
�Pq�tjd||f�q�Wtjd|�t|�SdSdS)
Nz%s is not online, skippingrr�F)r�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)rQr<rS�lstripr�rZ�CFG_CPU_EPP_FLAGrNr�rJrKrLrlrrorErFr=r^rOrr�)rr/r"r�r�r��vals�energy_perf_bias_pathrprHr�rrr�_set_energy_perf_bias\sX








z&CPULatencyPlugin._set_energy_perf_biascCsjyt|�}WnXtk
rd}z<yt|d�}Wn&tk
rR}z
|}WYdd}~XnXWYdd}~XnX|S)N�)r~r)rr�rs�errr�_try_parse_num�s(zCPULatencyPlugin._try_parse_numcCsdddd�j|j|�|�S)N�performance�normalZ	powersave)r��)r;r�)rr�rrr�_energy_perf_policy_to_human�sz-CPULatencyPlugin._energy_perf_policy_to_humancCsdddddd�j|j|�|�S)Nr�zbalance-performancer�z
balance-powerZpower)r�r��r�)r;r�)rr�rrr�_energy_perf_policy_to_human_v2�sz0CPULatencyPlugin._energy_perf_policy_to_human_v2c
Cs�d}|j|�s tjd|�dS|jd�}tj|j�krb|j|�}tj	j
|�r�|j|jj
|��}nz|jr�|jjdd|dg�\}}|dkr�xR|j�D]F}|j�}	t|	�dkr�|j|	d�}Pq�t|	�d	kr�|j|	d�}Pq�W|S)
Nz%s is not online, skippingrrBz-cz-rr�r�)rQr<rSr�rZr�rNr�rJrKrLr�rrkrrD�
splitlinesr�r�r�)
rr"r�r/r�r�rH�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_usr)rr"rrr�_pm_qos_resume_latency_us_path�sz/CPULatencyPlugin._pm_qos_resume_latency_us_pathcCs4|jdkr.tjj|j|��|_|js.tjd�|jS)NzGOption 'pm_qos_resume_latency_us' is not supported on current hardware.)rrJrKrLr�r<r=)rr"rrr�_check_pm_qos_resume_latency_us�s


z0CPULatencyPlugin._check_pm_qos_resume_latency_usr3cCs�|j|�stjd|�dS|j|dd�\}}|s>|j|�rBdS|dksZ|dkrp|dkrptjd||f�dS|s�|jj|j|�||r�t	j
gndd�|S)	Nz%s is not online, skippingT)r�zn/arz<Invalid pm_qos_resume_latency_us specified: '%s', cpu: '%s'.F)r�)rQr<rSr�r�rGrror�rErF)rr3r"r�r�r�r�rrr�_set_pm_qos_resume_latency_us�s
z.CPULatencyPlugin._set_pm_qos_resume_latency_uscCsD|j|�stjd|�dS|j|�s*dS|jj|j|�|d�j�S)Nz%s is not online, skipping)r�)rQr<rSr�rrkr�rl)rr"r�rrr�_get_pm_qos_resume_latency_us�s

z.CPULatencyPlugin._get_pm_qos_resume_latency_usr4c	Cs�|j|�stjd|�dS|jd�}tjj|j|d��r�|jd�}|s�t	|j
j|j|d��j��}xn|D]X}||kr�|j
j|j|�||r�t
jgndd�tjd||f�Pqjtjd||f�qjWtjd	|�t|�Stjd
�dS)Nz%s is not online, skippingrTr�F)r�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?zyenergy_performance_available_preferences file missing, which can happen if the system is booted without a P-state driver.)rQr<rSr�rJrKrLr�r�rrrkrorErFr=r�r^rO)	rr4r"r�r�r�r�Z
avail_valsrprrr�"_set_energy_performance_preference�s(




z3CPULatencyPlugin._set_energy_performance_preferencecCs^|j|�stjd|�dS|jd�}tjj|j|d��rP|jj	|j|��j
�Stjd�dS)Nz%s is not online, skippingrTzyenergy_performance_available_preferences file missing, which can happen if the system is booted without a P-state driver.)rQr<rSr�rJrKrLr�rrkrl)rr"r�r�rrr�"_get_energy_performance_preferences


z3CPULatencyPlugin._get_energy_performance_preference)F)F)F)F)r�)F)F)F)F)F):�__name__�
__module__�__qualname__�__doc__r	r#r'�classmethodr5rAr>r?r@rNrQrRrTrgrjrnrqrtrurZZ
ROLLBACK_SOFTrxrzryr}r�r�r�r�r�rwr�Zcommand_setr�Zcommand_getr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rrrsn,		



		
8r)rCrZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrZtuned.constsrZrJrEr�r6r8Zlogsr;r<r�ZPluginrrrrr�<module>s



?>