Skip to content

Add --cpu-rt-runtime to allow Docker allocate real-time CPU time (#1235)#1236

Merged
agners merged 2 commits intohome-assistant:devfrom
agners:add-rt-scheduling-caps
Feb 25, 2021
Merged

Add --cpu-rt-runtime to allow Docker allocate real-time CPU time (#1235)#1236
agners merged 2 commits intohome-assistant:devfrom
agners:add-rt-scheduling-caps

Conversation

@agners
Copy link
Member

@agners agners commented Feb 19, 2021

No description provided.

@pvizeli
Copy link
Member

pvizeli commented Feb 20, 2021

@jens-maus
Copy link
Member

This refs #1235

@jens-maus
Copy link
Member

jens-maus commented Feb 21, 2021

I tested the changes suggested by this PR in HAos and I could reproduce that at least docker has now enough cpu.rt_runtime_us resources assigned now:

# cat /sys/fs/cgroup/cpu/docker/cpu.rt_runtime_us
950000

However, the suggested change by @pvizeli in home-assistant/supervisor#2593 seems not be enough to get each container started by docker with enough real-time shares so that applications using sched_setscheduler() are able to run correctly. So even after using a supervisor developer build with the changes by home-assistant/supervisor#2593 and the new realtime option used in config.json of the add-on ends up in ...

# cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us
0
# multimacd -l 0 -c
[...]
2021/02/21 18:55:42.923 <Warning> Could not set scheduling priority: Operation not permitted
2021/02/21 18:55:42.923 <Warning> Could not set scheduling priority: Operation not permitted
2021/02/21 18:55:42.923 <Warning> Could not set scheduling priority: Operation not permitted

Reviewing the changes suggested by home-assistant/supervisor#2593 it looks like only the --ulimit rtprio=99 option is added by the new realtime option when starting docker containers of add-ons. However, AFAIK the --cpu-rt-runtime=950000 option is also additionally required to get the cpu.rt_runtime_us cgroup raised also.

See https://docs.docker.com/config/containers/resource_constraints/#configure-the-realtime-scheduler

@pvizeli
Copy link
Member

pvizeli commented Feb 22, 2021

home-assistant/supervisor#2602

Need also an SUPERVISOR_CPU_RT=1 on the env @agners

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPERVISOR_CPU_RT=1 for supervisor startup

)

Since we have CONFIG_RT_GROUP_SCHED enabled in the Home Assistant OS
kernel the Supervisor needs to enable CPU bandwith allocation for
Add-Ons which need real-time scheduling. Set the appropriate environment
variable.
@agners agners force-pushed the add-rt-scheduling-caps branch from 9c853bd to 0f4771f Compare February 25, 2021 15:33
@agners agners merged commit 82a40de into home-assistant:dev Feb 25, 2021
@agners agners added the REL-5 label Feb 25, 2021
@agners agners mentioned this pull request Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants