커널 번역(기사,문서)

[번역] lwn - CFS bandwidth control

iamyooon 2018. 9. 7. 22:57

CFS bandwidth control

https://lwn.net/Articles/428230/

Jonathan Corbet

February 16, 2011


CFS 스케쥴러는 CPU를 두고 경쟁하는 프로세스들에게 프로세스들의 CPU utilization은 거의 같게 유지하며 CPU 시간을 나눠주기 위해 최선을 다한다. 하지만 시스템에 남은 CPU 시간이 있을때도 스케쥴러가 프로세스의 CPU utilization을  동일하게 유지하면서 CPU 시간을 나눠줄 수 있다고는 할 수 없다. 스케쥴러는 CPU를 idle 상태로 두는 대신, 남은 CPU 시간을 프로세스들에게 준다. 이런 접근법은 합당하다. 다만 더이상 CPU를 원하는 프로세스가 없을때 runnable 상태의 프로세스를 throttling하는 것에는 이유가 없다. 

The CFS scheduler does its best to divide the available CPU time between contending processes, keeping the CPU utilization of each about the same. The scheduler will not, however, insist on equal utilization when there is free CPU time available; rather than let the CPU go idle, the scheduler will give any left-over time to processes which can make use of it. This approach makes sense; there is little point in throttling runnable processes when nobody else wants the CPU anyway.


때때로 이렇게 동작하는 것을 시스템관리자가 원하는 경우는 제외한다. 이 프로세스들이 한 고객에 속해 있고 고객은 오직 특정 양의 CPU 시간에 대한 비용만 지불했거나 프로세스들간의 엄격한 CPU 자원 사용을 통제할 필요가 있는 상황에 있을 경우가 있다. 이 경우 프로세스 그룹이나 프로세스가 사용할 CPU 시간의 maximum share를 제한하는 것은 바람직할 수 있다. CFS 스케줄러는 이런식으로는 CPU 사용을 제한할 수는 없다. 하지만 Paul Turner에 의해 작성된 CFS bandwidth control 패치를 사용하면 이 상황을 바꿀 수 있다.

Except that, sometimes, that’s exactly what a system administrator may want to do. Limiting the maximum share of CPU time that a process (or group of processes) may consume can be desirable if those processes belong to a customer who has only paid for a certain amount of CPU time or in situations where it is necessary to provide strict resource-use isolation between processes. The CFS scheduler cannot limit CPU use in that manner, but the CFS bandwidth control patches, posted by Paul Turner, may change that situation.


이 패치는 CPU cgroup 메카니즘에 2개의 새로운 file을 추가한다: cpu.cfs_period_us는 태스크 그룹의 CPU 사용량을 통제할 주기(period)를 정의한다. cpu.cfs_quota_us는 태스크 그룹이 주기동안 얼마나 많은 CPU 시간을 사용할 수 있는지를 제어한다. 2개의 새로운 kernel knob을 사용하면 관리자는 쉽게 특정 태스크그룹이 지정된 양의 CPU시간만 쓰도록 제한할 수 있다. 그리고 이 제한이 금지되는 최소한의 CPU시간도 제어할 수 있다.

This patch adds a couple of new control files to the CPU control group mechanism: cpu.cfs_period_us defines the period over which the group’s CPU usage is to be regulated, and cpu.cfs_quota_us controls how much CPU time is available to the group over that period. With these two knobs, the administrator can easily limit a group to a certain amount of CPU time and also control the granularity with which that limit is enforced.


Paul의 패치는 이문제만 해결하는게 목적이 아니다. CFS의 Bharata B Rao가 제출한 hard limits patch set는 비록 구현은 다르지만 거의 동일한 기능을 제공한다.  hard limits 패치는 CPU를 사용하는것을 제한하기 위해 실시간스케쥴러의 bandwidth-limiting code의 일부를 재사용하려고 했다.

Paul’s patch is not the only one aimed at solving this problem; the CFS hard limits patch set from Bharata B Rao provides nearly identical functionality. The implementation is different, though; the hard limits patch tries to reuse some of the bandwidth-limiting code from the realtime scheduler to impose the limits.


Paul은 이 코드를 재사용할 때의 오버헤드와 CPU 시간이 거의 모두 예약된 상황에서 잘 동작할지에 대해서도 우려를 나타냈다. 그리고 이런 우려는 실제로 일어났다. 2010년 초 이후로는 hard limits 패치는 더이상 업데이트되지 않았다. 따라서 CFS bandwidth control patch가 이런 기능을 메인라인 커널에 올리기에는 적합해 보였다.

Paul has expressed concerns about the overhead of using this code and how well it will work in situations where the CPU is almost fully subscribed. These concerns appear to have carried the day – there has not been a hard limits patch posted since early 2010. So the CFS bandwidth control patches look like the form this functionality will take in the mainline.