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_scheduler.cpython-312.pyc
�

�]�i�����ddlmZddl�ddlZddlZddl�ddlZ	ddlZddl
Z
ddlmZddl
Z
ddlmZddlZddlZddlZddlZ	ej(ej.j1�ZGd�de�ZGd�d	e�ZGd
�de�ZGd�d
e�ZGd�dej>�Z y#e	$rY��wxYw#e$rddlZY�rwxYw)�)�base)�*�N)�commandsc�L�eZdZ		dd�Zed��Zejd��Zy)�SchedulerParamsNc�X�||_||_||_||_||_||_y�N)�_cmd�cmdline�	scheduler�priority�affinity�cgroup)�self�cmdrr
rrrs       �C/usr/lib/python3.12/site-packages/tuned/plugins/plugin_scheduler.py�__init__zSchedulerParams.__init__"s,���$�)��$�,��$�.��$�-��$�-��$�+�c�f�|j�y|jj|j�Sr
)�	_affinityr�bitmask2cpulist�rs rrzSchedulerParams.affinity+s(��	�^�^��
�
�)�)�
#�
#�D�N�N�
3�3rc�X�|�d|_y|jj|�|_yr
)rr�cpulist2bitmask�r�values  rrzSchedulerParams.affinity2s$��
�]��4�>��I�I�-�-�e�4�4�>r)NNNNN)�__name__�
__module__�__qualname__r�propertyr�setter�rrrr!s9��59�.2���4��4��/�/�5��5rrc��eZdZd�Zy)�
IRQAffinitiesc�.�i|_d|_g|_yr
)�irqs�default�unchangeablers rrzIRQAffinities.__init__:s���$�)��$�,��$�rN)rrr rr#rrr%r%9s��rr%c�\�eZdZdZdddddd�Zd�Zd	�Zd
�Zd�Zd�Z	d
�Z
d�Zd�Zd�Z
d�Zy)�SchedulerUtilsz=
	Class encapsulating scheduler implementation in os module
	�
SCHED_FIFO�SCHED_BATCH�SCHED_RR�SCHED_OTHER�
SCHED_IDLE)�f�b�r�o�ic��td�|jj�D��|_td�|jj	�D��|_y)Nc3�FK�|]\}}|tt|�f���y�wr
��getattr�os��.0�k�names   r�	<genexpr>z*SchedulerUtils.__init__.<locals>.<genexpr>Os#���� n�Gm�G�A�t�!�W�R��%6�!7�Gm���!c3�@K�|]}tt|�|f���y�wr
r8�r<r>s  rr?z*SchedulerUtils.__init__.<locals>.<genexpr>Qs����"q�Ip��G�B��$5�t�#<�Ip�����dict�_dict_schedcfg2schedconst�items�_dict_schedcfg2num�values�_dict_num2schedconstrs rrzSchedulerUtils.__init__MsF�� � n�t�Ge�Ge�Gk�Gk�Gm� n�n�$��"�"q��Ig�Ig�In�In�Ip�"q�q�$�rc�8�|jj|�Sr
)rH�get)r�
str_schedulers  r�sched_cfg_to_numzSchedulerUtils.sched_cfg_to_numSs��	
�	 �	 �	$�	$�]�	3�3rc�8�|jj|�Sr
)rJrL)rr
s  r�sched_num_to_constz!SchedulerUtils.sched_num_to_constWs��	
�	"�	"�	&�	&�y�	1�1rc�,�tj|�Sr
)r:�sched_getscheduler�r�pids  r�
get_schedulerzSchedulerUtils.get_schedulerZs��	�	�	�s�	#�#rc�X�tj||tj|��yr
)r:�sched_setscheduler�sched_param�rrT�sched�prios    r�
set_schedulerzSchedulerUtils.set_scheduler]s������U�B�N�N�4�$8�9rc�,�tj|�Sr
)r:�sched_getaffinityrSs  r�get_affinityzSchedulerUtils.get_affinity`s��	�	�	�c�	"�"rc�0�tj||�yr
)r:�sched_setaffinity�rrTrs   r�set_affinityzSchedulerUtils.set_affinitycs�����s�H�%rc�@�tj|�jSr
)r:�sched_getparam�sched_priorityrSs  r�get_priorityzSchedulerUtils.get_priorityfs��	�	�	�3�	�	.�	.�.rc�,�tj|�Sr
)r:�sched_get_priority_min�rrZs  r�get_priority_minzSchedulerUtils.get_priority_mini���	�	"�	"�5�	)�)rc�,�tj|�Sr
)r:�sched_get_priority_maxrjs  r�get_priority_maxzSchedulerUtils.get_priority_maxlrlrN)rrr �__doc__rFrrNrPrUr\r_rcrgrkror#rrr+r+@sS���
�������r�4�2�$�:�#�&�/�*�*rr+c�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�SchedulerUtilsSchedutilszE
	Class encapsulating scheduler implementation in schedutils module
	c��td�|jj�D��|_td�|jj	�D��|_y)Nc3�FK�|]\}}|tt|�f���y�wr
�r9�
schedutilsr;s   rr?z4SchedulerUtilsSchedutils.__init__.<locals>.<genexpr>us#���� v�Ou�G�A�t�!�W�Z��%>�!?�Ou�r@c3�@K�|]}tt|�|f���y�wr
rurBs  rr?z4SchedulerUtilsSchedutils.__init__.<locals>.<genexpr>ws����"y�Qx��G�J��$=�t�#D�Qx�rCrDrs rrz!SchedulerUtilsSchedutils.__init__ssG�� � v�t�Om�Om�Os�Os�Ou� v�v�$��"�"y�QU�Qo�Qo�Qv�Qv�Qx�"y�y�$�rc�,�tj|�Sr
)rvrUrSs  rrUz&SchedulerUtilsSchedutils.get_schedulerys��	�	!�	!�#�	&�&rc�2�tj|||�yr
)rvr\rYs    rr\z&SchedulerUtilsSchedutils.set_scheduler|s�����3��t�,rc�,�tj|�Sr
)rvr_rSs  rr_z%SchedulerUtilsSchedutils.get_affinity���	�	 �	 ��	%�%rc�0�tj||�yr
)rvrcrbs   rrcz%SchedulerUtilsSchedutils.set_affinity�s�����#�x�(rc�,�tj|�Sr
)rvrgrSs  rrgz%SchedulerUtilsSchedutils.get_priority�r{rc�,�tj|�Sr
)rvrkrjs  rrkz)SchedulerUtilsSchedutils.get_priority_min����	�	$�	$�U�	+�+rc�,�tj|�Sr
)rvrorjs  rroz)SchedulerUtilsSchedutils.get_priority_max�rrN)rrr rprrUr\r_rcrgrkror#rrrrrros0���z�'�-�&�)�&�,�,rrrc�J��eZdZdZdddd�Zd�Z�fd�Zd�Zd�Zd	�Z	e
d
��Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdzd�Zd�Zd�Zd�Zdzd�Zd�Zd�Zd�Zd�Zd �Z d!�Z!d"�Z"d#�Z#d$�Z$d%�Z%dzd&�Z&d'�Z'd(�Z(�fd)�Z)d*�Z*d+�Z+d,�Z,e-j\f�fd-�	Z/d.�Z0d/�Z1�fd0�Z2d1�Z3d2�Z4d3�Z5e6d4d�5�d6��Z7e6d7d�5�d8��Z8e6d9d�5�d:��Z9e6d;d�5�d<��Z:e6d=d�5�d>��Z;e6d?d�5�d@��Z<e6dAd�5�dB��Z=dC�Z>dD�Z?dE�Z@dzdF�ZAdG�ZBdH�ZCdI�ZDdJ�ZEdK�ZFdL�ZGdM�ZHdN�ZIdO�ZJe6dPddQ�R�dS��ZKdT�ZLdU�ZMdV�ZNdW�ZOdzdX�ZPeQdY�dZ��ZReSdY�d[��ZTeQd\�d]��ZUeSd\�d^��ZVeQd_�d`��ZWeSd_�da��ZXeQdb�dc��ZYeSdb�dd��ZZeQde�df��Z[eSde�dg��Z\eQdh�di��Z]eSdh�dj��Z^eQdk�dl��Z_eSdk�dm��Z`eQdn�do��ZaeSdn�dp��ZbeQdq�dr��ZceSdq�ds��ZdeQdt�du��ZeeSdt�dv��ZfeQdw�dx��ZgeSdw�dy��Zh�xZiS){�SchedulerPluginaX.
	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]`irq_process` option controls whether the scheduler plugin
	applies the `isolated_cores` parameter to IRQ affinities. The default
	value is `true`, which means that the scheduler plugin will move all
	possible IRQs away from the isolated cores. When `irq_process` is set
	to `false`, the plugin will not change any IRQ affinities.

	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`
	+
	The 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`.

	* an 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"]
	----
	group.__groupname__=__rule_prio__:__sched__:__prio__:__affinity__:__regex__
	----

	Here, `__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"]
	----
	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"]
	----
	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\b
	----
	The scheduler plug-in will move all processes away from core 1 except processes which
	belong to cgroup '/daemons'. The '\b' is a regular expression
	metacharacter that matches a word boundary.
	----
	[scheduler]
	isolated_cores=1
	cgroup_ps_blacklist=\b8:blkio:
	----
	The scheduler plug-in will exclude all processes which belong to a cgroup
	with hierarchy-ID 8 and controller-list blkio.
	====

	Kernels 5.13 and newer 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`.
	Moreover in kernel 6.6 and newer support for the `sched_wakeup_granularity_ns` and
	`sched_latency_ns` were removed. The `sched_min_granularity_ns` was renamed to
	`sched_base_slice_ns`. Based on the kernel used, TuneD will write the specified
	value to the correct location or ignore it. For the compatibility the alias
	[option]`sched_base_slice_ns` was added, but the [option]`sched_min_granularity_ns`
	can be still used instead.

	.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`.
	====
	��
base_slice_ns)�wakeup_granularity_ns�min_granularity_ns�
latency_nsc�<�tjd�d|_y)Nzupython-perf unavailable, disabling perf support and runtime tuning, you can try to (re)install python(3)-perf packageF)�log�warning�_perf_availablers r�
_disable_perfzSchedulerPlugin._disable_perf�s���+�+�G�H��$�rc	
���tt|�||||||||�d|_tj
|_ttj�|_	|�o|jtjtj
�|_t|jtjtj��|_	t�|_d|_i|_d|_d|_d|_d|_d|_	t/j0�|_|j=d��|_d|_ |j=d��|_!d|_"	tG�|_$y#t4t6f$r2|j9�|jj;�|_Y��wxYw#t6$rtK�|_$YywxYw)NTz.*r�r
)�command_name�irq)&�superr�r�_has_dynamic_options�consts�CFG_DEF_DAEMON�_daemon�int�CFG_DEF_SLEEP_INTERVAL�_sleep_interval�get_bool�
CFG_DAEMONrL�CFG_SLEEP_INTERVALrr�_secure_boot_hint�_sched_knob_paths_cache�
_ps_whitelist�
_ps_blacklist�_kthread_process�_cgroup_ps_blacklist_rer��perf�cpu_map�_cpus�	NameError�AttributeErrorr��get_cpus�_storage_key�_scheduler_storage_key�_irq_process�_irq_storage_key�_evlistr+�_scheduler_utilsrr)
r�monitor_repository�storage_factory�hardware_inventory�device_matcher�device_matcher_udev�plugin_instance_factory�
global_cfg�	variables�	__class__s
         �rrzSchedulerPlugin.__init__�s�������'�(:�O�M_�ao�rE�G^�`j�lu�v�"�$���&�&�$�,��V�:�:�;�$�����%�%�f�&7�&7��9N�9N�O�4�<��j�n�n�V�-F�-F��He�He�f�g�4���j�$�)��$��!#�$���$���$���$��!#�$���$��%�����4�:�!%� 1� 1��!2�! �$���$���+�+��,��$���$�,�6�)�+�4����^�	$�%������	�	�"�"�$�4�:�	%��
�6�3�5�4��6�s$�E.�F2�.>F/�.F/�2G
�G
c	��|�y	t|�}|dkrytdtjtj|d��z�S#t$rYywxYw)Nr�)r��
ValueError�math�ceilr�)r�
mmap_pages�mps   r�_calc_mmap_pagesz SchedulerPlugin._calc_mmap_pages�s\����
���J��2��1�W�
�	�Q�$�)�)�D�H�H�R��O�,�
,�	-�-��
��
��s�A�	A�Ac��d|_d|_d|_d|_|jj|ji�|_t|j�dkDrQtjd�|j�i|_|jj|j�t�|_d|_d|_d|_t%j&|j(j+�D��cgc]J\}}|dddk(r=t|�dkDr/|j-|dd�|j.j1|�f��Lc}}�|_|j(|_|j.j1|j(d�}|j7|�}|dk(rtj9d|z�d}|�(t;|�|k7rtjd	||fz�|j4D]7}|j.j1|j4|�|j4|<�9|j<j?|j4jd
d��dk(rd|_tAjB�|_"|jF�r7|j�r*|jH�r	tKjL�|_'tKjPtJjRtJjTddddddtJjVtJjXz�
�	}|j[|j\|jN��tKj^|j\|jN�|_|jja|�|�|jjc�n|jjc|��|jHsd|_yycc}}w#|je�Y�/xYw)NFTrz0recovering scheduling settings from previous run��cgroup.�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'�runtimer�0)	�type�config�task�comm�mmap�freq�
wakeup_events�	watermark�sample_type)�cpus�threads)�pages)3r��_has_dynamic_tuning�_has_static_tuning�_runtime_tuning�_storagerLr��_scheduler_original�lenr��info�_restore_ps_affinity�unsetrE�_cgroups_original_affinityr�_cgroup_affinity_initialized�_cgroup�collections�OrderedDict�optionsrG�_sanitize_cgroup_path�
_variables�expand�_cgroups�
_schedulerr��error�strrr��	threading�Event�
_terminater�r�r��
thread_map�_threads�evsel�
TYPE_SOFTWARE�COUNT_SW_DUMMY�
SAMPLE_TID�
SAMPLE_CPU�openr��evlist�addr�r�)r�instance�optionr�perf_mmap_pages_rawr�r=r�s        r�_instance_initzSchedulerPlugin._instance_init�sb���(��!&�(�� $�(��"�(��"�]�]�.�.�����%�$����	!�	!�"�Q�&��8�8�>�?����� �4���=�=���t�2�2�3�$(�F�$�!��$�.�&+�$�#��$�,��)�)�#�+�+�1�1�3�+d�3��v�x�v�b�q�z�Y�7N�SV�W]�S^�ab�Sb�-1�,F�,F�v�a�b�z�,R�TX�Tc�Tc�Tj�Tj�ks�Tt�+u�3�+d�e�$�-�!�(�(�(�����.�.�x�/?�/?�@Q�/R�S���)�)�*=�>�/�����9�9�
Z�]p�
p�q��?�� �S��%9�=P�%P��8�8�Z��/�*�
+�,����a� �O�O�2�2�8�3F�3F�q�3I�J�8���q���	�Y�Y����+�+�/�/�	�1�=�>�#�E�#�8��!���)�(��	�\�\�h�.�.�4�3G�3G�����)�H���J�J�d�0�0��!�!�
�a��!��A��?�?�T�_�_�4�	
6�E�

�J�J�d�j�j�H�,=�,=�J�>��{�{�4�:�:�x�/@�/@�A�H�����������
������
�����?��3�
�	�	�#�8��
��I+d��D�����s�AO'
�6DO-�-Pc��|jr?|jj�D]!}tj|j��#yyr
)r��
get_pollfdr:�closer>)rr��fds   r�_instance_cleanupz!SchedulerPlugin._instance_cleanup;s9��
���
�
�
�
(�
(�
*�r��H�H�R�W�W��+�rc	��idd�dtj�dd�dd�dd�dd�d	d�d
d�dd�dd�d
d�dd�dd�dd�dd�dd�dd�dddddddd��S)N�isolated_cores�cgroup_mount_point�cgroup_mount_point_initF�cgroup_groups_initT�cgroup_for_isolated_cores�cgroup_ps_blacklist�ps_whitelist�ps_blacklist�kthread_process�irq_process�default_irq_smp_affinity�calcr��perf_process_fork�false�sched_min_granularity_ns�sched_base_slice_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��DEF_CGROUP_MOUNT_POINT)�clss r�_get_config_optionsz#SchedulerPlugin._get_config_options@s���
��T�
���6�6�
��e�
���	
�
��
��$�

��4�
��4�
��d�
��$�
��v�
��d�
���
��t�
��$�
� �t�!
�"!�$�#
�$!�"��#'�(,�(,�"&�1
�rc�@�|�t|�jdd�SdS)N�.�/)r��replacers  rr�z%SchedulerPlugin._sanitize_cgroup_path]s#��).�):��U��	�	�C��	%�D��Drc���t|tj�s|}tj|�}tj|�}|j	|�rd|zdz}|S)N�[�])�
isinstance�procfs�process�process_cmdline�_is_kthread)rr"rTrs    r�_get_cmdlinezSchedulerPlugin._get_cmdlineasT��	�G�V�^�^�	,�	�3�
�^�^�C�
 �7��"�"�7�+�'�	���g��
�7�]�S�
 �7�	�.rc��tj�}|j�i}|j�D]n}	|js|j|�r�"|j
|�}|d}|||<d|vr.|dj�D]}|j
|�}|||<��p|S#ttf$rE}|jtjk(s|jtjk(rYd}~���d}~wwxYw)NrTr�)
r!�pidstats�reload_threadsrIr�r$r%�keys�OSError�IOError�errno�ENOENT�ESRCH)r�ps�	processes�procrrT�es       r�
get_processeszSchedulerPlugin.get_processesks���
����"������)��i�i�k�d��� � �T�%5�%5�d�%;�
�
�
�
�D�
!�C�
�u�+�C��I�c�N��D���Y��$�$�&�����d�#�c��i��n�'���"
���
�G�
���w�w�%�,�,��	
���E�K�K�	�
�
���s$�B*�A
B*�*C>�9:C9�8C9�9C>c���|jj|�}|jj|�}|jj|�}tjd|||fz�||fS)Nz8Read scheduler policy '%s' and priority '%d' of PID '%d')r�rUrPrgr��debug)rrTr
�	sched_strrs     r�_get_rtzSchedulerPlugin._get_rt�sm���#�#�1�1�#�6�)��#�#�6�6�y�A�)�
�
"�
"�
/�
/��
4�(��)�)�F��(�C� �
!�"�
�X�	�rc���|jj|�}tjd|||fz�	|jj	|�}|jj|�}||ks||kDrtj
d||||fz�	|jj|||�y#ttf$r"}tj
d|z�Yd}~�Kd}~wwxYw#ttf$rk}t|d�r6|jtjk(rtjd|z�ntj
d||fz�Yd}~yYd}~yd}~wwxYw)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)
r�rPr�r5rkror��SystemErrorr*r\�hasattrr,r.)rrTrZr[r6�prio_min�prio_maxr2s        r�_set_rtzSchedulerPlugin._set_rt�sT���#�#�6�6�u�=�)��)�)�P��$���
��
��#�#�4�4�U�;�8��#�#�4�4�U�;�8�
�X�o�����I�I�I�	�H���	�������&�&�s�E�4�8��	�w�	�
��9�9�
7��	�
�
��
��
�w�	��
�a���a�g�g����4��I�I�Q���
��I�I�A�	�a�����
���s1�AB3�C'�3C$�C�C$�'E!�6AE�E!c�N�|ddtjjzdk7S)N�stat�flagsr)r!�pidstat�
PF_KTHREAD�rr"s  rr$zSchedulerPlugin._is_kthread�s%��	����	!�F�N�N�$=�$=�	=��	B�Brc��|jdk(rytj|j|j|��duS)Nr�F)r��re�search�_get_stat_cgrouprCs  r�_process_in_blacklisted_cgroupz.SchedulerPlugin._process_in_blacklisted_cgroup�s;��	�!�!�R�'�
�	���4�/�/��1F�1F�w�1O�	P�X\�	\�\rc	��|j}	|dddk(rtjd|z�y|j|�rtjd|z�y|dj	�rC|j|�rtjd|z�ytj
d|z�ytjd	||j|�fz�tjd
||j|�fz�tjd|t|jj|��fz�y#ttf$r{}|jtj k(s|jtj"k(rtjd|z�Yd}~ytj%d
||fz�Yd}~yd}~wt&t(f$r$}tj%d
||fz�Yd}~yd}~wwxYw)Nr?�state�Zz9Affinity of zombie task with PID %d could not be changed.Tz`Affinity of task with PID %d could not be changed, the task was moved into a blacklisted cgroup.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.zTask %d cmdline: %szTask %d cgroup: %szTask %d affinity: %sz6Failed to get task info for PID %d, the task vanished.z&Failed to get task info for PID %d: %sF)rTr�r5rH�is_bound_to_cpur$r�r�r%rG�listr�r_r*r+r,r-r.r�r��KeyError)rr"rTr2s    r�_ignore_set_affinity_errorz*SchedulerPlugin._ignore_set_affinity_error�s������#��
�f�o�g��#�%��I�I�I���
��
�)�)�'�2��I�I�p���
��
�f�o�%�%�'����� ��Y�Y�l�	�
��
�	�[�[�e�	�
����8�8�!�S�$�*;�*;�G�*D�$E�E�F��8�8� �C��)>�)>�w�)G�#H�H�I��8�8�"�c�4��0E�0E�0R�0R�SV�0W�+X�%Y�Y�Z�
���7�	���g�g��������E�K�K�!7��I�I�F���
���9�9�
5��Q�x����

���(�	#���9�9�
5��Q�x����	���sB�#E�)E�<E�E�2BE�G<�AG�'G�G<�G7�7G<c���	|j|}|j�|j
�||_||_yyy#t$r't|j�}||j|<Y�XwxYwr
)r�rNrrr
r)rrTr
r�paramss     r�_store_orig_process_rtz&SchedulerPlugin._store_orig_process_rt�st��*��$�$�S�)�6�����&�/�/�"9��6���6�?�#:���
�*��D�I�I�&�6�#)�4���C� �*�s�:�-A*�)A*c��d}|�|�|S	|j|�\}}|�|}|j|||�|j|||�|S#ttf$r�}t|d�rS|jtjk(r6tjd|z�||jvr
|j|=d}ntjd||fz�Yd}~|Sd}~wwxYw)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)r7r=rRr9r*r:r,r.r�r5r�r�)rrTrZr[�cont�
prev_sched�	prev_prior2s        r�_tune_process_rtz SchedulerPlugin._tune_process_rt�s���	
�$�
�]�t�|�
�;��!�\�\�#�.��J�	��m��E��<�<��U�D�!����s�J�	�:�
�+���w�	�	�
�a���a�g�g����4��I�I�M���
�
�d�&�&�&�	
�	!�	!�#�	&��D��I�I�s�	�a�����	
�+��	�s�>A
�
C�A9C�Cc�$�t|�dddk(S)Nr�r�)r�)rrs  r�_is_cgroup_affinityz#SchedulerPlugin._is_cgroup_affinity�s��	�X��r��	�i�	'�'rFc���	|j|}|j�|j
�|r||_y||_yyy#t$r't|j�}||j|<Y�[wxYwr
)r�rNrrrr)rrTr�	is_cgrouprQs     r�_store_orig_process_affinityz,SchedulerPlugin._store_orig_process_affinity�st��*��$�$�S�)�6��_�_�����!6���F�M��F�O�	"7���
�*��D�I�I�&�6�#)�4���C� �*�s�=�-A-�,A-c�
�|jjtj�dt	|��dd��d��jd�D]&}	|jd�ddd}|dk7r|cSdcSy#t$rY�5wxYw)	NrrT��no_error�
z:cpuset:rr�)r�	read_filer��PROCFS_MOUNT_POINTr��split�
IndexError)rrT�lrs    r�_get_cgroup_affinityz$SchedulerPlugin._get_cgroup_affinitys����9�9���V�-F�-F��C��RZ�[�hl��m�s�s�tx�y�a�	�
�W�W�Z�
 ��
#�A�B�
'�F��r�\�6�*�s�*�z�

���	��	�s�A6�0A6�6	B�Bc��|j|�}|j}|dk7r|�d|��}|jjd|zt	|�d��y)Nrz%s/tasksTr^)r��_cgroup_mount_pointr�
write_to_filer�)rrTr�paths    r�_set_cgroupzSchedulerPlugin._set_cgroupsP���%�%�f�-�&�	
�	!�	!�$��s�]��6�
"�4��)�)���*�t�+�S��X�$��Grc�V�|dd}t|t�xrt|�dkD}||fS)Nr�r)r rMr�)rrr[s   r�_parse_cgroup_affinityz&SchedulerPlugin._parse_cgroup_affinitys4���!�"�:�&��V�T�*�*�>�s�6�{�Q��)�	�F�	�rc�J�d}|�|S	|j|�\}}|r$|j|�}|j||�n8|j|�}|r|j	|||�}|j||�|j
|||�|S#ttf$r�}t|d�rS|jtjk(r6tjd|z�||jvr
|j|=d}ntjd||fz�Yd}~|Sd}~wwxYw)NTr,z5Failed to read affinity of PID %d, the task vanished.FzLRefusing to set CPU affinity of PID %d, reading original affinity failed: %s)rmrfrk�
_get_affinity�_get_intersect_affinity�
_set_affinityr\r9r*r:r,r.r�r5r�r�)	rrTr�	intersectrTr[r�
prev_affinityr2s	         r�_tune_process_affinityz&SchedulerPlugin._tune_process_affinity s1��	
�$�
��
�;���4�4�X�>��I�v���-�-�c�2�M����S�&�!��&�&�s�+�M���,�,��h���X�	���s�H�%��$�$�S��I��
�+���w�	�	�
�a���a�g�g����4��I�I�E���
�
�d�&�&�&�	
�	!�	!�#�	&��D��I�I�\�	�a�����	
�+��	�s�BB�D"�A9D�D"c��|j|||�}|sy|j||�}|r||jvry||j|_yr
)rWrtr�r)rrTrrZr[rrTs       r�
_tune_processzSchedulerPlugin._tune_process?sT��	
�	�	�s�E�4�	0�$�	
�	�	
�	$�	$�S�(�	3�$�	
��D�4�4�4�	�*-�$���3��'rc���|jj|�}|�|dk7rtjd|z�y	t	|�}||fS#t
$rtjd|z�YywxYw)Nrz>Invalid scheduler: %s. Scheduler and priority will be ignored.)NNz=Invalid priority: %s. Scheduler and priority will be ignored.)r�rNr�r�r�r�)rrM�str_priorityr
rs     r�_convert_sched_paramsz%SchedulerPlugin._convert_sched_paramsHs����#�#�4�4�]�C�)���=�C�/��9�9�
M����
���<� �H�
�X�	���	���I�I�M�	�����s�A�!A0�/A0c��|dk(rd}|S|j|�r|}|S|jj|�}|stj	d|z�d}|S)Nrz)Invalid affinity: %s. It will be ignored.)rYr�hex2cpulistr�r�)r�str_affinityrs   r�_convert_affinityz!SchedulerPlugin._convert_affinityWsl���S���8�
�/�����-��8�
�/��i�i�#�#�L�1�8�
��I�I�9�����H�	�/rc�l�|\}}}}}|j||�\}}|j|�}|||||fSr
)ryr})r�vals�	rule_prior
rr�regexs       r�_convert_sched_cfgz"SchedulerPlugin._convert_sched_cfgdsM��6:�3�9�i��8�U��4�4�
�x���9�h�
�
#�
#�H�
-�(�
�Y��(�E�	:�:rc��|j�d|��}	tj|tj�|jj|�dd��|jj|j�dd��d��d��stjd|z�yy#t
$r%}tjd|�d|���Yd}~��d}~wwxYw)NrzUnable to create cgroup '�': zcpuset.memsTr^z3Unable to initialize 'cpuset.mems ' for cgroup '%s')rhr:�mkdirr��DEF_CGROUP_MODEr*r�r�rrira)rrrjr2s    r�_cgroup_create_groupz$SchedulerPlugin._cgroup_create_groupks����,�,�f�	5�$�=��8�8�D�&�(�(�)��)�)�
!�
!�T�=�"A��I�I���4�#;�#;�]�K�X\��]��"��	�Y�Y�D�t�K�L���
�=��9�9�4��
;�<�<��=�s�$B�	C�'C�Cc���|j�3|j|jvr|j|j�|jD]}|j|��yr
)r�r�r��r�cgs  r�_cgroup_initialize_groupsz)SchedulerPlugin._cgroup_initialize_groupsvsI��	�\�\��d�l�l�d�m�m�&C����T�\�\�*��M�M�b����R� �
rc	��tjd�	tj|jt
j�|jjdddddd|jg�\}}|dk7r#tjd	|jz�yy#t$r"}tjd|z�Yd}~�~d}~wwxYw)
NzInitializing cgroups settingsz'Unable to create cgroup mount point: %s�mountz-trz-o�cpusetrzUnable to mount '%s')r�r5r:�makedirsrhr�r�r*r�r�execute)rr2�ret�outs    r�_cgroup_initializez"SchedulerPlugin._cgroup_initialize|s����)�)�+�,�<��;�;�t�'�'��)?�)?�@��y�y� � �'�4��4��8�UY�Um�Um�!n�o�*�3���A�X��9�9�
#�d�&>�&>�
>�?���
�<��9�9�
6��
:�;�;��<�s�.B�	C�&C�Cc��	tj|�y#t$r%}tj	d|�d|���Yd}~yd}~wwxYw)NzUnable to remove directory 'r�)r:�rmdirr*r�r�)rrr2s   r�_remove_dirzSchedulerPlugin._remove_dir�s:��B��8�8�F���	�B��9�9�f�a�
@�A�A��B�s��	A�A�Ac��t|j�D]"}|j|j�d|����$|j�D|j|jvr+|j|j�d|j���yyy)Nr)�reversedr�r�rhr�r�s  r�_cgroup_finalize_groupsz'SchedulerPlugin._cgroup_finalize_groups�sm���T�]�]�#�b����t�7�7��<�=�
$�	�\�\��d�l�l�d�m�m�&C����t�7�7����F�G�'D�rc��tjd�|jjd|jg�\}}|dk7r#tjd|jz�y|j
|j�tjj|j�}|dk7r|j
|�yy)NzRemoving cgroups settings�umountrzUnable to umount '%s'Fr)
r�r5rr�rhr�r�r:rj�dirname)rr�r��ds    r�_cgroup_finalizez SchedulerPlugin._cgroup_finalize�s����)�)�'�(��y�y� � �(�D�,D�,D�!E�F�*�3���A�X��9�9�
$�t�'?�'?�
?�@�
����4�+�+�,��g�g�o�o�d�.�.�/�!��3�h����A��rc���|dk7rtjd|�d|�d��ntjd|z�y|j�d|�dd��}|rZ|jj	|dd	�
�j�}|dk7r||j|<ntjd|z�y|jj||d	��stjd
|�d|�d��yy)Nr�zSetting cgroup 'z' affinity to '�'z.Skipping cgroup '%s', empty affinity requestedr�cpuset.cpus�ERRT��err_retr_zIRefusing to set affinity of cgroup '%s', reading original affinity failedr^zUnable to set affinity 'z' for cgroup ')	r�r5rhrra�stripr�r�ri)rrr�backuprj�
orig_affinitys      r�_cgroup_set_affinity_onez(SchedulerPlugin._cgroup_set_affinity_one�s���
��^��9�9�v�x�
H�I��9�9�
=��
F�G�	��/�/���	G�$���9�9�&�&�t�u��&�N�T�T�V�=��u��.;�D�#�#�F�+��I�I�Y�\b�b�c�
�	
���	 �	 ��x�D�	 �	A��9�9�h��
O�P�
Brc�x�|jrytjd�|j�L|j�@|j|j
vr(|j
|j|jd��|j
j�D]}|j
|d|dd���d|_y)NzSetting cgroups affinitiesT)r�rr)r�r�r5rr�r�r�rGr�s  r�_cgroup_set_affinityz$SchedulerPlugin._cgroup_set_affinity�s���	�&�&�	��)�)�(�)�	�^�^��D�L�L�$<�T�\�\�UY�Ub�Ub�Eb�� � ����t�~�~�� �M��M�M���!�b�� � ��A���1��� �=�
"�&*�$�#rc��tjd�|jj�D]}|j	|d|d��y)NzRestoring cgroups affinitiesrr)r�r5r�rGr�r�s  r�_cgroup_restore_affinityz(SchedulerPlugin._cgroup_restore_affinity�s@���)�)�*�+��+�+�1�1�3�b�� � ��A���1��.�
4rc�x��|jj|jd�|_|jj|jj|jd��dk(|_|jj|jj|jd��dk(|_|j|jj|jd��|_	|jr|j�|js|jr|j�tt|�;|�|j�	|j!�}|j*j-�D��cgc]"\}}|t/|�j1dd�f��$}}}|D��cgc]<\}}t3j4d	|�r!t7|�d
k(r||j9|�f��>}}}t;|d���}t=�}	i|_|D]�\}\}
}}}
}	t3j@|�}|j-�D��cgc] \}}t3jB||���||f��"}}}t=|D��cgc]\}}||||||
|ff��c}}�}|	jE|�t3jFddt/|��}|||
g|j>|<��|	j-�D]!\}\}}}}}
}|jI|||||
��#|jJjM|jN|jP�|jRrO|jTrBtWjX|jZ|g��|_.|j\j_�yyy#t"t$f$r"}t&j)d|z�Yd}~yd}~wwxYwcc}}wcc}}w#t2j($r,}t&j)d
t/|�z�Yd}~��d}~wwxYwcc}}wcc}}w)Nr�r��1rr�Ierror applying tuning, cannot get information about running processes: %s�:�zgroup\.�c��|ddS)Nrrr#)�option_valss r�<lambda>z8SchedulerPlugin._instance_apply_static.<locals>.<lambda>�s
��+�a�.��2Cr)�keyz(error compiling regular expression: '%s'z(?<!\\)\((?!\?)z(?:)�target�args)0r�r�r�rhrr��_cgroup_mount_point_init�_cgroup_groups_initr�r�r�r�r�r��_instance_apply_staticr�r3r*r+r�r�r�rGr�rcrE�matchr�r��sortedrE�
_sched_lookup�compilerF�update�subrvr��setr�r�r�r�r��Thread�_thread_code�_thread�start)rr�r/r2r�r�	sched_cfgr�buf�	sched_allr�r
rrr�r3rTrr0rZr�s                    �rr�z&SchedulerPlugin._instance_apply_static�s����"�_�_�3�3�H�4D�4D�EY�4Z�[�$��"&�)�)�"4�"4�T�_�_�5K�5K����-�.�60�#1�47�#8�$��!�Y�Y�/�/����0F�0F����(�)�1+�,�/2�3�$���+�+�D�O�O�,B�,B����/�0�-2�3�$�,�
�"�"�����	����!>�!>��!�!�#����5�h�?�����
�����2�
HP�GZ�GZ�G`�G`�Gb�c�Gb�m�f�e���E�
�(�(��a�0�1�Gb�)�c�!�	�!����	�x�x�
�F�#��D�	�Q���$�)�)�$�/�	0�!��	��S�C�D�)��f�)��(���@�f�?�y�)�X�x��
�
�
�
�5��A�,.�8�8�:�W�:�x�s�C����1�c�9J�9V��c�
�:�9�W��� ����c���V�Y��(�E�J�K�� �!�5����E���6�6�$�e�S��Z�8�5�$-�x��#B�8���%� �� ����?�c�>�C���H�h�����c�3�	�
�x����-�-���D�/�/�����	�\�\�h�.�.��&�&��0A�0A�8�*�U�8��������/�\��G�7�	�
��9�9�
X��	�
�	��
��d��	��
�(�(�
��I�I�8�3�u�:�E�F���
��X�� sO�%N.�'O"�AO(�3O.�P0�:P0�
P6�.O�=O�O�.P-�!P(�(P-c�z�	|j�}|j
j
�D]�\}}||vs|||jk7r�|j�3|j�'|j||j|j�|j�|j||j���|j���|j||j���i|_|jj!|j"�y#ttf$r"}tj	d|z�Yd}~yd}~wwxYw)NzKerror unapplying tuning, cannot get information about running processes: %s)r3r*r+r�r�r�rGrr
rr=rrkrrqr�r�r�)rr/r2rT�orig_paramss     rr�z$SchedulerPlugin._restore_ps_affinity�s��
�����2�
�2�2�8�8�:��c�;�	��m�r�#�w�+�"5�"5�5�����'�	�	�	�	)��L�L��k�+�+��������$����S�+�,�,�-����(����s�K�0�0�1�;� �$���-�-���d�1�1�2��#�7�	�
��9�9�
Z��	�
�	��
�s�D	�	D:�D5�5D:c��ttj�}d}|dk7r�|dkDr�|jj	|j
�d|�dd��dd��}|dvrC|j
d	�D]/}|jj|j
�dd��|d�
��1|dz}|dk7r|dkDr��|dk(rtjd|z�yy)
N� r�rr�tasksTr�)r�r�r`r^rz(Unable to cleanup tasks from cgroup '%s')
r�r��CGROUP_CLEANUP_TASKS_RETRYrrarhrcrir�r�)rr�cnt�datares     r�_cgroup_cleanup_tasks_onez)SchedulerPlugin._cgroup_cleanup_tasks_ones����F�-�-�.�#�	�$���
�s�Q�w�
�)�)�
�
�D�,D�,D�f�g�V��d��$�4�
�)��
�Z�Z��
��	�Y�Y����(@�(@�'�J�A�Z^��_���!�8�3�
	
��
�s�Q�w�	�A�X��;�;�9�F�B�C�rc���|j�3|j|jvr|j|j�|jD]}|j|��yr
)r�r�r�r�s  r�_cgroup_cleanup_tasksz%SchedulerPlugin._cgroup_cleanup_taskssI��	�\�\��d�l�l�d�m�m�&C��!�!�$�,�,�/��M�M�b��!�!�"�%�
rc���tt|�||�|jr@|jr4|j
j
�|jj�|j�|j�|j�|js|jr|j�|jr|j�yyr
)r�r��_instance_unapply_staticr�r�r�r�r��joinr�r�r�r�r�r�r�)rr��rollbackr�s   �rr�z(SchedulerPlugin._instance_unapply_static"s�������7��(�K�	�\�\�h�.�.��������������������!�����	����!>�!>����!�	�"�"�����#rc�,�tjd|z�|j�d|�dd��}|jj	|dd��}|dk(ry|jj|jj
|��}|jj|jj
|��}d|z}||k(r)tjtj||fz�ytjtj|||fz�y)	NzVerifying cgroup '%s' affinityrr�r�Tr�zcgroup '%s' affinityF)r�r5rhrra�cpulist2string�cpulist_packr�r��STR_VERIFY_PROFILE_VALUE_OKr��STR_VERIFY_PROFILE_VALUE_FAIL)rrrrj�current_affinity�affinity_descriptions      r�_cgroup_verify_affinity_onez+SchedulerPlugin._cgroup_verify_affinity_one/s����)�)�,�v�5�6��/�/���	G�$��Y�Y�(�(���4�(�P�����
��Y�Y�-�-�d�i�i�.D�.D�EU�.V�W��
�Y�Y�
%�
%�d�i�i�&<�&<�X�&F�
G�(�/�&�8����!��8�8�F�.�.��.�/�
0�1�
��9�9�V�
1�
1��.�
����rc�^�tjd�d}|j�N|j�B|j|jvr*|xr&|j|j|j�}|jj
�D]}|xr|j|d|d�}� |S)NzVeryfying cgroups affinitiesTrr)r�r5rr�r�r�rG)rr�r�s   r�_cgroup_verify_affinityz'SchedulerPlugin._cgroup_verify_affinityBs����)�)�*�+��#�	�^�^��D�L�L�$<�T�\�\�UY�Ub�Ub�Eb�	�	O��1�1�$�,�,����O�3��M�M���!�b�	�	?��1�1�"�Q�%��A��?�3�
"�	�*rc�Z��tt|�|||�}|j�}|xr|Sr
)r�r��_instance_verify_staticr�)rr��ignore_missing�devices�ret1�ret2r�s      �rr�z'SchedulerPlugin._instance_verify_staticKs1���	���	=�h��X_�	`�$�	
�	%�	%�	'�$�	
��$�rc���	tj|�}|js|j|�ry|j	|�}|jj|j||�}|�||j vrptjd||t#|�fz�|\}}	}
|j%||||	|
�|j&j)|j*|j �yyy#t
tf$rw}|jtjk(s|jtjk(rtjd|z�ntjd||fz�Yd}~yd}~wwxYw)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*r+r,r-r.r�r5r�r�	re_lookupr�r�r�rvr�r�r�)rr�rTr3r1rr2�vrZr[rs           r�_add_pidzSchedulerPlugin._add_pidPsJ��

�
�.�.��
�4�
�
�
�D�$4�$4�T�$:�
�	
�	�	�3�	�3��i�i���(�0�0�#�q�9�!��]�3�$�":�":�:��9�9�
<��S�#�a�&�?Q�
Q�R���E�4�����c�3��t�
���=�=���T�0�0�	����;�]���7�	�
��g�g�����	���5�;�;���I�I�C���
��I�I�3�	�a����	��
�s�2C/�C/�/E5�>A-E0�0E5c���||jvrV|j|=tjd|z�|jj	|j
|j�yy)Nz)removed PID %d from the rollback database)r�r�r5r�r�r�)rr�rTs   r�_remove_pidzSchedulerPlugin._remove_pidhsX���D�$�$�$�����$��9�9�
8�3�
>�?��=�=���T�0�0�	����%rc��|jj|j�}tj�}|j
j
�}|D]}|j|��|jj��s�t|j	|jdz��dkD�r;|jj��s d}|�rd}|jD�]}|j
j|�}|s�"d}t|tj �sC|j"r^t|tj$�rD|j&tj(k(r'|j+|t-|j.�|���t|tj$�s��|j&tj0k(s��|j3|t-|j.����|r��|jj�s���yy)Ni�rTF)r�re_lookup_compiler��select�pollr�r��registerr��is_setr�r�r��read_on_cpur r��
comm_event�_perf_process_fork_value�
task_eventr��RECORD_FORKr�r��tid�RECORD_EXITr�)	rr�r3r��fdsr��read_events�cpu�events	         rr�zSchedulerPlugin._thread_codeosr��
�i�i�!�!�(�"8�"8�9�!�	����$�	���#�#�%�#��b��=�=���
����&�&�(�	�$�)�)�D�(�(�4�/�
0�1�A�5�h�>Q�>Q�>X�>X�>Z��K�
��[��
�
�����*�*�3�/�e�	��{�
�U�D�O�O�
,��%�%��u�d�o�o�.��J�J�$�*�*�*��
�
�h��E�I�I���2��u�d�o�o�.�5�:�:��AQ�AQ�3Q�����3�u�y�y�>�2���	
���&�&�(�(rr)�
per_devicec��|ry|rH|�Edjtjdt|��D�cgc]}d|z��	c}�|_yyycc}w�N�|z(?<!\\);z(%s))r�rErcr�r��r�enablingr�verifyr�r�r�s       r�_cgroup_ps_blacklistz$SchedulerPlugin._cgroup_ps_blacklist�sT���
�
�%�#�"%�(�(�����VY�Z_�V`�@a�+b�@a�1�F�Q�J�@a�+b�"c�4��$�X��+b��Arc��|ry|rH|�Edjtjdt|��D�cgc]}d|z��	c}�|_yyycc}wr)r�rErcr�r�rs       rr�zSchedulerPlugin._ps_whitelist��R���
�
�%�#����b�h�h�{�C�PU�J�6W�!X�6W��&�1�*�6W�!X�Y�4��$�X��!Xr	rc��|ry|rH|�Edjtjdt|��D�cgc]}d|z��	c}�|_yyycc}wr)r�rErcr�r�rs       rr�zSchedulerPlugin._ps_blacklist�rr	rc�\�|ry|r'|�$|jj|�dk(|_yyy�Nr�)rr�r��rrrrr�r�s      rr�z SchedulerPlugin._kthread_process�s5���
�
�%�#��9�9�-�-�e�4��;�4��$�Xrrc�\�|ry|r'|�$|jj|�dk(|_yyyr)rr�r�rs      rr�zSchedulerPlugin._irq_process�s5���
�
�%�#��y�y�)�)�%�0�C�7�4��$�Xrrc�n�|ry|r0|�-|dvr||_y|jj|�|_yyy)N)r�ignore)�_default_irq_smp_affinity_valuer�cpulist_unpackrs      r�_default_irq_smp_affinityz)SchedulerPlugin._default_irq_smp_affinity�sA���
�
�%�#��!�!�+0�D�(�+/�9�9�+C�+C�E�+J�D�(�	$�Xrr	c�\�|ry|r'|�$|jj|�dk(|_yyyr)rr�r�rs      r�_perf_process_forkz"SchedulerPlugin._perf_process_fork�s5���
�
�%�#�#'�9�9�#5�#5�e�#<��#C�4� �$�Xrc�p�|jj|�}tjd||fz�|S)NzRead affinity '%s' of PID %d)r�r_r�r5)rrT�ress   rrozSchedulerPlugin._get_affinity�s3�����*�*�3�/�#��)�)�*�c�3�Z�7�8�	�*rc��tj|�}|j|�rtj	d|z�ytj	d||fz�	|j
j
||�y#ttf$r;}|j|�s tjd|||fz�Yd}~yYd}~yd}~wwxYw)NzMNot setting CPU affinity of PID %d, the task belongs to a blacklisted cgroup.z'Setting CPU affinity of PID %d to '%s'.z,Failed to set affinity of PID %d to '%s': %s)r!r"rHr�r5r�rcr9r*rOr�)rrTrr"r2s     rrqzSchedulerPlugin._set_affinity�s����N�N�3��'�	�(�(��1��9�9�
\�_b�
b�c�	��)�)�5��h��G�H�����%�%�c�8�4���w�	��
�
)�
)�'�
2��I�I�<�	�h������3���s�A8�8C�,B=�=Cc�f�t|�jt|��}|rt|�S|Sr
)r��intersectionrM)r�	affinity1�	affinity2�	affinity3�affs     rrpz'SchedulerPlugin._get_intersect_affinity�s-���I��#�#�C�	�N�3�#��
�s�)��	�rc	��|}|js!|D�cgc]}|j|�r�|��}}|D�cgc]5}tj|j|j|��	��4|��7}}|jdk7r@|D�cgc]5}tj|j|j|��	��4|��7}}t|D�cgc]}|j|f��c}�}|D]�}	|j||�}|j%||d��}
|
s�/||j&vr||j&|_|r�Td||vs�\|j+||dj-�|d���ycc}wcc}wcc}wcc}w#ttf$rx}	|	jtjk(s|	jtjk(rtj!d|z�ntj#d||	fz�Yd}	~	��d}	~	wwxYw)Nr�r�zARefusing to set affinity of PID %d, failed to get its cmdline: %sT)rrr�)r�r$rErFr��_get_stat_commr�rErTr%r*r+r,r-r.r�r5r�rtr�r�_set_all_obj_affinityrI)r�objsrr��pslr��psdrTrr2rTs           rr#z%SchedulerPlugin._set_all_obj_affinity�s���#�	
�	�	��	4�S��� 0� 0�� 3�!�S�3�	4��	)�C�q�2�9�9�T�%7�%7�������#'�(��C�#�	)�	���2���
&�S��B�I�I�d�&8�&8�	������ $�%�!�S�3�
&��#�
&�#�Q�q�u�u�a�j�#�
&�'�#�
�c�

�
�
�
�C��H�
%�C��
%�
%�c�8��&��4�
��	�T�
%�
%�%�,/�D���S�!�)�
�i�3�s�8�+����	�#�h�y�� � �"����)��
5��	)��
&��
&���G�
�
��w�w�%�,�,��	
���E�K�K�	��Y�Y�D�	�
��	�Y�Y�R�

�q������
�s@�E,�E,�5E1�*E1�5E6�9E6�E;�*F�H�A-H�Hc�B�	|dS#tttf$rYywxYw)N�cgroupsr��r*r+rN�rr4s  rrGz SchedulerPlugin._get_stat_cgroups*��
�
�I�,���
�7�H�	%�
�
�
�s���c�H�	|ddS#tttf$rYywxYw)Nr?r�r�r)r*s  rr"zSchedulerPlugin._get_stat_comm
s/��
�
�F�)�F�
���
�7�H�	%�
�
�
�s�
�!�!c��	tj�}|j�|j|j	�|d�y#t
tf$r"}tjd|z�Yd}~yd}~wwxYw)NFr�)	r!r'r(r#rIr*r+r�r�)rrr/r2s    r�_set_ps_affinityz SchedulerPlugin._set_ps_affinitysh��
�����2��������b�i�i�k�8�U�;��
�7�	�
��9�9�
X��	�
�
��
�s�AA�A9�A4�4A9c	���	|jj|�}tjd|�d|�d��d|z}t	|d�5}|j|�ddd�y#1swYyxYw#ttf$rp}t|d�r<|jtjk(r|stjd|z�Yd}~y	tjd
|�d�d|���Yd}~yd}~wwxYw)
NzSetting SMP affinity of IRQ z to 'r�z/proc/irq/%s/smp_affinity�wrr,z/Setting SMP affinity of IRQ %s is not supported���z"Failed to set SMP affinity of IRQ r����)r�cpulist2hexr�r5r��writer*r+r:r,�EIOr�)rr�r�	restoring�affinity_hex�filenamer1r2s        r�_set_irq_affinityz!SchedulerPlugin._set_irq_affinitys�����)�)�'�'��1�<��9�9��\���)�C�/�8��X�s��q��G�G�L��	�
�	�
��
�7�	�
�
�a���a�g�g����2�
��I�I�?���
�
��I�I�	�l�A�� �
��
�s=�AA1�
A%�A1�%A.�*A1�.A1�1C0�AC+�C+�+C0c�>�	|jj|�}tjd|z�t	dd�5}|j|�ddd�y#1swYyxYw#ttf$r%}tjd�d|���Yd}~yd}~wwxYw)Nz(Setting default SMP IRQ affinity to '%s'�/proc/irq/default_smp_affinityr/z+Failed to set default SMP IRQ affinity to 'r�)	rr2r�r5r�r3r*r+r�)rrr6r1r2s     r�_set_default_irq_affinityz)SchedulerPlugin._set_default_irq_affinity6s�����)�)�'�'��1�<��9�9�
7�����
-�s�3�q��G�G�L��	4�3�3��
�7�	���9�9��a������s5�?A(�A�A(�A%�!A(�%A(�(B�7B�Bc�>�t�}tj�}|j�D]�}	||d}tjd|�d|�d��|j|||�}t|�t|�k(r�S|j||d�}|dk(r||j|<�{|dk(s��|jj|���|jjd�}|jj|�}|j d	k(r|j|||�}n|j d
k7r|j }|j d
k7r|j#�||_|j&j|j(|�y#t$rY��lwxYw)NrzRead affinity of IRQ '�': 'r�Frr0r:rr)r%r!�
interruptsr)r�r5rNrpr�r8r'r)�appendrrar{rr;r(r�r�)	rr�irq_originalr'r�rsrr�prev_affinity_hexs	         r�_set_all_irq_affinityz%SchedulerPlugin._set_all_irq_affinityAsz����,�	�	�	�	�$�
�Y�Y�[�c�
���I�j�)�M��I�I�	�m����+�+�M�8�X�N�9�	�)�n��M�*�*��	
�	�	��Y��	6�3�	�Q�h�*�L���c���r�	����$�$�S�)��"�i�i�)�)�*J�K���)�)�'�'�(9�:�-�	�)�)�V�3��+�+�M�8�X�N�9��+�+�x�7��3�3�9�	�)�)�X�5��!�!�)�,�'�<���-�-���D�)�)�<�8��+�
��
�s�$F�	F�Fc�b�|jj|jd�}|�y|jj	�D]\}}|j||d��|jdk7r|j}|j|�|jj|j�y)NTr)
r�rLr�r'rGr8rr(r;r�)rr@r�rs    r�_restore_all_irq_affinityz)SchedulerPlugin._restore_all_irq_affinity`s������"�"�4�#8�#8�$�?�,���	�#�(�(�.�.�0�m�c�8����#�x��.�1�	�)�)�X�5��"�"�8��!�!�(�+��-�-���d�+�+�,rc��t|�jt|��}|r*tjtj
||fz�|Stj
tj|||fz�|Sr
)r��issubsetr�r�r�r�r�r�)r�irq_description�correct_affinityr�rs     r�_verify_irq_affinityz$SchedulerPlugin._verify_irq_affinityksz�����&�&�s�+;�'<�=�#���8�8�F�.�.��)�*�
+�,�

�*��9�9�V�
1�
1��)�����

�*rc��|jj|jd�}tj�}d}|j�D]}}||jvr.|r,d|z}tjtj|z��?	||d}tjd|�d|�d��d|z}	|j|	||�sd}�|jjd	�}
|jj!|
�}|j"d
k7r0|jd||j"dk(r|n|j"�sd}|S#t$rY��wxYw)
NTz-IRQ %s does not support changing SMP affinityrzRead SMP affinity of IRQ 'r=r�zSMP affinity of IRQ %sFr:rzdefault IRQ SMP affinityr)r�rLr�r!r>r)r)r�r�r�� STR_VERIFY_PROFILE_VALUE_MISSINGr5rIrNrrar{r)rrHr�r@r'rr��descriptionr�rG�current_affinity_hexs           r�_verify_all_irq_affinityz(SchedulerPlugin._verify_all_irq_affinitywsT�����"�"�4�#8�#8�$�?�,�	�	�	�	�$��#�
�Y�Y�[�c�	�\�
&�
&�&�>�A�C�G�K��H�H�V�
4�
4�{�
B�C��
��C�y��,���I�I�	�� �!�.��4�O��$�$������S���$���,�,�$�&���Y�Y�*�*�+?�@��	�)�)�X�5�d�>W�>W�Xr��$�*N�*N�RX�*X�&��(�(�?*�
�3�	�*���
��
�s�
>E�	E�Er��
)rrc���d}d|_|��t|jj|��}t|j�}|j|�r/t
||z
�}|jj|�|_nA|jj|j�}	tjd|�d|	�d��|s|r|�y|r|jr|j||�Sy|r]|jr |j�d|jz}
n|}
|j|
�|jr|j|�y|jr|j!�y)Nz#Invalid isolated_cores specified, 'z"' does not match available cores 'r�Tz	cgroup.%s)rr�rrr�rFrMr�r�r�r�rNr�r�r-rBrD)rrrrr�r�r�isolated�present�str_cpus�ps_affinitys           r�_isolated_coreszSchedulerPlugin._isolated_cores�s7��
�(��$�.�
���$�)�)�*�*�5�1�2�8�
����_�7����� ��G�h�&�'�H��Y�Y�-�-�h�7�D�N��y�y�'�'��
�
�3�H��I�I�	�����&�h�.�
��
����(�(��>�B�B�
��
�l�l���������,�K��K�����%�
������x�(�
�����"�"�$�	
rc�B�|dk(r|�d|��}d|zS|�d|�d|��}d|zS)Nr�rz/sys/kernel/debug/%sr#)r�prefix�	namespace�knobrjs     r�_sched_assembly_pathz$SchedulerPlugin._sched_assembly_path�s9���r�\���
%�4�
 �$�	&�&��	�4�
0�4�	�$�	&�&rc��|}|dk(r6|jj|�}|�|r|j|||�}|Sd}|S)NrZr�)�_dict_sched_knob_maprLrZ)rrjrWrXrY�lpath�lknobs       r�_sched_assembly_path2z%SchedulerPlugin._sched_assembly_path2�sU��
�%��'���$�$�(�(��.�5����
�
&�
&�v�y�%�
@�U�
�,��U�	�,rc��|�d|�d|��}|jj|�}|s|dk(r|Sd|�d|��}tjj	|�s^|j|||�}tjj	|�s|j
||||�}|dk7r|j�d|_||j|<|S)N�_r�z/proc/sys/kernel/T)r�rLr:rj�existsrZr_r�)rrWrXrYr�rjs      r�_get_sched_knob_pathz$SchedulerPlugin._get_sched_knob_path�s����i��.�#�	
�	%�	%�	)�	)�#�	.�$�	�T�R�Z�
�;��%.��	5�$�	������	�
�
#�
#�F�I�t�
<�4�
�'�'�.�.��
��%�%�d�F�I�t�D�D�
�b�j�T�+�+�3�!�D��&*�$���s�#�	
�+rc��d}|j|||�}|dk7r_|jj|d��}|�@tj	d|z�|j
rtj	d�d|_|S)Nr�)r�zError reading '%s'zUThis may not work with Secure Boot or kernel_lockdown (this hint is logged only once)F)rcrrar�r�r�)rrWrXrYr�rjs      r�_get_sched_knobzSchedulerPlugin._get_sched_knob�su��	
�$�	
�	"�	"�6�9�d�	;�$�	�R�Z�
�)�)�
�
�d�d�
�
3�4�
�l��I�I�"�T�)�*�����Y�Y�f�g�#�T��	
�+rc��|�y|j|||�}|stjd|z�y|sM|jj	|||rt
jgnd��stjd|�d|�d��|S)Nz(knob '%s' ignored, unsupported by kernelFr^zError writing value 'z' to 'r�)rcr�r5rrir,r-r�)rrWrXrYr�sim�removerjs        r�_set_sched_knobzSchedulerPlugin._set_sched_knob�sw��
�]�
�	
�	"�	"�6�9�d�	;�$�	
��9�9�
7�$�
>�?�
�	�
�)�)�
!�
!�$��!'����~�U�"�4��Y�Y�U�D�A�B�	�,rrc�(�|jddd�S�Nr�rZr��re�rr�s  r�_get_sched_min_granularity_nsz-SchedulerPlugin._get_sched_min_granularity_ns�s��	
�	�	�b�'�+?�	@�@rc�.�|jddd|||�Srk�ri�rrr�rgrhs     r�_set_sched_min_granularity_nsz-SchedulerPlugin._set_sched_min_granularity_ns�s��	
�	�	�b�'�+?���V�	T�Trrc�$�|j|�Sr
)rnrms  r�_get_sched_base_slice_nsz(SchedulerPlugin._get_sched_base_slice_ns�s��	
�	+�	+�H�	5�5rc�*�|j||||�Sr
)rrrqs     r�_set_sched_base_slice_nsz(SchedulerPlugin._set_sched_base_slice_nss��	
�	+�	+�E�8�S�&�	I�Irr
c�(�|jddd�S�Nr�rZr�rlrms  r�_get_sched_latency_nsz%SchedulerPlugin._get_sched_latency_ns���	
�	�	�b�'�<�	8�8rc�.�|jddd|||�Srxrprqs     r�_set_sched_latency_nsz%SchedulerPlugin._set_sched_latency_ns���	
�	�	�b�'�<���V�	L�Lrrc�(�|jddd�S�Nr�rZr�rlrms  r� _get_sched_wakeup_granularity_nsz0SchedulerPlugin._get_sched_wakeup_granularity_nss��	
�	�	�b�'�+B�	C�Crc�.�|jddd|||�Srrprqs     r� _set_sched_wakeup_granularity_nsz0SchedulerPlugin._set_sched_wakeup_granularity_nss��	
�	�	�b�'�+B�E�3�PV�	W�Wrrc�(�|jddd�S�Nr�rZ�tunable_scalingrlrms  r�_get_sched_tunable_scalingz*SchedulerPlugin._get_sched_tunable_scalings��	
�	�	�b�'�+<�	=�=rc�.�|jddd|||�Sr�rprqs     r�_set_sched_tunable_scalingz*SchedulerPlugin._set_sched_tunable_scalings��	
�	�	�b�'�+<�e�S�&�	Q�Qrrc�(�|jddd�S�Nr�rZ�migration_cost_nsrlrms  r�_get_sched_migration_cost_nsz,SchedulerPlugin._get_sched_migration_cost_nss��	
�	�	�b�'�+>�	?�?rc�.�|jddd|||�Sr�rprqs     r�_set_sched_migration_cost_nsz,SchedulerPlugin._set_sched_migration_cost_ns#s��	
�	�	�b�'�+>��s�F�	S�Srrc�(�|jddd�S�Nr�rZ�
nr_migraterlrms  r�_get_sched_nr_migratez%SchedulerPlugin._get_sched_nr_migrate'rzrc�.�|jddd|||�Sr�rprqs     r�_set_sched_nr_migratez%SchedulerPlugin._set_sched_nr_migrate+r}rrc�(�|jddd�S�NrZ�numa_balancing�
scan_delay_msrlrms  r�!_get_numa_balancing_scan_delay_msz1SchedulerPlugin._get_numa_balancing_scan_delay_ms/s��	
�	�	�g�'7��	I�Irc�.�|jddd|||�Sr�rprqs     r�!_set_numa_balancing_scan_delay_msz1SchedulerPlugin._set_numa_balancing_scan_delay_ms3s ��	
�	�	�g�'7��%�QT�V\�	]�]rrc�(�|jddd�S�NrZr��scan_period_min_msrlrms  r�&_get_numa_balancing_scan_period_min_msz6SchedulerPlugin._get_numa_balancing_scan_period_min_ms7���	
�	�	�g�'7�9M�	N�Nrc�.�|jddd|||�Sr�rprqs     r�&_set_numa_balancing_scan_period_min_msz6SchedulerPlugin._set_numa_balancing_scan_period_min_ms;�!��	
�	�	�g�'7�9M�u�VY�[a�	b�brrc�(�|jddd�S�NrZr��scan_period_max_msrlrms  r�&_get_numa_balancing_scan_period_max_msz6SchedulerPlugin._get_numa_balancing_scan_period_max_ms?r�rc�.�|jddd|||�Sr�rprqs     r�&_set_numa_balancing_scan_period_max_msz6SchedulerPlugin._set_numa_balancing_scan_period_max_msCr�rrc�(�|jddd�S�NrZr��scan_size_mbrlrms  r� _get_numa_balancing_scan_size_mbz0SchedulerPlugin._get_numa_balancing_scan_size_mbGs��	
�	�	�g�'7��	H�Hrc�.�|jddd|||�Sr�rprqs     r� _set_numa_balancing_scan_size_mbz0SchedulerPlugin._set_numa_balancing_scan_size_mbKs ��	
�	�	�g�'7���PS�U[�	\�\r)F)jrrr rpr\r�rr�r�r��classmethodrr�r%r3r7r=r$rHrOrRrWrYr\rfrkrmrtrvryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
ROLLBACK_SOFTr�r�r�r�r�r�r��command_customrr�r�r�r�rrrorqrpr#rGr"r-r8r;rBrDrIrNrUrZr_rcreri�command_getrn�command_setrrrtrvryr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__)r�s@rr�r��s����k�\	�'�����
%6�N
.�?$�B�
����8E���6��8C�]� �D��,(�
�	
�H���>.�
��;�	M�!�@�B�H�	�Q�"+�/�
:�x3�,D�&�:@�9M�9M���&
��
�0�3�8�&�U�;�d�<�d���e�4�Z�5�Z���e�4�Z�5�Z��"��7�<�8�<���U�3�8�4�8��+�%�@�K�A�K��$�5�9�D�:�D�
�

� � �D
�
�
��0	�9�>	-�

�
�>�!��"�E�"�F�"�H'�	�� 
���(�)�A�*�A��(�)�U�*�U��#�$�6�%�6��#�$�J�%�J�� �!�9�"�9�� �!�M�"�M��+�,�D�-�D��+�,�X�-�X��%�&�>�'�>��%�&�R�'�R��'�(�@�)�@��'�(�T�)�T�� �!�9�"�9�� �!�M�"�M��,�-�J�.�J��,�-�^�.�^��1�2�O�3�O��1�2�c�3�c��1�2�O�3�O��1�2�c�3�c��+�,�I�-�I��+�,�]�-�]rr�)!r�r�
decorators�
tuned.logs�tunedrE�
subprocessr�r��ImportErrorr��tuned.constsr�r!�tuned.utils.commandsrr,r:r�r�r,r�rv�logsrLr��objectrr%r+rr�Pluginr�r#rr�<module>r�s���
���	�������
�)��	��������j�j�n�n���5�f�5�0�F��-*�V�-*�^,�~�,�>]�d�k�k�]��A���������s#�B/�B:�/B7�6B7�:	C�C