+
     GiVz  c                   s    ^RI Ht ^RI5 ^ RIt^ RIHt ^ RIHt ^ RI	t	^ RI
t
^ RIt^ RI
t
^ RIt^ RIt]P                  P                  4       tRt ! R R]P$                  4      tR# )i   )hotplug)Z*N)commandsz$/sys/devices/system/cpu/cpu0/cpuidlec                   s  a a ] tR t^t oRtV 3R ltR tR t]R 4       t	R t
R tR tR	 tR
 tR tR tR tR tR tV 3R ltR tR tR tV 3R lt]P4                  3V 3R lltR tR tR tR tR t R@R lt!R@R lt"R@R lt#R t$R t%]&! R R!R"7      R# 4       t'](! R 4      R@R$ l4       t)RAR% lt*]&! R&R!^
R'7      R( 4       t+](! R&4      R@R) l4       t,R* t-R+ t.R@R, lt/R- t0]&! R.R!R"7      R/ 4       t1R0 t2R1 t3R2 t4](! R.4      R@R3 l4       t5R4 t6R5 t7]&! R6R!R"7      R7 4       t8](! R64      R@R8 l4       t9]&! R9R!R"7      R: 4       t:](! R94      R@R; l4       t;]&! R<R!R"7      R= 4       t<](! R<4      R@R> l4       t=R?t>Vt?V ;t@# )B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. On Intel systems with the
intel_pstate driver, setting boost=0 will automatically set no_turbo=1
to ensure boost is properly disabled.
+
.Allowing CPU boost
====
----
[cpu]
boost=1
----
====
c                s   < \         \        V `
  ! V/ VB  R V n        RV n        RV n        RV n        RV n        RV n        RV n	        RV n
        RV n        RV n        RV n        RV n        RV n        / V n        \#        4       V n        RV n        R# )Tx86_64FN)superr   __init___has_pm_qos_arch_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)selfZargsZkwargs	__class__s   &*,=/usr/lib/python3.14/site-packages/tuned/plugins/plugin_cpu.pyr   ZCPULatencyPlugin.__init__   s    $($9&9$$*$,$.$,$*/$' $$'+$$ $ $$$j$)$+    c                s    R V n         \        4       V n        V P                  P	                  R4       F(  pV P                  P                  VP                  4       K*  	  \        4       V n        R# )TcpuN)_devices_supportedset_free_devices_hardware_inventoryZget_devicesZaddZsys_name_assigned_devicesr   devices   & r   _init_devicesZCPULatencyPlugin._init_devices   sS     $u$((44U;f&//* < 5$r   c                sb    V Uu. uF  q P                   P                  R V4      NK   	  up# u upi )r   )r   Z
get_device)r   ZdevicesZx   && r   _get_device_objectsZ$CPULatencyPlugin._get_device_objects   s+    AH	IA
"
"
-
-eQ
7	II	Is   $,c                s:    R RR^dRRRRRRRRR	RR
RRRRRRRRRRR/# )load_thresholdg?latency_lowlatency_highi  force_latencyNgovernorsampling_down_factorenergy_perf_biasmin_perf_pctmax_perf_pctno_turbopm_qos_resume_latency_usenergy_performance_preferenceboost r      &r   _get_config_optionsZ$CPULatencyPlugin._get_config_options   sO     CCDDDDDDDDt"T
D
 r   c                s   . R	Op\         P                  ! 4       V n        V P                  V9   dz   \        P                  ! 4       pVP
                  P                  R4      pVR8X  d	   RV n        MVR8X  g   VR8X  d	   RV n        MRV n        \        P                  RV,          4       M&\        P                  RV P                  ,          4       \        P                  V P                  4       9   V n        V P                  '       d3   V P                  '       g   V P                  4        V P!                  4        V P                  '       d   V P#                  4        R# R# )
r   Z	vendor_idZGenuineIntelTZAuthenticAMDZHygonGenuinez$We are running on an x86 %s platformzWe are running on %s (non x86)N)r   Zi686Zi585Zi486Zi386)platformZmachiner   procfscpuinfotagsgetr	   r
   loginfoconstsZCFG_CPU_EPP_FLAG_get_cpuinfo_flagsr   "_check_energy_perf_policy_and_bias_check_intel_pstate_check_amd_pstate)r   Zintel_archsr   Zvendor   &   r   _check_archZCPULatencyPlugin._check_arch  s    <+!$*	ZZ; 
	3HHLL%6DN. Fn$<DL DN882V;<88,tzz9:--1H1H1JJ$	^^^ 


++-	\\\ r   c                s    ^pV P                   P                  RR.\        P                  V.R7      w  r#V^ 8X  d   VR8w  d
   RV n        R# V^ 8  d   \
        P                  R4       R# \
        P                  R4       R# )	z_Check for EPB via x86_energy_perf_policy, warn if the tool is not available or EPB unsupported.x86_energy_perf_policy-r)Z	no_errors 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ENOENTr   r;   warning)r   Zretcode_unsupportedretcodeoutrB   r   r?   Z3CPULatencyPlugin._check_energy_perf_policy_and_bias%  sn    ""$<d#CRWR^R^`sQt"u,' \cRi+/4({;;xy;;ijr   c                    \         P                  P                  R 4      V n        V P                  '       d   \        P                  R4       R# R# )z$/sys/devices/system/cpu/intel_pstatezintel_pstate detectedN)ospathexistsr   r;   r<   r3   r4   r   r@   Z$CPULatencyPlugin._check_intel_pstate3  s6    77>>*PQ$	88#$ r   c                rM   )z"/sys/devices/system/cpu/amd_pstatezamd-pstate detectedN)rN   rO   rP   r   r;   r<   r3   r4   r   rA   Z"CPULatencyPlugin._check_amd_pstate8  s6    (LM$	88!" r   c                s    V P                   f5   \        P                  ! 4       P                  P	                  R. 4      V n         V P                   # )NZflags)r   r7   r8   r9   r:   r3   r4   r   r>   Z#CPULatencyPlugin._get_cpuinfo_flags=  s7    	[[!&&**7B74;	r   c                s    \        V4      pV P                  P                  \        V4      P                  R R4      4      # )r   rF   )strr   Zis_cpu_onlineZreplace)r   r!   Zsdr#   r   _is_cpu_onlineZCPULatencyPlugin._is_cpu_onlineB  s1    
6{"		 	 V!4!4UB!?	@@r   c                sN    \         P                  P                  R V,          4      # )3/sys/devices/system/cpu/%s/cpufreq/scaling_governor)rN   rO   rP   r       &&r   _cpu_has_scaling_governorZ*CPULatencyPlugin._cpu_has_scaling_governorF  s    	MPVV	WWr   c                s    V P                  V4      '       g   \        P                  R V,          4       R# V P                  V4      '       g   \        P                  RV,          4       R# R# )z'%s' is not online, skippingFz.there is no scaling governor fo '%s', skippingT)rR   r;   debugrU   r    rT   r   _check_cpu_can_change_governorZ/CPULatencyPlugin._check_cpu_can_change_governorI  sQ    			V	$	$99+f45
		'	'	/	/99=FG
	r   c                s   R Vn         RVn        RVn        \        V P                  P                  4       4      ^ ,          V8X  d   R Vn         \        P                  ! \        P                  \        P                  4      V n        RV n        VP$                  R,          f   VP$                  R,          f   R Vn        V P'                  4        M-RVn        \        P                  RVP(                  ,          4        \        VP*                  4      ^ ,          Vn        R#   \         d5    \        P                  R\        P                  ,          4       RT n         Li ; i  \.         d    RTn         R# i ; i)TFNz-Unable to open '%s', disabling PM_QoS controlr(   r/   zILatency settings from non-first CPU plugin instance '%s' will be ignored.)Z_has_static_tuningZ_has_dynamic_tuning_load_monitorlistZ
_instancesvalues_first_instancerN   Zopenr=   ZPATH_CPU_DMA_LATENCYZO_WRONLY_cpu_latency_fdZOSErrorr;   r<   r   _latencyoptionsrC   nameZassigned_devices_first_deviceZ
IndexErrorr   instancerT   r   _instance_initZCPULatencyPlugin._instance_initR  s+    $(!&(( 
$//
 
 
"#A&(2"8776#>#>LD 4='/H4D4DE_4`4h#'H #888WZbZgZggh! !:!:;A>8  HH<v?Z?ZZ[D 
 ! 8!s$   8D <!E! <EE!E76E7c                s    VP                   '       dj   V P                  '       d!   \        P                  ! V P                  4       VP
                  e(   V P                  P                  VP
                  4       R # R # R # N)r[   r   rN   Zcloser\   rX   _monitors_repositoryZdeletera   rT   r   _instance_cleanupZ"CPULatencyPlugin._instance_cleanupn  s\    
HHT!!"($$X%;%;< ) r   c                s   < \         \        V `  V4       VP                  '       d$   V P                  P                  R R4      Vn        R# R# )loadN)r   r   _instance_init_dynamicr[   re   ZcreaterX   )r   rb   r   s   &&r   rh   Z'CPULatencyPlugin._instance_init_dynamicu  s?    $6x@ 55<<VTJ8 r   c                sd    V P                   P                  R V,          R4      P                  4       # )'/sys/devices/system/cpu/intel_pstate/%sN)r   	read_filestrip)r   attrrT   r   _get_intel_pstate_attrZ'CPULatencyPlugin._get_intel_pstate_attrz  s(    			FMt	T	Z	Z	\\r   c                s\    Ve(   V P                   P                  RV,          VRR7       R # R # )Nri   T)ignore_same)r   write_to_file)r   rl   val   &&&r   _set_intel_pstate_attrZ'CPULatencyPlugin._set_intel_pstate_attr}  s,    _99DtKS^bc r   c                sV    Vf   R # V P                  V4      pV P                  W4       V# rd   )rm   rr   )r   rl   valuev   &&& r   _getset_intel_pstate_attrZ*CPULatencyPlugin._getset_intel_pstate_attr  s-    
]

!!$'!d*	
(r   c                s  < \         \        V `  V4       VP                  '       g   R # V P                  P                  VP                  R,          4      pVe   V P                  V4       V P                  '       d   V P                  P                  VP                  R,          4      pV P                  RV4      V n
        V P                  P                  VP                  R,          4      pV P                  RV4      V n        V P                  P                  V P                  P                  VP                  R,          4      4      pV P                  RV4      V n        R # R # )Nr(   r,   r-   r.   )r   r   _instance_apply_staticr[   Z
_variablesZexpandr^   _set_latencyr   rv   r   r   r   Zget_boolr   )r   rb   Zforce_latency_valueZ	new_valuer   s   &&  r   rw   Z'CPULatencyPlugin._instance_apply_static  s*   $6x@		!	!	!	..O$&$()	%%^$&9!;;I4%%^$&9!;;I4yy!!$//"8"8Z #" #977	4 r   c                s&  < \         \        V `  W4       VP                  '       dk   V P                  '       dW   V P                  R V P                  4       V P                  RV P                  4       V P                  RV P                  4       R# R# R# )r,   r-   r.   N)	r   r   _instance_unapply_staticr[   r   rr   r   r   r   )r   rb   Zrollbackr   s   &&&r   ry   Z)CPULatencyPlugin._instance_unapply_static  st    $8L$"8"8"8~t/F/FG~t/F/FGz4+>+>? #9r   c                s(    V P                  W4       R # rd   )_instance_update_dynamicr   rb   r!   rq   r   _instance_apply_dynamicZ(CPULatencyPlugin._instance_apply_dynamic  s    1r   c                s&   W!P                   8w  d   R # VP                  P                  4       R,          pW1P                  R,          8  d%   V P	                  VP                  R,          4       R # V P	                  VP                  R,          4       R # )NZsystemr%   r'   r&   )r`   rX   Zget_loadr^   rx   )r   rb   r!   rg   ru   r   rz   Z)CPULatencyPlugin._instance_update_dynamic  sn    %%%					(	(	*8	4$	-..X%%n56X%%m45r   c                s    R # rd   r2   r{   rq   r   _instance_unapply_dynamicZ*CPULatencyPlugin._instance_unapply_dynamic  s    r   c                sJ     \        V4      #   \        \        3 d     R # i ; ird   )int
ValueErrorZ	TypeErrorr   srT   r   _str2intZCPULatencyPlugin._str2int  s'    
a&=
i	  
s   
 ""c                s   / V n         \        P                  ! \        4       F  p\        R V,          ,           pV P                  P                  VR,           RRR7      pV P                  P                  VR,           RRR7      pVf   Kg  Vf   Km  V P                  V4      pVf   K  W@P                   VP                  4       &   K  	  R# )z/%s/r_   NTZerr_retno_errorlatency)cstates_latencyrN   Zlistdircpuidle_states_pathr   rj   r   rk   )r   ZdZcstate_pathr_   r   s   &    r   _read_cstates_latencyZ&CPULatencyPlugin._read_cstates_latency  s    $::)*a$vz1;
))

kF2dt

T4YY  y!8DUY Z7
7.mmG$G*1$**,' +r   c                sr   \         P                  R V,          4       V P                  f&   \         P                  R4       V P                  4        V P                  P	                  VR4      pV'       d   V^ 8X  d   \         P                  R4       R# \         P                  R\        V4      ,          4       V# )z)getting latency for cstate with name '%s'Nzreading cstates latency table"skipping latency 0 as set by paramz!cstate name mapped to latency: %s)r;   rV   r   r   r:   rQ   )r   r_   no_zeror   ru   r   _get_latency_by_cstate_nameZ,CPULatencyPlugin._get_latency_by_cstate_name  s    ))7$>?	!99,-  $$T40'A9912
))/#g,>?	.r   c                s   \         P                  R \        V4      ,          4       V P                  V4      pVf   \         P                  R4       R# \        RRV,          ,          ,           pV P                  V P
                  P                  VRRR7      4      pV'       d   V^ 8X  d   \         P                  R4       R# \         P                  R\        V4      ,          4       V# )	z'getting latency for cstate with ID '%s'Nzcstate ID is invalidz/%s/latencyzstate%dTr   r   zcstate ID mapped to latency: %s)r;   rV   rQ   r   r   r   rj   )r   Zlidr   Zlatency_pathr   s   &&&  r   _get_latency_by_cstate_idZ*CPULatencyPlugin._get_latency_by_cstate_id  s    ))5C@Ac#[99#$
$}	C'HH,MM$))--ldW[-\]'A9912
))-G<=	.r   c                sJ   R V n         \        V4      P                  R4      p\        P	                  RV: RV: R24       V F4  p \        V4      p\        P	                  RV,          4       Tf   K1   TR3# 	  VR3#   \         Ed    TR,          R8X  d   T P                  TR,          R	R
7      p LGTR,          R8X  d   T P                  TR,          4      p LoTR,          R8X  d   T P                  TR,          R	R
7      p LTR,          R8X  d   T P                  TR,          4      p LTR9   d   \        P	                  R4       Ru u # T'       d    TR8X  d   \        P	                  R4        EL
\        P	                  R\        T4      ,          4       R p EL4i ; i)N|zparsing latency 'z', allow_na ''z+parsed directly specified latency value: %d:       Nzcstate.id_no_zero::r   NNT)r   :r   
   Nz
cstate.id::r   NN:r      Nzcstate.name_no_zero::r   NN:r      Nzcstate.name::r   NNzlatency 'none' specifiedn/azlatency 'n/a' specifiedzinvalid latency specified: '%s'F)ZnoneZNone)NT)	r   rQ   splitr;   rV   r~   r   r   r   )r   r   allow_naZ	latenciesru   r   _parse_latencyZCPULatencyPlugin._parse_latency  sh   $'l  %)))WhGHg'lGII;gEF& 		%1 0 
%)  t},,--gclD-IW	,	&--gcl;W	0	0//d/KW	.	(//=W	$	$YY)*	g&YY()	YY03w<?@W#s<   'A>>4F"4&F"(F"&F".F"F"F"7'F"!F"c                s   V P                  V4      w  rV'       g   V P                  '       d   Vf   \        P                  R4       RV n        R # V P                  V8w  d]   \        P                  RV,          4       \        P                  ! RV4      p\        P                  ! V P                  V4       Wn        R # R # R # R # )Nztunable to evaluate latency value (probably wrong settings in the 'cpu' section of current profile), disabling PM QoSFzsetting new cpu latency %dZi)r   r   r;   errorr]   r<   structZpackrN   Zwriter\   )r   r   skipZlatency_bin   &&  r   rx   ZCPULatencyPlugin._set_latency  s    %%g.-'	$"""oII  E  FD HH)G34++c7+KHHT!!;/M	 	!	 #r   c                s~    V P                   P                  R V,          4      P                  4       P                  4       # )z>/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors)r   rj   rk   r   r    rT   r   _get_available_governorsZ)CPULatencyPlugin._get_available_governors  s0    			]`ff	g	m	m	o	u	u	wwr   r)   T)
per_devicec                s   V P                  V4      '       g   R # \        V4      pVP                  R4      pV Uu. uF  qfP                  4       NK  	  ppV F+  p\	        V4      ^ 8X  g   K  \
        P                  R4        R # 	  V P                  V4      pV F  pWg9   dh   V'       g]   \
        P                  RV: RV: R24       V P                  P                  RV,          Ye'       d   \        P                  .MRRR	7        V# V'       d   Kz  \
        P                  R
V: RV: R24       K  	  \
        P                  RRP                  V4      ,          4       R pV# u upi )Nr   z.The 'governor' option contains an empty value.zsetting governor '
' on cpu 'r   rS   FTr   rn   zIgnoring governor 'z', it is not supportedz.None of the scaling governors is supported: %sz, )rW   rQ   r   rk   lenr;   r   r   r<   r   ro   rH   rI   rV   rJ   Zjoin)r   Z	governorsr!   rb   simremover)   Zavailable_governors   &&&&&&  r   _set_governorZCPULatencyPlugin._set_governor  s5   		,	,V	4	4
)n)ooc")09:	H~~	):h	(mqII>?  55f=h%XX
F 	YYR	u||nEW[  ]	 
/ CII	6   ;;?yy 8	/+ ;s   E#c                s   R pV P                  V4      '       g   R # V P                  P                  RV,          VR7      P                  4       p\	        V4      ^ 8  d   TpVf   \
        P                  RV,          4       V# )NrS   r   z*could not get current governor on cpu '%s')rW   r   rj   rk   r   r;   r   )r   r!   rb   ignore_missingr)   Zdata   &&&&  r   _get_governorZCPULatencyPlugin._get_governor/  sr    (		,	,V	4	4
			RU[[ft		u	{	{	}$Y]8999FBC	/r   c                    R V,          # )z7/sys/devices/system/cpu/cpufreq/%s/sampling_down_factorr2   )r   r)   rT   r   _sampling_down_factor_pathZ+CPULatencyPlugin._sampling_down_factor_path=  s    	BX	MMr   r*   )r   Zpriorityc                s   R pW P                   9   d   V P                   P                  4        R V P                   V&   V P                  W#4      pVf   \        P	                  RV,          4       R # V\        V P                   P                  4       4      9  d   WpP                   V&   V P                  V4      p\        P                  P                  V4      '       g!   \        P	                  RV: RV: R24       R # \        V4      pV'       gU   \        P                  RV: RV: R24       V P                  P                  YV'       d   \        P                   .MRR	7       V# )
NzIignoring sampling_down_factor setting for CPU '%s', cannot match governorz/ignoring sampling_down_factor setting for CPU 'z', governor 'z' doesn't support itz!setting sampling_down_factor to 'z' for governor 'r   Fr   )r   Zclearr   r;   rV   rY   rZ   r   rN   rO   rP   rQ   r<   r   ro   rH   rI   )	r   r*   r!   rb   r   r   rp   r)   rO   s	   &&&&&&   r   _set_sampling_down_factorZ*CPULatencyPlugin._set_sampling_down_factor@  s   #
 """ $$f1(99X[aab
T$--44677!)v

)
)(
34
''..

IIhnpxyz	!	"3
HHhWXIIDF5<<.PUV	*r   c                s    V P                  WVR 7      pVf   R# V P                  V4      p\        P                  P	                  V4      '       g   R# V P
                  P                  V4      P                  4       # ))r   N)r   r   rN   rO   rP   r   rj   rk   )r   r!   rb   r   r)   rO   r   r   _get_sampling_down_factorZ*CPULatencyPlugin._get_sampling_down_factor[  sd    P(
		(	(	2$			
			T	"	(	(	**r   c                sb    V P                   P                  R RV\        V4      .RR7      w  r4pW53# )rD   -cT)Z
return_err)r   rG   rQ   )r   cpu_idrs   rK   rL   err_msgs   &&&   r   _try_set_energy_perf_biasZ*CPULatencyPlugin._try_set_energy_perf_biase  sD     II--&J  . 7 	r   c                r   )z./sys/devices/system/cpu/cpufreq/policy%s/boostr2   r   r   rT   r   _pstate_boost_pathZ#CPULatencyPlugin._pstate_boost_pathn  s    	9F	BBr   c                s0    R V: RV'       d   R: 2# R: 2# )z&/sys/devices/system/cpu/cpufreq/policyz/energy_performance_Zavailable_preferencesZ
preferencer2   )r   r   Z	availablerq   r   _pstate_preference_pathZ(CPULatencyPlugin._pstate_preference_pathq  s8    MSpyUl  VL  
M  M  @L  VL  
M  Mr   c                r   )z4/sys/devices/system/cpu/cpu%s/power/energy_perf_biasr2   r   rT   r   _energy_perf_bias_pathZ'CPULatencyPlugin._energy_perf_bias_patht  s    	?&	HHr   r+   c                s   V P                  V4      '       g   \        P                  R V,          4       R# VP                  R4      pVP	                  R4      pV P
                  '       d   V P                  V4      p\        P                  P                  V4      '       d   V'       g   V Fp  p	V	P                  4       p	V P                  P                  YV'       d   \        P                  .MRRR7      '       g   KR  \        P                  RV	: RV: R	24        M	  \        P!                  R
V,          4       \#        V4      # \        P!                  RV,          4       R# V P$                  '       d   V'       g   V F  p	V	P                  4       p	\        P                  RV	: RV: R	24       V P'                  Wi4      w  rV
^ 8X  d!   \        P                  RV	: RV: R	24        McV
^ 8  d   \        P!                  RV,          4        M>\        P                  RV	: RV: R24       K  	  \        P!                  R
V,          4       \#        V4      # R# )%s is not online, skippingNr   r   FTr   z&energy_perf_bias successfully set to 'r   r   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.z#Trying to set energy_perf_bias to 'z"Failed to set energy_perf_bias: %sz#Could not set energy_perf_bias to 'z', trying another value)rR   r;   rV   lstripr   r   r   rN   rO   rP   rk   r   ro   rH   rI   r<   r   rQ   r   r   )r   r+   r!   rb   r   r   r   valsenergy_perf_bias_pathrp   rK   r   s   &&&&&&      r   _set_energy_perf_biasZ&CPULatencyPlugin._set_energy_perf_biasw  s   			V	$	$99)F23
==&				$$ 
66v>ggnn*++IIKc		 	 !6$*5<<.4 
! 
I 
I6 	  
iib    IIh
 ,,,
99;SYY
v 88g1	hh 
A+	ii4
 	ii  $ 	YYa	 


r   c                s     \        V4      pV#   \         d8   p \        T^4      p Rp?T#   \         d   pTp Rp? Rp?T# Rp?ii ; iRp?ii ; i)i   N)r~   r   )r   r   rt   er   r   _try_parse_numZCPULatencyPlugin._try_parse_num  s]    

1v1 
( 
 

Ar
A 
(  
	AA	
(

s.    A-A	AAA		AAc                sP    ^ R^R^R/P                  V P                  V4      V4      # )r   performancenormalZ	powersaver:   r   r   rT   r   _energy_perf_policy_to_humanZ-CPULatencyPlugin._energy_perf_policy_to_human  s.    
M1Xr+	6	:	:4;N;Nq;QST	UUr   c           
     sX    ^ R^R^R^R^R/P                  V P                  V4      V4      # )r   r   zbalance-performancer   zbalance-powerZpowerr   r   rT   r   _energy_perf_policy_to_human_v2Z0CPULatencyPlugin._energy_perf_policy_to_human_v2  s?    
Mhow	

 
c$

a
 !$%r   c                s   R pV P                  V4      '       g   \        P                  RV,          4       R # VP                  R4      pV P                  '       dc   V P                  V4      p\        P                  P                  V4      '       d+   V P                  V P                  P                  V4      4      pV# V P                  '       d   V P                  P                  RRVR.4      w  rxV^ 8X  d~   VP                  4        Fi  p	V	P                  4       p
\!        V
4      ^8X  d   V P#                  V
^,          4      p V# \!        V
4      ^8X  g   KP  V P                  V
^,          4      p V# 	  V# )Nr   r   rD   r   rE   )rR   r;   rV   r   r   r   rN   rO   rP   r   r   rj   r   rG   Z
splitlinesr   r   r   )r   r!   rb   r   r+   r   r   rK   ZlinesZlineZls   &&&&       r   _get_energy_perf_biasZ&CPULatencyPlugin._get_energy_perf_bias  sG   			V	$	$99)F23
==&	66v>ggnn*++;;DII<O<OPe<fg 
 ,,,II%%'?vt&TU>7l  "	QA!::1Q4@
 
	 a&A+==adC	 # 
r   c                r   )z9/sys/devices/system/cpu/%s/power/pm_qos_resume_latency_usr2   r    rT   r   _pm_qos_resume_latency_us_pathZ/CPULatencyPlugin._pm_qos_resume_latency_us_path  s    	Dv	MMr   c                s    V P                   f[   \        P                  P                  V P	                  V4      4      V n         V P                   '       g   \
        P                  R4       V P                   # )NzGOption 'pm_qos_resume_latency_us' is not supported on current hardware.)r   rN   rO   rP   r   r;   r<   r    rT   r   _check_pm_qos_resume_latency_usZ0CPULatencyPlugin._check_pm_qos_resume_latency_us  sT    	''/(*t7Z7Z[a7b(c4%

,
,
,HHVW		+	++r   r/   c                s   V P                  V4      '       g   \        P                  R V,          4       R# V P                  VRR7      w  rgV'       g   V P	                  V4      '       g   R# Ve   VR8w  d(   V^ 8  d!   \        P                  RV: RV: R24       R# V'       gG   V P                  P                  V P                  V4      TV'       d   \        P                  .MRR	7       V# )
r   NT)r   r   z-Invalid pm_qos_resume_latency_us specified: 'z	', cpu: 'z'.Fr   )rR   r;   rV   r   r   rJ   r   ro   r   rH   rI   )r   r/   r!   rb   r   r   r   r   r   r   _set_pm_qos_resume_latency_usZ.CPULatencyPlugin._set_pm_qos_resume_latency_us  s    			V	$	$99)F23
%%&>%N-'	55f==
_E)gk;;Qikqrs
	994>>vF!'~U  4	.r   c                s   V P                  V4      '       g   \        P                  R V,          4       R# V P                  V4      '       g   R# V P                  P                  V P                  V4      VR7      P                  4       # )r   Nr   )rR   r;   rV   r   r   rj   r   rk   )r   r!   rb   r   s   &&&&r   _get_pm_qos_resume_latency_usZ.CPULatencyPlugin._get_pm_qos_resume_latency_us  sk    			V	$	$99)F23
		-	-f	5	5
			T@@HSa		b	h	h	jjr   r1   c                s   V P                  V4      '       g   \        P                  R V,          4       R# VP                  R4      pRp\        P
                  P                  V P                  V4      4      '       d   V'       g   VR8X  g   VR8X  di   V P                  P                  V P                  V4      TV'       d   \        P                  .MRRR7       \        P                  RV: R	V: R
24       RpM2\        P                  RV,          4       M\        P                  R4       V P                  '       dN   VR9   dG   VR8X  d   RMRpV'       g4    V P                  RV4       \        P                  RV: RV: R24       RpV'       g	   V'       d   \%        V4      # VR9   d   \        P#                  RV,          4       R#   \          d0   p	\        P#                  R\%        T	4      ,          4        Rp	?	LuRp	?	ii ; i)r   Nr   F01Tr   zSetting boost value '' for cpu 'r   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.r.   zSetting no_turbo to 'z!' for intel_pstate driver (boost=Z)z+Failed to set no_turbo for intel_pstate: %szaUnable to set boost on cpu '%s'. Neither per-policy boost nor intel_pstate no_turbo is available.)r   r   )rR   r;   rV   r   rN   rO   rP   r   r   ro   rH   rI   r<   r   r   rr   Z	ExceptionrJ   rQ   )
r   r1   r!   rb   r   r   r   Z	boost_setZno_turbo_valr   s
   &&&&&&    r   
_set_boostZCPULatencyPlugin._set_boost  s   			V	$	$99)F23
==&)WW^^D++F344
|u|	YYT44V<e#)%,,u$  HXXGHYYYVY__`99HI 
 3##3<
I	  \:XX|]bcdY #
e*
;;ru{{|	  I[[>QGHHIs   2G H%HHc                s   V P                  V4      '       g   \        P                  R V,          4       R# VP                  R4      p\        P
                  P                  V P                  V4      4      '       d9   V P                  P                  V P                  V4      4      P                  4       # \        P                  R4       R# )r   Nr   r   )rR   r;   rV   r   rN   rO   rP   r   r   rj   rk   r   r!   rb   r   r      &&&& r   
_get_boostZCPULatencyPlugin._get_boost*  s    			V	$	$99)F23
==&WW^^D++F344
))

d55f=
>
D
D
FF99HI	r   r0   c                s   V P                  V4      '       g   \        P                  R V,          4       R# VP                  R4      p\        P
                  P                  V P                  VR4      4      '       EdG   VP                  R4      pV'       Eg"   \        V P                  P                  V P                  VR4      4      P                  4       4      pV F  p	 \        V	4      p	^ T	u;8*  ;'       d    R8  Mu p
\        V	4      p	V
'       dh   V P                  P                  V P                  V4      T	V'       d   \         P"                  .MRRR7       \        P%                  RV	: R	V: R
24        M>\        P'                  RV	: RV: R
24       K  	  \        P)                  RV,          4       \        V4      # \        P                  R4       R#   \         d    Y9   p
 Li ; i)r   Nr   Tr   i   Fr   z-Setting energy_performance_preference value 'r   r   z%energy_performance_preference value 'z' unavailable for cpu '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.)rR   r;   rV   r   rN   rO   rP   r   r   r   r   rj   r~   rQ   r   ro   rH   rI   r<   rJ   r   )r   r0   r!   rb   r   r   r   r   Z
avail_valsrp   Zvalids   &&&&&&     r   "_set_energy_performance_preferenceZ3CPULatencyPlugin._set_energy_performance_preference6  s   			V	$	$99)F23
==&WW^^D00>??
'
-
-c
24
#TYY(()E)Efd)STZZ\]J Hc3nnneHc 	
iid::6BC$*5<<.4  I	hhRUW]^_	kkY\^def  	YYn 
+
,,99  I  J	   e s   ,GG,+G,c                s   V P                  V4      '       g   \        P                  R V,          4       R# VP                  R4      p\        P
                  P                  V P                  VR4      4      '       d9   V P                  P                  V P                  V4      4      P                  4       # \        P                  R4       R# )r   Nr   Tr   )rR   r;   rV   r   rN   rO   rP   r   r   rj   rk   r   r   r   "_get_energy_performance_preferenceZ3CPULatencyPlugin._get_energy_performance_preferenceV  s    			V	$	$99)F23
==&WW^^D00>??
))

d::6B
C
I
I
KK99  I  J	r   )r   r   r   r\   r   r   r   r   r   r   r   r   r   r   r
   r	   r   r]   r   r   r   r   )F)Zondemand)AZ__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r   r"   r$   Zclassmethodr5   rC   r?   r@   rA   r>   rR   rU   rW   rc   rf   rh   rm   rr   rv   rw   r=   ZROLLBACK_SOFTry   r|   rz   r}   r   r   r   r   r   rx   r   Zcommand_setr   Zcommand_getr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r   r   r      sL    yv,!J  "!Fk%
#

AX!8=K
]d0 :@9M9M @2	6	2
<
x jT* +8 j N $4BG H4 $%+ &+CMI  T25 35nV%  ! "0N, (T: ; ()k *k g$'% (%N g	 	 -$? @> -.
 /
 
r   r   )rF   r    Z
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsr   Ztuned.constsr=   rN   rH   r   r6   r7   Zlogsr:   r;   r   ZPluginr   r2   r   r   <module>r      sN       )  	     jjnn< Ow~~ Or   