sched-rt-group.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Real-Time group scheduling.
  2. The problem space:
  3. In order to schedule multiple groups of realtime tasks each group must
  4. be assigned a fixed portion of the CPU time available. Without a minimum
  5. guarantee a realtime group can obviously fall short. A fuzzy upper limit
  6. is of no use since it cannot be relied upon. Which leaves us with just
  7. the single fixed portion.
  8. CPU time is divided by means of specifying how much time can be spent
  9. running in a given period. Say a frame fixed realtime renderer must
  10. deliver 25 frames a second, which yields a period of 0.04s. Now say
  11. it will also have to play some music and respond to input, leaving it
  12. with around 80% for the graphics. We can then give this group a runtime
  13. of 0.8 * 0.04s = 0.032s.
  14. This way the graphics group will have a 0.04s period with a 0.032s runtime
  15. limit.
  16. Now if the audio thread needs to refill the DMA buffer every 0.005s, but
  17. needs only about 3% CPU time to do so, it can do with a 0.03 * 0.005s
  18. = 0.00015s.
  19. The Interface:
  20. system wide:
  21. /proc/sys/kernel/sched_rt_period_ms
  22. /proc/sys/kernel/sched_rt_runtime_us
  23. CONFIG_FAIR_USER_SCHED
  24. /sys/kernel/uids/<uid>/cpu_rt_runtime_us
  25. or
  26. CONFIG_FAIR_CGROUP_SCHED
  27. /cgroup/<cgroup>/cpu.rt_runtime_us
  28. [ time is specified in us because the interface is s32; this gives an
  29. operating range of ~35m to 1us ]
  30. The period takes values in [ 1, INT_MAX ], runtime in [ -1, INT_MAX - 1 ].
  31. A runtime of -1 specifies runtime == period, ie. no limit.
  32. New groups get the period from /proc/sys/kernel/sched_rt_period_us and
  33. a runtime of 0.
  34. Settings are constrained to:
  35. \Sum_{i} runtime_{i} / global_period <= global_runtime / global_period
  36. in order to keep the configuration schedulable.