HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_vm.cpython-39.opt-1.pyc
a

Y��dN
�@sfddlmZddlTddlZddlZddlZddlZddlm	Z	ej
��Ze	�Z
Gdd�dej�ZdS)�)�base)�*�N)�commandsc@s�eZdZdZedd��Zdd�Zdd�Zedd	��Ze	d
�dd��Z
e	d
�dd��Zed
�dd��Z
ed
�dd��Ze	d�dd��Zed�dd��ZdS)�VMPlugina|
	`vm`::
	
	Enables or disables transparent huge pages depending on value of the
	[option]`transparent_hugepages` option. The option can have one of three
	possible values `always`, `madvise` and `never`.
	+
	.Disable transparent hugepages
	====
	----
	[vm]
	transparent_hugepages=never
	----
	====
	+
	The [option]`transparent_hugepage.defrag` option specifies the
	defragmentation policy. Possible values for this option are `always`,
	`defer`, `defer+madvise`, `madvise` and `never`. For a detailed
	explanation of these values refer to
	link:https://www.kernel.org/doc/Documentation/vm/transhuge.txt[Transparent Hugepage Support].
	cCsdddd�S)N)�transparent_hugepages�transparent_hugepage�transparent_hugepage.defrag���selfr
r
�;/usr/lib/python3.9/site-packages/tuned/plugins/plugin_vm.py�_get_config_options$s�zVMPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning�r�instancer
r
r
�_instance_init,szVMPlugin._instance_initcCsdS�Nr
rr
r
r
�_instance_cleanup0szVMPlugin._instance_cleanupcCsd}tj�|�sd}|S)Nz#/sys/kernel/mm/transparent_hugepagez*/sys/kernel/mm/redhat_transparent_hugepage)�os�path�exists)rrr
r
r
�	_thp_path3szVMPlugin._thp_pathrcCs�|dvr"|st�dt|��dStjddd�}|�d�dkrP|sLt�d�dStj�	|�
�d	�}tj�|�r�|s~t�||�|S|s�t�d
�dSdS)N)�always�neverZmadvisez-Incorrect 'transparent_hugepages' value '%s'.z
/proc/cmdlineT)Zno_errorztransparent_hugepage=rzWtransparent_hugepage is already set in kernel boot cmdline, ignoring value from profile�enabledzDOption 'transparent_hugepages' is not supported on current hardware.)
�log�warn�str�cmd�	read_file�find�inforr�joinrr�
write_to_file)r�value�simZcmdline�sys_filer
r
r
�_set_transparent_hugepages;s"

z#VMPlugin._set_transparent_hugepagesrcCs|�||�dSr)r')rr$r%r
r
r
�_set_transparent_hugepageSsz"VMPlugin._set_transparent_hugepagecCs6tj�|��d�}tj�|�r.t�t�|��SdSdS)Nr�rrr"rrrZget_active_optionr�rr&r
r
r
�_get_transparent_hugepagesWsz#VMPlugin._get_transparent_hugepagescCs|��Sr)r+rr
r
r
�_get_transparent_hugepage`sz"VMPlugin._get_transparent_hugepager	cCsHtj�|��d�}tj�|�r2|s.t�||�|S|s@t�d�dSdS)N�defragzJOption 'transparent_hugepage.defrag' is not supported on current hardware.)	rrr"rrrr#rr)rr$r%r&r
r
r
� _set_transparent_hugepage_defragds
z)VMPlugin._set_transparent_hugepage_defragcCs6tj�|��d�}tj�|�r.t�t�|��SdSdS)Nr-r)r*r
r
r
� _get_transparent_hugepage_defragpsz)VMPlugin._get_transparent_hugepage_defragN)�__name__�
__module__�__qualname__�__doc__�classmethodrrrrZcommand_setr'r(Zcommand_getr+r,r.r/r
r
r
r
r
s&






r)�rZ
decoratorsZ
tuned.logsZtunedr�struct�globZtuned.utils.commandsrZlogs�getrrZPluginrr
r
r
r
�<module>s