From 6f9e89572e917a58305051f50dd8875ff173af03 Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Thu, 29 Oct 2020 19:35:39 +0800 Subject: [PATCH] MemController: add method reset_max_usage We need a method to reset the max memory usage recorded. Signed-off-by: Tim Zhang --- src/memory.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/memory.rs b/src/memory.rs index 9f641e8..9b1e804 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -733,6 +733,15 @@ impl MemController { }) } + /// Reset the max memory usage recorded + pub fn reset_max_usage(&self) -> Result<()> { + self.open_path("memory.max_usage_in_bytes", true) + .and_then(|mut file| { + file.write_all("0".to_string().as_ref()) + .map_err(|e| Error::with_cause(WriteFailed, e)) + }) + } + /// Set the memory usage limit of the control group, in bytes. pub fn set_limit(&self, limit: i64) -> Result<()> { let mut file = "memory.limit_in_bytes";