+
     GiG  c                   s    ^RI Ht ^RI5 ^ RIt^RI Ht ^ RIHt ^ RIH	t	 ^ RI
t
^ RIt]P                  P                  4       t ! R R]P                  4      tR# )i   )base)Z*N)
exceptions)commandsc                   s   a a ] tR t^t oRtV 3R ltR tR t]R 4       t	R t
R tR tR	 tR
 tR tR t]P$                  3R ltR t]! RRR7      R 4       tRtVtV ;t# )SystemdPlugina  
Plug-in for tuning systemd options.

The [option]`cpu_affinity` option allows setting CPUAffinity in
`/etc/systemd/system.conf`. This configures the CPU affinity for the
service manager as well as the default CPU affinity for all forked
off processes. The option takes a comma-separated list of CPUs with
optional CPU ranges specified by the minus sign (`-`).

.Set the CPUAffinity for `systemd` to `0 1 2 3`
====
----
[systemd]
cpu_affinity=0-3
----
====

NOTE: These tunings are unloaded only on profile change followed by a reboot.
c                s
  < \         P                  P                  \        P                  4      '       g,   \
        P                  ! R \        P                  ,          4      h\        \        V `&  ! V/ VB  \        4       V n        R# )zERequired systemd '%s' configuration file not found, disabling plugin.N)ospathZisfileconstsSYSTEMD_SYSTEM_CONF_FILEr   ZNotSupportedPluginExceptionZsuperr   __init__r   _cmd)selfZargsZkwargs	__class__s   &*,A/usr/lib/python3.14/site-packages/tuned/plugins/plugin_systemd.pyr   ZSystemdPlugin.__init__"   sl    	77	8	8		/	/0w  {A  {Z  {Z  1Z  
[  [t%t6v6j$)    c                s"    R Vn         RVn        R# )FTN)Z_has_dynamic_tuningZ_has_static_tuningr
   instance   &&r   _instance_initZSystemdPlugin._instance_init(   s    !&( $(r   c                s    R # N r   r   r   _instance_cleanupZSystemdPlugin._instance_cleanup,   s    r   c                s
    R R/# )cpu_affinityNr   )Zcls   &r   _get_config_optionsZ!SystemdPlugin._get_config_options/   s     4
 r   c                s    Ve\   \         P                  ! RV,           R,           V\         P                  R7      pVe#   VP                  ^8X  d   VP	                  ^4      # R # )N^\s*z\s*=\s*(.*)$Zflags)reZsearch	MULTILINEZ	lastindexZgroup)r
   confkeyZmos   &&& r   _get_keyvalZSystemdPlugin._get_keyval5   sH    	
		'C-/14N2n*88A;	r   c                sF   \         P                  ! R V,           R,           R\        V4      ,           V\         P                  R7      w  rEV^8  dA    VR,          R8w  d
   VR,          pYR,           \        T4      ,           R,           ,          pT# V#   \         d     L7i ; i)z^(\s*z\s*=).*$z\g<1>r   Z
Z=i)r   Zsubnstrr   Z
IndexError)r
   r   r   ZvalZconf_newZnsubss   &&&&  r   _add_keyvalZSystemdPlugin._add_keyval=   s    gghn{:Hs3x<OQU_a_k_kl8
QY	Bx4	T\T 9s3x$&&4
;	/	  		s   B B B c                sn    \         P                  ! R V,           R,           RV\         P                  R7      # )r   z\s*=.*\n r   )r   subr   )r
   r   r      &&&r   _del_keyZSystemdPlugin._del_keyI   s$    	#+Rr||	LLr   c                s    V P                   P                  \        P                  R R7      pVf   \        P                  R4       R # V# )N)err_retz(error reading systemd configuration file)r	   	read_filer   r   logerror)r
   Zsystemd_system_conf   & r   _read_systemd_system_confZ'SystemdPlugin._read_systemd_system_confL   s?    		++F,K,KW[+\ 9978
	r   c                s   \         P                  \         P                  ,           pV P                  P	                  W!4      '       g5   \
        P                  R 4       V P                  P                  VRR7       R# V P                  P                  V\         P                  4      '       gJ   \
        P                  R\         P                  ,          4       V P                  P                  VRR7       R# R# )z(error writing systemd configuration fileT)no_errorFz/error replacing systemd configuration file '%s')	r   r   ZTMP_FILE_SUFFIXr	   write_to_filer'   r(   unlinkZrename)r
   r   Ztmpfiles   && r   _write_systemd_system_confZ(SystemdPlugin._write_systemd_system_confS   s    ++f.D.DD'		 	 	/	/997899G-
 
		'6#B#B	C	C99>A`A``a99G-
	r   c                sr    \         P                  P                  \        P                  V P
                  4      # r   )r   r   joinr   ZPERSISTENT_STORAGE_DIRZname)r
   r   r   _get_storage_filenameZ#SystemdPlugin._get_storage_filenamea   s!    	f33TYY	??r   c                sr   V P                  4       pVe   V P                  4       pV P                  P                  VR RR7      pV P                  P	                  V4       Vf"   V P                  V\        P                  4      pM!V P                  V\        P                  V4      pV P                  V4       R # R # )NTr%   r+   )
r*   r0   r	   r&   r-   r$   r   SYSTEMD_CPUAFFINITY_VARr    r.   )r
   r   fnamecpu_affinity_saveds   &   r   _remove_systemd_tuningZ$SystemdPlugin._remove_systemd_tuningd   s    		'	'	)$
%%'5		++ETd+S99E ==v==>DD&"@"@BTUD""4( r   c                s    V\         P                  8X  dR   \        P                  R \         P                  ,          4       V P                  4        \        P                  R4       R# R# )z6removing '%s' systemd tuning previously added by TuneDz[you may need to manualy run 'dracut -f' to update the systemd configuration in initrd imageN)r   ZROLLBACK_FULLr'   infor2   r5   Zconsole)r
   r   Zrollbackr#   r   _instance_unapply_staticZ&SystemdPlugin._instance_unapply_staticp   sF    %%%88DvGeGeef ;;lm &r   c                s    Vf   R# RP                  R V P                  P                  \        P                  ! RR\        P                  ! RRV4      4      4       4       4      # )Nr!    c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   Z.0vr)   r   	<genexpr>Z8SystemdPlugin._cpulist_convert_unpack.<locals>.<genexpr>z   s     q"pQ#a&&"p   z\s+Z,z,\s+)r/   r	   cpulist_unpackr   r"   )r
   Zcpulistr   r   _cpulist_convert_unpackZ%SystemdPlugin._cpulist_convert_unpackw   sN    _
	q$))":":266&$PRPVPVW^`dfmPn;o"pq	qqr   r   F)Z
per_devicec           	     sl   R pR pV P                   P                  V P                  P                  V P                   P	                  V4      4      4      pRP                  R V P                   P                  V4       4       4      p	V P                  4       p
V
e2   V P                  V
\        P                  4      pV P                  V4      pV'       d   V P                  RWV4      # V'       d   V P                  4       pV P                   P                  VR RR7      pVe(   Vf$   W8w  d   V P                   P                  WRR7       \         P#                  R\        P                  : RV	: R	\        P$                  : R
24       V P'                  V P)                  V
\        P                  V	4      4       R# R # )Nr8   c              3   r9   r   r:   r;   r)   r   r=   Z)SystemdPlugin._cmdline.<locals>.<genexpr>   s     D(C1A(Cr>   r   Tr1   )Zmakedirz	setting 'z' to 'z
' in the 'Z')r	   ZunescapeZ
_variablesZexpandZunquoter/   r?   r*   r   r   r2   r@   Z_verify_valuer0   r&   r,   r'   r6   r   r.   r    )r
   ZenablingZvalueZverifyZignore_missingr   Zconf_affinityZconf_affinity_unpackedr<   Z
v_unpackedr   r3   r4   s   &&&&&&       r   _cmdlineZSystemdPlugin._cmdline|   sX   -
ii//		0A0A%0HIJ!xxD		(@(@(CDD*		'	'	)$	##D&*H*HI= 88G


^ZQ_
``%%'5		++ETd+S$6$>:CgIIEDA88&2P2PR\^d^}^}~""4#3#3D&:X:XZd#ef
	r   )r	   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r   r   r   Zclassmethodr   r   r    r$   r*   r.   r0   r5   r   ZROLLBACK_SOFTr7   r@   Zcommand_customrA   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r   r   r      s     (%  

M@
) :@9M9M nr
 e4 5 r   r   )r!   r    Z
decoratorsZ
tuned.logsZtunedr   Ztuned.utils.commandsr   Ztuned.constsr   r   r   ZlogsZgetr'   ZPluginr   r   r   r   <module>rB      s?        )  	 	jjnnDDKK Dr   