HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_vm.cpython-39.pyc
a

,�g
 �@snddlmZddlTddlZddlZddlZddlZddlZddl	m
Z
ej��Z
e
�ZGdd�dej�ZdS)�)�base)�*�N)�commandsc@seZdZdZedd��Zedd��Zedd��Zdd	�Z	d
d�Z
edd
��Zed�dd��Z
ed�dd��Zed�dd��Zed�dd��Zed�dd��Zed�dd��Zdd�Zdd �Zd!d"�Zed#�d$d%��Zed&�d'd(��Zed)�d*d+��Zed,�d-d.��Zd/d0�Zd1S)2�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].
	cCsdddddddd�S)N)�transparent_hugepages�transparent_hugepage�transparent_hugepage.defrag�dirty_bytes�dirty_ratio�dirty_background_bytes�dirty_background_ratio�)�selfrr�;/usr/lib/python3.9/site-packages/tuned/plugins/plugin_vm.py�_get_config_options)s�zVMPlugin._get_config_optionscCs2|j|dur.|j|dur.t�d||f�dS)NzEConflicting options '%s' and '%s', this may cause undefined behavior.)�options�log�error)�instance�first�secondrrr� _check_conflicting_dirty_options5sz)VMPlugin._check_conflicting_dirty_optionscCstj�d|�S)Nz/proc/sys/vm)�os�path�join)�optionrrr�_proc_sys_vm_option_path:sz!VMPlugin._proc_sys_vm_option_pathcCs,d|_d|_|�|dd�|�|dd�dS)NTFr
rrr
)Z_has_static_tuningZ_has_dynamic_tuningr�rrrrr�_instance_init>szVMPlugin._instance_initcCsdS�Nrrrrr�_instance_cleanupDszVMPlugin._instance_cleanupcCsd}tj�|�sd}|S)Nz#/sys/kernel/mm/transparent_hugepagez*/sys/kernel/mm/redhat_transparent_hugepage)rr�exists)rrrrr�	_thp_pathGszVMPlugin._thp_pathrcCs�|dvr"|st�dt|��dStjddd�}|�d�dkrP|sLt�d�dStj�	|�
�d	�}tj�|�r�|s�tj|||r�t
jgnd
d�|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�enabledFzDOption 'transparent_hugepages' is not supported on current hardware.)r�warning�str�cmd�	read_file�find�inforrrr#r"�
write_to_file�errno�ENOENT)r�valuer�sim�removeZcmdline�sys_filerrr�_set_transparent_hugepagesOs&
�
z#VMPlugin._set_transparent_hugepagesrcCs|�||||�dSr )r5)rr1rr2r3rrr�_set_transparent_hugepagehsz"VMPlugin._set_transparent_hugepagecCs6tj�|��d�}tj�|�r.t�t�|��SdSdS)Nr'�rrrr#r"r*Zget_active_optionr+�rrr4rrr�_get_transparent_hugepageslsz#VMPlugin._get_transparent_hugepagescCs
|�|�Sr )r9rrrr�_get_transparent_hugepageusz"VMPlugin._get_transparent_hugepager	cCsXtj�|��d�}tj�|�rB|s>tj|||r6tjgndd�|S|sPt	�
d�dSdS)N�defragFr&zJOption 'transparent_hugepage.defrag' is not supported on current hardware.)rrrr#r"r*r.r/r0rr()rr1rr2r3r4rrr� _set_transparent_hugepage_defragys�
z)VMPlugin._set_transparent_hugepage_defragcCs6tj�|��d�}tj�|�r.t�t�|��SdSdS)Nr;r7r8rrr� _get_transparent_hugepage_defrag�sz)VMPlugin._get_transparent_hugepage_defragcCs4dtt�d��}||kr0t�d||f�dSdS)N�ZPAGESIZEz<The value of '%s' must be at least twice the page size (%s).FT)�intr*Zgetconfrr)rr�	int_valueZ	min_bytesrrr�_check_twice_pagesize�s
zVMPlugin._check_twice_pagesizecCs|dkrt�d|�dSdS)Nrz#The value of '%s' must be positive.FT�rr�rrr@rrr�_check_positive�szVMPlugin._check_positivecCs,d|krdks(nt�d|�dSdS)Nr�dz,The value of '%s' must be between 0 and 100.FTrBrCrrr�_check_ratio�szVMPlugin._check_ratior
cCs|�dd|j|||�S)Nr
r)�
_dirty_optionrA�r�enablingr1�verifyZignore_missingrrrr�_dirty_bytes�szVMPlugin._dirty_bytesrcCs|�dd|j|||�S)Nrr
�rGrFrHrrr�_dirty_ratio�szVMPlugin._dirty_ratiorcCs|�dd|j|||�S)Nrr
)rGrDrHrrr�_dirty_background_bytes�sz VMPlugin._dirty_background_bytesr
cCs|�dd|j|||�S)Nr
rrLrHrrr�_dirty_background_ratio�sz VMPlugin._dirty_background_ratiocCs�|�|�}|�|�}|j|d�}	|j|d�}
tj�|�sFt�d|�t�|��	�}|r`||kS|�rzt
|�}Wn ty�t�d|�Yn0|||�s�dS||kr�t�
d||f�|St
|�dkr�t�|��	�}
|j�|
|
�n|j�|	|�t�
d||f�t�||�|S|j�|	�}|j�|
�}|du�r\t�
d||f�t�||�n8|du�r�t�
d||f�t�||�nt�
d|�dS)	N)Zcommand_namez5Option '%s' is not supported on the current hardware.z%The value of '%s' must be an integer.z-Not setting option '%s' to '%s', already set.rzSetting option '%s' to '%s'.zSetting option '%s' to '%s'z:Not restoring '%s', previous value is the same or unknown.)rZ_storage_keyrr�isfilerr(r*r+�stripr?�
ValueErrorrr-Z_storage�setr.�get)rrZcounterpartZ	check_funrIr1rJZoption_pathZcounterpart_pathZ
option_keyZcounterpart_keyZ
current_valuer@Zcurrent_counterpart_value�	old_valueZold_counterpart_valuerrrrG�sH




zVMPlugin._dirty_optionN)�__name__�
__module__�__qualname__�__doc__�classmethodr�staticmethodrrrr!r#Zcommand_setr5r6Zcommand_getr9r:r<r=rArDrFZcommand_customrKrMrNrOrGrrrrrsF













r)�rZ
decoratorsZ
tuned.logsZtunedrr/�struct�globZtuned.utils.commandsrZlogsrTrr*ZPluginrrrrr�<module>s