MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/plugins/__pycache__/plugin_vm.cpython-312.opt-1.pyc
�

�]�i�"���ddlmZddl�ddlZddlZddlZddlZddlZddl	m
Z
ejj�Z
e
�ZGd�dej�Zy)�)�base)�*�N)�commandsc��eZdZdZed��Zed��Zed��Zd�Z	d�Z
ed��Zed�d	��Z
ed
�d��Zed�d��Zed
�d
��Zed�d��Zed�d��Zd�Zd�Zd�Zed�d��Zed�d��Zed�d��Zed�d��Zd�Zy)�VMPlugina�
	Tunes selected sysctl options in `/proc/sys/vm`, currently
	[option]`dirty_ratio`, [option]`dirty_background_ratio`,
	[option]`dirty_bytes`, and [option]`dirty_background_bytes`.
	See https://docs.kernel.org/admin-guide/sysctl/vm.html for detailed
	documentation of these options.

	Additionaly enables or disables transparent huge pages depending on
	the 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].
	c��dddddddd�S)N)�transparent_hugepages�transparent_hugepage�transparent_hugepage.defrag�dirty_bytes�dirty_ratio�dirty_background_bytes�dirty_background_ratio�)�selfs �</usr/lib/python3.12/site-packages/tuned/plugins/plugin_vm.py�_get_config_optionszVMPlugin._get_config_options)s#��"� �#'���"�"�
��c�|�|j|�-|j|�tjd|�d|�d��yyy)NzConflicting options 'z' and 'z%', this may cause undefined behavior.)�options�log�warning)�instance�first�seconds   r� _check_conflicting_dirty_optionsz)VMPlugin._check_conflicting_dirty_options5s?��
���e��(�X�-=�-=�f�-E�-Q��;�;�Z_�ag�h�i�.R�(rc�B�tjjd|�S)Nz/proc/sys/vm)�os�path�join)�options r�_proc_sys_vm_option_pathz!VMPlugin._proc_sys_vm_option_path:s��	�����n�f�	-�-rc�l�d|_d|_|j|dd�|j|dd�y)NTFr
rrr)�_has_static_tuning�_has_dynamic_tuningr�rrs  r�_instance_initzVMPlugin._instance_init>s8�� $�(��!&�(���'�'��-��O��'�'��2J�Ld�erc��y�Nrr's  r�_instance_cleanupzVMPlugin._instance_cleanupDs��rc�L�d}tjj|�sd}|S)Nz#/sys/kernel/mm/transparent_hugepagez*/sys/kernel/mm/redhat_transparent_hugepage)rr �exists)rr s  r�	_thp_pathzVMPlugin._thp_pathGs!��	.�$�	������	�7�4�	
�+rr
c��|dvr$|s!tjdt|�z�ytj	dd��}|jd�dkDr|stj
d�ytjj|j�d	�}tjj|�r/|s+tj|||rtjgnd
��|S|stjd�y)N)�always�never�madvisez-Incorrect 'transparent_hugepages' value '%s'.z
/proc/cmdlineT��no_errorztransparent_hugepage=rzWtransparent_hugepage is already set in kernel boot cmdline, ignoring value from profile�enabledFzDOption 'transparent_hugepages' is not supported on current hardware.)rr�str�cmd�	read_file�find�inforr r!r.r-�
write_to_file�errno�ENOENT)r�valuer�sim�remove�cmdline�sys_files       r�_set_transparent_hugepagesz#VMPlugin._set_transparent_hugepagesOs���
�0�0�

��K�K�?�#�e�*�L�M�
��M�M�/�d�M�;�'��\�\�)�*�Q�.�

��H�H�
f�g�
�
�W�W�\�\�$�.�.�*�I�
6�(��W�W�^�^�H��

����h��"(�����e��5�
�<�

��K�K�V�W�
rrc�,�|j||||�yr*)rC)rr>rr?r@s     r�_set_transparent_hugepagez"VMPlugin._set_transparent_hugepagehs���!�!�%��3��?rc���tjj|j�d�}tjj	|�r(t
j
t
j|��Sy)Nr5�rr r!r.r-r7�get_active_optionr8�rrrBs   r�_get_transparent_hugepagesz#VMPlugin._get_transparent_hugepageslsJ��
�W�W�\�\�$�.�.�*�I�
6�(��W�W�^�^�H��

�
�
��
�
�h� 7�
8�8�
rc�$�|j|�Sr*)rJr's  r�_get_transparent_hugepagez"VMPlugin._get_transparent_hugepageus��	
�	(�	(��	2�2rrc�*�tjj|j�d�}tjj	|�r/|s+t
j
|||rtjgnd��|S|stjd�y)N�defragFr3zJOption 'transparent_hugepage.defrag' is not supported on current hardware.)rr r!r.r-r7r;r<r=rr)rr>rr?r@rBs      r� _set_transparent_hugepage_defragz)VMPlugin._set_transparent_hugepage_defragysl��
�W�W�\�\�$�.�.�*�H�
5�(��W�W�^�^�H��

����h��"(�����e��5�
�<�

��K�K�\�]�
rc���tjj|j�d�}tjj	|�r(t
j
t
j|��Sy)NrNrGrIs   r� _get_transparent_hugepage_defragz)VMPlugin._get_transparent_hugepage_defrag�sJ��
�W�W�\�\�$�.�.�*�H�
5�(��W�W�^�^�H��

�
�
��
�
�h� 7�
8�8�
rc��dttjd��z}||krtj	d|�d|�d��yy)N��PAGESIZEzThe value of 'z(' must be at least twice the page size (z).FT)�intr7�getconfr�error)rr"�	int_value�	min_bytess    r�_check_twice_pagesizezVMPlugin._check_twice_pagesize�s:���#�c�k�k�*�-�.�.�)�����9�9�v�W`�
a�b�
�	
rc�@�|dkrtjd|z�yy)Nrz#The value of '%s' must be positive.FT�rrW�rr"rXs   r�_check_positivezVMPlugin._check_positive�s!���!�^��9�9�
2�V�
;�<�
�	
rc�P�d|cxkrdksntjd|z�yy)Nr�dz,The value of '%s' must be between 0 and 100.FTr\r]s   r�_check_ratiozVMPlugin._check_ratio�s'��	
�i�	�3�	��9�9�
;�f�
D�E�
�	
rr
c	��|�\|j�jd�r=|jdd|j||j�j	d�|�S|jdd|j
|||�S)N�%rr
)�strip�endswith�
_dirty_optionra�rstriprZ�r�enablingr>�verify�ignore_missingrs      r�_dirty_byteszVMPlugin._dirty_bytes�sw��
��5�;�;�=�1�1�#�6�
�
�
�]�M�4�;L�;L�h�X]�Xc�Xc�Xe�Xl�Xl�mp�Xq�sy�
z�z�	
�	�	�M�=�$�:T�:T�V^�`e�gm�	n�nrrc�l�tjd�|jdd|j|||�S)NzlThe 'dirty_ratio' option is deprecated and does not support inheritance, use 'dirty_bytes' with '%' instead.rr
�rrrfrarhs      r�_dirty_ratiozVMPlugin._dirty_ratio�s2���+�+�|�}�	
�	�	�M�=�$�:K�:K�X�W\�^d�	e�errc	��|�\|j�jd�r=|jdd|j||j�j	d�|�S|jdd|j
|||�S)Nrcrr)rdrerfrargr^rhs      r�_dirty_background_bytesz VMPlugin._dirty_background_bytes�s���
��5�;�;�=�1�1�#�6�
�
�
�5�7O�QU�Qb�Qb�dl�ns�ny�ny�n{�oC�oC�DG�oH�JP�Q�Q�	
�	�	�4�6N�PT�Pd�Pd�fn�pu�w}�	~�~rrc�l�tjd�|jdd|j|||�S)Nz�The 'dirty_background_ratio' option is deprecated and does not support inheritance, use 'dirty_background_bytes' with '%' instead.rrrnrhs      r�_dirty_background_ratioz VMPlugin._dirty_background_ratio�s<���+�+�S�T�	
�	�	�4�6N�PT�Pa�Pa�ck�mr�tz�	{�{rc���|j|�}|j|�}|j|��}	|j|��}
tjj	|�st
j
d|z�tj|�j�}|r||k(S|r�	t|�}|||�sy||k(rt
jd|�d|�d��|St|�dk(r@tj|�j�}
|jj|
|
�n|jj|	|�t
jd|�d|�d	��tj!||�|S|jj#|	�}|jj#|
�}|�3t
jd|�d|�d
��tj!||�y|�3t
jd|�d|�d
��tj!||�yt
jd|z�y#t$rt
jd|z�YywxYw)N)�command_namez5Option '%s' is not supported on the current hardware.z%The value of '%s' must be an integer.zNot setting option 'z' to 'z', already set.rzSetting option 'z'.�'z:Not restoring '%s', previous value is the same or unknown.)r#�_storage_keyrr �isfilerrr7r8rdrU�
ValueErrorrWr:�_storage�setr;�get)rr"�counterpart�	check_funrir>rj�option_path�counterpart_path�
option_key�counterpart_key�
current_valuerX�current_counterpart_value�	old_value�old_counterpart_values                rrfzVMPlugin._dirty_option�s���-�-�f�5�+��2�2�;�?��� � �f� �5�*��%�%�;�%�?�/�	������	$��;�;�F��O�P��-�-��,�2�2�4�-��
�5�
 � �
���E�
�I��F�I�
&���u���H�H���
N�O��L�
�-��A�� #�
�
�.>� ?� E� E� G���M�M���o�'@�A��M�M���j�-�0��8�8�f�e�<�=����[�%�(�
�<��m�m���
�+�)��-�-�+�+�O�<�����8�8�V�Y�?�@����[�)�,�
��(��8�8�[�:O�P�Q����%�'<�=�
��8�8�H�6�Q�R�	
��A���I�I�5��>�?���s�+H:�:!I�IN)�__name__�
__module__�__qualname__�__doc__�classmethodr�staticmethodrr#r(r+r.�command_setrCrE�command_getrJrLrOrQrZr^ra�command_customrlrorqrsrfrrrrrs����4�	��	��j��j��.��.�f�������%�&��'��0�$�%�@�&�@��%�&��'���$�%�3�&�3��+�,�
�-�
��+�,��-��������o� �o�
���f� �f��)�*��+��
�)�*�|�+�|�-rr)�r�
decorators�
tuned.logs�tunedrr<�struct�glob�tuned.utils.commandsr�logsr|rr7�Pluginrrrr�<module>r�sF�����	��
��)��j�j�n�n����j��V�t�{�{�Vr