Merge pull request #113 from gkurz/fix-hugetlb-limit-in-bytes

Fix HugeTlbController::limit_in_bytes() for v2
This commit is contained in:
Bin Liu
2023-03-14 13:32:38 +08:00
committed by GitHub
+5 -2
View File
@@ -138,8 +138,11 @@ impl HugeTlbController {
/// Get the limit (in bytes) of how much memory can be backed by hugepages of a certain size /// Get the limit (in bytes) of how much memory can be backed by hugepages of a certain size
/// (`hugetlb_size`). /// (`hugetlb_size`).
pub fn limit_in_bytes(&self, hugetlb_size: &str) -> Result<u64> { pub fn limit_in_bytes(&self, hugetlb_size: &str) -> Result<u64> {
self.open_path(&format!("hugetlb.{}.limit_in_bytes", hugetlb_size), false) let mut file_name = format!("hugetlb.{}.limit_in_bytes", hugetlb_size);
.and_then(read_u64_from) if self.v2 {
file_name = format!("hugetlb.{}.max", hugetlb_size);
}
self.open_path(&file_name, false).and_then(read_u64_from)
} }
/// Get the current usage of memory that is backed by hugepages of a certain size /// Get the current usage of memory that is backed by hugepages of a certain size