2

I've been trying to understand how the Completely Fair Scheduler in the Linux kernel does CPU bandwidth control.

After many readings, I still cannot understand how the CFS allows for each cgroup to define its own CFS period and how that ties in to the kernel.sched_cfs_bandwidth_slice_us sysctl setting.

Example A: On a single CPU machine and there are two cgroups with different CFS periods defined. The quotas of each cgroup represent 50% of CPU time, totalling 100%.

cgroup-A: cpu.cfs_period_us=100ms
          cpu.cfs_quota_us=50ms
cgroup-B: cpu.cfs_period_us=1000ms
          cpu.cfs_quota_us=500ms

If each cgroup has a single process running, how are these processes scheduled given the CFS period (assuming both processes constantly require CPU time)?

Example B: What happens when cgroup-B have a higher quota than what's actually physically possible to fulfill, ie. cgroup-B set a 90% of the CPU time, and cgroup-A continues to set a quota to be 50% of the CPU time.

cgroup-A: cpu.cfs_period_us=100ms
          cpu.cfs_quota_us=50ms
cgroup-B: cpu.cfs_period_us=1000ms
          cpu.cfs_quota_us=900ms

How would CFS schedule the processes in this case when the quota is oversubscribed?

  • I think by typing this question out... I'm starting to gain some clarity. Correct me if I'm wrong here. If cfs_period and quota is merely used for accounting, where the period is a timer which periodically reset the usage in CPU time per cgroup - and where quota is used to compare with actual usage. Then only if the usage exceeds quota during the evaluation period, do the process get throttled and pre-empted. Does that sound sane? – Otto Yiu Mar 9 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.