进程忽略全局 CPUAffinity 设置

进程忽略全局 CPUAffinity 设置

我正在通过设置全局CPUAffinity /etc/systemd/system.conf。请参阅下面的片段:

root@PC1-03:~# cat /etc/systemd/system.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See systemd-system.conf(5) for details.

[Manager]
#LogLevel=info
#LogTarget=journal-or-kmsg
#LogColor=yes
#LogLocation=no
#LogTime=no
#DumpCore=yes
#ShowStatus=yes
#CrashChangeVT=no
#CrashShell=no
#CrashReboot=no
#CtrlAltDelBurstAction=reboot-force
CPUAffinity=2 3 4 5 6 7 10 11 12 13 14 15 18 19 20 21 22 23 26 27 28 29 30 31 34 35 36 37 38 39 42 43 44 45 46 47 50 51 52 53 54 55 58 59 60 61 62 63 66 67 68 69 70 71 74 75 76 77 78 79 82 83 84 85 86 87 90 91 92 93 94 95 98 99 100 101 102 103 106 107 108 109 110 111 114 115 116 117 118 119 122 123 124 125 126 127 130 131 132 133 134 135 138 139 140 141 142 143 146 147 148 149 150 151 154 155 156 157 158 159 162 163 164 165 166 167 170 171 172 173 174 175 178 179 180 181 182 183 186 187 188 189 190 191 194 195 196 197 198 199 202 203 204 205 206 207 210 211 212 213 214 215 218 219 220 221 222 223 226 227 228 229 230 231 234 235 236 237 238 239 242 243 244 245 246 247 250 251 252 253 254 255
#NUMAPolicy=default
#NUMAMask=
#RuntimeWatchdogSec=0
#RebootWatchdogSec=10min
#ShutdownWatchdogSec=10min
#KExecWatchdogSec=0
#WatchdogDevice=
#CapabilityBoundingSet=
#NoNewPrivileges=no
#SystemCallArchitectures=
#TimerSlackNSec=
#StatusUnitFormat=description
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=journal
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTimeoutAbortSec=
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
#DefaultEnvironment=
#DefaultCPUAccounting=no
#DefaultIOAccounting=no
#DefaultIPAccounting=no
#DefaultBlockIOAccounting=no
#DefaultMemoryAccounting=yes
#DefaultTasksAccounting=yes
#DefaultTasksMax=15%
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
#DefaultLimitSTACK=
#DefaultLimitCORE=
#DefaultLimitRSS=
#DefaultLimitNOFILE=1024:524288
#DefaultLimitAS=
#DefaultLimitNPROC=
#DefaultLimitMEMLOCK=
#DefaultLimitLOCKS=
#DefaultLimitSIGPENDING=
#DefaultLimitMSGQUEUE=
#DefaultLimitNICE=
#DefaultLimitRTPRIO=
#DefaultLimitRTTIME=

然而,在运行虚拟负载时,我观察到 CPU 0 上的负载为 14%。

    0[||      14.6%]   16[         0.0%]   32[         0.0%]  48[         0.0%]  64[         0.0%]  80[         0.0%]  96[         0.0%] 112[         0.0%]   128[         0.0%]  144[         0.0%]  160[         0.0%] 176[         0.0%] 192[         0.0%] 208[         0.0%] 224[         0.0%] 240[         0.0%]
    1[         0.0%]   17[         0.0%]   33[         0.0%]  49[         0.0%]  65[         0.0%]  81[         0.0%]  97[         0.0%] 113[         0.0%]   129[         0.0%]  145[         0.0%]  161[         0.0%] 177[         0.0%] 193[         0.0%] 209[         0.0%] 225[         0.0%] 241[         0.0%]
    2[|||||||100.0%]   18[|||||||100.0%]   34[|||||||100.0%]  50[|||||||100.0%]  66[|||||||100.0%]  82[|||||||100.0%]  98[|||||||100.0%] 114[|||||||100.0%]   130[|||||||100.0%]  146[|||||||100.0%]  162[|||||||100.0%] 178[|||||||100.0%] 194[|||||||100.0%] 210[|||||||100.0%] 226[|||||||100.0%] 242[|||||||100.0%]
    3[|||||||100.0%]   19[|||||||100.0%]   35[|||||||100.0%]  51[|||||||100.0%]  67[|||||||100.0%]  83[|||||||100.0%]  99[|||||||100.0%] 115[|||||||100.0%]   131[|||||||100.0%]  147[|||||||100.0%]  163[|||||||100.0%] 179[|||||||100.0%] 195[|||||||100.0%] 211[|||||||100.0%] 227[|||||||100.0%] 243[|||||||100.0%]
    4[|||||||100.0%]   20[|||||||100.0%]   36[|||||||100.0%]  52[|||||||100.0%]  68[|||||||100.0%]  84[|||||||100.0%] 100[|||||||100.0%] 116[|||||||100.0%]   132[|||||||100.0%]  148[|||||||100.0%]  164[|||||||100.0%] 180[|||||||100.0%] 196[|||||||100.0%] 212[|||||||100.0%] 228[|||||||100.0%] 244[|||||||100.0%]
    5[|||||||100.0%]   21[|||||||100.0%]   37[|||||||100.0%]  53[|||||||100.0%]  69[|||||||100.0%]  85[|||||||100.0%] 101[|||||||100.0%] 117[|||||||100.0%]   133[|||||||100.0%]  149[|||||||100.0%]  165[|||||||100.0%] 181[|||||||100.0%] 197[|||||||100.0%] 213[|||||||100.0%] 229[|||||||100.0%] 245[|||||||100.0%]
    6[|||||||100.0%]   22[|||||||100.0%]   38[|||||||100.0%]  54[|||||||100.0%]  70[|||||||100.0%]  86[|||||||100.0%] 102[|||||||100.0%] 118[|||||||100.0%]   134[|||||||100.0%]  150[|||||||100.0%]  166[|||||||100.0%] 182[|||||||100.0%] 198[|||||||100.0%] 214[|||||||100.0%] 230[|||||||100.0%] 246[|||||||100.0%]
    7[|||||||100.0%]   23[|||||||100.0%]   39[|||||||100.0%]  55[|||||||100.0%]  71[|||||||100.0%]  87[|||||||100.0%] 103[|||||||100.0%] 119[|||||||100.0%]   135[|||||||100.0%]  151[|||||||100.0%]  167[|||||||100.0%] 183[|||||||100.0%] 199[|||||||100.0%] 215[|||||||100.0%] 231[|||||||100.0%] 247[|||||||100.0%]
    8[         0.0%]   24[         0.0%]   40[         0.0%]  56[         0.0%]  72[         0.0%]  88[         0.0%] 104[         0.0%] 120[         0.0%]   136[         0.0%]  152[         0.0%]  168[         0.0%] 184[         0.0%] 200[         0.0%] 216[         0.0%] 232[         0.0%] 248[         0.0%]
    9[         0.0%]   25[         0.0%]   41[         0.0%]  57[         0.0%]  73[         0.0%]  89[         0.0%] 105[         0.0%] 121[         0.0%]   137[         0.0%]  153[         0.0%]  169[         0.0%] 185[         0.0%] 201[         0.0%] 217[         0.0%] 233[         0.0%] 249[         0.0%]
   10[|||||||100.0%]   26[|||||||100.0%]   42[|||||||100.0%]  58[|||||||100.0%]  74[|||||||100.0%]  90[|||||||100.0%] 106[|||||||100.0%] 122[|||||||100.0%]   138[|||||||100.0%]  154[|||||||100.0%]  170[|||||||100.0%] 186[|||||||100.0%] 202[|||||||100.0%] 218[|||||||100.0%] 234[|||||||100.0%] 250[|||||||100.0%]
   11[|||||||100.0%]   27[|||||||100.0%]   43[|||||||100.0%]  59[|||||||100.0%]  75[|||||||100.0%]  91[|||||||100.0%] 107[|||||||100.0%] 123[|||||||100.0%]   139[|||||||100.0%]  155[|||||||100.0%]  171[|||||||100.0%] 187[|||||||100.0%] 203[|||||||100.0%] 219[|||||||100.0%] 235[|||||||100.0%] 251[|||||||100.0%]
   12[|||||||100.0%]   28[|||||||100.0%]   44[|||||||100.0%]  60[|||||||100.0%]  76[|||||||100.0%]  92[|||||||100.0%] 108[|||||||100.0%] 124[|||||||100.0%]   140[|||||||100.0%]  156[|||||||100.0%]  172[|||||||100.0%] 188[|||||||100.0%] 204[|||||||100.0%] 220[|||||||100.0%] 236[|||||||100.0%] 252[|||||||100.0%]
   13[|||||||100.0%]   29[|||||||100.0%]   45[|||||||100.0%]  61[|||||||100.0%]  77[|||||||100.0%]  93[|||||||100.0%] 109[|||||||100.0%] 125[|||||||100.0%]   141[|||||||100.0%]  157[|||||||100.0%]  173[|||||||100.0%] 189[|||||||100.0%] 205[|||||||100.0%] 221[|||||||100.0%] 237[|||||||100.0%] 253[|||||||100.0%]
   14[|||||||100.0%]   30[|||||||100.0%]   46[|||||||100.0%]  62[|||||||100.0%]  78[|||||||100.0%]  94[|||||||100.0%] 110[|||||||100.0%] 126[|||||||100.0%]   142[|||||||100.0%]  158[|||||||100.0%]  174[|||||||100.0%] 190[|||||||100.0%] 206[|||||||100.0%] 222[|||||||100.0%] 238[|||||||100.0%] 254[|||||||100.0%]
   15[|||||||100.0%]   31[|||||||100.0%]   47[|||||||100.0%]  63[|||||||100.0%]  79[|||||||100.0%]  95[|||||||100.0%] 111[|||||||100.0%] 127[|||||||100.0%]   143[|||||||100.0%]  159[|||||||100.0%]  175[|||||||100.0%] 191[|||||||100.0%] 207[|||||||100.0%] 223[|||||||100.0%] 239[|||||||100.0%] 255[|||||||100.0%]

我检查了核心上运行的进程,仍然存在一些进程。

下面的小片段。

root@PC1-03:~# ps -A -o psr,pid,args | grep '^ *0' | head -n 25
  0       3 [rcu_gp]
  0       4 [rcu_par_gp]
  0       5 [netns]
  0       7 [kworker/0:0H-events_highpri]
  0       9 [kworker/0:1H-events_highpri]
  0      11 [mm_percpu_wq]
  0      12 [rcu_tasks_kthread]
  0      13 [rcu_tasks_rude_kthread]
  0      14 [rcu_tasks_trace_kthread]
  0      15 [ksoftirqd/0]
  0      17 [migration/0]
  0      18 [kworker/0:1-events]
  0      19 [cpuhp/0]
  0      94 [kworker/15:0H]
  0     110 [kworker/18:0H]
  0     120 [kworker/20:0H]
  0     125 [kworker/21:0H]
  0     130 [kworker/22:0H]
  0     140 [kworker/24:0H]
  0     145 [kworker/25:0H]
  0     165 [kworker/29:0H]
  0     170 [kworker/30:0H]
  0     186 [kworker/33:0H]
  0     216 [kworker/39:0H]
  0     221 [kworker/40:0H]

我是否需要设置额外的配置以确保某些内容不会在我不希望的核心上运行?

答案1

这些进程是内核进程,不受控制systemd

要查看“正常”进程,请使用pstree.您可以在那里看到流程依赖性。

相关内容