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_irq.cpython-312.opt-1.pyc
�

�]�i�&���ddlmZddl�ddlmZddlZddlZddlZejj�ZGd�de�Z
Gd�dej�Zy)	�)�hotplug)�*�Nc��eZdZd�Zy)�IrqInfoc�B�||_d|z|_d|_d|_y)Nzirq%sF)�irq�device�unchangeable�original_affinity)�selfr	s  �=/usr/lib/python3.12/site-packages/tuned/plugins/plugin_irq.py�__init__zIrqInfo.__init__
s$��
�$�(��#�
�$�+��$���$��N)�__name__�
__module__�__qualname__r�rrrrs�� rrc����eZdZdZ�fd�Zd�Zed��Zd�Zd�Z	�fd�Z
�fd�Z�fd	�Zd
�Z
d�Zd�Zd
�Zd�Zeddd��d��Zedd��d��Z�xZS)�	IrqPlugina�
	Allows tuning of IRQ affinities, and thus re-implements functionality
	already present in the `scheduler` plugin. However, this plugin offers
	more flexibility, as it allows tuning of individual interrupts with
	different affinities. When using the `irq` plugin, make sure to disable
	IRQ processing in the `scheduler` plugin by setting its option
	[option]`irq_process=false`.

	The plugin handles individual IRQs as devices and multiple plugin
	instances can be defined, each addressing different devices/irqs.
	The device names used by the plugin are `irq<n>`, where `<n>` is the
	IRQ number. The special device `DEFAULT` controls values written to
	`/proc/irq/default_smp_affinity`, which applies to all non-active IRQs.

	The option [option]`affinity` controls the IRQ affinity to be set. It is
	a string in "cpulist" format (such as `1,3-4`). If the configured affinity
	is empty, then the affinity of the respective IRQs is not touched.

	The option [option]`mode` is a string which can either be `set` (default)
	or `intersect`. In `set` mode the [option]`affinity` is always written
	as configured, whereas in `intersect` mode, the new affinity will be
	calculated as the intersection of the current and the configured affinity.
	If that intersection is empty, the configured affinity will be used.

	.Moving all IRQs to CPU0, except irq16, which is directed to CPU2
	====
	----
	[irq_special]
	type=irq
	devices=irq16
	affinity=2

	[irq]
	affinity=0
	----
	====
	c	
�H��tt|�||||||||�i|_y�N)�superrr�_irqs)
r
�monitor_repository�storage_factory�hardware_inventory�device_matcher�device_matcher_udev�plugin_instance_factory�
global_cfg�	variables�	__class__s
         �rrzIrqPlugin.__init__:s=����	�4�!�"4�o�GY�[i�k~�AX�Zd�fo�p��$�*rc�.�d|_t�|_t�|_t	j
d�D]�}tjjd|�}tjj|�s�C|j�s�Tt|�}||j|<|jj|j���td�}d|_
||jd<|jj|j�y)z$Read /proc/irq to collect devices
		Tz	/proc/irq�DEFAULTN)�_devices_supported�set�
_free_devices�_assigned_devices�os�listdir�path�join�isdir�isdigitrr�addr
)r
�i�p�info�default_infos     r�
_init_deviceszIrqPlugin._init_devicesAs���!�$���u�$���5�$��
�:�:�k�"�a�	�w�w�|�|�K��#�1��g�g�m�m�A��1�9�9�;��1�:�D��D�J�J�q�M������4�;�;�'�#���#�,�!�,��&�$�*�*�Y��������,�,�-rc��ddd�S)N�r')�affinity�moder)�clss r�_get_config_optionszIrqPlugin._get_config_optionsSs����
�rc��d|_d|_|jj|jjd��}|jj|�}t|j��dk(r*tjd|jz�d|_
n;t|�dk(r-tjd|j�d|�d��d|_
|jj|jjd	��}|d
vr6tjd|�d|j�d
��d|jd	<yy)NTFr8rz;Instance '%s' configured with empty affinity. Deactivating.z
Instance 'z' with invalid affinity 'z'. Deactivating.r9)r'�	intersectzInvalid operating mode 'z' for instance 'z#'. Using the default 'set' instead.r')�_has_static_tuning�_has_dynamic_tuning�
_variables�expand�options�get�_cmd�cpulist_unpack�len�strip�logr3�name�_active�error)r
�instancer8�
affinity_listr9s     r�_instance_initzIrqPlugin._instance_init]s�� $�(��!&�(��
�_�_�
#�
#�H�$4�$4�$8�$8��$D�
E�(��)�)�*�*�8�4�-�����	��a���8�8�I�H�M�M�Y�Z��8��
�=��Q���9�9�(�-�-�Ya�
b�c��8��	
���	�	�� 0� 0� 4� 4�V� <�	=�$�	�%�%��9�9��h�m�m���#�8���F��&rc��yrr)r
rLs  r�_instance_cleanupzIrqPlugin._instance_cleanuprs��rc�p��tjd|jz�tt|�|�y)NzApplying IRQ affinities (%s))rH�debugrIrr�_instance_apply_static)r
rLr#s  �rrSz IrqPlugin._instance_apply_staticus(����)�)�*�X�]�]�:�;��	�4�/��9rc�r��tjd|jz�tt|�||�y)NzUnapplying IRQ affinities (%s))rHrRrIrr�_instance_unapply_static)r
rL�rollbackr#s   �rrUz"IrqPlugin._instance_unapply_staticys*����)�)�,�x�}�}�<�=��	�4�1�(�H�Erc�r��tjd|jz�tt|�|||�S)NzVerifying IRQ affinities (%s))rHrRrIrr�_instance_verify_static)r
rL�ignore_missing�devicesr#s    �rrXz!IrqPlugin._instance_verify_static}s0����)�)�+�h�m�m�;�<�	�y�$�	7��.�RY�	Z�Zrc�d�	|dk(rdnd|z}t|d�5}|j�j�}ddd�t|jj��S#1swY�-xYw#ttf$r/}tjd|�d|���t�cYd}~Sd}~wwxYw)z�Get current IRQ affinity from the kernel

		Args:
			irq (str): IRQ number (as string) or "DEFAULT"

		Returns:
			affinity (set): set of all CPUs that belong to the IRQ affinity mask,
				if reading of the affinity fails, an empty set is returned
		r%�/proc/irq/default_smp_affinity�/proc/irq/%s/smp_affinity�rNz#Failed to read SMP affinity of IRQ z: )
�open�readlinerGr'rD�hex2cpulist�OSError�IOErrorrHrR)r
r	�filename�f�affinity_hex�es      r�_get_irq_affinityzIrqPlugin._get_irq_affinity�s����25��2B�.�Hc�fi�Hi�8��X�s��q��:�:�<�%�%�'�L�	�

�d�i�i�#�#�L�1�
2�2�	����7�	���9�9�C��
C�D�

�%�<���s3�A1�A%�+A1�%A.�*A1�1B/�$B*�$B/�*B/c	��	|jjt|��}tj	d|�d|�d��|dk(rdnd|z}t|d�5}|j
|�ddd�y	#1swYy	xYw#ttf$rp}t|d
�r<|jtjk(r|stj	d|z�Yd}~ytjd
|�d�d|���Yd}~yd}~wwxYw)aDSet IRQ affinity in the kernel

		Args:
			irq (str): IRQ number (as string) or "DEFAULT"
			affinity (set): affinity mask as set of CPUs
			restoring (bool): are we rolling back a previous change?

		Returns:
			status (int):  0 on success, -2 if changing the affinity is not
				supported, -1 if some other error occurs
		zSetting SMP affinity of IRQ z to '�'r%r\r]�wNr�errnoz/Setting SMP affinity of IRQ %s is not supported���z"Failed to set SMP affinity of IRQ z': ���)
rD�cpulist2hex�listrHrRr_�writerbrc�hasattrrl�EIOrK)r
r	r8�	restoringrfrdrergs        r�_set_irq_affinityzIrqPlugin._set_irq_affinity�s�����)�)�'�'��X��7�<��9�9��l�
K�L�25��2B�.�Hc�fi�Hi�8��X�s��q��G�G�L��	�
�	�
��
�7�	�
�
�a���a�g�g����2�9��I�I�?�#�E�F�
��I�I�C��WX�Y�Z�
��
�s=�AB�A5�,B�5A>�:B�>B�D�AC;�C;�;Dc��|j|j�}|dk(r	||zxs|}|js||k(ry|j|j|d�}|dk(r|j�||_yy|dk(rd|_yy)zxApply IRQ affinity tuning

		Args:
			irqinfo (IrqInfo): IRQ that should be tuned
			affinity (set): desired affinity
		r=NFrrmT)rhr	rrur)r
�irqinfor8r9�original�ress      r�_apply_irq_affinityzIrqPlugin._apply_irq_affinity�s����
#�
#�G�K�K�
0�(�	�[����!�-�X�8����X��1�	����w�{�{�H�e�<�#��A�X�
���'� (�G��(�
�b�y��7��rc��|js|j�y|j|j|jd�d|_y)zRRestore IRQ affinity

		Args:
			irqinfo (IrqInfo): IRQ that should be restored
		NT)rrrur	)r
rws  r�_restore_irq_affinityzIrqPlugin._restore_irq_affinity�s?��
���W�6�6�>�	�������g�&?�&?��F�"�'�rc�J�|jryd|jz}|}|jj|jj	t|���}|j
|j�}|jj|jj	t|���}|dk(rd|z}|dk(r||ks
|dk(r.||k(r)tjtj||fz�ytjtj|||fz�y)z�Verify IRQ affinity tuning

		Args:
			irqinfo (IrqInfo): IRQ that should be verified
			affinity (set): desired affinity

		Returns:
			status (bool): True if verification successful, False otherwise
		TzIRQ %s affinityr=z
subset of r'F)
rr	rD�cpulist2string�cpulist_packrprhrHr3�consts�STR_VERIFY_PROFILE_VALUE_OKrK�STR_VERIFY_PROFILE_VALUE_FAIL)	r
rwr8r9�affinity_description�desired_affinity�desired_affinity_string�current_affinity�current_affinity_strings	         r�_verify_irq_affinityzIrqPlugin._verify_irq_affinity�s��
���
�*�W�[�[�8���� �I�I�4�4�T�Y�Y�5K�5K�D�Qa�Lb�5c�d���+�+�G�K�K�8�� �I�I�4�4�T�Y�Y�5K�5K�D�Qa�Lb�5c�d��	�[��*�,C�C���{��/�3C�C�
�e�m�(�,<�<��8�8�F�.�.��5�6�
7�8�
��9�9�V�
1�
1��5�7N�O�P�Q�
rr9Fi����)�
per_device�priorityc�"�|s|r|�||_yyyr)�	_mode_val)r
�enabling�value�verifyrYrLs      r�_modezIrqPlugin._mode�s���&�e�/��4�>�	0�&rr8T)r�c���|dk(rdn
|td�d}||jvrtjd|z�y|j|}|rAt	|j
j
|��}	|j||	|j�S|rAt	|j
j
|��}	|j||	|j�S|j|�S)Nr%r	zUnknown device: %s)rFrrHrKr'rDrEr�r�rzr|)
r
r�r�r
r�rYrLr	rwr8s
          r�	_affinityzIrqPlugin._affinitys����y�(�	�f�S��Z�[�.A�#���
�
���9�9�
!�F�
*�+�
��J�J�s�O�'���$�)�)�*�*�5�1�2�8�
�
#�
#�G�X�t�~�~�
F�F�
��$�)�)�*�*�5�1�2�8�
�
"�
"�7�H�d�n�n�
E�E�
�
$�
$�W�
-�-r)rrr�__doc__rr5�classmethodr;rNrPrSrUrXrhrurzr|r��command_customr�r��
__classcell__)r#s@rrrs����$�L�.�$����$�*�:�F�[��&�D�(	#��D��E�C�8��9�����-�
.�.�
.rr)r7r�
decorators�tuned.constsr��
tuned.logs�tunedrlr*�logsrCrH�objectr�Pluginrrrr�<module>r�sE�������	��j�j�n�n��� �f� �}.����}.r