Determine the cgroup mode in add_task() to avoid the wrong operation of the caller writing threads to cgroup.threads in non-thread mode.
Fixes: #103
Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
Some system has the `Discard` field in io service data, current the
library can't handle it correctly.
With this commit the blkio can get metrics whether it has the discard field.
Fixes: #109
Signed-off-by: bin liu <liubin0329@gmail.com>
Fixes: #98
Add a Kill method for cgroups v2. This uses the new functionality in
kernels 5.14+ where writing to a cgroup.kill file will send a SIGKILL
to every process running in the cgroup. This would be useful for
kata to avoid freezing+manually sending SIGKILL+thawing process it
does currently to emulate runc's behavior.
Signed-off-by: Danny Canter <danny@dcantah.dev>
Support to set threaded mode in cgroup v2. The premise of switching to threaded mode is that only the cgroup of cpuset, cpu and pids is supported.
Fixes: #90
Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
For some cgroup file operations, when failed, add the path
and the value (for write operation) to the error message.
Fixes: #93
Signed-off-by: bin liu <liubin0329@gmail.com>
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>