← Documents Documentation/scheduler/sched-bwc.rst GitHub 원문 ↗

Linux 6.18.37 · Scheduler

CFS bandwidth control

cgroup CPU quota, period, runtime slice, burst와 hierarchical throttling 통계를 설명합니다.

Source pathDocumentation/scheduler/sched-bwc.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

Period마다 지급되는 CPU runtime

sched-bwc.rst:1-24

CFS bandwidth control은 task group에 period와 quota를 설정하여 일정 구간에 사용할 수 있는 CPU time을 제한합니다. Group의 runnable task가 여러 CPU에서 동시에 실행하면 quota는 wall-clock보다 빠르게 소모될 수 있습니다.

Runtime이 소진되면 group의 CFS runqueue가 throttled되고 다음 period에서 quota가 보충될 때까지 실행하지 못합니다. 이는 task priority가 낮아지는 것이 아니라 실행 자격 자체가 잠시 중단되는 것입니다.

Burst로 평균 quota와 순간 demand 분리

sched-bwc.rst:25-67

Burst allowance는 이전에 사용하지 않은 runtime 일부를 모아 짧은 demand spike에 사용할 수 있게 합니다. 평균 CPU budget을 유지하면서 tail latency를 줄일 수 있지만 여러 group이 동시에 burst하면 host 전체 contention이 커집니다.

Burst는 보장된 CPU reservation이 아니라 통계적 slack 사용입니다. Deadline이 엄격한 workload에는 SCHED_DEADLINE admission과 RT bandwidth 같은 별도 mechanism을 검토합니다.

cgroup v1·v2 설정과 runtime slice

sched-bwc.rst:68-124
# cgroup v2: quota 50ms / period 100ms
cat cpu.max
50000 100000

# 제한 해제
max 100000

Kernel은 global group runtime pool에서 각 CPU runqueue로 sched_cfs_bandwidth_slice_us 단위 runtime을 전달합니다. Slice가 너무 작으면 accounting lock traffic이 늘고 너무 크면 CPU별로 남은 runtime이 흩어져 quota 활용과 throttling 반응이 거칠어질 수 있습니다.

Throttling 통계

sched-bwc.rst:125-140
항목의미
nr_periodsbandwidth period가 지난 횟수
nr_throttledperiod 중 한 번 이상 throttled된 횟수
throttled_usecgroup runnable entity가 throttled 상태였던 누적 시간
nr_burstsburst runtime을 사용한 period 수
burst_usecquota를 초과해 사용한 누적 runtime

Hierarchical quota와 caveat

sched-bwc.rst:141-205

Child group은 자신의 quota뿐 아니라 parent의 남은 runtime에도 제한됩니다. Child quota 합이 parent보다 커도 각 child가 동시에 사용하면 parent가 먼저 throttled될 수 있습니다. Effective CPU capacity와 cpuset 범위까지 함께 계산해야 합니다.

짧은 period와 작은 quota는 timer, accounting과 migration overhead를 키웁니다. Per-CPU runtime이 일부 남아 있는데 다른 CPU task가 throttled되는 일시적 imbalance도 생길 수 있어 application latency를 통계와 함께 측정합니다.

설정 예와 해석

sched-bwc.rst:206-247

100ms period에 50ms quota는 한 CPU 기준 평균 50%이지만 두 CPU에서 25ms씩 동시에 실행해도 quota가 끝납니다. Quota를 CPU 개수처럼 해석하지 말고 모든 CPU에서 소비한 runtime의 합으로 봅니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =====================
2 CFS Bandwidth Control
3 =====================
4
5 .. note::
6 This document only discusses CPU bandwidth control for SCHED_NORMAL.
7 The SCHED_RT case is covered in Documentation/scheduler/sched-rt-group.rst
8
9 CFS bandwidth control is a CONFIG_FAIR_GROUP_SCHED extension which allows the
10 specification of the maximum CPU bandwidth available to a group or hierarchy.
11
12 The bandwidth allowed for a group is specified using a quota and period. Within
13 each given "period" (microseconds), a task group is allocated up to "quota"
14 microseconds of CPU time. That quota is assigned to per-cpu run queues in
15 slices as threads in the cgroup become runnable. Once all quota has been
16 assigned any additional requests for quota will result in those threads being
17 throttled. Throttled threads will not be able to run again until the next
18 period when the quota is replenished.
19
20 A group's unassigned quota is globally tracked, being refreshed back to
21 cfs_quota units at each period boundary. As threads consume this bandwidth it
22 is transferred to cpu-local "silos" on a demand basis. The amount transferred
23 within each of these updates is tunable and described as the "slice".
24
25 Burst feature
26 -------------
27 This feature borrows time now against our future underrun, at the cost of
28 increased interference against the other system users. All nicely bounded.
29
30 Traditional (UP-EDF) bandwidth control is something like:
31
32 (U = \Sum u_i) <= 1
33
34 This guaranteeds both that every deadline is met and that the system is
35 stable. After all, if U were > 1, then for every second of walltime,
36 we'd have to run more than a second of program time, and obviously miss
37 our deadline, but the next deadline will be further out still, there is
38 never time to catch up, unbounded fail.
39
40 The burst feature observes that a workload doesn't always executes the full
41 quota; this enables one to describe u_i as a statistical distribution.
42
43 For example, have u_i = {x,e}_i, where x is the p(95) and x+e p(100)
44 (the traditional WCET). This effectively allows u to be smaller,
45 increasing the efficiency (we can pack more tasks in the system), but at
46 the cost of missing deadlines when all the odds line up. However, it
47 does maintain stability, since every overrun must be paired with an
48 underrun as long as our x is above the average.
49
50 That is, suppose we have 2 tasks, both specify a p(95) value, then we
51 have a p(95)*p(95) = 90.25% chance both tasks are within their quota and
52 everything is good. At the same time we have a p(5)p(5) = 0.25% chance
53 both tasks will exceed their quota at the same time (guaranteed deadline
54 fail). Somewhere in between there's a threshold where one exceeds and
55 the other doesn't underrun enough to compensate; this depends on the
56 specific CDFs.
57
58 At the same time, we can say that the worst case deadline miss, will be
59 \Sum e_i; that is, there is a bounded tardiness (under the assumption
60 that x+e is indeed WCET).
61
62 The interference when using burst is valued by the possibilities for
63 missing the deadline and the average WCET. Test results showed that when
64 there many cgroups or CPU is under utilized, the interference is
65 limited. More details are shown in:
66 https://lore.kernel.org/lkml/[email protected]/
67
68 Management
69 ----------
70 Quota, period and burst are managed within the cpu subsystem via cgroupfs.
71
72 .. note::
73 The cgroupfs files described in this section are only applicable
74 to cgroup v1. For cgroup v2, see
75 :ref:`Documentation/admin-guide/cgroup-v2.rst <cgroup-v2-cpu>`.
76
77 - cpu.cfs_quota_us: run-time replenished within a period (in microseconds)
78 - cpu.cfs_period_us: the length of a period (in microseconds)
79 - cpu.stat: exports throttling statistics [explained further below]
80 - cpu.cfs_burst_us: the maximum accumulated run-time (in microseconds)
81
82 The default values are::
83
84 cpu.cfs_period_us=100ms
85 cpu.cfs_quota_us=-1
86 cpu.cfs_burst_us=0
87
88 A value of -1 for cpu.cfs_quota_us indicates that the group does not have any
89 bandwidth restriction in place, such a group is described as an unconstrained
90 bandwidth group. This represents the traditional work-conserving behavior for
91 CFS.
92
93 Writing any (valid) positive value(s) no smaller than cpu.cfs_burst_us will
94 enact the specified bandwidth limit. The minimum quota allowed for the quota or
95 period is 1ms. There is also an upper bound on the period length of 1s.
96 Additional restrictions exist when bandwidth limits are used in a hierarchical
97 fashion, these are explained in more detail below.
98
99 Writing any negative value to cpu.cfs_quota_us will remove the bandwidth limit
100 and return the group to an unconstrained state once more.
101
102 A value of 0 for cpu.cfs_burst_us indicates that the group can not accumulate
103 any unused bandwidth. It makes the traditional bandwidth control behavior for
104 CFS unchanged. Writing any (valid) positive value(s) no larger than
105 cpu.cfs_quota_us into cpu.cfs_burst_us will enact the cap on unused bandwidth
106 accumulation.
107
108 Any updates to a group's bandwidth specification will result in it becoming
109 unthrottled if it is in a constrained state.
110
111 System wide settings
112 --------------------
113 For efficiency run-time is transferred between the global pool and CPU local
114 "silos" in a batch fashion. This greatly reduces global accounting pressure
115 on large systems. The amount transferred each time such an update is required
116 is described as the "slice".
117
118 This is tunable via procfs::
119
120 /proc/sys/kernel/sched_cfs_bandwidth_slice_us (default=5ms)
121
122 Larger slice values will reduce transfer overheads, while smaller values allow
123 for more fine-grained consumption.
124
125 Statistics
126 ----------
127 A group's bandwidth statistics are exported via 5 fields in cpu.stat.
128
129 cpu.stat:
130
131 - nr_periods: Number of enforcement intervals that have elapsed.
132 - nr_throttled: Number of times the group has been throttled/limited.
133 - throttled_time: The total time duration (in nanoseconds) for which entities
134 of the group have been throttled.
135 - nr_bursts: Number of periods burst occurs.
136 - burst_time: Cumulative wall-time (in nanoseconds) that any CPUs has used
137 above quota in respective periods.
138
139 This interface is read-only.
140
141 Hierarchical considerations
142 ---------------------------
143 The interface enforces that an individual entity's bandwidth is always
144 attainable, that is: max(c_i) <= C. However, over-subscription in the
145 aggregate case is explicitly allowed to enable work-conserving semantics
146 within a hierarchy:
147
148 e.g. \Sum (c_i) may exceed C
149
150 [ Where C is the parent's bandwidth, and c_i its children ]
151
152
153 There are two ways in which a group may become throttled:
154
155 a. it fully consumes its own quota within a period
156 b. a parent's quota is fully consumed within its period
157
158 In case b) above, even though the child may have runtime remaining it will not
159 be allowed to until the parent's runtime is refreshed.
160
161 CFS Bandwidth Quota Caveats
162 ---------------------------
163 Once a slice is assigned to a cpu it does not expire. However all but 1ms of
164 the slice may be returned to the global pool if all threads on that cpu become
165 unrunnable. This is configured at compile time by the min_cfs_rq_runtime
166 variable. This is a performance tweak that helps prevent added contention on
167 the global lock.
168
169 The fact that cpu-local slices do not expire results in some interesting corner
170 cases that should be understood.
171
172 For cgroup cpu constrained applications that are cpu limited this is a
173 relatively moot point because they will naturally consume the entirety of their
174 quota as well as the entirety of each cpu-local slice in each period. As a
175 result it is expected that nr_periods roughly equal nr_throttled, and that
176 cpuacct.usage will increase roughly equal to cfs_quota_us in each period.
177
178 For highly-threaded, non-cpu bound applications this non-expiration nuance
179 allows applications to briefly burst past their quota limits by the amount of
180 unused slice on each cpu that the task group is running on (typically at most
181 1ms per cpu or as defined by min_cfs_rq_runtime). This slight burst only
182 applies if quota had been assigned to a cpu and then not fully used or returned
183 in previous periods. This burst amount will not be transferred between cores.
184 As a result, this mechanism still strictly limits the task group to quota
185 average usage, albeit over a longer time window than a single period. This
186 also limits the burst ability to no more than 1ms per cpu. This provides
187 better more predictable user experience for highly threaded applications with
188 small quota limits on high core count machines. It also eliminates the
189 propensity to throttle these applications while simultaneously using less than
190 quota amounts of cpu. Another way to say this, is that by allowing the unused
191 portion of a slice to remain valid across periods we have decreased the
192 possibility of wastefully expiring quota on cpu-local silos that don't need a
193 full slice's amount of cpu time.
194
195 The interaction between cpu-bound and non-cpu-bound-interactive applications
196 should also be considered, especially when single core usage hits 100%. If you
197 gave each of these applications half of a cpu-core and they both got scheduled
198 on the same CPU it is theoretically possible that the non-cpu bound application
199 will use up to 1ms additional quota in some periods, thereby preventing the
200 cpu-bound application from fully using its quota by that same amount. In these
201 instances it will be up to the CFS algorithm (see sched-design-CFS.rst) to
202 decide which application is chosen to run, as they will both be runnable and
203 have remaining quota. This runtime discrepancy will be made up in the following
204 periods when the interactive application idles.
205
206 Examples
207 --------
208 1. Limit a group to 1 CPU worth of runtime::
209
210 If period is 250ms and quota is also 250ms, the group will get
211 1 CPU worth of runtime every 250ms.
212
213 # echo 250000 > cpu.cfs_quota_us /* quota = 250ms */
214 # echo 250000 > cpu.cfs_period_us /* period = 250ms */
215
216 2. Limit a group to 2 CPUs worth of runtime on a multi-CPU machine
217
218 With 500ms period and 1000ms quota, the group can get 2 CPUs worth of
219 runtime every 500ms::
220
221 # echo 1000000 > cpu.cfs_quota_us /* quota = 1000ms */
222 # echo 500000 > cpu.cfs_period_us /* period = 500ms */
223
224 The larger period here allows for increased burst capacity.
225
226 3. Limit a group to 20% of 1 CPU.
227
228 With 50ms period, 10ms quota will be equivalent to 20% of 1 CPU::
229
230 # echo 10000 > cpu.cfs_quota_us /* quota = 10ms */
231 # echo 50000 > cpu.cfs_period_us /* period = 50ms */
232
233 By using a small period here we are ensuring a consistent latency
234 response at the expense of burst capacity.
235
236 4. Limit a group to 40% of 1 CPU, and allow accumulate up to 20% of 1 CPU
237 additionally, in case accumulation has been done.
238
239 With 50ms period, 20ms quota will be equivalent to 40% of 1 CPU.
240 And 10ms burst will be equivalent to 20% of 1 CPU::
241
242 # echo 20000 > cpu.cfs_quota_us /* quota = 20ms */
243 # echo 50000 > cpu.cfs_period_us /* period = 50ms */
244 # echo 10000 > cpu.cfs_burst_us /* burst = 10ms */
245
246 Larger buffer setting (no larger than quota) allows greater burst capacity.
247

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

CFS 대역폭 제어

1-23

이 문서는 SCHED_NORMAL에 대한 CPU 대역폭 제어만 다룬다. SCHED_RT의 경우는 Documentation/scheduler/sched-rt-group.rst에서 설명한다.

CFS 대역폭 제어는 CONFIG_FAIR_GROUP_SCHED의 확장 기능으로, 하나의 그룹 또는 계층에 제공할 수 있는 최대 CPU 대역폭을 지정하게 한다.

그룹에 허용되는 대역폭은 quota와 period로 지정한다. 각 period(마이크로초) 안에서 task group에는 최대 quota 마이크로초의 CPU 시간이 할당된다. cgroup의 thread가 runnable 상태가 되면 이 quota를 slice 단위로 per-CPU run queue에 나누어 준다. 모든 quota가 배분된 뒤 추가 quota 요청이 들어오면 해당 thread는 throttling된다. throttling된 thread는 다음 period가 시작되어 quota가 보충될 때까지 다시 실행할 수 없다.

아직 배분되지 않은 그룹 quota는 전역에서 추적하며 period 경계마다 cfs_quota 값으로 갱신한다. thread가 대역폭을 소비하면 필요한 시점에 전역 pool의 실행 시간을 CPU-local silo로 옮긴다. 한 번 갱신할 때 옮기는 양은 조정할 수 있으며 이를 slice라고 부른다.

Burst 기능

25-66

Burst 기능은 다른 시스템 사용자에 대한 간섭이 늘어나는 대가로, 앞으로 발생할 underrun을 담보 삼아 현재 실행 시간을 빌린다. 다만 그 양은 명확한 한계 안에 머문다.

전통적인 단일 프로세서 EDF(UP-EDF) 대역폭 제어는 다음 조건으로 표현할 수 있다.

(U = \Sum u_i) <= 1

이 조건은 모든 deadline을 지킬 수 있고 시스템도 안정적이라는 사실을 보장한다. U가 1보다 크면 벽시계 시간 1초마다 1초보다 많은 프로그램 실행 시간을 처리해야 하므로 deadline을 놓친다. 다음 deadline은 더 뒤로 밀리고 이를 따라잡을 시간은 영원히 생기지 않아 실패량이 제한 없이 커진다.

그러나 workload가 항상 quota 전체를 쓰지는 않는다는 점을 이용하면 u_i를 통계 분포로 기술할 수 있다. 예를 들어 u_i = {x,e}_i에서 x를 p(95), x+e를 p(100), 즉 전통적인 WCET로 둘 수 있다. 그러면 u를 더 작게 잡아 한 시스템에 더 많은 task를 배치할 수 있지만, 불리한 경우가 동시에 겹치면 deadline을 놓칠 수 있다. 그래도 x가 평균보다 크다면 모든 overrun에는 underrun이 대응하므로 안정성은 유지된다.

두 task가 모두 p(95)를 지정했다고 하자. 두 task가 모두 quota 안에 들어올 확률은 p(95)×p(95)=90.25%이다. 반대로 두 task가 동시에 quota를 초과할 확률은 p(5)×p(5)=0.25%이며 이 경우 deadline 실패가 확정된다. 한쪽이 초과하고 다른 쪽의 underrun이 이를 충분히 보상하지 못하는 경계는 두 workload의 구체적인 CDF에 따라 달라진다.

x+e가 실제 WCET라는 가정 아래 최악의 deadline 지연은 \Sum e_i로 제한된다. Burst 사용에 따른 간섭은 deadline을 놓칠 가능성과 평균 WCET로 평가한다. 시험 결과 cgroup 수가 많거나 CPU 활용률이 낮을 때에는 간섭이 제한적이었다.

cgroupfs를 통한 관리

68-109

Quota, period, burst는 cgroupfs의 cpu subsystem에서 관리한다.

이 절에서 설명하는 cgroupfs 파일은 cgroup v1에만 적용된다. cgroup v2는 Documentation/admin-guide/cgroup-v2.rst의 cgroup-v2-cpu 절을 참조한다.

  • cpu.cfs_quota_us: 한 period마다 보충되는 실행 시간(마이크로초)
  • cpu.cfs_period_us: period의 길이(마이크로초)
  • cpu.stat: 아래에서 설명하는 throttling 통계
  • cpu.cfs_burst_us: 누적할 수 있는 최대 실행 시간(마이크로초)

기본값은 다음과 같다.

cpu.cfs_period_us=100ms
cpu.cfs_quota_us=-1
cpu.cfs_burst_us=0

cpu.cfs_quota_us가 -1이면 그룹에 대역폭 제한이 없다는 뜻이며 이를 unconstrained bandwidth group이라고 한다. 이것은 CFS의 전통적인 work-conserving 동작을 나타낸다.

cpu.cfs_burst_us 이상인 유효한 양수를 quota와 period에 기록하면 지정한 대역폭 제한이 적용된다. quota와 period에 허용되는 최소값은 1ms이고, period 길이의 상한은 1초이다. 계층적으로 대역폭 제한을 사용할 때에는 아래에 설명하는 제약이 추가된다. cpu.cfs_quota_us에 음수를 기록하면 제한을 제거하여 그룹을 다시 unconstrained 상태로 돌린다.

cpu.cfs_burst_us가 0이면 그룹은 사용하지 않은 대역폭을 축적할 수 없으므로 기존 CFS 대역폭 제어 동작이 그대로 유지된다. cpu.cfs_quota_us 이하인 유효한 양수를 cpu.cfs_burst_us에 기록하면 미사용 대역폭 누적량에 상한을 둔다. 대역폭 명세를 갱신할 때 그룹이 constrained 상태로 throttling되어 있었다면 즉시 unthrottle된다.

시스템 전역 설정

111-123

효율을 위해 실행 시간은 전역 pool과 CPU-local silo 사이에서 batch 단위로 이동한다. 대규모 시스템에서 전역 accounting에 가해지는 압력을 크게 낮추며, 한 번 갱신할 때 옮기는 양을 slice라고 한다.

/proc/sys/kernel/sched_cfs_bandwidth_slice_us (default=5ms)

slice 값을 크게 하면 전송 overhead가 줄고, 작게 하면 실행 시간을 더 세밀한 단위로 소비할 수 있다.

통계

125-139

그룹의 대역폭 통계는 cpu.stat의 다섯 field로 노출된다.

field의미
nr_periods지금까지 경과한 enforcement interval 수
nr_throttled그룹이 throttling 또는 제한된 횟수
throttled_time그룹 entity들이 throttling된 전체 시간(나노초)
nr_burstsburst가 발생한 period 수
burst_time각 period에서 CPU들이 quota를 초과하여 사용한 누적 벽시계 시간(나노초)

이 interface는 읽기 전용이다.

계층 구조에서 고려할 사항

141-159

Interface는 개별 entity의 대역폭이 언제나 실제로 제공 가능한 값이 되도록 max(c_i) <= C를 강제한다. 반면 계층 안에서 work-conserving 의미를 유지하기 위해 전체 합의 oversubscription은 명시적으로 허용한다.

\Sum (c_i) may exceed C

C: 부모의 대역폭
c_i: 각 자식의 대역폭

그룹이 throttling되는 경우는 두 가지다. 첫째, 한 period 안에서 자신의 quota를 모두 소비한 경우이다. 둘째, 부모가 자신의 period 안에서 quota를 모두 소비한 경우이다. 두 번째 경우에는 자식에게 실행 시간이 남아 있어도 부모 실행 시간이 갱신될 때까지 실행할 수 없다.

CFS bandwidth quota의 주의 사항

161-204

한번 CPU에 할당된 slice에는 만료 시간이 없다. 다만 해당 CPU의 모든 thread가 unrunnable 상태가 되면 slice에서 1ms만 남기고 나머지는 전역 pool로 돌려보낼 수 있다. 남겨 두는 값은 compile time 변수 min_cfs_rq_runtime으로 설정한다. 전역 lock의 추가 경합을 막기 위한 성능 조정이다.

CPU 사용량 제한에 계속 걸리는 CPU-bound cgroup application은 매 period마다 quota 전체와 CPU-local slice 전체를 자연스럽게 소비하므로 이 특성이 거의 문제되지 않는다. 이런 workload에서는 nr_periods와 nr_throttled가 대체로 비슷하고, cpuacct.usage도 각 period마다 cfs_quota_us와 비슷한 양만큼 증가할 것으로 예상한다.

thread가 많지만 CPU-bound가 아닌 application에서는 CPU-local slice가 만료되지 않는 특성 때문에 여러 CPU에 남아 있던 미사용 slice만큼 quota를 잠깐 초과할 수 있다. 일반적으로 CPU당 최대 1ms이며 정확한 값은 min_cfs_rq_runtime이 정한다. 이전 period에 특정 CPU로 quota를 옮겼지만 모두 사용하거나 반환하지 않은 경우에만 이 짧은 burst가 가능하다. 남은 양은 core 사이에서 이동하지 않는다.

따라서 단일 period보다 긴 관찰 구간에서는 task group의 평균 사용량이 여전히 quota로 엄격히 제한되고 burst도 CPU당 1ms를 넘지 않는다. Core 수가 많고 quota가 작은 highly-threaded application의 동작을 더 예측 가능하게 하며, CPU 사용량이 quota보다 적은데도 불필요하게 throttling되는 상황을 줄인다. 즉, slice의 미사용 부분을 period 경계 너머에서도 유효하게 두어 전체 slice가 필요하지 않은 CPU-local silo에서 quota가 낭비되며 만료될 가능성을 낮춘다.

CPU-bound application과 CPU-bound가 아닌 interactive application 사이의 상호 작용도 고려해야 하며, 특히 한 core의 사용률이 100%일 때 중요하다. 두 application에 각각 CPU core의 절반을 주고 둘 다 같은 CPU에 배치하면 interactive application이 어떤 period에는 최대 1ms의 quota를 더 쓸 수 있고, 그만큼 CPU-bound application이 자신의 quota를 모두 쓰지 못할 수 있다. 둘 다 runnable이고 quota가 남아 있으므로 어느 쪽을 실행할지는 CFS가 결정한다. 이 실행 시간 차이는 interactive application이 idle 상태가 되는 뒤의 period에서 보상된다.

설정 예

206-246

1. CPU 한 개 분량의 실행 시간

period와 quota가 모두 250ms이면 그룹은 250ms마다 CPU 한 개 분량의 실행 시간을 받는다.

# echo 250000 > cpu.cfs_quota_us  /* quota = 250ms */
# echo 250000 > cpu.cfs_period_us /* period = 250ms */

2. 여러 CPU가 있는 시스템에서 CPU 두 개 분량

period가 500ms이고 quota가 1000ms이면 그룹은 500ms마다 CPU 두 개 분량의 실행 시간을 받을 수 있다. period가 더 길기 때문에 burst capacity도 커진다.

# echo 1000000 > cpu.cfs_quota_us /* quota = 1000ms */
# echo 500000 > cpu.cfs_period_us  /* period = 500ms */

3. CPU 한 개의 20%

period 50ms와 quota 10ms는 CPU 한 개의 20%에 해당한다. 짧은 period를 사용하면 burst capacity를 희생하는 대신 latency 응답을 일정하게 유지할 수 있다.

# echo 10000 > cpu.cfs_quota_us /* quota = 10ms */
# echo 50000 > cpu.cfs_period_us /* period = 50ms */

4. CPU 한 개의 40%와 추가 burst 20%

period 50ms와 quota 20ms는 CPU 한 개의 40%에 해당한다. 여기에 burst 10ms를 설정하면 대역폭이 미리 축적된 경우 CPU 한 개의 20%를 추가로 사용할 수 있다.

# echo 20000 > cpu.cfs_quota_us /* quota = 20ms */
# echo 50000 > cpu.cfs_period_us /* period = 50ms */
# echo 10000 > cpu.cfs_burst_us /* burst = 10ms */

quota 이하의 범위에서 buffer 값을 크게 설정할수록 burst capacity가 커진다.