pub struct Subsystem { /* private fields */ }Expand description
Handler of a HugeTLB subsystem.
Implementations§
Source§impl Subsystem
impl Subsystem
Sourcepub fn size_supported(&self, size: HugepageSize) -> bool
pub fn size_supported(&self, size: HugepageSize) -> bool
Returns whether the system supports hugepage in size.
Note that this method returns false if the directory of this cgroup is not created yet.
§Example
use std::path::PathBuf;
use controlgroup::v1::{hugetlb::{self, HugepageSize}, Cgroup, CgroupPath, SubsystemKind};
let mut cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
cgroup.create()?;
let support_2mb = cgroup.size_supported(HugepageSize::Mb2);
let support_1gb = cgroup.size_supported(HugepageSize::Gb1);Sourcepub fn limit_in_bytes(&self, size: HugepageSize) -> Result<u64>
pub fn limit_in_bytes(&self, size: HugepageSize) -> Result<u64>
Reads the limit of hugepage TLB usage in bytes from hugetlb.<hugepage size>.limit_in_bytes file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse hugetlb.<hugepage size>.limit_in_bytes file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{hugetlb, Cgroup, CgroupPath, SubsystemKind};
let cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
let limit_in_bytes = cgroup.limit_in_bytes(hugetlb :: HugepageSize :: Mb2)?;Sourcepub fn limit_in_pages(&self, size: HugepageSize) -> Result<u64>
pub fn limit_in_pages(&self, size: HugepageSize) -> Result<u64>
Reads the limit of hugepage TLB usage in bytes in pages. See limit_in_bytes method for more information.
Sourcepub fn set_limit(&mut self, size: HugepageSize, limit: Limit) -> Result<()>
pub fn set_limit(&mut self, size: HugepageSize, limit: Limit) -> Result<()>
Sets a limit of hugepage TLB usage by writing to hugetlb.<hugepage size>.limit_in_bytes file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to write to hugetlb.<hugepage size>.limit_in_bytes file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{hugetlb, Cgroup, CgroupPath, SubsystemKind};
let mut cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
cgroup.set_limit(hugetlb::HugepageSize::Mb2, hugetlb::Limit::Pages(4))?;Sourcepub fn set_limit_in_bytes(
&mut self,
size: HugepageSize,
bytes: u64,
) -> Result<()>
pub fn set_limit_in_bytes( &mut self, size: HugepageSize, bytes: u64, ) -> Result<()>
Sets a limit of hugepage TLB usage in bytes. See set_limit method for more information.
Sourcepub fn set_limit_in_pages(
&mut self,
size: HugepageSize,
pages: u64,
) -> Result<()>
pub fn set_limit_in_pages( &mut self, size: HugepageSize, pages: u64, ) -> Result<()>
Sets a limit of hugepage TLB usage in pages. See set_limit method for more information.
Sourcepub fn usage_in_bytes(&self, size: HugepageSize) -> Result<u64>
pub fn usage_in_bytes(&self, size: HugepageSize) -> Result<u64>
Reads the current usage of hugepage TLB in bytes from hugetlb.<hugepage size>.usage_in_bytes file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse hugetlb.<hugepage size>.usage_in_bytes file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{hugetlb, Cgroup, CgroupPath, SubsystemKind};
let cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
let usage_in_bytes = cgroup.usage_in_bytes(hugetlb :: HugepageSize :: Mb2)?;Sourcepub fn usage_in_pages(&self, size: HugepageSize) -> Result<u64>
pub fn usage_in_pages(&self, size: HugepageSize) -> Result<u64>
Reads the current usage of hugepage TLB in bytes in pages. See usage_in_bytes method for more information.
Sourcepub fn max_usage_in_bytes(&self, size: HugepageSize) -> Result<u64>
pub fn max_usage_in_bytes(&self, size: HugepageSize) -> Result<u64>
Reads the maximum recorded usage of hugepage TLB in bytes from hugetlb.<hugepage size>.max_usage_in_bytes file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse hugetlb.<hugepage size>.max_usage_in_bytes file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{hugetlb, Cgroup, CgroupPath, SubsystemKind};
let cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
let max_usage_in_bytes = cgroup.max_usage_in_bytes(hugetlb :: HugepageSize :: Mb2)?;Sourcepub fn max_usage_in_pages(&self, size: HugepageSize) -> Result<u64>
pub fn max_usage_in_pages(&self, size: HugepageSize) -> Result<u64>
Reads the maximum recorded usage of hugepage TLB in bytes in pages. See max_usage_in_bytes method for more information.
Sourcepub fn failcnt(&self, size: HugepageSize) -> Result<u64>
pub fn failcnt(&self, size: HugepageSize) -> Result<u64>
Reads the number of allocation failure due to the limit, from hugetlb.<hugepage size>.failcnt file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse hugetlb.<hugepage size>.failcnt file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{hugetlb, Cgroup, CgroupPath, SubsystemKind};
let cgroup = hugetlb::Subsystem::new(
CgroupPath::new(SubsystemKind::HugeTlb, PathBuf::from("students/charlie")));
let failcnt = cgroup.failcnt(hugetlb::HugepageSize::Mb2)?;Trait Implementations§
Source§impl Cgroup for Subsystem
impl Cgroup for Subsystem
Source§fn apply(&mut self, resources: &Resources) -> Result<()>
fn apply(&mut self, resources: &Resources) -> Result<()>
Applies resources.hugetlb.limits if it is not empty.
Source§fn new(path: CgroupPath) -> Self
fn new(path: CgroupPath) -> Self
Source§fn subsystem(&self) -> SubsystemKind
fn subsystem(&self) -> SubsystemKind
Source§fn is_root(&self) -> bool
fn is_root(&self) -> bool
Source§fn root_cgroup(&self) -> Box<Self>
fn root_cgroup(&self) -> Box<Self>
Source§fn tasks(&self) -> Result<Vec<Pid>>
fn tasks(&self) -> Result<Vec<Pid>>
tasks file. The resulting tasks are represented by their thread IDs. Read moreSource§fn add_task(&mut self, pid: impl Into<Pid>) -> Result<()>
fn add_task(&mut self, pid: impl Into<Pid>) -> Result<()>
tasks file. Read moreSource§fn remove_task(&mut self, pid: impl Into<Pid>) -> Result<()>
fn remove_task(&mut self, pid: impl Into<Pid>) -> Result<()>
tasks file of the root cgroup. Read moreSource§fn procs(&self) -> Result<Vec<Pid>>
fn procs(&self) -> Result<Vec<Pid>>
cgroup.procs file. The resulting tasks are represented by their PIDs. Read moreSource§fn add_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
fn add_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
cgroup.procs file. Read moreSource§fn remove_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
fn remove_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
cgroup.procs file of the root cgroup. Read moreSource§fn notify_on_release(&self) -> Result<bool>
fn notify_on_release(&self) -> Result<bool>
release_agent file
when this cgroup no longer has any task, from notify_on_release file. Read moreSource§fn set_notify_on_release(&mut self, enable: bool) -> Result<()>
fn set_notify_on_release(&mut self, enable: bool) -> Result<()>
release_agent file
when this cgroup no longer has any task, by writing to notify_on_release file. Read moreSource§fn release_agent(&self) -> Result<String>
fn release_agent(&self) -> Result<String>
release_agent file. Read moreSource§fn set_release_agent(&mut self, agent_path: impl AsRef<[u8]>) -> Result<()>
fn set_release_agent(&mut self, agent_path: impl AsRef<[u8]>) -> Result<()>
release_agent file. Read moreSource§fn sane_behavior(&self) -> Result<bool>
fn sane_behavior(&self) -> Result<bool>
cgroup.sane_behavior file. Read more