pub struct CgroupCpuController {
pub shares: u32,
pub quota_us: u64,
pub period_us: u64,
pub burst_us: u64,
pub stats: CpuBandwidthStats,
pub throttled: bool,
pub parent_id: u64,
pub cgroup_id: u64,
/* private fields */
}Expand description
Cgroup CPU controller with shares and bandwidth limiting.
Fields§
CPU shares (weight-based fair scheduling, default 1024).
quota_us: u64CPU quota in microseconds per period (0 = unlimited).
period_us: u64CPU period in microseconds (default 100000 = 100ms).
burst_us: u64Burst capacity in microseconds (0 = no burst).
stats: CpuBandwidthStatsBandwidth statistics.
throttled: boolWhether currently throttled.
parent_id: u64Parent cgroup ID for hierarchical distribution (0 = root).
cgroup_id: u64Unique cgroup ID.
Implementations§
Source§impl CgroupCpuController
impl CgroupCpuController
pub fn new(cgroup_id: u64) -> Self
Set CPU shares (weight). Minimum 2, maximum 262144.
Sourcepub fn set_bandwidth(
&mut self,
quota_us: u64,
period_us: u64,
) -> Result<(), KernelError>
pub fn set_bandwidth( &mut self, quota_us: u64, period_us: u64, ) -> Result<(), KernelError>
Set CPU bandwidth quota and period. quota_us=0 means unlimited. Period must be >= 1000us and <= 1000000us.
Sourcepub fn consume_runtime(&mut self, ns: u64) -> bool
pub fn consume_runtime(&mut self, ns: u64) -> bool
Consume runtime. Returns true if the task is now throttled.
Sourcepub fn new_period(&mut self)
pub fn new_period(&mut self)
Begin a new scheduling period. Refills runtime and handles burst.
Sourcepub fn effective_cpu_percent_x100(&self) -> u64
pub fn effective_cpu_percent_x100(&self) -> u64
Calculate the effective CPU percentage (quota/period * 100). Returns percentage * 100 (fixed-point with 2 decimal digits). For example, quota=50000, period=100000 returns 5000 (50.00%).
Sourcepub fn proportional_runtime_ns(&self, total_shares: u32) -> u64
pub fn proportional_runtime_ns(&self, total_shares: u32) -> u64
Compute the weight-proportional share of CPU time for this cgroup relative to a total weight sum. Returns nanoseconds per period.
Trait Implementations§
Source§impl Clone for CgroupCpuController
impl Clone for CgroupCpuController
Source§fn clone(&self) -> CgroupCpuController
fn clone(&self) -> CgroupCpuController
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CgroupCpuController
impl RefUnwindSafe for CgroupCpuController
impl Send for CgroupCpuController
impl Sync for CgroupCpuController
impl Unpin for CgroupCpuController
impl UnwindSafe for CgroupCpuController
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)