Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time fixes #2630

Merged
merged 3 commits into from
Feb 25, 2021
Merged

Real-time fixes #2630

merged 3 commits into from
Feb 25, 2021

Conversation

agners
Copy link
Member

@agners agners commented Feb 25, 2021

  • Fix path of cpu.rt_runtime_us sysfs file

Fix detection of CPU bandwidth allocation (CONFIG_RT_GROUP_SCHED) option
by checking the correct file location.

  • Set priority limit and memory lock limit

Set a soft limit of real-time priority 90 and hard limit of 99. The
maximum is 99, to avoid add-ons using such a high priority without
second thought set the soft limit to 90. This allows a process to higher
the limit to 99, if really required.

Also set max locked memory to 128MB. Locking memory from getting paged
out is often used for the real-time process/thread to avoid delays due
to swapping/pageing in. Ideally a real-time process should only do the
real-time job, hence not need too much memory.

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

Fix detection of CPU bandwidth allocation (CONFIG_RT_GROUP_SCHED) option
by checking the correct file location.
Set a soft limit of real-time priority 90 and hard limit of 99. The
maximum is 99, to avoid add-ons using such a high priority without
second thought set the soft limit to 90. This allows a process to higher
the limit to 99, if really required.

Also set max locked memory to 128MB. Locking memory from getting paged
out is often used for the real-time process/thread to avoid delays due
to swapping/pageing in. Ideally a real-time process should only do the
real-time job, hence not need too much memory.
@agners
Copy link
Member Author

agners commented Feb 25, 2021

@jens-maus not sure what priority your add-on will use, but I'd recommend to use something lower than 90. it will still be the highest priority in the system (aside from some special kernel threads).

@pvizeli pvizeli added the refactor A code change that neither fixes a bug nor adds a feature label Feb 25, 2021
@pvizeli pvizeli merged commit baa86f0 into home-assistant:main Feb 25, 2021
@@ -265,8 +265,12 @@ def ulimits(self) -> Optional[List[docker.types.Ulimit]]:
limits: List[docker.types.Ulimit] = []

# Need schedule functions
if self.addon.with_realtime and self.sys_docker.info.support_cpu_realtime:

Choose a reason for hiding this comment

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

@agners Did you remove the self.sys_docker.info.support_cpu_realtime on purpose? Because this seems to skip the check if the system (kernel) has CONFIG_RT_GROUP_SCHED or not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed refactor A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants