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_irq.cpython-39.pyc
a

,�g�&�@shddlmZddlTddlmZddlZddlZddlZej	�
�ZGdd�de�Z
Gdd�dej�ZdS)	�)�hotplug)�*�Nc@seZdZdd�ZdS)�IrqInfocCs ||_d||_d|_d|_dS)Nzirq%sF)�irq�device�unchangeable�original_affinity)�selfr�r�</usr/lib/python3.9/site-packages/tuned/plugins/plugin_irq.py�__init__
s
zIrqInfo.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrcs�eZdZdZ�fdd�Zdd�Zedd��Zdd	�Zd
d�Z	�fdd
�Z
�fdd�Z�fdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zedddd�d d!��Zed"d#d$�d%d&��Z�ZS)'�	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		
s(tt|��||||||||�i|_dS�N)�superrr
�_irqs)	r
Zmonitor_repositoryZstorage_factoryZhardware_inventoryZdevice_matcherZdevice_matcher_udevZplugin_instance_factoryZ
global_cfgZ	variables��	__class__rrr
:szIrqPlugin.__init__cCs�d|_t�|_t�|_t�d�D]F}tj�d|�}tj�|�r |�	�r t
|�}||j|<|j�|j
�q t
d�}d|_
||jd<|j�|j
�dS)z$Read /proc/irq to collect devices
		Tz	/proc/irq�DEFAULTN)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�os�listdir�path�join�isdir�isdigitrr�addr)r
�i�p�infoZdefault_inforrr�
_init_devicesAs

zIrqPlugin._init_devicescCs
ddd�S)N�r)�affinity�moder)�clsrrr�_get_config_optionsSs�zIrqPlugin._get_config_optionscCs�d|_d|_|j�|j�d��}|j�|�}t|�	��dkrTt
�d|j�d|_
n&t|�dkrzt
�d|j|f�d|_
|j�|j�d��}|dvr�t
�d	||jf�d
|jd<dS)NTFr%rz;Instance '%s' configured with empty affinity. Deactivating.z7Instance '%s' with invalid affinity '%s'. Deactivating.r&)r�	intersectzOInvalid operating mode '%s' for instance '%s'. Using the default 'set' instead.r)Z_has_static_tuningZ_has_dynamic_tuningZ
_variables�expand�options�get�_cmd�cpulist_unpack�len�strip�logr"�name�_active�error)r
�instancer%Z
affinity_listr&rrr�_instance_init]s �zIrqPlugin._instance_initcCsdSrr�r
r5rrr�_instance_cleanuprszIrqPlugin._instance_cleanupcs$t�d|j�tt|��|�dS)NzApplying IRQ affinities (%s))r1�debugr2rr�_instance_apply_staticr7rrrr:usz IrqPlugin._instance_apply_staticcs&t�d|j�tt|��||�dS)NzUnapplying IRQ affinities (%s))r1r9r2rr�_instance_unapply_static)r
r5Zrollbackrrrr;ysz"IrqPlugin._instance_unapply_staticcs$t�d|j�tt|��|||�S)NzVerifying IRQ affinities (%s))r1r9r2rr�_instance_verify_static)r
r5�ignore_missingZdevicesrrrr<}sz!IrqPlugin._instance_verify_staticc
Cs�z\|dkrdnd|}t|d��}|����}Wd�n1sB0Yt|j�|��WSttfy�}z$t�	d||f�t�WYd}~Sd}~00dS)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 %s: %s)
�open�readliner0rr-Zhex2cpulist�OSError�IOErrorr1r9)r
r�filename�f�affinity_hex�errr�_get_irq_affinity�s
*zIrqPlugin._get_irq_affinityc
Cs�zp|j�t|��}t�d||f�|dkr0dnd|}t|d��}|�|�Wd�n1sb0YWdSttfy�}zdt	|d�r�|j
t
jkr�|s�t�d	|�WYd}~d
St�d|||f�WYd}~dSWYd}~n
d}~00dS)
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
		z&Setting SMP affinity of IRQ %s to '%s'rr>r?�wNr�errnoz/Setting SMP affinity of IRQ %s is not supported���z0Failed to set SMP affinity of IRQ %s to '%s': %s���)
r-Zcpulist2hex�listr1r9rA�writerCrD�hasattrrKZEIOr4)r
rr%Z	restoringrGrErFrHrrr�_set_irq_affinity�s(zIrqPlugin._set_irq_affinitycCsn|�|j�}|dkr ||@p|}|js.||kr2dS|�|j|d�}|dkr\|jdurj||_n|dkrjd|_dS)zxApply IRQ affinity tuning

		Args:
			irqinfo (IrqInfo): IRQ that should be tuned
			affinity (set): desired affinity
		r)NFrrLT)rIrrrQr	)r
�irqinfor%r&�original�resrrr�_apply_irq_affinity�s
zIrqPlugin._apply_irq_affinitycCs0|js|jdurdS|�|j|jd�d|_dS)zRRestore IRQ affinity

		Args:
			irqinfo (IrqInfo): IRQ that should be restored
		NT)rr	rQr)r
rRrrr�_restore_irq_affinity�szIrqPlugin._restore_irq_affinityc	Cs�|jr
dSd|j}|}|j�|j�t|���}|�|j�}|j�|j�t|���}|dkrdd|}|dkrt||ks�|dkr�||kr�t�t	j
||f�dSt�t	j|||f�dSdS)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 rFN)
rrr-Zcpulist2stringZcpulist_packrNrIr1r"�constsZSTR_VERIFY_PROFILE_VALUE_OKr4ZSTR_VERIFY_PROFILE_VALUE_FAIL)	r
rRr%r&Zaffinity_descriptionZdesired_affinityZdesired_affinity_stringZcurrent_affinityZcurrent_affinity_stringrrr�_verify_irq_affinity�s,

����zIrqPlugin._verify_irq_affinityr&Fi����)�
per_device�prioritycCs|s|r|dur||_dSr)�	_mode_val)r
�enabling�value�verifyr=r5rrr�_mode�szIrqPlugin._moder%T)rYc
Cs�|dkrdn|td�d�}||jvr8t�d|�dS|j|}|rft|j�|��}	|�||	|j�S|r�t|j�|��}	|�	||	|j�S|�
|�SdS)NrrzUnknown device: %s)r/rr1r4rr-r.rXr[rUrV)
r
r\r]rr^r=r5rrRr%rrr�	_affinitys

zIrqPlugin._affinity)rrr�__doc__r
r#�classmethodr(r6r8r:r;r<rIrQrUrVrXZcommand_customr_r`�
__classcell__rrrrrs&&
	""

r)r$rZ
decoratorsZtuned.constsrWZ
tuned.logsZtunedrKrZlogsr,r1�objectrZPluginrrrrr�<module>s