Your IP : 18.117.231.160
3
�<�e�
� @ sn d dl mZ d dlT ddlZddlZddlZddlZddlZddl m
Z
ejj� Z
e
� ZG dd� dej�ZdS )� )�base)�*� N)�commandsc @ s� e Zd ZdZedd� �Zdd� Zdd� Zedd � �Ze d
�dd� �Z
e d
�dd� �Zed
�dd� �Z
ed
�dd� �Ze d�dd� �Zed�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].
c C s d d d d�S )N)�transparent_hugepages�transparent_hugepageztransparent_hugepage.defrag� )�selfr r �/usr/lib/python3.6/plugin_vm.py�_get_config_options% s zVMPlugin._get_config_optionsc C s d|_ d|_d S )NTF)Z_has_static_tuningZ_has_dynamic_tuning)r
�instancer r r �_instance_init- s zVMPlugin._instance_initc C s d S )Nr )r
r
r r r �_instance_cleanup1 s zVMPlugin._instance_cleanupc C s d}t jj|�sd}|S )Nz#/sys/kernel/mm/transparent_hugepagez*/sys/kernel/mm/redhat_transparent_hugepage)�os�path�exists)r
r r r r � _thp_path4 s zVMPlugin._thp_pathr c C s� |dkr"|st jdt|� � d S tjddd�}|jd�d krP|sLt jd
� d S tjj | j
� d�}tjj|�r�|s�tj|||r�t
jgndd� |S |s�t jd
� d S d S )N�always�never�madvisez-Incorrect 'transparent_hugepages' value '%s'.z
/proc/cmdlineT)�no_errorztransparent_hugepage=r zWtransparent_hugepage is already set in kernel boot cmdline, ignoring value from profile�enabledFzDOption 'transparent_hugepages' is not supported on current hardware.)r r r )�log�warn�str�cmd� read_file�find�infor r �joinr r �
write_to_file�errno�ENOENT)r
�value�sim�removeZcmdline�sys_filer r r �_set_transparent_hugepages<