3

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?

1
  • 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, 2019 at 6:58

1 Answer 1

0

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

What you've configured means 50% of a cpu core/HT, it doesn't means 50% of the whole system.

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

The same as the above, there isn't any oversubscription, it just means the two process can use 0.5 cpu and 0.9 cpu time each. To understand, consider the case if there were 20 cpu core/HT in your system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .