Setting (writing into) `memory.kmem.limit_in_bytes` is not supported in
Linux kernel >= 5.16 (see kernel commit 58056f77502: "memcg, kmem:
further deprecate kmem.limit_in_bytes"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58056f77502
If the write call in `set_kmem_limit()` returns EOPNOTSUPP, log a
warning message but ignore the error (do nothing).
Add a unit-test for `set_kmem_limit` in cgroups v1.
Fix#81
Signed-off-by: Dov Murik <dov.murik1@il.ibm.com>
With #77 nix provides statfs::CGROUP2_SUPER_MAGIC for the target_os
"android". Fix the build build for `target_os = "android"` by adding
this cfg setting to the "linux and not musl" impl of
`is_cgroup2_unified_mode`.
This patch depends opn #77 beeing merged.
Signed-off-by: Felix Obenhuber <felix@obenhuber.de>
Add feature "serde" that derives all resource and statistics types from
Serialize and Deserialize. The feature is turned off by default.
Fixes#54Fixes#55Fixes#56
Signed-off-by: Felix Obenhuber <felix@obenhuber.de>
When reading from the freezer file, it should trim it
first, and the string may container an '\n'.
Fixes: #48
Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
cargo-clippy has moved the upper_case_acronyms lint to
pedantic(removed from the default list), but we need
the lint to keep names consistent and follow the rust
naming conventions.
Signed-off-by: Tim Zhang <tim@hyper.sh>
It should remove the child cgroups recursively
and then remove the parent cgroup, otherwise,
it would remove failed.
Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
There's so many Duplicated read_string_from method in different
subsystem's implementation, so as read_u64_from/read_i64_from methods.
(1) Move the read_string_from method into `lib.rs`,
called by each subsystem implementation as needed.
(2) Refactor read_u[i]64_from method with the help Rust Generic f
unction `read_from` and wrapped by read_u64_from or read_i64_from.
fix: #20
Signed-off-by: LiYa'nan <oliverliyn@gmail.com>
> Print like following:
unable to write to a control group file caused by: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }) }
Signed-off-by: Tim Zhang <tim@hyper.sh>
Delete check_support and stop detecting subsystems by finding in the
root folders because the detecting method is not accurate.
Signed-off-by: Tim Zhang <tim@hyper.sh>
The cgroup writeback feature requires cooperation
between memcgs and blkcgs.
To avoid exceptions, we should add_task for blkcg before
memcg(push BlkIo before Mem).
For more Information:
https://www.alibabacloud.com/help/doc-detail/155509.ht
Signed-off-by: Tim Zhang <tim@hyper.sh>
Use idiomatic Option::None to represent optional fields.
This enables updates where not all fields need to be specified.
Signed-off-by: Tim Zhang <tim@hyper.sh>
Customized attributes are useful for customized kernels.
Usage:
let resource = &mut cgroups::Resources::default();
resource.cpu.attrs.insert("cpu.cfs_init_buffer_us", "10".to_string());
// apply here
Signed-off-by: Tim Zhang <tim@hyper.sh>