usphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget'/translations/zh_CN/scheduler/sched-bwcmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/zh_TW/scheduler/sched-bwcmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/it_IT/scheduler/sched-bwcmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/ja_JP/scheduler/sched-bwcmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/ko_KR/scheduler/sched-bwcmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/sp_SP/scheduler/sched-bwcmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hCFS Bandwidth Controlh]hCFS Bandwidth Control}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhA/var/lib/git/docbuild/linux/Documentation/scheduler/sched-bwc.rsthKubhnote)}(hThis document only discusses CPU bandwidth control for SCHED_NORMAL. The SCHED_RT case is covered in Documentation/scheduler/sched-rt-group.rsth]h paragraph)}(hThis document only discusses CPU bandwidth control for SCHED_NORMAL. The SCHED_RT case is covered in Documentation/scheduler/sched-rt-group.rsth]hThis document only discusses CPU bandwidth control for SCHED_NORMAL. The SCHED_RT case is covered in Documentation/scheduler/sched-rt-group.rst}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hCFS bandwidth control is a CONFIG_FAIR_GROUP_SCHED extension which allows the specification of the maximum CPU bandwidth available to a group or hierarchy.h]hCFS bandwidth control is a CONFIG_FAIR_GROUP_SCHED extension which allows the specification of the maximum CPU bandwidth available to a group or hierarchy.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hXThe bandwidth allowed for a group is specified using a quota and period. Within each given "period" (microseconds), a task group is allocated up to "quota" microseconds of CPU time. That quota is assigned to per-cpu run queues in slices as threads in the cgroup become runnable. Once all quota has been assigned any additional requests for quota will result in those threads being throttled. Throttled threads will not be able to run again until the next period when the quota is replenished.h]hXThe bandwidth allowed for a group is specified using a quota and period. Within each given “period” (microseconds), a task group is allocated up to “quota” microseconds of CPU time. That quota is assigned to per-cpu run queues in slices as threads in the cgroup become runnable. Once all quota has been assigned any additional requests for quota will result in those threads being throttled. Throttled threads will not be able to run again until the next period when the quota is replenished.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hX)A group's unassigned quota is globally tracked, being refreshed back to cfs_quota units at each period boundary. As threads consume this bandwidth it is transferred to cpu-local "silos" on a demand basis. The amount transferred within each of these updates is tunable and described as the "slice".h]hX3A group’s unassigned quota is globally tracked, being refreshed back to cfs_quota units at each period boundary. As threads consume this bandwidth it is transferred to cpu-local “silos” on a demand basis. The amount transferred within each of these updates is tunable and described as the “slice”.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h Burst featureh]h Burst feature}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hThis feature borrows time now against our future underrun, at the cost of increased interference against the other system users. All nicely bounded.h]hThis feature borrows time now against our future underrun, at the cost of increased interference against the other system users. All nicely bounded.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h9Traditional (UP-EDF) bandwidth control is something like:h]h9Traditional (UP-EDF) bandwidth control is something like:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh block_quote)}(h(U = \Sum u_i) <= 1 h]h)}(h(U = \Sum u_i) <= 1h]h(U = Sum u_i) <= 1}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hj,ubah}(h]h ]h"]h$]h&]uh1j*hhhK hhhhubh)}(hXDThis guaranteeds both that every deadline is met and that the system is stable. After all, if U were > 1, then for every second of walltime, we'd have to run more than a second of program time, and obviously miss our deadline, but the next deadline will be further out still, there is never time to catch up, unbounded fail.h]hXFThis guaranteeds both that every deadline is met and that the system is stable. After all, if U were > 1, then for every second of walltime, we’d have to run more than a second of program time, and obviously miss our deadline, but the next deadline will be further out still, there is never time to catch up, unbounded fail.}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK"hhhhubh)}(hThe burst feature observes that a workload doesn't always executes the full quota; this enables one to describe u_i as a statistical distribution.h]hThe burst feature observes that a workload doesn’t always executes the full quota; this enables one to describe u_i as a statistical distribution.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hhhhubh)}(hXFor example, have u_i = {x,e}_i, where x is the p(95) and x+e p(100) (the traditional WCET). This effectively allows u to be smaller, increasing the efficiency (we can pack more tasks in the system), but at the cost of missing deadlines when all the odds line up. However, it does maintain stability, since every overrun must be paired with an underrun as long as our x is above the average.h]hXFor example, have u_i = {x,e}_i, where x is the p(95) and x+e p(100) (the traditional WCET). This effectively allows u to be smaller, increasing the efficiency (we can pack more tasks in the system), but at the cost of missing deadlines when all the odds line up. However, it does maintain stability, since every overrun must be paired with an underrun as long as our x is above the average.}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK+hhhhubh)}(hXThat is, suppose we have 2 tasks, both specify a p(95) value, then we have a p(95)*p(95) = 90.25% chance both tasks are within their quota and everything is good. At the same time we have a p(5)p(5) = 0.25% chance both tasks will exceed their quota at the same time (guaranteed deadline fail). Somewhere in between there's a threshold where one exceeds and the other doesn't underrun enough to compensate; this depends on the specific CDFs.h]hXThat is, suppose we have 2 tasks, both specify a p(95) value, then we have a p(95)*p(95) = 90.25% chance both tasks are within their quota and everything is good. At the same time we have a p(5)p(5) = 0.25% chance both tasks will exceed their quota at the same time (guaranteed deadline fail). Somewhere in between there’s a threshold where one exceeds and the other doesn’t underrun enough to compensate; this depends on the specific CDFs.}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hhhhubh)}(hAt the same time, we can say that the worst case deadline miss, will be \Sum e_i; that is, there is a bounded tardiness (under the assumption that x+e is indeed WCET).h]hAt the same time, we can say that the worst case deadline miss, will be Sum e_i; that is, there is a bounded tardiness (under the assumption that x+e is indeed WCET).}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hhhhubh)}(hXGThe interference when using burst is valued by the possibilities for missing the deadline and the average WCET. Test results showed that when there many cgroups or CPU is under utilized, the interference is limited. More details are shown in: https://lore.kernel.org/lkml/5371BD36-55AE-4F71-B9D7-B86DC32E3D2B@linux.alibaba.com/h](hThe interference when using burst is valued by the possibilities for missing the deadline and the average WCET. Test results showed that when there many cgroups or CPU is under utilized, the interference is limited. More details are shown in: }(hjhhhNhNubh reference)}(hThttps://lore.kernel.org/lkml/5371BD36-55AE-4F71-B9D7-B86DC32E3D2B@linux.alibaba.com/h]hThttps://lore.kernel.org/lkml/5371BD36-55AE-4F71-B9D7-B86DC32E3D2B@linux.alibaba.com/}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhK>hhhhubeh}(h] burst-featureah ]h"] burst featureah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Managementh]h Management}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKEubh)}(hJQuota, period and burst are managed within the cpu subsystem via cgroupfs.h]hJQuota, period and burst are managed within the cpu subsystem via cgroupfs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKFhjhhubh)}(hThe cgroupfs files described in this section are only applicable to cgroup v1. For cgroup v2, see :ref:`Documentation/admin-guide/cgroup-v2.rst `.h]h)}(hThe cgroupfs files described in this section are only applicable to cgroup v1. For cgroup v2, see :ref:`Documentation/admin-guide/cgroup-v2.rst `.h](hbThe cgroupfs files described in this section are only applicable to cgroup v1. For cgroup v2, see }(hjhhhNhNubh)}(h>:ref:`Documentation/admin-guide/cgroup-v2.rst `h]hinline)}(hjh]h'Documentation/admin-guide/cgroup-v2.rst}(hjhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocscheduler/sched-bwc refdomainjreftyperef refexplicitrefwarn reftarget cgroup-v2-cpuuh1hhhhKIhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKIhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh bullet_list)}(hhh](h list_item)}(hHcpu.cfs_quota_us: run-time replenished within a period (in microseconds)h]h)}(hjh]hHcpu.cfs_quota_us: run-time replenished within a period (in microseconds)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h;cpu.cfs_period_us: the length of a period (in microseconds)h]h)}(hj1h]h;cpu.cfs_period_us: the length of a period (in microseconds)}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKNhj/ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hAcpu.stat: exports throttling statistics [explained further below]h]h)}(hjHh]hAcpu.stat: exports throttling statistics [explained further below]}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjFubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hEcpu.cfs_burst_us: the maximum accumulated run-time (in microseconds) h]h)}(hDcpu.cfs_burst_us: the maximum accumulated run-time (in microseconds)h]hDcpu.cfs_burst_us: the maximum accumulated run-time (in microseconds)}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhj]ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKMhjhhubh)}(hThe default values are::h]hThe default values are:}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjhhubh literal_block)}(h>cpu.cfs_period_us=100ms cpu.cfs_quota_us=-1 cpu.cfs_burst_us=0h]h>cpu.cfs_period_us=100ms cpu.cfs_quota_us=-1 cpu.cfs_burst_us=0}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKThjhhubh)}(hA value of -1 for cpu.cfs_quota_us indicates that the group does not have any bandwidth restriction in place, such a group is described as an unconstrained bandwidth group. This represents the traditional work-conserving behavior for CFS.h]hA value of -1 for cpu.cfs_quota_us indicates that the group does not have any bandwidth restriction in place, such a group is described as an unconstrained bandwidth group. This represents the traditional work-conserving behavior for CFS.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjhhubh)}(hXeWriting any (valid) positive value(s) no smaller than cpu.cfs_burst_us will enact the specified bandwidth limit. The minimum quota allowed for the quota or period is 1ms. There is also an upper bound on the period length of 1s. Additional restrictions exist when bandwidth limits are used in a hierarchical fashion, these are explained in more detail below.h]hXeWriting any (valid) positive value(s) no smaller than cpu.cfs_burst_us will enact the specified bandwidth limit. The minimum quota allowed for the quota or period is 1ms. There is also an upper bound on the period length of 1s. Additional restrictions exist when bandwidth limits are used in a hierarchical fashion, these are explained in more detail below.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hjhhubh)}(hWriting any negative value to cpu.cfs_quota_us will remove the bandwidth limit and return the group to an unconstrained state once more.h]hWriting any negative value to cpu.cfs_quota_us will remove the bandwidth limit and return the group to an unconstrained state once more.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjhhubh)}(hX;A value of 0 for cpu.cfs_burst_us indicates that the group can not accumulate any unused bandwidth. It makes the traditional bandwidth control behavior for CFS unchanged. Writing any (valid) positive value(s) no larger than cpu.cfs_quota_us into cpu.cfs_burst_us will enact the cap on unused bandwidth accumulation.h]hX;A value of 0 for cpu.cfs_burst_us indicates that the group can not accumulate any unused bandwidth. It makes the traditional bandwidth control behavior for CFS unchanged. Writing any (valid) positive value(s) no larger than cpu.cfs_quota_us into cpu.cfs_burst_us will enact the cap on unused bandwidth accumulation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjhhubh)}(hxAny updates to a group's bandwidth specification will result in it becoming unthrottled if it is in a constrained state.h]hzAny updates to a group’s bandwidth specification will result in it becoming unthrottled if it is in a constrained state.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKlhjhhubeh}(h] managementah ]h"] managementah$]h&]uh1hhhhhhhhKEubh)}(hhh](h)}(hSystem wide settingsh]hSystem wide settings}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKpubh)}(hXFor efficiency run-time is transferred between the global pool and CPU local "silos" in a batch fashion. This greatly reduces global accounting pressure on large systems. The amount transferred each time such an update is required is described as the "slice".h]hX For efficiency run-time is transferred between the global pool and CPU local “silos” in a batch fashion. This greatly reduces global accounting pressure on large systems. The amount transferred each time such an update is required is described as the “slice”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKqhjhhubh)}(hThis is tunable via procfs::h]hThis is tunable via procfs:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKvhjhhubj)}(h;/proc/sys/kernel/sched_cfs_bandwidth_slice_us (default=5ms)h]h;/proc/sys/kernel/sched_cfs_bandwidth_slice_us (default=5ms)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKxhjhhubh)}(hqLarger slice values will reduce transfer overheads, while smaller values allow for more fine-grained consumption.h]hqLarger slice values will reduce transfer overheads, while smaller values allow for more fine-grained consumption.}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjhhubeh}(h]system-wide-settingsah ]h"]system wide settingsah$]h&]uh1hhhhhhhhKpubh)}(hhh](h)}(h Statisticsh]h Statistics}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj<hhhhhK~ubh)}(hEA group's bandwidth statistics are exported via 5 fields in cpu.stat.h]hGA group’s bandwidth statistics are exported via 5 fields in cpu.stat.}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj<hhubh)}(h cpu.stat:h]h cpu.stat:}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj<hhubj)}(hhh](j)}(h>nr_periods: Number of enforcement intervals that have elapsed.h]h)}(hjnh]h>nr_periods: Number of enforcement intervals that have elapsed.}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlubah}(h]h ]h"]h$]h&]uh1jhjihhhhhNubj)}(hCnr_throttled: Number of times the group has been throttled/limited.h]h)}(hjh]hCnr_throttled: Number of times the group has been throttled/limited.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjihhhhhNubj)}(hmthrottled_time: The total time duration (in nanoseconds) for which entities of the group have been throttled.h]h)}(hmthrottled_time: The total time duration (in nanoseconds) for which entities of the group have been throttled.h]hmthrottled_time: The total time duration (in nanoseconds) for which entities of the group have been throttled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjihhhhhNubj)}(h*nr_bursts: Number of periods burst occurs.h]h)}(hjh]h*nr_bursts: Number of periods burst occurs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjihhhhhNubj)}(hlburst_time: Cumulative wall-time (in nanoseconds) that any CPUs has used above quota in respective periods. h]h)}(hkburst_time: Cumulative wall-time (in nanoseconds) that any CPUs has used above quota in respective periods.h]hkburst_time: Cumulative wall-time (in nanoseconds) that any CPUs has used above quota in respective periods.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjihhhhhNubeh}(h]h ]h"]h$]h&]j{j|uh1jhhhKhj<hhubh)}(hThis interface is read-only.h]hThis interface is read-only.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj<hhubeh}(h] statisticsah ]h"] statisticsah$]h&]uh1hhhhhhhhK~ubh)}(hhh](h)}(hHierarchical considerationsh]hHierarchical considerations}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hThe interface enforces that an individual entity's bandwidth is always attainable, that is: max(c_i) <= C. However, over-subscription in the aggregate case is explicitly allowed to enable work-conserving semantics within a hierarchy:h]hThe interface enforces that an individual entity’s bandwidth is always attainable, that is: max(c_i) <= C. However, over-subscription in the aggregate case is explicitly allowed to enable work-conserving semantics within a hierarchy:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj+)}(he.g. \Sum (c_i) may exceed C h]h)}(he.g. \Sum (c_i) may exceed Ch]he.g. Sum (c_i) may exceed C}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j*hhhKhjhhubh)}(h;[ Where C is the parent's bandwidth, and c_i its children ]h]h=[ Where C is the parent’s bandwidth, and c_i its children ]}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h9There are two ways in which a group may become throttled:h]h9There are two ways in which a group may become throttled:}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj+)}(hka. it fully consumes its own quota within a period b. a parent's quota is fully consumed within its period h]henumerated_list)}(hhh](j)}(h/it fully consumes its own quota within a periodh]h)}(hj[h]h/it fully consumes its own quota within a period}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjYubah}(h]h ]h"]h$]h&]uh1jhjVubj)}(h5a parent's quota is fully consumed within its period h]h)}(h4a parent's quota is fully consumed within its periodh]h6a parent’s quota is fully consumed within its period}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjpubah}(h]h ]h"]h$]h&]uh1jhjVubeh}(h]h ]h"]h$]h&]enumtype loweralphaprefixhsuffix.uh1jThjPubah}(h]h ]h"]h$]h&]uh1j*hhhKhjhhubh)}(hIn case b) above, even though the child may have runtime remaining it will not be allowed to until the parent's runtime is refreshed.h]hIn case b) above, even though the child may have runtime remaining it will not be allowed to until the parent’s runtime is refreshed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]hierarchical-considerationsah ]h"]hierarchical considerationsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hCFS Bandwidth Quota Caveatsh]hCFS Bandwidth Quota Caveats}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXCOnce a slice is assigned to a cpu it does not expire. However all but 1ms of the slice may be returned to the global pool if all threads on that cpu become unrunnable. This is configured at compile time by the min_cfs_rq_runtime variable. This is a performance tweak that helps prevent added contention on the global lock.h]hXCOnce a slice is assigned to a cpu it does not expire. However all but 1ms of the slice may be returned to the global pool if all threads on that cpu become unrunnable. This is configured at compile time by the min_cfs_rq_runtime variable. This is a performance tweak that helps prevent added contention on the global lock.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hpThe fact that cpu-local slices do not expire results in some interesting corner cases that should be understood.h]hpThe fact that cpu-local slices do not expire results in some interesting corner cases that should be understood.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXvFor cgroup cpu constrained applications that are cpu limited this is a relatively moot point because they will naturally consume the entirety of their quota as well as the entirety of each cpu-local slice in each period. As a result it is expected that nr_periods roughly equal nr_throttled, and that cpuacct.usage will increase roughly equal to cfs_quota_us in each period.h]hXvFor cgroup cpu constrained applications that are cpu limited this is a relatively moot point because they will naturally consume the entirety of their quota as well as the entirety of each cpu-local slice in each period. As a result it is expected that nr_periods roughly equal nr_throttled, and that cpuacct.usage will increase roughly equal to cfs_quota_us in each period.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXFor highly-threaded, non-cpu bound applications this non-expiration nuance allows applications to briefly burst past their quota limits by the amount of unused slice on each cpu that the task group is running on (typically at most 1ms per cpu or as defined by min_cfs_rq_runtime). This slight burst only applies if quota had been assigned to a cpu and then not fully used or returned in previous periods. This burst amount will not be transferred between cores. As a result, this mechanism still strictly limits the task group to quota average usage, albeit over a longer time window than a single period. This also limits the burst ability to no more than 1ms per cpu. This provides better more predictable user experience for highly threaded applications with small quota limits on high core count machines. It also eliminates the propensity to throttle these applications while simultaneously using less than quota amounts of cpu. Another way to say this, is that by allowing the unused portion of a slice to remain valid across periods we have decreased the possibility of wastefully expiring quota on cpu-local silos that don't need a full slice's amount of cpu time.h]hXFor highly-threaded, non-cpu bound applications this non-expiration nuance allows applications to briefly burst past their quota limits by the amount of unused slice on each cpu that the task group is running on (typically at most 1ms per cpu or as defined by min_cfs_rq_runtime). This slight burst only applies if quota had been assigned to a cpu and then not fully used or returned in previous periods. This burst amount will not be transferred between cores. As a result, this mechanism still strictly limits the task group to quota average usage, albeit over a longer time window than a single period. This also limits the burst ability to no more than 1ms per cpu. This provides better more predictable user experience for highly threaded applications with small quota limits on high core count machines. It also eliminates the propensity to throttle these applications while simultaneously using less than quota amounts of cpu. Another way to say this, is that by allowing the unused portion of a slice to remain valid across periods we have decreased the possibility of wastefully expiring quota on cpu-local silos that don’t need a full slice’s amount of cpu time.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXThe interaction between cpu-bound and non-cpu-bound-interactive applications should also be considered, especially when single core usage hits 100%. If you gave each of these applications half of a cpu-core and they both got scheduled on the same CPU it is theoretically possible that the non-cpu bound application will use up to 1ms additional quota in some periods, thereby preventing the cpu-bound application from fully using its quota by that same amount. In these instances it will be up to the CFS algorithm (see sched-design-CFS.rst) to decide which application is chosen to run, as they will both be runnable and have remaining quota. This runtime discrepancy will be made up in the following periods when the interactive application idles.h]hXThe interaction between cpu-bound and non-cpu-bound-interactive applications should also be considered, especially when single core usage hits 100%. If you gave each of these applications half of a cpu-core and they both got scheduled on the same CPU it is theoretically possible that the non-cpu bound application will use up to 1ms additional quota in some periods, thereby preventing the cpu-bound application from fully using its quota by that same amount. In these instances it will be up to the CFS algorithm (see sched-design-CFS.rst) to decide which application is chosen to run, as they will both be runnable and have remaining quota. This runtime discrepancy will be made up in the following periods when the interactive application idles.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]cfs-bandwidth-quota-caveatsah ]h"]cfs bandwidth quota caveatsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hExamplesh]hExamples}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubjU)}(hhh](j)}(hXLimit a group to 1 CPU worth of runtime:: If period is 250ms and quota is also 250ms, the group will get 1 CPU worth of runtime every 250ms. # echo 250000 > cpu.cfs_quota_us /* quota = 250ms */ # echo 250000 > cpu.cfs_period_us /* period = 250ms */ h](h)}(h)Limit a group to 1 CPU worth of runtime::h]h(Limit a group to 1 CPU worth of runtime:}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj"ubj)}(hIf period is 250ms and quota is also 250ms, the group will get 1 CPU worth of runtime every 250ms. # echo 250000 > cpu.cfs_quota_us /* quota = 250ms */ # echo 250000 > cpu.cfs_period_us /* period = 250ms */h]hIf period is 250ms and quota is also 250ms, the group will get 1 CPU worth of runtime every 250ms. # echo 250000 > cpu.cfs_quota_us /* quota = 250ms */ # echo 250000 > cpu.cfs_period_us /* period = 250ms */}hj4sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj"ubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hXXLimit a group to 2 CPUs worth of runtime on a multi-CPU machine With 500ms period and 1000ms quota, the group can get 2 CPUs worth of runtime every 500ms:: # echo 1000000 > cpu.cfs_quota_us /* quota = 1000ms */ # echo 500000 > cpu.cfs_period_us /* period = 500ms */ The larger period here allows for increased burst capacity. h](h)}(h?Limit a group to 2 CPUs worth of runtime on a multi-CPU machineh]h?Limit a group to 2 CPUs worth of runtime on a multi-CPU machine}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjHubh)}(h[With 500ms period and 1000ms quota, the group can get 2 CPUs worth of runtime every 500ms::h]hZWith 500ms period and 1000ms quota, the group can get 2 CPUs worth of runtime every 500ms:}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjHubj)}(h# echo 1000000 > cpu.cfs_quota_us /* quota = 1000ms */ # echo 500000 > cpu.cfs_period_us /* period = 500ms */ The larger period here allows for increased burst capacity.h]h# echo 1000000 > cpu.cfs_quota_us /* quota = 1000ms */ # echo 500000 > cpu.cfs_period_us /* period = 500ms */ The larger period here allows for increased burst capacity.}hjhsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjHubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hXCLimit a group to 20% of 1 CPU. With 50ms period, 10ms quota will be equivalent to 20% of 1 CPU:: # echo 10000 > cpu.cfs_quota_us /* quota = 10ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */ By using a small period here we are ensuring a consistent latency response at the expense of burst capacity. h](h)}(hLimit a group to 20% of 1 CPU.h]hLimit a group to 20% of 1 CPU.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj|ubh)}(hAWith 50ms period, 10ms quota will be equivalent to 20% of 1 CPU::h]h@With 50ms period, 10ms quota will be equivalent to 20% of 1 CPU:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj|ubj)}(hg# echo 10000 > cpu.cfs_quota_us /* quota = 10ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */h]hg# echo 10000 > cpu.cfs_quota_us /* quota = 10ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj|ubh)}(hlBy using a small period here we are ensuring a consistent latency response at the expense of burst capacity.h]hlBy using a small period here we are ensuring a consistent latency response at the expense of burst capacity.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj|ubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hXLimit a group to 40% of 1 CPU, and allow accumulate up to 20% of 1 CPU additionally, in case accumulation has been done. With 50ms period, 20ms quota will be equivalent to 40% of 1 CPU. And 10ms burst will be equivalent to 20% of 1 CPU:: # echo 20000 > cpu.cfs_quota_us /* quota = 20ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */ # echo 10000 > cpu.cfs_burst_us /* burst = 10ms */ Larger buffer setting (no larger than quota) allows greater burst capacity.h](h)}(hxLimit a group to 40% of 1 CPU, and allow accumulate up to 20% of 1 CPU additionally, in case accumulation has been done.h]hxLimit a group to 40% of 1 CPU, and allow accumulate up to 20% of 1 CPU additionally, in case accumulation has been done.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(htWith 50ms period, 20ms quota will be equivalent to 40% of 1 CPU. And 10ms burst will be equivalent to 20% of 1 CPU::h]hsWith 50ms period, 20ms quota will be equivalent to 40% of 1 CPU. And 10ms burst will be equivalent to 20% of 1 CPU:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(h# echo 20000 > cpu.cfs_quota_us /* quota = 20ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */ # echo 10000 > cpu.cfs_burst_us /* burst = 10ms */h]h# echo 20000 > cpu.cfs_quota_us /* quota = 20ms */ # echo 50000 > cpu.cfs_period_us /* period = 50ms */ # echo 10000 > cpu.cfs_burst_us /* burst = 10ms */}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjubh)}(hKLarger buffer setting (no larger than quota) allows greater burst capacity.h]hKLarger buffer setting (no larger than quota) allows greater burst capacity.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]jarabicjhjjuh1jThjhhhhhKubeh}(h]examplesah ]h"]examplesah$]h&]uh1hhhhhhhhKubeh}(h]cfs-bandwidth-controlah ]h"]cfs bandwidth controlah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj:error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjjj9j6jjjjj jj j u nametypes}(jjjj9jjj j uh}(jhjhjjj6jjj<jjjjj ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.