Your IP : 18.226.17.3


Current Path : /usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/plugin_irqbalance.cpython-36.pyc

3

�<�e�
�@sdddlmZddlmZddlmZddlZddlZddlZddl	Z	ej
j�ZGdd�dej
�ZdS)�)�base)�command_custom�)�constsNcs�eZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zeddd�dd��Z�ZS)�IrqbalancePlugina�
	`irqbalance`::
	
	Plug-in for irqbalance settings management. The plug-in
	configures CPUs which should be skipped when rebalancing IRQs in
	`/etc/sysconfig/irqbalance`. It then restarts irqbalance if and
	only if it was previously running.
	+
	The banned/skipped CPUs are specified as a CPU list via the
	[option]`banned_cpus` option.
	+
	.Skip CPUs 2,4 and 9-13 when rebalancing IRQs
	====
	----
	[irqbalance]
	banned_cpus=2,4,9-13
	----
	====
	cs tt|�j||�tj�|_dS)N)�superr�__init__�perfZcpu_map�_cpus)�self�args�kwargs)�	__class__��'/usr/lib/python3.6/plugin_irqbalance.pyr szIrqbalancePlugin.__init__cCsd|_d|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning)r�instancerrr�_instance_init$szIrqbalancePlugin._instance_initcCsdS)Nr)rrrrr�_instance_cleanup(sz"IrqbalancePlugin._instance_cleanupcCsddiS)N�banned_cpusr)�clsrrr�_get_config_options+sz$IrqbalancePlugin._get_config_optionscCsly ttjd��
}|j�SQRXWnFtk
rf}z*|jtjkrJtjd�ntj	d|�dSd}~XnXdS)N�rz>irqbalance sysconfig file is missing. Is irqbalance installed?z,Failed to read irqbalance sysconfig file: %s)
�openr�IRQBALANCE_SYSCONFIG_FILE�read�IOError�errno�ENOENT�log�warn�error)r�f�errr�_read_irqbalance_sysconfig1sz+IrqbalancePlugin._read_irqbalance_sysconfigcCsZy&ttjd��}|j|�WdQRXdStk
rT}ztjd|�dSd}~XnXdS)N�wTz-Failed to write irqbalance sysconfig file: %sF)rrr�writerrr )r�contentr!r"rrr�_write_irqbalance_sysconfig<sz,IrqbalancePlugin._write_irqbalance_sysconfigcCs|d|S)NzIRQBALANCE_BANNED_CPUS=%s
r)r�	sysconfig�banned_cpumaskrrr�_write_banned_cpusEsz#IrqbalancePlugin._write_banned_cpuscCs8g}x(|jd�D]}tjd|�s|j|�qWdj|�S)N�
z\s*IRQBALANCE_BANNED_CPUS=)�split�re�match�append�join)rr(�lines�linerrr�_clear_banned_cpusHs
z#IrqbalancePlugin._clear_banned_cpuscCs2|jjdddgdgd�\}}|dkr.tjd�dS)NZ	systemctlztry-restartZ
irqbalance�)Z	no_errorsrz.Failed to restart irqbalance. Is it installed?)�_cmdZexecuterr)rZretcode�outrrr�_restart_irqbalanceOs
z$IrqbalancePlugin._restart_irqbalancecCs@|j�}|dkrdS|j|�}|j||�}|j|�r<|j�dS)N)r#r3r*r'r7)rr)r&rrr�_set_banned_cpusXs

z!IrqbalancePlugin._set_banned_cpuscCs4|j�}|dkrdS|j|�}|j|�r0|j�dS)N)r#r3r'r7)rr&rrr�_restore_banned_cpusas

z%IrqbalancePlugin._restore_banned_cpusrF)Z
per_devicec	Cs�d}|dk	rjt|jj|��}t|j�}|j|�rB|jjt|��}n(djdd�|jD��}tj	d||f�|sr|r~|dkr~dS|r�dS|r�|j
|�n|j�dS)N�,cSsg|]}t|��qSr)�str)�.0�xrrr�
<listcomp>rsz1IrqbalancePlugin._banned_cpus.<locals>.<listcomp>zGInvalid banned_cpus specified, '%s' does not match available cores '%s')�setr5Zcpulist_unpackr
�issubsetZcpulist2hex�listr0rr r8r9)	rZenabling�valueZverifyZignore_missingr)ZbannedZpresentZstr_cpusrrr�_banned_cpusis 

zIrqbalancePlugin._banned_cpus)�__name__�
__module__�__qualname__�__doc__rrr�classmethodrr#r'r*r3r7r8r9rrC�
__classcell__rr)rrrs			r)�rZ
decoratorsrZtunedrZ
tuned.logsrr	r-Zlogs�getrZPluginrrrrr�<module>s


?>