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>
This commit is contained in:
Tim Zhang
2020-11-04 18:03:42 +08:00
parent ca610bb57e
commit 0c18b0855e
3 changed files with 50 additions and 5 deletions

View File

@@ -21,8 +21,8 @@ use crate::events;
use crate::flat_keyed_to_hashmap;
use crate::{
ControllIdentifier, ControllerInternal, Controllers, MaxValue, MemoryResources, Resources,
Subsystem,
ControllIdentifier, ControllerInternal, Controllers, CustomizedAttribute, MaxValue,
MemoryResources, Resources, Subsystem,
};
/// A controller that allows controlling the `memory` subsystem of a Cgroup.
@@ -834,6 +834,8 @@ impl ControllIdentifier for MemController {
}
}
impl CustomizedAttribute for MemController {}
impl<'a> From<&'a Subsystem> for &'a MemController {
fn from(sub: &'a Subsystem) -> &'a MemController {
unsafe {