summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Onyshchuk <oandrew@meta.com>2023-12-05 06:56:57 -0800
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2023-12-05 06:56:57 -0800
commitba700bd2d01bcbc160ce6848e481d37d1940a63b (patch)
treea6bd99628a9d28d757f6524968d73e824be89fc7
parentf807f621653cd4d5750c9e95b67f9da2785a8f74 (diff)
Add support for memory.stat kernel field
Summary: Display `kernel` field from `memory.stat` - kernel memory used by cgroup. This was added in 5.18: https://github.com/torvalds/linux/commit/a8c49af3be5f0 This field is not present in `memory.numa.stat` Reviewed By: brianc118 Differential Revision: D51832461 fbshipit-source-id: 98ca0561e05bb626edd3e0f285756191e0cc783c
-rw-r--r--below/cgroupfs/src/lib.rs1
-rw-r--r--below/cgroupfs/src/types.rs1
-rw-r--r--below/dump/src/test.rs1
-rw-r--r--below/model/src/cgroup.rs3
-rw-r--r--below/model/src/common_field_ids.rs3
-rw-r--r--below/render/src/default_configs.rs2
-rw-r--r--below/view/src/cgroup_tabs.rs2
7 files changed, 12 insertions, 1 deletions
diff --git a/below/cgroupfs/src/lib.rs b/below/cgroupfs/src/lib.rs
index 53d9085f..8ca6d27e 100644
--- a/below/cgroupfs/src/lib.rs
+++ b/below/cgroupfs/src/lib.rs
@@ -657,6 +657,7 @@ key_values_format!(CpuStat; cpu.stat; [
key_values_format!(MemoryStat; memory.stat; [
anon,
file,
+ kernel,
kernel_stack,
slab,
sock,
diff --git a/below/cgroupfs/src/types.rs b/below/cgroupfs/src/types.rs
index 99018982..764fc49d 100644
--- a/below/cgroupfs/src/types.rs
+++ b/below/cgroupfs/src/types.rs
@@ -52,6 +52,7 @@ pub struct IoStat {
pub struct MemoryStat {
pub anon: Option<u64>,
pub file: Option<u64>,
+ pub kernel: Option<u64>,
pub kernel_stack: Option<u64>,
pub slab: Option<u64>,
pub sock: Option<u64>,
diff --git a/below/dump/src/test.rs b/below/dump/src/test.rs
index 43e5ba67..36ec8542 100644
--- a/below/dump/src/test.rs
+++ b/below/dump/src/test.rs
@@ -497,6 +497,7 @@ fn test_dump_cgroup_titles() {
"Mem Swap",
"Mem Anon",
"Mem File",
+ "Kernel",
"Kernel Stack",
"Mem Slab",
"Mem Sock",
diff --git a/below/model/src/cgroup.rs b/below/model/src/cgroup.rs
index af018bbb..4917f26b 100644
--- a/below/model/src/cgroup.rs
+++ b/below/model/src/cgroup.rs
@@ -471,6 +471,7 @@ pub struct CgroupMemoryModel {
pub swap: Option<u64>,
pub anon: Option<u64>,
pub file: Option<u64>,
+ pub kernel: Option<u64>,
pub kernel_stack: Option<u64>,
pub slab: Option<u64>,
pub sock: Option<u64>,
@@ -522,6 +523,7 @@ impl std::ops::Add for CgroupMemoryModel {
swap: opt_add(self.swap, other.swap),
anon: opt_add(self.anon, other.anon),
file: opt_add(self.file, other.file),
+ kernel: opt_add(self.kernel, other.kernel),
kernel_stack: opt_add(self.kernel_stack, other.kernel_stack),
slab: opt_add(self.slab, other.slab),
sock: opt_add(self.sock, other.sock),
@@ -608,6 +610,7 @@ impl CgroupMemoryModel {
if let Some(stat) = &sample.memory_stat {
model.anon = stat.anon;
model.file = stat.file;
+ model.kernel = stat.kernel;
model.kernel_stack = stat.kernel_stack;
model.slab = stat.slab;
model.sock = stat.sock;
diff --git a/below/model/src/common_field_ids.rs b/below/model/src/common_field_ids.rs
index 0456a978..e8b59586 100644
--- a/below/model/src/common_field_ids.rs
+++ b/below/model/src/common_field_ids.rs
@@ -23,7 +23,7 @@
///
/// This list also servers as documentation for available field ids that could
/// be used in other below crates. A test ensures that this list is up-to-date.
-pub const COMMON_MODEL_FIELD_IDS: [&str; 373] = [
+pub const COMMON_MODEL_FIELD_IDS: [&str; 374] = [
"system.hostname",
"system.kernel_version",
"system.os_release",
@@ -156,6 +156,7 @@ pub const COMMON_MODEL_FIELD_IDS: [&str; 373] = [
"cgroup.[path:/<cgroup_path>/.]mem.swap",
"cgroup.[path:/<cgroup_path>/.]mem.anon",
"cgroup.[path:/<cgroup_path>/.]mem.file",
+ "cgroup.[path:/<cgroup_path>/.]mem.kernel",
"cgroup.[path:/<cgroup_path>/.]mem.kernel_stack",
"cgroup.[path:/<cgroup_path>/.]mem.slab",
"cgroup.[path:/<cgroup_path>/.]mem.sock",
diff --git a/below/render/src/default_configs.rs b/below/render/src/default_configs.rs
index 28abb22d..be35ca48 100644
--- a/below/render/src/default_configs.rs
+++ b/below/render/src/default_configs.rs
@@ -200,6 +200,7 @@ impl HasRenderConfigForDump for model::SingleCgroupModel {
EventsOomKill => Some(counter),
Anon => Some(gauge.unit("bytes")),
File => Some(gauge.unit("bytes")),
+ Kernel => Some(gauge.unit("bytes")),
KernelStack => Some(gauge.unit("bytes")),
Slab => Some(gauge.unit("bytes")),
Sock => Some(gauge.unit("bytes")),
@@ -309,6 +310,7 @@ impl HasRenderConfig for model::CgroupMemoryModel {
EventsOomKill => rc.title("Events Kill"),
Anon => rc.title("Anon").format(ReadableSize),
File => rc.title("File").format(ReadableSize),
+ Kernel => rc.title("Kernel").format(ReadableSize),
KernelStack => rc.title("Kernel Stack").format(ReadableSize),
Slab => rc.title("Slab").format(ReadableSize),
Sock => rc.title("Sock").format(ReadableSize),
diff --git a/below/view/src/cgroup_tabs.rs b/below/view/src/cgroup_tabs.rs
index cc9c9fe9..da2798c5 100644
--- a/below/view/src/cgroup_tabs.rs
+++ b/below/view/src/cgroup_tabs.rs
@@ -253,6 +253,7 @@ pub mod default_tabs {
use model::CgroupMemoryModelFieldId::FileWriteback;
use model::CgroupMemoryModelFieldId::InactiveAnon;
use model::CgroupMemoryModelFieldId::InactiveFile;
+ use model::CgroupMemoryModelFieldId::Kernel;
use model::CgroupMemoryModelFieldId::KernelStack;
use model::CgroupMemoryModelFieldId::Pgactivate;
use model::CgroupMemoryModelFieldId::Pgdeactivate;
@@ -352,6 +353,7 @@ pub mod default_tabs {
ViewItem::from_default(Mem(Swap)),
ViewItem::from_default(Mem(Anon)),
ViewItem::from_default(Mem(File)),
+ ViewItem::from_default(Mem(Kernel)),
ViewItem::from_default(Mem(KernelStack)),
ViewItem::from_default(Mem(Slab)),
ViewItem::from_default(Mem(Sock)),