편집하다:현재 해결되지 않은 오류가 있습니다.이것.
편집 2chrt
: 이 문제의 해결 방법은 아래에 설명된 방법을 사용하는 것입니다 .
편집 3: 이 문제는 이제 v252에서 해결되었습니다.https://github.com/systemd/systemd/commit/40c05a34595ed769ce676206f3c5de874f9a9234
임베디드 시스템에서 PREEMT_RT 패치를 사용하여 Debian Buster 5.4.91을 실행합니다. systemd
버전은 247입니다.
프로세스를 실시간 우선순위로 설정해 보세요. systemd.service 장치에서 로컬로 프로세스의 실시간 우선 순위를 설정할 수 없습니다.
거기에는 여러 개의 링크가 있으며 그 중 하나의 제목이 적절합니다.내 서비스는 실시간으로 제공되지 않습니다!이것은 올바른 방향을 가리키는 것 같지만 제대로 작동하도록 할 수는 없습니다.
내 서비스 파일에 있는 내용은 다음과 같습니다.
[Service]
RestrictRealtime=false
LimitRTPRIO=infinity
CPUSchedulingPriority=99
CPUSchedulingPolicy=rr
IOSchedulingClass=realtime
IOSchedulingPriority=3
ExecStart=/usr/bin/local/foo.bar
Type=notify
....
귀찮게도 내가 설정하면
[Service]
LimitRTPRIO=infinity
ExecStart=/usr/bin/chrt --rr 99 /usr/bin/local/foo.bar
루트가 아닌 사용자에게도 원하는 결과를 얻었습니다.
왜 systemd 자체에서는 이 작업을 허용하지 않습니까?
편집하다systemctl show
:요청 시 덤프:
Type=notify
Restart=always
NotifyAccess=main
RestartUSec=3s
TimeoutStartUSec=3s
TimeoutStopUSec=2s
TimeoutAbortUSec=2s
TimeoutStartFailureMode=terminate
TimeoutStopFailureMode=terminate
RuntimeMaxUSec=infinity
WatchdogUSec=3s
WatchdogTimestamp=Thu 2021-01-28 18:42:01 UTC
WatchdogTimestampMonotonic=426381837441
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=4758
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
UID=107
GID=113
NRestarts=0
OOMPolicy=stop
ExecMainStartTimestamp=Thu 2021-01-28 18:40:40 UTC
ExecMainStartTimestampMonotonic=426300331189
ExecMainExitTimestampMonotonic=0
ExecMainPID=4758
ExecMainCode=0
ExecMainStatus=0
ExecStart={ path=/usr/local/bin/foo.bar ; argv[]=/usr/local/bin/foo.bar --daemonize ; ignore_errors=no ; start_time=[Thu 2021-01-28 18:40:40 UTC] ; stop_time=[n/a] ; pid=4758 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/usr/local/bin/foo.bar; argv[]=/usr/local/bin/foo.bar --daemonize ; flags= ; start_time=[Thu 2021-01-28 18:40:40 UTC] ; stop_time=[n/a] ; pid=4758 ; code=(null) ; status=0/0 }
ExecReload={ path=/bin/kill ; argv[]=/bin/kill -HUP $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecReloadEx={ path=/bin/kill ; argv[]=/bin/kill -HUP $MAINPID ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
Slice=system.slice
ControlGroup=/system.slice/foo.bar.service
MemoryCurrent=1081344
CPUUsageNSec=6725421000
EffectiveCPUs=
EffectiveMemoryNodes=
TasksCurrent=5
IPIngressBytes=[no data]
IPIngressPackets=[no data]
IPEgressBytes=[no data]
IPEgressPackets=[no data]
IOReadBytes=18446744073709551615
IOReadOperations=18446744073709551615
IOWriteBytes=18446744073709551615
IOWriteOperations=18446744073709551615
Delegate=no
CPUAccounting=yes
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
CPUQuotaPeriodUSec=infinity
AllowedCPUs=
AllowedMemoryNodes=
IOAccounting=no
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=no
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=yes
DefaultMemoryLow=0
DefaultMemoryMin=0
MemoryMin=0
MemoryLow=0
MemoryHigh=infinity
MemoryMax=infinity
MemorySwapMax=infinity
MemoryLimit=infinity
DevicePolicy=auto
TasksAccounting=yes
TasksMax=1061
IPAccounting=no
ManagedOOMSwap=auto
ManagedOOMMemoryPressure=auto
ManagedOOMMemoryPressureLimitPercent=0%
Environment=PATH=/usr/local/bin:/usr/bin:/bin
EnvironmentFiles=/etc/environment (ignore_errors=no)
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=0
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=524288
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=3539
LimitNPROCSoft=3539
LimitMEMLOCK=65536
LimitMEMLOCKSoft=65536
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=3539
LimitSIGPENDINGSoft=3539
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=infinity
LimitRTPRIOSoft=infinity
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
WorkingDirectory=/opt/foo
RootHashSignature=
OOMScoreAdjust=0
CoredumpFilter=0x33
Nice=0
IOSchedulingClass=1
IOSchedulingPriority=3
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
CPUAffinity=
CPUAffinityFromNUMA=no
NUMAPolicy=n/a
NUMAMask=
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardInputData=
StandardOutput=journal
StandardError=journal
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SyslogLevel=6
SyslogFacility=3
LogLevelMax=-1
LogRateLimitIntervalUSec=0
LogRateLimitBurst=0
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap
AmbientCapabilities=
User=foo
Group=foo
DynamicUser=no
RemoveIPC=no
MountFlags=
PrivateTmp=yes
PrivateDevices=no
ProtectClock=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectKernelLogs=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
PrivateMounts=no
ProtectHome=read-only
ProtectSystem=full
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=2147483646
LockPersonality=no
RuntimeDirectoryPreserve=no
RuntimeDirectoryMode=0755
RuntimeDirectory=foo
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
LogsDirectory=foo
ConfigurationDirectoryMode=0755
TimeoutCleanUSec=infinity
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictSUIDSGID=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
ProtectProc=default
ProcSubset=all
ProtectHostname=no
KillMode=mixed
KillSignal=15
RestartKillSignal=15
FinalKillSignal=9
SendSIGKILL=yes
SendSIGHUP=no
WatchdogSignal=6
Id=foo.bar.service
Names=foo.bar.service
Requires=sysinit.target var.mount system.slice -.mount tmp.mount
PartOf=foo.service
Conflicts=shutdown.target
Before=shutdown.target
After=systemd-journald.socket sysinit.target var.mount -.mount systemd-remount-fs.service tmp.mount sys-subsystem-net-devices-can1.device systemd-tmpfiles-setup.service sys-subsystem-net-devices-eth0.2.device system.slice basic.target
RequiresMountsFor=/run/foo /var/log/foo /opt/foo /tmp /var/tmp
Description=foo bar
LoadState=loaded
ActiveState=active
FreezerState=running
SubState=running
FragmentPath=/lib/systemd/system/foo.bar.service
UnitFileState=disabled
UnitFilePreset=enabled
StateChangeTimestamp=Thu 2021-01-28 18:40:40 UTC
StateChangeTimestampMonotonic=426300816780
InactiveExitTimestamp=Thu 2021-01-28 18:40:40 UTC
InactiveExitTimestampMonotonic=426300357891
ActiveEnterTimestamp=Thu 2021-01-28 18:40:40 UTC
ActiveEnterTimestampMonotonic=426300816780
ActiveExitTimestamp=Thu 2021-01-28 18:40:39 UTC
ActiveExitTimestampMonotonic=426300199732
InactiveEnterTimestamp=Thu 2021-01-28 18:40:40 UTC
InactiveEnterTimestampMonotonic=426300244778
CanStart=yes
CanStop=yes
CanReload=yes
CanIsolate=no
CanClean=runtime logs
CanFreeze=yes
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Thu 2021-01-28 18:40:40 UTC
ConditionTimestampMonotonic=426300306353
AssertTimestamp=Thu 2021-01-28 18:40:40 UTC
AssertTimestampMonotonic=426300306377
Transient=no
Perpetual=no
StartLimitIntervalUSec=1s
StartLimitBurst=3
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=3250e79f3cdc43268f1de989ad58b14b
CollectMode=inactive