a
���h� � @ sj d dl mZ d dlT ddlZddlmZ ddlZddlZej �
� Ze� ZdZ
dZd ZG dd� dej�ZdS ) � )�hotplug)�*� N)�commandsz//sys/devices/system/cpu/intel_uncore_frequency/c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z e
dd� �Zdd� Zdd� Z
dd� Zeddd�dd� �Zed�d$dd��Zeddd�dd � �Zed�d%d!d"��Zd#S )&�UncorePlugina�
An Intel-specific plug-in for limiting the maximum and minimum uncore frequency.
The options [option]`max_freq_khz`, [option]`min_freq_khz` correspond to
`sysfs` files exposed by Intel uncore frequency driver. Their values can be
specified in kHz or as a percentage of their configurable range.
.Limiting maximum uncore frequency
====
----
[uncore10]
type=uncore
devices=uncore10
max_freq_khz=4000000
[uncore_all]
type=uncore
max_freq_khz=90%
----
Using this options *TuneD* will limit maximum frequency of all uncore units
on the Intel system to 90% of the allowable range. Except uncore10 which
maximum frequency limit will be set to 4 GHz.
====
c C s� d| _ t� | _t� | _d| _zt�t�}W n ty> Y d S 0 t �
|d�}t|�dkrbd| _|}|D ]}| j�|� qft
�dt| j�� d S )NTFzuncore*r zdevices: %s)Z_devices_supported�setZ_assigned_devicesZ
_free_devicesZ_is_tpmi�os�listdir� SYSFS_DIR�OSError�fnmatch�filter�len�add�log�debug�str)�selfZdevicesZtpmi_devices�d� r �?/usr/lib/python3.9/site-packages/tuned/plugins/plugin_uncore.py�
_init_devices+ s zUncorePlugin._init_devicesc C s d|_ d|_d S )NTF)Z_has_static_tuningZ_has_dynamic_tuning�r �instancer r r �_instance_initA s zUncorePlugin._instance_initc C s d S )Nr r r r r �_instance_cleanupE s zUncorePlugin._instance_cleanupc C s2 t | d | }t�|�}t|�dkr.t|�S d S )N�/r )r
�cmdZ read_filer �int)r �dev_dir�file�
sysfs_file�valuer r r �_getH s
zUncorePlugin._getc C s( t | d | }t�|d| �r$|S d S )Nr z%u)r
r Z
write_to_file)r r r r"