a Á]›iä ã @ 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„ Zeddddd„ ƒZedƒd$dd„ƒZeddddd „ ƒ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" r! r r r Ú_setO s zUncorePlugin._setc C sd z4| |d¡}| |d¡}| |d¡}| |d¡}W n" ttfyV t d¡ Y d S 0 ||||fS )NÚinitial_max_freq_khzÚinitial_min_freq_khzÚmax_freq_khzÚmin_freq_khzú$fail to read uncore frequency values)r# r ÚIOErrorr Úerror)r Údevicer% r&