Felix Obenhuber
09499e7614
Add Serialize/Deserialize to resource and stat types
...
Add feature "serde" that derives all resource and statistics types from
Serialize and Deserialize. The feature is turned off by default.
Fixes #54
Fixes #55
Fixes #56
Signed-off-by: Felix Obenhuber <felix@obenhuber.de >
2021-08-03 09:55:10 +02:00
Tim Zhang
9ec1010a15
Fix clippy warnings
...
Fix clippy warnings.
Signed-off-by: Tim Zhang <tim@hyper.sh >
2021-03-03 13:44:29 +08:00
Peng Tao
0a3e4a828f
memory: fix parse_oom_control panic on older kernels
...
Where the oom control fields might not be present.
Fixes : #36
Signed-off-by: Peng Tao <bergwolf@hyper.sh >
2021-02-26 01:40:19 +08:00
Peng Tao
8720aed656
memory: fix panic when no hierarchical numa stat is available
...
For older kernels, it is possible that there is no hierarchical numa
stats.
Fixes : #36
Signed-off-by: Peng Tao <bergwolf@hyper.sh >
2021-02-25 11:00:48 +08:00
Tim Zhang
15b65c5e5e
Apply customized attributes in MemController.apply
...
Fixes : #25
Signed-off-by: Tim Zhang <tim@hyper.sh >
2021-01-25 12:11:43 +08:00
LiYa'nan
033fa4b857
optimize and refactor: read_to_string and read_i[u]64_from
...
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 >
2020-12-24 09:25:00 +08:00
Tim Zhang
e160df0751
Make read_i64_from private and merge read_str_from to its caller
...
Also remove duplicated read_i64_from.
Signed-off-by: Tim Zhang <tim@hyper.sh >
2020-12-17 17:56:46 +08:00
Tim Zhang
61a0957a65
Fix set_swappiness in cgroup v2
...
The file should be memory.swap.max in cgroup v2.
Signed-off-by: Tim Zhang <tim@hyper.sh >
2020-12-17 17:56:46 +08:00
Tim Zhang
059204589c
Ignore kmem in cgroup v2
...
Because there is no kmem in cgroup v2.
Signed-off-by: Tim Zhang <tim@hyper.sh >
2020-12-17 17:56:46 +08:00
Tim Zhang
1f188be405
Detect subsystems and get root from /proc/self/mountinfo
...
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 >
2020-12-17 17:56:46 +08:00
Tim Zhang
fbd7164c29
Fix warnings in tests
...
Remove following warnings
- unused import
- unused Result
Signed-off-by: Tim Zhang <tim@hyper.sh >
2020-12-17 17:56:46 +08:00
Tim Zhang
567cdb43b3
Use Option as resource fields, remove the update switch: update_values
...
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 >
2020-12-17 17:56:41 +08:00
Tim Zhang
0c18b0855e
Support customized attributes for CpuController and MemController
...
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 >
2020-12-17 16:45:41 +08:00
Tim Zhang
6f9e89572e
MemController: add method reset_max_usage
...
We need a method to reset the max memory usage recorded.
Signed-off-by: Tim Zhang <tim@hyper.sh >
2020-10-29 19:35:39 +08:00
bin liu
152af17f8f
fix build warnings
...
And in Travis CI, treat warnings as error
to keep from merging codes with warning.
Fixes : #13
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-23 16:19:51 +08:00
bin liu
250ada183a
cargo fmt
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-09 16:42:55 +08:00
bin liu
ff6a0ea82a
add SPDX-License-Identifier for modified files
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-09 13:35:46 +08:00
bin liu
bcbf438823
Merge remote-tracking branch 'upstream/master'
2020-09-09 13:27:12 +08:00
bin liu
86b245076c
add SPDX-License-Identifier for all source
...
Add SPDX-License-Identifier for all existing codes.
Fixes : #2
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-07 20:29:40 +08:00
bin liu
cd2c748a74
add systemd controller; add more tests; update blkio stat for v2
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-07 14:18:41 +08:00
bin liu
c623dc3fba
add basic v2 cpu/memory functions
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-09-02 22:03:11 +08:00
bin liu
9fe6cb58e4
change *limit* in memory from u64 to i64
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-08-27 23:06:44 +08:00
bin liu
c702852fd7
add disable oom_control function
...
Signed-off-by: bin liu <bin@hyper.sh >
2020-08-25 11:35:01 +08:00
Levente Kurusa
01a3c22829
Transition to Rust 2018
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-12-23 16:31:05 +01:00
Levente Kurusa
f9ffbe2ba4
memory: allow the fail counters to be reset
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-10-11 11:34:27 +02:00
Levente Kurusa
b3738c2c9b
memory: remove outdated TODOs
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-10-09 09:00:16 -04:00
Sam Wilson
c63dad411b
Hide most of the previously undocumented methods in a sealed trait
2018-10-12 09:49:52 +02:00
Sam Wilson
7826b798bd
Implement ::std::error::Error
2018-10-12 09:49:52 +02:00
Hidehito Yabuuchi
adc3323be4
Replace '/*' style comments with '//' style, which is recommended officially
2018-10-06 18:05:59 +02:00
Hidehito Yabuuchi
ffd4cd70e2
Capitalize static values in tests
2018-10-06 18:05:59 +02:00
Hidehito Yabuuchi
2149e1c0c4
Run rustfmt
2018-10-06 18:05:59 +02:00
Hidehito Yabuuchi
5660656e3a
Use self short-hand
2018-10-01 11:56:12 +02:00
Levente Kurusa
7fa4527c2a
memory: parse memory.stat
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-09-16 17:53:53 +02:00
Levente Kurusa
d9bc157388
memory: parse oom_control field
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-09-16 16:49:04 +02:00
Levente Kurusa
9da8998cd4
memory: parse numa_stat field
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-09-16 16:05:29 +02:00
Levente Kurusa
0e350463a1
controllers: verify that resource application went ok or not
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-09-14 15:59:29 +02:00
Levente Kurusa
c82a94b58e
tree: add some simple error reporting
...
There's still plenty to wish for.
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-09-03 00:11:33 +02:00
Levente Kurusa
367ea556ca
tests: move tests to tests/ directory and give the user cgroup perms
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-08-30 13:40:15 +02:00
Levente Kurusa
caa9241285
More documentation!
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-08-29 18:39:57 +02:00
Levente Kurusa
9162c5a6ad
Initial work
...
Signed-off-by: Levente Kurusa <lkurusa@acm.org >
2018-08-28 14:52:23 +02:00