cvra / robot-software

CVRA monorepo - All software running on our bots lives here
MIT License
43 stars 21 forks source link

Prevent page out for master-firmware memory. #302

Closed antoinealb closed 2 years ago

antoinealb commented 2 years ago

Paging out means storing part of the software's memory to disk and occurs when we use more memory than what is available on the system. This can cause high latency in some memory access, which is not possible in realtime operations. This can be prevented by "locking" some memory, which instructs the kernel to never page out memory.

This patch adds memory locking to the master firmware. As locking out memory requires special capabilities or root, the call to memory locking is put behind a flag that is disabled by default, and enabled on the robot. On the robot we must also increase the maximum mlock size, as by default it will only be a few kilobytes.

Ressources:

antoinealb commented 2 years ago

I still need to test it on hardware, I only checked that it builds.

msplr commented 2 years ago

I wonder how often paging out would happen.But it's a good idea to do this.

Another trick I heard of is CPU pinning for the real-time process to guarantee some compute resource.