\c@sddlmZddlTddlZddlZddlZddlZddlm Z ej j Z e Z dejfdYZdS(i(tbase(t*iN(tcommandstVMPlugincBseZdZedZdZdZedZeddZ eddZ e dd Z e dd Z ed d Ze d d ZRS(s( Plugin for tuning memory management. cCsidd6dd6dd6S(Nttransparent_hugepagesttransparent_hugepagestransparent_hugepage.defrag(tNone(tself((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_get_config_optionsscCst|_t|_dS(N(tTruet_has_static_tuningtFalset_has_dynamic_tuning(Rtinstance((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_instance_inits cCsdS(N((RR ((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_instance_cleanupscCs%d}tjj|s!d}n|S(Ns#/sys/kernel/mm/transparent_hugepages*/sys/kernel/mm/redhat_transparent_hugepage(tostpathtexists(RR((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt _thp_path!s RcCs|d kr0|s,tjdt|ndStjddt}|jddkrt|sptjd ndSt j j |j d }t j j |r|stj||n|S|stjd ndSdS( Ntalwaystnevertmadvises-Incorrect 'transparent_hugepages' value '%s'.s /proc/cmdlinetno_errorstransparent_hugepage=isWtransparent_hugepage is already set in kernel boot cmdline, ingoring value from profiletenabledsDOption 'transparent_hugepages' is not supported on current hardware.(salwaysRR(tlogtwarntstrRtcmdt read_fileR tfindtinfoRRtjoinRRt write_to_file(Rtvaluetsimtcmdlinetsys_file((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_set_transparent_hugepages)s" RcCs|j||dS(N(R&(RR"R#((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_set_transparent_hugepageAscCsKtjj|jd}tjj|rCtjtj|SdSdS(NR( RRR RRRtget_active_optionRR(RR%((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_get_transparent_hugepagesEscCs |jS(N(R)(R((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt_get_transparent_hugepageNsstransparent_hugepage.defragcCshtjj|jd}tjj|rJ|sFtj||n|S|s`tjdndSdS(NtdefragsJOption 'transparent_hugepage.defrag' is not supported on current hardware.( RRR RRRR!RRR(RR"R#R%((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt _set_transparent_hugepage_defragRscCsKtjj|jd}tjj|rCtjtj|SdSdS(NR+( RRR RRRR(RR(RR%((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyt _get_transparent_hugepage_defrag^s(t__name__t __module__t__doc__t classmethodRRRRt command_setR&R't command_getR)R*R,R-(((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyR s    (tRt decoratorst tuned.logsttunedRtstructtglobttuned.utils.commandsRtlogstgetRRtPluginR(((s;/usr/lib/python2.7/site-packages/tuned/plugins/plugin_vm.pyts