MINI MINI MANI MO

Path : /usr/lib/python2.7/site-packages/tuned/plugins/
File Upload :
Current File : //usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyc

ó
©=[c@s•ddlmZddlTddlZddlmZddljZddl	Z	ddl
Z
ddlZejj
ƒZdejfd„ƒYZdS(i(tbase(t*iÿÿÿÿN(tcommandstCPULatencyPlugincBs£eZdZd„Zd„Zd„Zed„ƒZd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zd„Zd„Zed„Zd„Zd„Zd„Zd„Zd„Zeddeƒd„ƒZedƒed„ƒZdd„Zeddeddƒd„ƒZ edƒed „ƒZ!d!„Z"ed"deƒd#„ƒZ#d$„Z$d%„Z%d&„Z&ed"ƒed'„ƒZ'RS((sP
	Plugin for tuning CPU options. Powersaving, governor, required latency, etc.
	cOshtt|ƒj||Žt|_t|_t|_d|_	d|_
d|_i|_t
ƒ|_dS(N(tsuperRt__init__tTruet_has_pm_qost_has_energy_perf_biastFalset_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-|jjdƒD]}|jj|jƒq(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_objects+scCsJi
dd6dd6dd6dd6dd6dd	6dd
6dd6dd6dd
6S(Ngš™™™™™É?tload_thresholdidtlatency_lowièt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_options.scCst|_d}|jjddgdtj|gƒd}|dkrRt|_n)|dkrntjdƒn
tjdƒdS(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	RRtexecuteterrnotENOENTRtlogtwarning(Rtretcode_unsupportedtretcode((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_check_energy_perf_bias=s	+cCs2tjjdƒ|_|jr.tjdƒndS(Ns$/sys/devices/system/cpu/intel_pstatesintel_pstate detected(tostpathtexistsR
R3tinfo(R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_check_intel_pstateHs	cCs.t|ƒ}|jjt|ƒjddƒƒS(NRt(tstrRt
is_cpu_onlinetreplace(RRtsd((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_is_cpu_onlineMscCstjjd|ƒS(Ns3/sys/devices/system/cpu/%s/cpufreq/scaling_governor(R8R9R:(RR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_cpu_has_scaling_governorQscCsL|j|ƒs$tjd|ƒtS|j|ƒsHtjd|ƒtStS(Ns'%s' is not online, skippings.there is no scaling governor fo '%s', skipping(RBR3tdebugR	RCR(RR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_check_cpu_can_change_governorTscCs!t|_t|_t|jjƒƒd|krêt|_ytj	t
jtjƒ|_
Wn.tk
r‰tjdt
jƒt|_nXd|_|jddkrÊ|jjddƒ|_t|_n	d|_|jƒ|jƒnt|_tjd|jƒt|jƒd|_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_instanceR8topentconststPATH_CPU_DMA_LATENCYtO_WRONLYt_cpu_latency_fdtOSErrorR3terrorRRt_latencytoptionst_monitors_repositorytcreatet
_load_monitorR7R<R;tnameR t
_first_device(Rtinstance((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_init]s&			

		

	cCsQ|jrM|jr%tj|jƒn|jdk	rM|jj|jƒqMndS(N(	RLRR8tcloseRQRXRRVtdelete(RR[((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_cleanup{s
		cCs|jjd|dƒjƒS(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_attr‚scCs*|dk	r&|jjd||ƒndS(Ns'/sys/devices/system/cpu/intel_pstate/%s(RRt
write_to_file(RRbtval((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_intel_pstate_attr…scCs3|dkrdS|j|ƒ}|j||ƒ|S(N(RRcRf(RRbtvaluetv((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_getset_intel_pstate_attr‰s
cCs°tt|ƒj|ƒ|js#dS|jd}|dk	rL|j|ƒn|jr¬|jd|jdƒ|_	|jd|jdƒ|_
|jd|jdƒ|_ndS(NR&R*R+R,(RRt_instance_apply_staticRLRURt_set_latencyR
RiRR
R(RR[tforce_latency_value((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRjs	
	cCsktt|ƒj||ƒ|jrg|jrg|jd|jƒ|jd|jƒ|jd|jƒndS(NR*R+R,(	RRt_instance_unapply_staticRLR
RfRR
R(RR[t
full_rollback((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRmžs
cCs|j||ƒdS(N(t_instance_update_dynamic(RR[R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_apply_dynamic¦scCsw|jst‚||jkr"dS|jjƒd}||jdkr_|j|jdƒn|j|jdƒdS(NtsystemR#R%R$(RLtAssertionErrorRZRXtget_loadRURk(RR[RRF((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRo©scCsdS(N((RR[R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_instance_unapply_dynamic´scCsjt|ƒ}|jrf|j|krftjd|ƒtjd|ƒ}tj|j	|ƒ||_ndS(Nssetting new cpu latency %dti(
tintRRTR3R;tstructtpackR8twriteRQ(Rtlatencytlatency_bin((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRk·scCs |jjd|ƒjƒjƒS(Ns>/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors(RR`Ratsplit(RR((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_available_governors¿sR't
per_devicecCs“|j|ƒsdS||j|ƒkrL|sHtjd||fƒndS|s‰tjd||fƒ|jjd|t|ƒƒnt|ƒS(Ns7ignoring governor '%s' on cpu '%s', it is not supporteds!setting governor '%s' on cpu '%s's3/sys/devices/system/cpu/%s/cpufreq/scaling_governor(RERR}R3R;RRdR>(RR'Rtsim((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt
_set_governorÂs 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'(RRERR`RatlenR3RS(RRtignore_missingR'tdata((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt
_get_governorÏs"	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_pathÝsR(tpriorityi
cCsd}||jkr%|jjƒnd|j|<|j|ƒ}|dkrbtjd|ƒdS|t|jjƒƒkr||j|<|j|ƒ}t	j
j|ƒsÆtjd||fƒdSt|ƒ}|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'(RRtclearR…R3RDRIRKR‡R8R9R:R>R;RRd(RR(RRReR'R9((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_sampling_down_factoràs&

cCs`|j|d|ƒ}|dkr%dS|j|ƒ}tjj|ƒsJdS|jj|ƒjƒS(NRƒ(	R…RR‡R8R9R:RR`Ra(RRRƒR'R9((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_sampling_down_factorûscCs=|jjdd|t|ƒgdtƒ\}}}||fS(NR.s-ct
return_err(RR0R>R(Rtcpu_idRgR6toutterr_msg((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_try_set_energy_perf_biass	R)c	Cs"|j|ƒs$tjd|ƒdS|jr|s|jdƒ}|jdƒ}x¼|D] }|jƒ}tjd||fƒ|j||ƒ\}}|dkrÀtj	d||fƒPqX|dkrátj
d|ƒPqXtjd||fƒqXWtj
d	|ƒnt|ƒSdSdS(
Ns%s is not online, skippingRt|s2Trying 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?(RBR3RDRRtlstripR|RaRR;RSR>(	RR)RRRtvalsReR6R((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_set_energy_perf_biass6	
					
cCsYyt|ƒ}WnBtk
rT}yt|dƒ}WqUtk
rP}|}qUXnX|S(Ni(Rvt
ValueError(RtsRhte((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_try_parse_num/scCs.idd6dd6dd6j|j|ƒ|ƒS(Ntperformanceitnormalit	powersavei(tgetR˜(RR–((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_energy_perf_policy_to_human:scCs<idd6dd6dd6dd6d	d
6j|j|ƒ|ƒS(NR™isbalance-performanceiRšis
balance-poweritpoweri(RœR˜(RR–((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_energy_perf_policy_to_human_v2>s

c	Csñd}|j|ƒs*tjd|ƒdS|jrí|jdƒ}|jjdd|dgƒ\}}|dkríxu|jƒD]d}|j	ƒ}t
|ƒdkrº|j|dƒ}Pqt
|ƒd	kr|j|dƒ}PqqWqín|S(
Ns%s is not online, skippingRR.s-cs-riiii(
RRBR3RDRR’RR0t
splitlinesR|R‚RRŸ(	RRRƒR)RR6tlinestlinetl((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt_get_energy_perf_biasFs"	$((t__name__t
__module__t__doc__RRR"tclassmethodR-R7R<RBRCRER\R_RcRfRiRjR	RmRpRoRtRkR}tcommand_setRR€tcommand_getR…R‡RŠR‹RR”R˜RRŸR¤(((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyRsH	
																				
	
!				!				(R=Rt
decoratorst
tuned.logsttunedttuned.utils.commandsRttuned.constsRNR8RwR1tlogsRœR3tPluginR(((s</usr/lib/python2.7/site-packages/tuned/plugins/plugin_cpu.pyt<module>s


OHA YOOOO