• File: plugin_cpu.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyo
  • Date Modified: 09/21/2022 11:48 AM
  • File size: 15.42 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

\c@sddlmZddlTddlZddlmZddljZddl	Z	ddl
Z
ddlZddlZddl
Z
ejjZdejfdYZdS(i(tbase(t*iN(tcommandstCPULatencyPlugincBseZdZdZdZdZedZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZedZdZdZdZdZdZeddedZededZddZ eddeddd Z!eded!Z"d"Z#ed#ded$Z$d%Z%d&Z&d'Z'ed#ed(Z(RS()sP
	Plugin for tuning CPU options. Powersaving, governor, required latency, etc.
	cOstt|j||t|_d|_t|_t|_t|_	t|_
t|_d|_
d|_d|_i|_t|_dS(Ntx86_64(tsuperRt__init__tTruet_has_pm_qost_archtFalset_is_x86t	_is_intelt_is_amdt_has_energy_perf_biast_has_intel_pstatetNonet_min_perf_pct_savet_max_perf_pct_savet_no_turbo_savet_governors_mapRt_cmd(tselftargstkwargs((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRs											cCsUt|_t|_x-|jjdD]}|jj|jq(Wt|_dS(Ntcpu(	Rt_devices_supportedtsett
_free_devicest_hardware_inventorytget_devicestaddtsys_namet_assigned_devices(Rtdevice((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt
_init_devices(s
	cCs&g|D]}|jjd|^qS(NR(Rt
get_device(Rtdevicestx((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_device_objects1scCsJi
dd6dd6dd6dd6dd6dd	6dd
6dd6dd6dd
6S(Ng?tload_thresholdidtlatency_lowitlatency_hight
force_latencytgovernortsampling_down_factortenergy_perf_biastmin_perf_pcttmax_perf_pcttno_turbo(R(R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_config_options4scCsdddddg}tj|_|j|krtj}|jjd}|dkrit|_n-|dks|d	krt|_	n	t|_t
jd
|nt
jd|j|jtkr|j|j
ndS(NRti686ti585ti486ti386t	vendor_idtGenuineInteltAuthenticAMDtHygonGenuines$We are running on an x86 %s platformsWe are running on %s (non x86)(tplatformtmachineR	tprocfstcpuinfottagstgetRRR
tlogtinfot_check_energy_perf_biast_check_intel_pstate(Rtintel_archsRtvendor((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_check_archCs	
cCst|_d}|jjddgdtj|gd}|dkrRt|_n)|dkrntjdn
tjddS(Nitx86_energy_perf_policys-rt	no_errorsisgunable to run x86_energy_perf_policy tool, ignoring CPU energy performance bias, is the tool installed?sXyour CPU doesn't support MSR_IA32_ENERGY_PERF_BIAS, ignoring CPU energy performance bias(	R
RRtexecuteterrnotENOENTRRAtwarning(Rtretcode_unsupportedtretcode((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRC^s	+cCs2tjjd|_|jr.tjdndS(Ns$/sys/devices/system/cpu/intel_pstatesintel_pstate detected(tostpathtexistsRRARB(R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRDis	cCs.t|}|jjt|jddS(NRt(tstrRt
is_cpu_onlinetreplace(RR"tsd((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_is_cpu_onlinenscCstjjd|S(Ns3/sys/devices/system/cpu/%s/cpufreq/scaling_governor(RPRQRR(RR"((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_cpu_has_scaling_governorrscCsL|j|s$tjd|tS|j|sHtjd|tStS(Ns'%s' is not online, skippings.there is no scaling governor fo '%s', skipping(RXRAtdebugR
RYR(RR"((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_check_cpu_can_change_governoruscCst|_t|_t|jjd|krt|_ytj	t
jtj|_
Wn.tk
rtjdt
jt|_nXd|_|jddkr|jjdd|_t|_n	d|_|jnt|_tjd|jt|jd|_dS(Nis-Unable to open '%s', disabling PM_QoS controlR+tloadsILatency settings from non-first CPU plugin instance '%s' will be ignored.(Rt_has_static_tuningR
t_has_dynamic_tuningtlistt
_instancestvaluest_first_instanceRPtopentconststPATH_CPU_DMA_LATENCYtO_WRONLYt_cpu_latency_fdtOSErrorRAterrorRRt_latencytoptionst_monitors_repositorytcreatet
_load_monitorRGRBtnametassigned_devicest
_first_device(Rtinstance((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_init~s$			

		
	cCsQ|jrM|jr%tj|jn|jdk	rM|jj|jqMndS(N(	RbRRPtcloseRgRnRRltdelete(RRr((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_cleanups
		cCs|jjd|djS(Ns'/sys/devices/system/cpu/intel_pstate/%s(Rt	read_fileRtstrip(Rtattr((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_intel_pstate_attrscCs*|dk	r&|jjd||ndS(Ns'/sys/devices/system/cpu/intel_pstate/%s(RRt
write_to_file(RRytval((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_intel_pstate_attrscCs3|dkrdS|j|}|j|||S(N(RRzR}(RRytvaluetv((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_getset_intel_pstate_attrs
cCstt|j||js#dS|jd}|dk	rL|j|n|jr|jd|jd|_	|jd|jd|_
|jd|jd|_ndS(NR+R/R0R1(RRt_instance_apply_staticRbRkRt_set_latencyRRRRR(RRrtforce_latency_value((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRs	
	cCsktt|j|||jrg|jrg|jd|j|jd|j|jd|jndS(NR/R0R1(	RRt_instance_unapply_staticRbRR}RRR(RRrt
full_rollback((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRs
cCs|j||dS(N(t_instance_update_dynamic(RRrR"((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_apply_dynamicscCsh||jkrdS|jjd}||jdkrP|j|jdn|j|jddS(NtsystemR(R*R)(RqRntget_loadRkR(RRrR"R\((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRscCsdS(N((RRrR"((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_unapply_dynamicscCsjt|}|jrf|j|krftjd|tjd|}tj|j	|||_ndS(Nssetting new cpu latency %dti(
tintRRjRARBtstructtpackRPtwriteRg(Rtlatencytlatency_bin((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRscCs |jjd|jjS(Ns>/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors(RRwRxtsplit(RR"((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_available_governorssR,t
per_devicecCs,|j|sdSt|}|jd}g|D]}|j^q5}x1|D])}t|dkrTtjddSqTW|j|}x|D]m}||kr|stj	d||f|j
jd||nPq|stjd||fqqWtj
ddj|d}|S(	Nt|is.The 'governor' option contains an empty value.s!setting governor '%s' on cpu '%s's3/sys/devices/system/cpu/%s/cpufreq/scaling_governors7Ignoring governor '%s' on cpu '%s', it is not supporteds.None of the scaling governors is supported: %ss, (R[RRTRRxtlenRARiRRBRR{RZtwarntjoin(Rt	governorsR"tsimR,tavailable_governors((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt
_set_governors2


			cCszd}|j|sdS|jjd|d|j}t|dkrV|}n|dkrvtjd|n|S(Ns3/sys/devices/system/cpu/%s/cpufreq/scaling_governortno_erroris*could not get current governor on cpu '%s'(RR[RRwRxRRARi(RR"tignore_missingR,tdata((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt
_get_governors"	tondemandcCsd|S(Ns7/sys/devices/system/cpu/cpufreq/%s/sampling_down_factor((RR,((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_sampling_down_factor_pathsR-tpriorityi
cCsd}||jkr%|jjnd|j|<|j|}|dkrbtjd|dS|t|jjkr||j|<|j|}t	j
j|stjd||fdSt|}|stj
d||f|jj||qn|S(NsIignoring sampling_down_factor setting for CPU '%s', cannot match governorsTignoring sampling_down_factor setting for CPU '%s', governor '%s' doesn't support its6setting sampling_down_factor to '%s' for governor '%s'(RRtclearRRARZR_RaRRPRQRRRTRBRR{(RR-R"RR|R,RQ((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_sampling_down_factors&

cCs`|j|d|}|dkr%dS|j|}tjj|sJdS|jj|jS(NR(	RRRRPRQRRRRwRx(RR"RR,RQ((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_sampling_down_factor)scCs=|jjdd|t|gdt\}}}||fS(NRHs-ct
return_err(RRJRTR(Rtcpu_idR~ROtoutterr_msg((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_try_set_energy_perf_bias3s	R.c	Cs"|j|s$tjd|dS|jr|s|jd}|jd}x|D]}|j}tjd||f|j||\}}|dkrtj	d||fPqX|dkrtj
d|PqXtjd||fqXWtj
d	|nt|SdSdS(
Ns%s is not online, skippingRRs2Trying to set energy_perf_bias to '%s' on cpu '%s'is5energy_perf_bias successfully set to '%s' on cpu '%s's"Failed to set energy_perf_bias: %ssHCould not set energy_perf_bias to '%s' on cpu '%s', trying another valuesPFailed to set energy_perf_bias on cpu '%s'. Is the value in the profile correct?(RXRARZRRtlstripRRxRRBRiRT(	RR.R"RRtvalsR|ROR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_energy_perf_bias<s6	
					
cCsYyt|}WnBtk
rT}yt|d}WqUtk
rP}|}qUXnX|S(Ni(Rt
ValueError(RtsRte((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_try_parse_num]scCs.idd6dd6dd6j|j||S(Ntperformanceitnormalit	powersavei(R@R(RR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_energy_perf_policy_to_humanhscCs<idd6dd6dd6dd6d	d
6j|j||S(NRisbalance-performanceiRis
balance-poweritpoweri(R@R(RR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_energy_perf_policy_to_human_v2ls

c	Csd}|j|s*tjd|dS|jr|jd}|jjdd|dg\}}|dkrxu|jD]d}|j	}t
|dkr|j|d}Pqt
|d	kr|j|d}PqqWqn|S(
Ns%s is not online, skippingRRHs-cs-riiii(
RRXRARZRRRRJt
splitlinesRRRR(	RR"RR.RROtlinestlinetl((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_energy_perf_biasts"	$()t__name__t
__module__t__doc__RR#R'tclassmethodR2RGRCRDRXRYR[RsRvRzR}RRR
RRRRRRtcommand_setRRtcommand_getRRRRRRRRRR(((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRsJ																							
!				!				(RSRt
decoratorst
tuned.logsttunedttuned.utils.commandsRttuned.constsRdRPRRKR;R=tlogsR@RAtPluginR(((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt<module>s