mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Ignore kmem in cgroup v2
Because there is no kmem in cgroup v2. Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
@@ -702,6 +702,11 @@ impl MemController {
|
|||||||
|
|
||||||
/// Reset the kernel memory fail counter
|
/// Reset the kernel memory fail counter
|
||||||
pub fn reset_kmem_fail_count(&self) -> Result<()> {
|
pub fn reset_kmem_fail_count(&self) -> Result<()> {
|
||||||
|
// Ignore kmem because there is no kmem in cgroup v2
|
||||||
|
if self.v2 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.open_path("memory.kmem.failcnt", true)
|
self.open_path("memory.kmem.failcnt", true)
|
||||||
.and_then(|mut file| {
|
.and_then(|mut file| {
|
||||||
file.write_all("0".to_string().as_ref())
|
file.write_all("0".to_string().as_ref())
|
||||||
@@ -711,6 +716,11 @@ impl MemController {
|
|||||||
|
|
||||||
/// Reset the TCP related fail counter
|
/// Reset the TCP related fail counter
|
||||||
pub fn reset_tcp_fail_count(&self) -> Result<()> {
|
pub fn reset_tcp_fail_count(&self) -> Result<()> {
|
||||||
|
// Ignore kmem because there is no kmem in cgroup v2
|
||||||
|
if self.v2 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.open_path("memory.kmem.tcp.failcnt", true)
|
self.open_path("memory.kmem.tcp.failcnt", true)
|
||||||
.and_then(|mut file| {
|
.and_then(|mut file| {
|
||||||
file.write_all("0".to_string().as_ref())
|
file.write_all("0".to_string().as_ref())
|
||||||
@@ -750,6 +760,11 @@ impl MemController {
|
|||||||
|
|
||||||
/// Set the kernel memory limit of the control group, in bytes.
|
/// Set the kernel memory limit of the control group, in bytes.
|
||||||
pub fn set_kmem_limit(&self, limit: i64) -> Result<()> {
|
pub fn set_kmem_limit(&self, limit: i64) -> Result<()> {
|
||||||
|
// Ignore kmem because there is no kmem in cgroup v2
|
||||||
|
if self.v2 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.open_path("memory.kmem.limit_in_bytes", true)
|
self.open_path("memory.kmem.limit_in_bytes", true)
|
||||||
.and_then(|mut file| {
|
.and_then(|mut file| {
|
||||||
file.write_all(limit.to_string().as_ref())
|
file.write_all(limit.to_string().as_ref())
|
||||||
@@ -771,6 +786,11 @@ impl MemController {
|
|||||||
|
|
||||||
/// Set how much kernel memory can be used for TCP-related buffers by the control group.
|
/// Set how much kernel memory can be used for TCP-related buffers by the control group.
|
||||||
pub fn set_tcp_limit(&self, limit: i64) -> Result<()> {
|
pub fn set_tcp_limit(&self, limit: i64) -> Result<()> {
|
||||||
|
// Ignore kmem because there is no kmem in cgroup v2
|
||||||
|
if self.v2 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.open_path("memory.kmem.tcp.limit_in_bytes", true)
|
self.open_path("memory.kmem.tcp.limit_in_bytes", true)
|
||||||
.and_then(|mut file| {
|
.and_then(|mut file| {
|
||||||
file.write_all(limit.to_string().as_ref())
|
file.write_all(limit.to_string().as_ref())
|
||||||
|
|||||||
Reference in New Issue
Block a user