HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_scheduler.cpython-39.pyc
a

Y��d���@s
ddlmZddlTddlZddlZddlTddlZddlZddl	Z	ddl
mZddlZddl
mZddlZddlZddlZddlZz
ejWney�ddlZYn0ej��ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�dej�ZdS)�)�base)�*�N)�commandsc@s0eZdZddd�Zedd��Zejdd��ZdS)�SchedulerParamsNcCs(||_||_||_||_||_||_dS�N)�_cmd�cmdline�	scheduler�priority�affinity�cgroup)�self�cmdr	r
rrr
�r�B/usr/lib/python3.9/site-packages/tuned/plugins/plugin_scheduler.py�__init__szSchedulerParams.__init__cCs |jdurdS|j�|j�SdSr)�	_affinityrZbitmask2cpulist�rrrrr&s
zSchedulerParams.affinitycCs"|durd|_n|j�|�|_dSr)rrZcpulist2bitmask�r�valuerrrr-s)NNNNN)�__name__�
__module__�__qualname__r�propertyr�setterrrrrrs�
	
rc@seZdZdd�ZdS)�
IRQAffinitiescCsi|_d|_g|_dSr)�irqs�default�unchangeablerrrrr5szIRQAffinities.__init__N)rrrrrrrrr4src@speZdZdZdddddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�SchedulerUtilsz=
	Class encapsulating scheduler implementation in os module
	�
SCHED_FIFO�SCHED_BATCH�SCHED_RR�SCHED_OTHER�
SCHED_IDLE)�f�b�r�o�icCs8tdd�|j��D��|_tdd�|j��D��|_dS)Ncss |]\}}|tt|�fVqdSr��getattr�os��.0�k�namerrr�	<genexpr>J�z*SchedulerUtils.__init__.<locals>.<genexpr>css|]}tt|�|fVqdSrr+�r/r1rrrr2Lr3��dict�_dict_schedcfg2schedconst�items�_dict_schedcfg2num�values�_dict_num2schedconstrrrrrHszSchedulerUtils.__init__cCs|j�|�Sr)r9�get)r�
str_schedulerrrr�sched_cfg_to_numNszSchedulerUtils.sched_cfg_to_numcCs|j�|�Sr)r;r<)rr
rrr�sched_num_to_constRsz!SchedulerUtils.sched_num_to_constcCs
t�|�Sr)r-�sched_getscheduler�r�pidrrr�
get_schedulerUszSchedulerUtils.get_schedulercCst�||t�|��dSr)r-�sched_setscheduler�sched_param�rrB�sched�priorrr�
set_schedulerXszSchedulerUtils.set_schedulercCs
t�|�Sr)r-�sched_getaffinityrArrr�get_affinity[szSchedulerUtils.get_affinitycCst�||�dSr)r-�sched_setaffinity�rrBrrrr�set_affinity^szSchedulerUtils.set_affinitycCst�|�jSr)r-�sched_getparam�sched_priorityrArrr�get_priorityaszSchedulerUtils.get_prioritycCs
t�|�Sr)r-�sched_get_priority_min�rrGrrr�get_priority_mindszSchedulerUtils.get_priority_mincCs
t�|�Sr)r-�sched_get_priority_maxrSrrr�get_priority_maxgszSchedulerUtils.get_priority_maxN)rrr�__doc__r7rr>r?rCrIrKrNrQrTrVrrrrr ;s"�r c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�SchedulerUtilsSchedutilszE
	Class encapsulating scheduler implementation in schedutils module
	cCs8tdd�|j��D��|_tdd�|j��D��|_dS)Ncss |]\}}|tt|�fVqdSr�r,�
schedutilsr.rrrr2pr3z4SchedulerUtilsSchedutils.__init__.<locals>.<genexpr>css|]}tt|�|fVqdSrrYr4rrrr2rr3r5rrrrrnsz!SchedulerUtilsSchedutils.__init__cCs
t�|�Sr)rZrCrArrrrCtsz&SchedulerUtilsSchedutils.get_schedulercCst�|||�dSr)rZrIrFrrrrIwsz&SchedulerUtilsSchedutils.set_schedulercCs
t�|�Sr)rZrKrArrrrKzsz%SchedulerUtilsSchedutils.get_affinitycCst�||�dSr)rZrNrMrrrrN}sz%SchedulerUtilsSchedutils.set_affinitycCs
t�|�Sr)rZrQrArrrrQ�sz%SchedulerUtilsSchedutils.get_prioritycCs
t�|�Sr)rZrTrSrrrrT�sz)SchedulerUtilsSchedutils.get_priority_mincCs
t�|�Sr)rZrVrSrrrrV�sz)SchedulerUtilsSchedutils.get_priority_maxN)rrrrWrrCrIrKrNrQrTrVrrrrrXjsrXcs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd�d!d"�Zd#d$�Zd%d&�Zd'd(�Zd�d)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d�d?d@�Z#dAdB�Z$dCdD�Z%�fdEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)e*j+f�fdMdN�	Z,dOdP�Z-dQdR�Z.�fdSdT�Z/dUdV�Z0dWdX�Z1dYdZ�Z2e3d[d d\�d]d^��Z4e3d_d d\�d`da��Z5e3dbd d\�dcdd��Z6e3ded d\�dfdg��Z7e3dhd d\�didj��Z8dkdl�Z9dmdn�Z:dodp�Z;d�dqdr�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdd��ZCd�d��ZDd�d��ZEe3d�d d�d��d�d���ZFd�d��ZGd�d��ZHd�d��ZIeJd��d�d���ZKeLd��d�d���ZMeJd��d�d���ZNeLd��d�d���ZOeJd��d�d���ZPeLd��d�d���ZQeJd��d�d���ZReLd��d�d���ZSeJd��d�d���ZTeLd��d�d���ZUeJd��d�d���ZVeLd��d�d���ZWeJd��d�d���ZXeLd��d�d���ZYeJd��d�d���ZZeLd��d�d���Z[eJd��d�d���Z\eLd��d�d���Z]eJd��d�d���Z^eLd��d�d���Z_�Z`S)��SchedulerPlugina�+
	`scheduler`::
	
	Allows tuning of scheduling priorities, process/thread/IRQ
	affinities, and CPU isolation.
	+
	To prevent processes/threads/IRQs from using certain CPUs, use
	the [option]`isolated_cores` option. It changes process/thread
	affinities, IRQs affinities and it sets `default_smp_affinity`
	for IRQs. The CPU affinity mask is adjusted for all processes and
	threads matching [option]`ps_whitelist` option subject to success
	of the `sched_setaffinity()` system call. The default setting of
	the [option]`ps_whitelist` regular expression is `.*` to match all
	processes and thread names. To exclude certain processes and threads
	use [option]`ps_blacklist` option. The value of this option is also
	interpreted as a regular expression and process/thread names (`ps -eo
	cmd`) are matched against that expression. Profile rollback allows
	all matching processes and threads to run on all CPUs and restores
	the IRQ settings prior to the profile application.
	+
	Multiple regular expressions for [option]`ps_whitelist`
	and [option]`ps_blacklist` options are allowed and separated by
	`;`. Quoted semicolon `\;` is taken literally.
	+
	.Isolate CPUs 2-4
	====
	----
	[scheduler]
	isolated_cores=2-4
	ps_blacklist=.*pmd.*;.*PMD.*;^DPDK;.*qemu-kvm.*
	----
	Isolate CPUs 2-4 while ignoring processes and threads matching
	`ps_blacklist` regular expressions.
	====
	The [option]`default_irq_smp_affinity` option controls the values
	*TuneD* writes to `/proc/irq/default_smp_affinity`. The file specifies
	default affinity mask that applies to all non-active IRQs. Once an
	IRQ is allocated/activated its affinity bitmask will be set to the
	default mask.
	+
	The following values are supported:
	+
	--
	`calc`::
	Content of `/proc/irq/default_smp_affinity` will be calculated
	from the `isolated_cores` parameter. Non-isolated cores
	are calculated as an inversion of the `isolated_cores`. Then
	the intersection of the non-isolated cores and the previous
	content of `/proc/irq/default_smp_affinity` is written to
	`/proc/irq/default_smp_affinity`. If the intersection is
	an empty set, then just the non-isolated cores are written to
	`/proc/irq/default_smp_affinity`. This behavior is the default if
	the parameter `default_irq_smp_affinity` is omitted.
	`ignore`::
	*TuneD* will not touch `/proc/irq/default_smp_affinity`.
	explicit cpulist::
	The cpulist (such as 1,3-4) is unpacked and written directly to
	`/proc/irq/default_smp_affinity`.
	--
	+
	.An explicit CPU list to set the default IRQ smp affinity to CPUs 0 and 2
	====
	----
	[scheduler]
	isolated_cores=1,3
	default_irq_smp_affinity=0,2
	----
	====
	To adjust scheduling policy, priority and affinity for a group of
	processes/threads, use the following syntax.
	+
	[subs="+quotes,+macros"]
	----
	group.__groupname__=__rule_prio__:__sched__:__prio__:__affinity__:__regex__
	----
	+
	where `__rule_prio__` defines internal *TuneD* priority of the
	rule. Rules are sorted based on priority. This is needed for
	inheritence to be able to reorder previously defined rules. Equal
	`__rule_prio__` rules should be processed in the order they were
	defined. However, this is Python interpreter dependant. To disable
	an inherited rule for `__groupname__` use:
	+
	[subs="+quotes,+macros"]
	----
	group.__groupname__=
	----
	+
	`__sched__` must be one of:
	*`f`* for FIFO,
	*`b`* for batch,
	*`r`* for round robin,
	*`o`* for other,
	*`*`* do not change.
	+
	`__affinity__` is CPU affinity in hexadecimal. Use `*` for no change.
	+
	`__prio__` scheduling priority (see `chrt -m`).
	+
	`__regex__` is Python regular expression. It is matched against the output of
	+
	[subs="+quotes,+macros"]
	----
	ps -eo cmd
	----
	+
	Any given process name may match more than one group. In such a case,
	the priority and scheduling policy are taken from the last matching
	`__regex__`.
	+
	.Setting scheduling policy and priorities to kernel threads and watchdog
	====
	----
	[scheduler]
	group.kthreads=0:*:1:*:\[.*\]$
	group.watchdog=0:f:99:*:\[watchdog.*\]
	----
	====
	+
	The scheduler plug-in uses perf event loop to catch newly created
	processes. By default it listens to `perf.RECORD_COMM` and
	`perf.RECORD_EXIT` events. By setting [option]`perf_process_fork`
	option to `true`, `perf.RECORD_FORK` events will be also listened
	to. In other words, child processes created by the `fork()` system
	call will be processed. Since child processes inherit CPU affinity
	from their parents, the scheduler plug-in usually does not need to
	explicitly process these events. As processing perf events can
	pose a significant CPU overhead, the [option]`perf_process_fork`
	option parameter is set to `false` by default. Due to this, child
	processes are not processed by the scheduler plug-in.
	+
	The CPU overhead of the scheduler plugin can be mitigated by using
	the scheduler [option]`runtime` option and setting it to `0`. This
	will completely disable the dynamic scheduler functionality and the
	perf events will not be monitored and acted upon. The disadvantage
	ot this approach is the procees/thread tuning will be done only at
	profile application.
	+
	.Disabling the scheduler dynamic functionality
	====
	----
	[scheduler]
	runtime=0
	isolated_cores=1,3
	----
	====
	+
	NOTE: For perf events, memory mapped buffer is used. Under heavy load
	the buffer may overflow. In such cases the `scheduler` plug-in
	may start missing events and failing to process some newly created
	processes. Increasing the buffer size may help. The buffer size can
	be set with the [option]`perf_mmap_pages` option. The value of this
	parameter has to expressed in powers of 2. If it is not the power
	of 2, the nearest higher power of 2 value is calculated from it
	and this calculated value used. If the [option]`perf_mmap_pages`
	option is omitted, the default kernel value is used.
	+
	The scheduler plug-in supports process/thread confinement using
	cgroups v1.
	+
	[option]`cgroup_mount_point` option specifies the path to mount the
	cgroup filesystem or where *TuneD* expects it to be mounted. If unset,
	`/sys/fs/cgroup/cpuset` is expected.
	+
	If [option]`cgroup_groups_init` option is set to `1` *TuneD*
	will create (and remove) all cgroups defined with the `cgroup*`
	options. This is the default behavior. If it is set to `0` the
	cgroups need to be preset by other means.
	+
	If [option]`cgroup_mount_point_init` option is set to `1`,
	*TuneD* will create (and remove) the cgroup mountpoint. It implies
	`cgroup_groups_init = 1`. If set to `0` the cgroups mount point
	needs to be preset by other means. This is the default behavior.
	+
	The [option]`cgroup_for_isolated_cores` option is the cgroup
	name used for the [option]`isolated_cores` option functionality. For
	example, if a system has 4 CPUs, `isolated_cores=1` means that all
	processes/threads will be moved to CPUs 0,2-3.
	The scheduler plug-in will isolate the specified core by writing
	the calculated CPU affinity to the `cpuset.cpus` control file of
	the specified cgroup and move all the matching processes/threads to
	this group. If this option is unset, classic cpuset affinity using
	`sched_setaffinity()` will be used.
	+
	[option]`cgroup.__cgroup_name__` option defines affinities for
	arbitrary cgroups. Even hierarchic cgroups can be used, but the
	hieararchy needs to be specified in the correct order. Also *TuneD*
	does not do any sanity checks here, with the exception that it forces
	the cgroup to be under [option]`cgroup_mount_point`.
	+
	The syntax of the scheduler option starting with `group.` has been
	augmented to use `cgroup.__cgroup_name__` instead of the hexadecimal
	`__affinity__`. The matching processes will be moved to the cgroup
	`__cgroup_name__`. It is also possible to use cgroups which have
	not been defined by the [option]`cgroup.` option as described above,
	i.e. cgroups not managed by *TuneD*.
	+
	All cgroup names are sanitized by replacing all all dots (`.`) with
	slashes (`/`). This is to prevent the plug-in from writing outside
	[option]`cgroup_mount_point`.
	+
	.Using cgroups v1 with the scheduler plug-in
	====
	----
	[scheduler]
	cgroup_mount_point=/sys/fs/cgroup/cpuset
	cgroup_mount_point_init=1
	cgroup_groups_init=1
	cgroup_for_isolated_cores=group
	cgroup.group1=2
	cgroup.group2=0,2
	
	group.ksoftirqd=0:f:2:cgroup.group1:ksoftirqd.*
	ps_blacklist=ksoftirqd.*;rcuc.*;rcub.*;ktimersoftd.*
	isolated_cores=1
	----
	Cgroup `group1` has the affinity set to CPU 2 and the cgroup `group2`
	to CPUs 0,2. Given a 4 CPU setup, the [option]`isolated_cores=1`
	option causes all processes/threads to be moved to CPU
	cores 0,2-3. Processes/threads that are blacklisted by the
	[option]`ps_blacklist` regular expression will not be moved.
	
	The scheduler plug-in will isolate the specified core by writing the
	CPU affinity 0,2-3 to the `cpuset.cpus` control file of the `group`
	and move all the matching processes/threads to this cgroup.
	====
	Option [option]`cgroup_ps_blacklist` allows excluding processes
	which belong to the blacklisted cgroups. The regular expression specified
	by this option is matched against cgroup hierarchies from
	`/proc/PID/cgroups`. Cgroups v1 hierarchies from `/proc/PID/cgroups`
	are separated by commas ',' prior to regular expression matching. The
	following is an example of content against which the regular expression
	is matched against: `10:hugetlb:/,9:perf_event:/,8:blkio:/`
	+
	Multiple regular expressions can be separated by semicolon ';'. The
	semicolon represents a logical 'or' operator.
	+
	.Cgroup-based exclusion of processes from the scheduler
	====
	----
	[scheduler]
	isolated_cores=1
	cgroup_ps_blacklist=:/daemons
	----
	
	The scheduler plug-in will move all processes away from core 1 except processes which
	belong to cgroup '/daemons'. The '' is a regular expression
	metacharacter that matches a word boundary.
	
	----
	[scheduler]
	isolated_cores=1
	cgroup_ps_blacklist=8:blkio:
	----
	
	The scheduler plug-in will exclude all processes which belong to a cgroup
	with hierarchy-ID 8 and controller-list blkio.
	====
	Recent kernels moved some `sched_` and `numa_balancing_` kernel run-time
	parameters from `/proc/sys/kernel`, managed by the `sysctl` utility, to
	`debugfs`, typically mounted under `/sys/kernel/debug`.  TuneD provides an
	abstraction mechanism for the following parameters via the scheduler plug-in:
	[option]`sched_min_granularity_ns`, [option]`sched_latency_ns`,
	[option]`sched_wakeup_granularity_ns`, [option]`sched_tunable_scaling`,
	[option]`sched_migration_cost_ns`, [option]`sched_nr_migrate`,
	[option]`numa_balancing_scan_delay_ms`,
	[option]`numa_balancing_scan_period_min_ms`,
	[option]`numa_balancing_scan_period_max_ms` and
	[option]`numa_balancing_scan_size_mb`.
	Based on the kernel used, TuneD will write the specified value to the correct
	location.
	+
	.Set tasks' "cache hot" value for migration decisions.
	====
	----
	[scheduler]
	sched_migration_cost_ns=500000
	----
	On the old kernels, this is equivalent to:
	----
	[sysctl]
	kernel.sched_migration_cost_ns=500000
	----
	that is, value `500000` will be written to `/proc/sys/kernel/sched_migration_cost_ns`.
	However, on more recent kernels, the value `500000` will be written to
	`/sys/kernel/debug/sched/migration_cost_ns`.
	====
	c		
s�tt|��||||||||�d|_tj|_ttj�|_	|durh|�
tjtj�|_t|�tj
tj��|_	t�|_d|_i|_d|_d|_d|_t��|_|jdd�|_|jdd�|_d|_zt�|_Wnty�t�|_Yn0dS)NTz.*�r
)Zcommand_name�irq) �superr[rZ_has_dynamic_options�constsZCFG_DEF_DAEMON�_daemon�intZCFG_DEF_SLEEP_INTERVAL�_sleep_interval�get_boolZ
CFG_DAEMONr<ZCFG_SLEEP_INTERVALrr�_secure_boot_hint�_sched_knob_paths_cache�
_ps_whitelist�
_ps_blacklist�_cgroup_ps_blacklist_re�perfZcpu_map�_cpusZ_storage_key�_scheduler_storage_key�_irq_storage_key�_evlistr �_scheduler_utils�AttributeErrorrX)	rZmonitor_repositoryZstorage_factoryZhardware_inventoryZdevice_matcherZdevice_matcher_udevZplugin_instance_factoryZ
global_cfgZ	variables��	__class__rrr�s2
��zSchedulerPlugin.__init__cCsT|durdSzt|�}Wnty,YdS0|dkr:dStdt�t�|d���S)Nr�)ra�
ValueError�mathZceil�log)rZ
mmap_pagesZmprrr�_calc_mmap_pages�sz SchedulerPlugin._calc_mmap_pagescsd|_d|_d|_d|_�j��ji��_t�j�dkr^t	�
d����i�_�j��j�t
��_d�_d�_d�_t��fdd�|j��D���_|j|_�j�|jd�}��|�}|dkr�t	�d|�d}|dur�t|�|kr�t	�
d	||f�|jD]}�j�|j|�|j|<�q�j�|j�d
d��dk�rDd|_t� �|_!�j"�r�|j�r�z�t#�$�|_%t#j&t#j't#j(ddddddt#j)t#j*Bd
�	}|j+�j,|j%d�t#�-�j,|j%�|_|j�.|�|du�r�|j�/�n|jj/|d�Wnd|_Yn0dS)NFTrz0recovering scheduling settings from previous runcsJg|]B\}}|dd�dkrt|�dkr��|dd���j�|�f�qS�N�zcgroup.)�len�_sanitize_cgroup_path�
_variables�expand)r/�optionrrrr�
<listcomp>�s"�z2SchedulerPlugin._instance_init.<locals>.<listcomp>�perf_mmap_pageszKInvalid 'perf_mmap_pages' value specified: '%s', using default kernel valuezL'perf_mmap_pages' value has to be power of two, specified: '%s', using: '%d'Zruntimer�0)	�typeZconfigZtask�comm�mmapZfreqZ
wakeup_eventsZ	watermarkZsample_type)Zcpus�threads)Zpages)0rmZ_has_dynamic_tuningZ_has_static_tuning�_runtime_tuning�_storager<rk�_scheduler_originalryru�info�_restore_ps_affinity�unsetr6�_cgroups_original_affinityr�_cgroup_affinity_initialized�_cgroup�collections�OrderedDict�optionsr8�_cgroups�
_schedulerr{r|rv�error�strrrc�	threading�Event�
_terminater`riZ
thread_mapZ_threads�evselZ
TYPE_SOFTWAREZCOUNT_SW_DUMMYZ
SAMPLE_TIDZ
SAMPLE_CPU�openrjZevlist�addr�)r�instanceZperf_mmap_pages_rawrr0r�rrr�_instance_init�sf�
�

�



�
zSchedulerPlugin._instance_initcCs&|jr"|j��D]}t�|j�qdSr)rm�
get_pollfdr-�closer1)rr��fdrrr�_instance_cleanupsz!SchedulerPlugin._instance_cleanupcCs2dtjdddddddddddddddddddd�S)NFT�calcZfalse)�isolated_cores�cgroup_mount_point�cgroup_mount_point_init�cgroup_groups_init�cgroup_for_isolated_cores�cgroup_ps_blacklist�ps_whitelist�ps_blacklist�default_irq_smp_affinityr�perf_process_fork�sched_min_granularity_ns�sched_latency_ns�sched_wakeup_granularity_ns�sched_tunable_scaling�sched_migration_cost_ns�sched_nr_migrate�numa_balancing_scan_delay_ms�!numa_balancing_scan_period_min_ms�!numa_balancing_scan_period_max_ms�numa_balancing_scan_size_mb)r_ZDEF_CGROUP_MOUNT_POINT)�clsrrr�_get_config_optionss,�z#SchedulerPlugin._get_config_optionscCs|durt|��dd�SdS)N�.�/)r��replacerrrrrz1sz%SchedulerPlugin._sanitize_cgroup_pathcCs>t|tj�s|}t�|�}t�|�}|�|�r:d|d}|S)N�[�])�
isinstance�procfs�processZprocess_cmdline�_is_kthread)rr�rBr	rrr�_get_cmdline5s


zSchedulerPlugin._get_cmdlinecCs�t��}|��i}|��D]�}zJ|�|�}|d}|||<d|vrh|d��D]}|�|�}|||<qPWqttfy�}z4|jtj	ks�|jtj
kr�WYd}~qn�WYd}~qd}~00q|S)NrBr�)r��pidstats�reload_threadsr:r��keys�OSError�IOError�errno�ENOENT�ESRCH)r�ps�	processes�procrrB�errr�
get_processes?s&


�zSchedulerPlugin.get_processescCs@|j�|�}|j�|�}|j�|�}t�d|||f�||fS)Nz8Read scheduler policy '%s' and priority '%d' of PID '%d')rnrCr?rQru�debug)rrBr
�	sched_strrrrr�_get_rtXs�zSchedulerPlugin._get_rtc
Cs|j�|�}t�d|||f�zB|j�|�}|j�|�}||ksJ||kr`t�d||||f�Wn6ttfy�}zt�d|�WYd}~n
d}~00z|j�	|||�Wnbttf�y}zDt
|d�r�|jtjkr�t�d|�nt�d||f�WYd}~n
d}~00dS)NzBSetting scheduler policy to '%s' and priority to '%d' of PID '%d'.z9Priority for %s must be in range %d - %d. '%d' was given.z(Failed to get allowed priority range: %sr�zAFailed to set scheduling parameters of PID %d, the task vanished.z1Failed to set scheduling parameters of PID %d: %s)
rnr?rur�rTrVr��SystemErrorr�rI�hasattrr�r�)rrBrGrHr�Zprio_minZprio_maxr�rrr�_set_rt`s6���
���zSchedulerPlugin._set_rtcCs|ddtjj@dkS)N�stat�flagsr)r�ZpidstatZ
PF_KTHREAD)rr�rrrr�|szSchedulerPlugin._is_kthreadc
Cs,znt�|�}|d��rf|dddkr8t�d|�n(|�|�rRt�d|�nt�d|�WdSWdSWn�ttfy�}z`|j	t	j
ks�|j	t	jkr�t�d	|�WYd}~d
St�d||f�WYd}~dSWYd}~nFd}~0t
tf�y&}z t�d||f�WYd}~dSd}~00dS)
Nr��state�ZzYAffinity of zombie task with PID %d cannot be changed, the task's affinity mask is fixed.z[Affinity of kernel thread with PID %d cannot be changed, the task's affinity mask is fixed.zRAffinity of task with PID %d cannot be changed, the task's affinity mask is fixed.rrz6Failed to get task info for PID %d, the task vanished.���z&Failed to get task info for PID %d: %s���)r�r�Zis_bound_to_cpurur�r��warnr�r�r�r�r�r�ro�KeyError)rrBr�r�rrr�_affinity_changeable�s>
�
��
��"�z$SchedulerPlugin._affinity_changeablecCsZz|j|}Wn&ty4t|j�}||j|<Yn0|jdurV|jdurV||_||_dSr)r�r�rrr
r)rrBr
r�paramsrrr�_store_orig_process_rt�s
z&SchedulerPlugin._store_orig_process_rtc
Cs�d}|dur|dur|Sz:|�|�\}}|dur4|}|�|||�|�|||�Wnvttfy�}zZt|d�r�|jtjkr�t�	d|�||j
vr�|j
|=d}nt�d||f�WYd}~n
d}~00|S)NTr�z=Failed to read scheduler policy of PID %d, the task vanished.FzcRefusing to set scheduler and priority of PID %d, reading original scheduling parameters failed: %s)r�r�r�r�r�r�r�r�rur�r�r�)rrBrGrH�contZ
prev_schedZ	prev_prior�rrr�_tune_process_rt�s*�
�z SchedulerPlugin._tune_process_rtcCst|�dd�dkSrw)r�)rrrrr�_is_cgroup_affinity�sz#SchedulerPlugin._is_cgroup_affinityFcCs`z|j|}Wn&ty4t|j�}||j|<Yn0|jdur\|jdur\|rV||_n||_dSr)r�r�rrrr
)rrBr�	is_cgroupr�rrr�_store_orig_process_affinity�s
z,SchedulerPlugin._store_orig_process_affinityc	Csp|jjdtjt|�dfdd��d�D]D}z,|�d�ddd�}|dkrN|nd	WStyhYq&0q&d	S)
N�%s/%s/%sr
T��no_error�
z:cpuset:rr\r�)r�	read_filer_ZPROCFS_MOUNT_POINTr��split�
IndexError)rrB�lr
rrr�_get_cgroup_affinity�s*z$SchedulerPlugin._get_cgroup_affinitycCsB|�|�}|j}|dkr$d||f}|jjd|t|�dd�dS)Nr��%s/%sz%s/tasksTr�)rz�_cgroup_mount_pointr�
write_to_filer�)rrBr
�pathrrr�_set_cgroup�s

zSchedulerPlugin._set_cgroupcCs,|dd�}t|t�o"t|�dk}||fS)Nrxr)r��listry)rr
r�rrr�_parse_cgroup_affinity�sz&SchedulerPlugin._parse_cgroup_affinityc	
Cs�d}|dur|Szd|�|�\}}|r<|�|�}|�||�n(|�|�}|rX|�|||�}|�||�|�|||�Wnvttfy�}zZt	|d�r�|j
t
jkr�t�
d|�||jvr�|j|=d}nt�d||f�WYd}~n
d}~00|S)NTr�z5Failed to read affinity of PID %d, the task vanished.FzLRefusing to set CPU affinity of PID %d, reading original affinity failed: %s)r�r�r��
_get_affinity�_get_intersect_affinity�
_set_affinityr�r�r�r�r�r�rur�r�r�)	rrBr�	intersectr�r�r
�
prev_affinityr�rrr�_tune_process_affinity�s<

���
�z&SchedulerPlugin._tune_process_affinitycCsD|�|||�}|sdS|�||�}|r0||jvr4dS||j|_dSr)r�r�r�r	)rrBrrGrHrr�rrr�
_tune_processszSchedulerPlugin._tune_processcCsf|j�|�}|dur.|dkr.t�d|�dSzt|�}Wn"ty\t�d|�YdS0||fS)Nrz>Invalid scheduler: %s. Scheduler and priority will be ignored.)NNz=Invalid priority: %s. Scheduler and priority will be ignored.)rnr>rur�rars)rr=Zstr_priorityr
rrrr�_convert_sched_paramss��z%SchedulerPlugin._convert_sched_paramscCsD|dkrd}n2|�|�r|}n"|j�|�}|s@t�d|�d}|S)Nrz)Invalid affinity: %s. It will be ignored.)r�r�hex2cpulistrur�)rZstr_affinityrrrr�_convert_affinity#s
�z!SchedulerPlugin._convert_affinitycCs6|\}}}}}|�||�\}}|�|�}|||||fSr)r�r�)r�vals�	rule_prior
rr�regexrrr�_convert_sched_cfg0s�
z"SchedulerPlugin._convert_sched_cfgc
Cs�d|j|f}zt�|tj�Wn6tyV}zt�d||f�WYd}~n
d}~00|jj	d|df|jj
d|jdfdd�dd�s�t�d|�dS)Nr�z Unable to create cgroup '%s': %szcpuset.memsTr�z3Unable to initialize 'cpuset.mems ' for cgroup '%s')r�r-�mkdirr_�DEF_CGROUP_MODEr�rur�rr�r�)rr
r�r�rrr�_cgroup_create_group7s(�z$SchedulerPlugin._cgroup_create_groupcCs<|jdur"|j|jvr"|�|j�|jD]}|�|�q(dSr)r�r�r�r�cgrrr�_cgroup_initialize_groupsBs
z)SchedulerPlugin._cgroup_initialize_groupsc
Cs�t�d�zt�|jtj�Wn2tyP}zt�d|�WYd}~n
d}~00|j	�
dddddd|jg�\}}|dkr�t�d	|j�dS)
NzInitializing cgroups settingsz'Unable to create cgroup mount point: %sZmountz-tr
z-oZcpusetrzUnable to mount '%s')rur�r-�makedirsr�r_rr�r�r�execute)rr��ret�outrrr�_cgroup_initializeHs
$ z"SchedulerPlugin._cgroup_initializec
CsJzt�|�Wn6tyD}zt�d||f�WYd}~n
d}~00dS)Nz#Unable to remove directory '%s': %s)r-�rmdirr�rur�)rr
r�rrr�_remove_dirRszSchedulerPlugin._remove_dircCsTt|j�D]}|�d|j|f�q
|jdurP|j|jvrP|�d|j|jf�dS)Nr�)�reversedr�rr�r�rrrr�_cgroup_finalize_groupsXsz'SchedulerPlugin._cgroup_finalize_groupscCslt�d�|j�d|jg�\}}|dkr<t�d|j�dS|�|j�tj�	|j�}|dkrh|�|�dS)NzRemoving cgroups settingsZumountrzUnable to umount '%s'Fr�)
rur�rr
r�r�rr-r��dirname)rrr�drrr�_cgroup_finalize^s
z SchedulerPlugin._cgroup_finalizecCs�|dkrt�d||f�nt�d|�dSd|j|df}|r~|jj|ddd���}|dkrl||j|<nt�d	|�dS|jj||dd
�s�t�d||f�dS)Nr\z$Setting cgroup '%s' affinity to '%s'z.Skipping cgroup '%s', empty affinity requestedr��cpuset.cpus�ERRT��err_retr�zIRefusing to set affinity of cgroup '%s', reading original affinity failedr�z+Unable to set affinity '%s' for cgroup '%s')	rur�r�rr��stripr�r�r�)rr
r�backupr�Z
orig_affinityrrr�_cgroup_set_affinity_oneisz(SchedulerPlugin._cgroup_set_affinity_onecCsz|jr
dSt�d�|jdurH|jdurH|j|jvrH|j|j|jdd�|j��D]}|j|d|ddd�qRd|_dS)NzSetting cgroups affinitiesT)rrr)r�rur�rr�r�rr8rrrr�_cgroup_set_affinityzs
 z$SchedulerPlugin._cgroup_set_affinitycCs2t�d�|j��D]}|�|d|d�qdS)NzRestoring cgroups affinitiesrr)rur�r�r8rrrrr�_cgroup_restore_affinity�s
z(SchedulerPlugin._cgroup_restore_affinitycsx�j�|jd��_�j��j�|jd��dk�_�j��j�|jd��dk�_���j�|jd���_	�jr|��
��js��jr����tt
���|����z���}Wn8ttfy�}zt�d|�WYd}~dSd}~00dd�|j��D�}�fd	d�|D�}t|d
d�d�}t�}i|_|D]�\�\}����zt����WnHtj�y�}z,t�d
t���WYd}~�q4WYd}~n
d}~00�fdd�|��D�}t�����fdd�|D��}	|�|	�t�ddt�������g|j�<�q4|��D](\}
\}�������|
|�����q
�j �!�j"�j#��j$�rt|j%�rtt&j'�j(|gd�|_)|j)�*�dS)Nr�r��1r�r��Ierror applying tuning, cannot get information about running processes: %scSs$g|]\}}|t|��dd�f�qS)�:�)r�r�)r/r}rrrrr~�r3z:SchedulerPlugin._instance_apply_static.<locals>.<listcomp>cs6g|].\}}t�d|�rt|�dkr|��|�f�qS)zgroup\.�)�re�matchryr)r/r}r�rrrr~�s�cSs|ddS)Nrrr)Zoption_valsrrr�<lambda>�r3z8SchedulerPlugin._instance_apply_static.<locals>.<lambda>)�keyz(error compiling regular expression: '%s'cs(g|] \}}t��|�dur||f�qSr)r#�search�r/rBr)r(rrr~�r3c	s$g|]\}}||�����ff�qSrrr()rr}rrr
rrr~�s�z(?<!\\)\((?!\?)z(?:)�target�args)+r{r|r�r�rrc�_cgroup_mount_point_init�_cgroup_groups_initrzr�r
rr^r[�_instance_apply_staticrr�r�r�rur�r�r8�sortedr6�
_sched_lookupr#�compiler��update�subr�r��setrkr�r`r�r��Thread�_thread_code�_thread�start)rr�r�r�Z	sched_cfg�bufZ	sched_allrr�rGrBrrp)rr}rr(rr
rrr-�sv����
��
��$�
�
�
�z&SchedulerPlugin._instance_apply_staticc
Cs�z|��}Wn8ttfyD}zt�d|�WYd}~dSd}~00|j��D]x\}}||vsP|||jkrpqP|jdur�|j	dur�|�
||j|j	�|jdur�|�||j�qP|j
durP|�||j
�qPi|_|j�|j�dS)NzKerror unapplying tuning, cannot get information about running processes: %s)r�r�r�rur�r�r8r	r
rr�r
r�rr�r�r�rk)rr�r�rBZorig_paramsrrrr��s,�
�
�

z$SchedulerPlugin._restore_ps_affinitycCs�ttj�}d}|dkrz|dkrz|jjd|j|dfddd�}|dvrp|�d	�D] }|jjd
|jdf|dd�qN|d8}q|dkr�t�	d
|�dS)N� r\rr�ZtasksTr)r\r9r�r�r�rz(Unable to cleanup tasks from cgroup '%s')
rar_ZCGROUP_CLEANUP_TASKS_RETRYrr�r�r�r�rur�)rr
Zcnt�datar�rrr�_cgroup_cleanup_tasks_one�s
�
z)SchedulerPlugin._cgroup_cleanup_tasks_onecCs<|jdur"|j|jvr"|�|j�|jD]}|�|�q(dSr)r�r�r;rrrr�_cgroup_cleanup_tasks�s
z%SchedulerPlugin._cgroup_cleanup_taskscsptt|��||�|jr2|jr2|j��|j��|�	�|�
�|��|jsV|j
r^|��|j
rl|��dSr)r^r[�_instance_unapply_staticr`r�r�r3r6�joinr�rr<r,r+rr)rr�Zrollbackrprrr=�s

z(SchedulerPlugin._instance_unapply_staticcCs�t�d|�d|j|df}|jj|ddd�}|dkr<dS|j�|j�|��}|j�|j�|��}d|}||kr�t�tj	||f�dSt�
tj|||f�dSdS)	NzVerifying cgroup '%s' affinityr�rrTrzcgroup '%s' affinityF)rur�r�rr��cpulist2stringZcpulist_packr�r_�STR_VERIFY_PROFILE_VALUE_OKr��STR_VERIFY_PROFILE_VALUE_FAIL)rr
rr��current_affinityZaffinity_descriptionrrr�_cgroup_verify_affinity_one�s&���z+SchedulerPlugin._cgroup_verify_affinity_onecCsnt�d�d}|jdurB|jdurB|j|jvrB|o@|�|j|j�}|j��D]}|of|�|d|d�}qL|S)NzVeryfying cgroups affinitiesTrr)rur�rr�r�rCr8)rrrrrr�_cgroup_verify_affinitys
 z'SchedulerPlugin._cgroup_verify_affinitycs$tt|��|||�}|��}|o"|Sr)r^r[�_instance_verify_staticrD)rr��ignore_missingZdevicesZret1Zret2rprrrEsz'SchedulerPlugin._instance_verify_staticc

Cs�z|�|�}Wndttfyr}zH|jtjks:|jtjkrJt�d|�nt�d||f�WYd}~dSd}~00|j	�
|j||�}|dur�||jvr�t�d||t
|�f�|\}}}	|�|||||	�|j�|j|j�dS)N�3Failed to get cmdline of PID %d, the task vanished.z#Failed to get cmdline of PID %d: %sz-tuning new process '%s' with PID '%d' by '%s')r�r�r�r�r�r�rur�r�rZ	re_lookupr/r�r�r�r�r3rk)
rr�rBr(rr��vrGrHrrrr�_add_pids.
���
�
�zSchedulerPlugin._add_pidcCs6||jvr2|j|=t�d|�|j�|j|j�dS)Nz)removed PID %d from the rollback database)r�rur�r�r3rk)rr�rBrrr�_remove_pid1s

�zSchedulerPlugin._remove_pidc	Cs�|j�|j�}t��}|j��}|D]}|�|�q$|j�	�s�t
|�|jd��dkr4|j�	�s4d}|r4d}|jD]j}|j�
|�}|rrd}|jtjks�|jr�|jtjkr�|�|t|j�|�qr|jtjkrr|�|t|j��qrqdq4dS)Ni�rTF)rZre_lookup_compiler/�select�pollrmr��registerr��is_setryrbrjZread_on_cpur�riZRECORD_COMM�_perf_process_fork_valueZRECORD_FORKrIra�tidZRECORD_EXITrJ)	rr�r(rLZfdsr�Zread_eventsZcpuZeventrrrr58s,

"
�
�zSchedulerPlugin._thread_coder�)�
per_devicecCs:|rdS|r6|dur6d�dd�t�dt|��D��|_dS)N�|cSsg|]}d|�qS�z(%s)r�r/rHrrrr~Wr3z8SchedulerPlugin._cgroup_ps_blacklist.<locals>.<listcomp>�(?<!\\);)r>r#r�r�rh�r�enablingr�verifyrFrrr�_cgroup_ps_blacklistQsz$SchedulerPlugin._cgroup_ps_blacklistr�cCs:|rdS|r6|dur6d�dd�t�dt|��D��|_dS)NrRcSsg|]}d|�qSrSrrTrrrr~_r3z1SchedulerPlugin._ps_whitelist.<locals>.<listcomp>rU)r>r#r�r�rfrVrrrrfYszSchedulerPlugin._ps_whitelistr�cCs:|rdS|r6|dur6d�dd�t�dt|��D��|_dS)NrRcSsg|]}d|�qSrSrrTrrrr~gr3z1SchedulerPlugin._ps_blacklist.<locals>.<listcomp>rU)r>r#r�r�rgrVrrrrgaszSchedulerPlugin._ps_blacklistr�cCs6|rdS|r2|dur2|dvr$||_n|j�|�|_dS)N)r��ignore)�_default_irq_smp_affinity_valuer�cpulist_unpackrVrrr�_default_irq_smp_affinityisz)SchedulerPlugin._default_irq_smp_affinityr�cCs*|rdS|r&|dur&|j�|�dk|_dS)Nr)rrcrOrVrrr�_perf_process_forktsz"SchedulerPlugin._perf_process_forkcCs"|j�|�}t�d||f�|S)NzRead affinity '%s' of PID %d)rnrKrur�)rrB�resrrrr��szSchedulerPlugin._get_affinityc
Cs�t�d||f�z|j�||�WdSttfy�}zbt|d�r`|jtjkr`t�d|�n.|�	|�}|dksz|dkr�t�
d|||f�WYd}~dSd}~00dS)	Nz'Setting CPU affinity of PID %d to '%s'.Tr�z4Failed to set affinity of PID %d, the task vanished.rr�z,Failed to set affinity of PID %d to '%s': %sF)rur�rnrNr�r�r�r�r�r�r�)rrBrr�r_rrrr��s�
�zSchedulerPlugin._set_affinitycCs"t|��t|��}|rt|�S|Sr)r3�intersectionr�)rZ	affinity1Z	affinity2Z	affinity3Zaffrrrr��sz'SchedulerPlugin._get_intersect_affinityc
sD�fdd�|D�}�jdkr.�fdd�|D�}�jdkrJ�fdd�|D�}tdd�|D��}|D]�}z��||�}Wnnttfy�}zR|jtjks�|jtjkr�t	�
d|�nt	�d||f�WYd}~q`WYd}~n
d}~00�j||d	d
�}	|	s�q`|�j
v�r|�j
|_|s`d||vr`��||d��|d	�q`dS)Ncs(g|] }t��j��|��dur|�qSr)r#r'rf�_get_stat_commrTrrrr~�s��z9SchedulerPlugin._set_all_obj_affinity.<locals>.<listcomp>r\cs(g|] }t��j��|��dur|�qSr)r#r'rgrarTrrrr~�s��cs(g|] }t��j��|��dur|�qSr)r#r'rh�_get_stat_cgrouprTrrrr~�s��cSsg|]}|j|f�qSr)rBrTrrrr~�r3rGzARefusing to set affinity of PID %d, failed to get its cmdline: %sT)r�r�)rgrhr6r�r�r�r�r�r�rur�r�r�r�r	�_set_all_obj_affinityr:)
rZobjsrr�ZpslZpsdrBrr�r�rrrrc�s@


���"��z%SchedulerPlugin._set_all_obj_affinityc
Cs*z
|dWStttfy$YdS0dS)NZcgroupsr\�r�r�r��rr)rrrrb�s
z SchedulerPlugin._get_stat_cgroupc
Cs.z|ddWStttfy(YdS0dS)Nr�r�r\rdrerrrra�szSchedulerPlugin._get_stat_commc
Csbz&t��}|��|�|��|d�Wn6ttfy\}zt�d|�WYd}~n
d}~00dS)NFr)	r�r�r�rcr:r�r�rur�)rrr�r�rrr�_set_ps_affinity�s�z SchedulerPlugin._set_ps_affinityc
Cs�z`|j�|�}t�d||f�d|}t|d��}|�|�Wd�n1sR0YWdSttfy�}zdt|d�r�|j	t	j
kr�|s�t�d|�WYd}~dSt�d|||f�WYd}~d	SWYd}~n
d}~00dS)
Nz&Setting SMP affinity of IRQ %s to '%s'z/proc/irq/%s/smp_affinity�wrr�z/Setting SMP affinity of IRQ %s is not supportedr�z0Failed to set SMP affinity of IRQ %s to '%s': %sr�)r�cpulist2hexrur�r��writer�r�r�r�ZEIOr�)rr]rZ	restoring�affinity_hex�filenamer&r�rrr�_set_irq_affinity�s*�(���z!SchedulerPlugin._set_irq_affinityc
Cs�zR|j�|�}t�d|�tdd��}|�|�Wd�n1sF0YWn:ttfy�}zt�d||f�WYd}~n
d}~00dS)Nz(Setting default SMP IRQ affinity to '%s'�/proc/irq/default_smp_affinityrgz2Failed to set default SMP IRQ affinity to '%s': %s)	rrhrur�r�rir�r�r�)rrrjr&r�rrr�_set_default_irq_affinity�s�,�z)SchedulerPlugin._set_default_irq_affinityc		Cst�}t��}|��D]�}z"||d}t�d||f�WntyRYqYn0|�|||�}t|�t|�krtq|�	||d�}|dkr�||j
|<q|dkr|j�|�q|j
�d�}|j
�|�}|jdkr�|�|||�}n|jdkr�|j}|jdk�r
|�|�||_|j�|j|�dS)	NrzRead affinity of IRQ '%s': '%s'Frr�rmr�rZ)rr��
interruptsr�rur�r�r�r3rlrr�appendrr�r�r[rnrr�rl)	rr�irq_originalrr]r�rr_Zprev_affinity_hexrrr�_set_all_irq_affinity�s8�




z%SchedulerPlugin._set_all_irq_affinitycCsj|j�|jd�}|durdS|j��D]\}}|�||d�q&|jdkrX|j}|�|�|j�	|j�dS)NTrZ)
r�r<rlrr8rlr[rrnr�)rrqr]rrrr�_restore_all_irq_affinitys

z)SchedulerPlugin._restore_all_irq_affinitycCsFt|��t|��}|r,t�tj||f�nt�tj|||f�|Sr)r3�issubsetrur�r_r@r�rA)r�irq_description�correct_affinityrBr_rrr�_verify_irq_affinity$s���z$SchedulerPlugin._verify_irq_affinityc	Cs�|j�|jd�}t��}d}|��D]�}||jvrP|rPd|}t�t	j
|�q$z<||d}t�d||f�d|}	|�|	||�s�d}Wq$t
y�Yq$Yq$0q$|j�d�}
|j�|
�}|jdkr�|�d	||jd
kr�|n|j�s�d}|S)NTz-IRQ %s does not support changing SMP affinityrz#Read SMP affinity of IRQ '%s': '%s'zSMP affinity of IRQ %sFrmrZzdefault IRQ SMP affinityr�)r�r<rlr�ror�rrur�r_Z STR_VERIFY_PROFILE_VALUE_MISSINGr�rwr�rr�r�r[)rrvrFrqrr_r]�descriptionrBruZcurrent_affinity_hexrrr�_verify_all_irq_affinity0s@����z(SchedulerPlugin._verify_all_irq_affinityr��
)rQrc
Cs�d}d|_|durrt|j�|��}t|j�}|�|�rRt||�}|j�|�|_n |j�|j�}t�	d||f�|sz|r�|dur�dS|r�|�
||�S|r�|jr�|��d|j}	n|}	|�
|	�|�|�n|��dS)NzJInvalid isolated_cores specified, '%s' does not match available cores '%s'z	cgroup.%s)rr3rr\rjrtr�r?rur�ryr�rrfrrrs)
rrWrrXrFr�isolatedZpresentZstr_cpusZps_affinityrrr�_isolated_coresOs0

�
zSchedulerPlugin._isolated_corescCs�d|||f}|j�|�}|r"|Sd||f}tj�|�sv|dkrPd||f}nd|||f}d|}|jdurvd|_||j|<|S)Nz%s_%s_%sz/proc/sys/kernel/%s_%sr\r�r�z/sys/kernel/debug/%sT)rer<r-r��existsrd)r�prefix�	namespace�knobr&r�rrr�_get_sched_knob_pathos

z$SchedulerPlugin._get_sched_knob_pathcCsJ|jj|�|||�dd�}|durFt�d|�|jrFt�d�d|_|S)N)rzError reading '%s'zUThis may not work with Secure Boot or kernel_lockdown (this hint is logged only once)F)rr�r�rur�rd)rr~rr�r:rrr�_get_sched_knob�s
zSchedulerPlugin._get_sched_knobcCs>|durdS|s:|j�|�|||�|�s:t�d||f�|S)Nz Error writing value '%s' to '%s')rr�r�rur�)rr~rr�r�simrrr�_set_sched_knob�szSchedulerPlugin._set_sched_knobr�cCs|�ddd�S�Nr\rGZmin_granularity_ns�r�rrrr�_get_sched_min_granularity_ns�sz-SchedulerPlugin._get_sched_min_granularity_nscCs|�ddd||�Sr��r��rrr�rrr�_set_sched_min_granularity_ns�sz-SchedulerPlugin._set_sched_min_granularity_nsr�cCs|�ddd�S�Nr\rGZ
latency_nsr�rrrr�_get_sched_latency_ns�sz%SchedulerPlugin._get_sched_latency_nscCs|�ddd||�Sr�r�r�rrr�_set_sched_latency_ns�sz%SchedulerPlugin._set_sched_latency_nsr�cCs|�ddd�S�Nr\rGZwakeup_granularity_nsr�rrrr� _get_sched_wakeup_granularity_ns�sz0SchedulerPlugin._get_sched_wakeup_granularity_nscCs|�ddd||�Sr�r�r�rrr� _set_sched_wakeup_granularity_ns�sz0SchedulerPlugin._set_sched_wakeup_granularity_nsr�cCs|�ddd�S�Nr\rGZtunable_scalingr�rrrr�_get_sched_tunable_scaling�sz*SchedulerPlugin._get_sched_tunable_scalingcCs|�ddd||�Sr�r�r�rrr�_set_sched_tunable_scaling�sz*SchedulerPlugin._set_sched_tunable_scalingr�cCs|�ddd�S�Nr\rGZmigration_cost_nsr�rrrr�_get_sched_migration_cost_ns�sz,SchedulerPlugin._get_sched_migration_cost_nscCs|�ddd||�Sr�r�r�rrr�_set_sched_migration_cost_ns�sz,SchedulerPlugin._set_sched_migration_cost_nsr�cCs|�ddd�S�Nr\rGZ
nr_migrater�rrrr�_get_sched_nr_migrate�sz%SchedulerPlugin._get_sched_nr_migratecCs|�ddd||�Sr�r�r�rrr�_set_sched_nr_migrate�sz%SchedulerPlugin._set_sched_nr_migrater�cCs|�ddd�S�NrG�numa_balancingZ
scan_delay_msr�rrrr�!_get_numa_balancing_scan_delay_ms�sz1SchedulerPlugin._get_numa_balancing_scan_delay_mscCs|�ddd||�Sr�r�r�rrr�!_set_numa_balancing_scan_delay_ms�sz1SchedulerPlugin._set_numa_balancing_scan_delay_msr�cCs|�ddd�S�NrGr�Zscan_period_min_msr�rrrr�&_get_numa_balancing_scan_period_min_ms�sz6SchedulerPlugin._get_numa_balancing_scan_period_min_mscCs|�ddd||�Sr�r�r�rrr�&_set_numa_balancing_scan_period_min_ms�sz6SchedulerPlugin._set_numa_balancing_scan_period_min_msr�cCs|�ddd�S�NrGr�Zscan_period_max_msr�rrrr�&_get_numa_balancing_scan_period_max_ms�sz6SchedulerPlugin._get_numa_balancing_scan_period_max_mscCs|�ddd||�Sr�r�r�rrr�&_set_numa_balancing_scan_period_max_ms�sz6SchedulerPlugin._set_numa_balancing_scan_period_max_msr�cCs|�ddd�S�NrGr�Zscan_size_mbr�rrrr� _get_numa_balancing_scan_size_mb�sz0SchedulerPlugin._get_numa_balancing_scan_size_mbcCs|�ddd||�Sr�r�r�rrr� _set_numa_balancing_scan_size_mb�sz0SchedulerPlugin._set_numa_balancing_scan_size_mb)F)F)F)F)arrrrWrrvr�r��classmethodr�rzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrrrrrr-r�r;r<r_Z
ROLLBACK_SOFTr=rCrDrErIrJr5Zcommand_customrYrfrgr]r^r�r�r�rcrbrarfrlrnrrrsrwryr|r�r�r�Zcommand_getr�Zcommand_setr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrrprr[�s�#?





	



<

	











"
	


















r[) r\rZ
decoratorsZ
tuned.logsZtunedr#�
subprocessr�rirKZtuned.constsr_r�Ztuned.utils.commandsrr�r-r�rtr!rorZZlogsr<ru�objectrrr rXZPluginr[rrrr�<module>s0

/