Skip to content

Commit eb29988

Browse files
oandrewmeta-codesync[bot]
authored andcommitted
Add cgroup "Shmem THP" column
Summary: Show per-cgroup "Shmem THP" Reviewed By: lnyng Differential Revision: D84376003 fbshipit-source-id: 7eaaa07fdd3df13869051e62e0759ae06123b448
1 parent 0fee2ea commit eb29988

7 files changed

Lines changed: 41 additions & 33 deletions

File tree

below/cgroupfs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ key_values_format!(MemoryStat; memory.stat; [
715715
file_writeback,
716716
file_thp,
717717
anon_thp,
718+
shmem_thp,
718719
inactive_anon,
719720
active_anon,
720721
inactive_file,

below/cgroupfs/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct MemoryStat {
6464
pub file_writeback: Option<u64>,
6565
pub file_thp: Option<u64>,
6666
pub anon_thp: Option<u64>,
67+
pub shmem_thp: Option<u64>,
6768
pub inactive_anon: Option<u64>,
6869
pub active_anon: Option<u64>,
6970
pub inactive_file: Option<u64>,

below/dump/src/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ fn test_dump_cgroup_titles() {
503503
"File WB",
504504
"File THP",
505505
"Anon THP",
506+
"Shmem THP",
506507
"Inactive Anon",
507508
"Active Anon",
508509
"Inactive File",

below/model/src/cgroup.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ pub struct CgroupMemoryModel {
469469
pub file_writeback: Option<u64>,
470470
pub file_thp: Option<u64>,
471471
pub anon_thp: Option<u64>,
472+
pub shmem_thp: Option<u64>,
472473
pub inactive_anon: Option<u64>,
473474
pub active_anon: Option<u64>,
474475
pub inactive_file: Option<u64>,
@@ -527,6 +528,7 @@ impl std::ops::Add for CgroupMemoryModel {
527528
file_writeback: opt_add(self.file_writeback, other.file_writeback),
528529
file_thp: opt_add(self.file_thp, other.file_thp),
529530
anon_thp: opt_add(self.anon_thp, other.anon_thp),
531+
shmem_thp: opt_add(self.shmem_thp, other.shmem_thp),
530532
inactive_anon: opt_add(self.inactive_anon, other.inactive_anon),
531533
active_anon: opt_add(self.active_anon, other.active_anon),
532534
inactive_file: opt_add(self.inactive_file, other.inactive_file),
@@ -598,48 +600,45 @@ impl CgroupMemoryModel {
598600
zswap: sample.memory_zswap_current.map(|v| v as u64),
599601
..Default::default()
600602
};
601-
if let Some(events) = &sample.memory_events {
602-
if let Some((
603+
if let Some(events) = &sample.memory_events
604+
&& let Some((
603605
CgroupSample {
604606
memory_events: Some(last_memory_events),
605607
..
606608
},
607609
delta,
608610
)) = last
609-
{
610-
model.events_low = count_per_sec!(last_memory_events.low, events.low, delta, u64);
611-
model.events_high =
612-
count_per_sec!(last_memory_events.high, events.high, delta, u64);
613-
model.events_max = count_per_sec!(last_memory_events.max, events.max, delta, u64);
614-
model.events_oom = count_per_sec!(last_memory_events.oom, events.oom, delta, u64);
615-
model.events_oom_kill =
616-
count_per_sec!(last_memory_events.oom_kill, events.oom_kill, delta, u64);
617-
}
611+
{
612+
model.events_low = count_per_sec!(last_memory_events.low, events.low, delta, u64);
613+
model.events_high = count_per_sec!(last_memory_events.high, events.high, delta, u64);
614+
model.events_max = count_per_sec!(last_memory_events.max, events.max, delta, u64);
615+
model.events_oom = count_per_sec!(last_memory_events.oom, events.oom, delta, u64);
616+
model.events_oom_kill =
617+
count_per_sec!(last_memory_events.oom_kill, events.oom_kill, delta, u64);
618618
}
619-
if let Some(events_local) = &sample.memory_events_local {
620-
if let Some((
619+
if let Some(events_local) = &sample.memory_events_local
620+
&& let Some((
621621
CgroupSample {
622622
memory_events_local: Some(last_memory_events_local),
623623
..
624624
},
625625
delta,
626626
)) = last
627-
{
628-
model.events_local_low =
629-
count_per_sec!(last_memory_events_local.low, events_local.low, delta, u64);
630-
model.events_local_high =
631-
count_per_sec!(last_memory_events_local.high, events_local.high, delta, u64);
632-
model.events_local_max =
633-
count_per_sec!(last_memory_events_local.max, events_local.max, delta, u64);
634-
model.events_local_oom =
635-
count_per_sec!(last_memory_events_local.oom, events_local.oom, delta, u64);
636-
model.events_local_oom_kill = count_per_sec!(
637-
last_memory_events_local.oom_kill,
638-
events_local.oom_kill,
639-
delta,
640-
u64
641-
);
642-
}
627+
{
628+
model.events_local_low =
629+
count_per_sec!(last_memory_events_local.low, events_local.low, delta, u64);
630+
model.events_local_high =
631+
count_per_sec!(last_memory_events_local.high, events_local.high, delta, u64);
632+
model.events_local_max =
633+
count_per_sec!(last_memory_events_local.max, events_local.max, delta, u64);
634+
model.events_local_oom =
635+
count_per_sec!(last_memory_events_local.oom, events_local.oom, delta, u64);
636+
model.events_local_oom_kill = count_per_sec!(
637+
last_memory_events_local.oom_kill,
638+
events_local.oom_kill,
639+
delta,
640+
u64
641+
);
643642
}
644643
if let Some(stat) = &sample.memory_stat {
645644
model.anon = stat.anon;
@@ -659,6 +658,7 @@ impl CgroupMemoryModel {
659658
model.file_writeback = stat.file_writeback;
660659
model.file_thp = stat.file_thp;
661660
model.anon_thp = stat.anon_thp;
661+
model.shmem_thp = stat.shmem_thp;
662662
model.inactive_anon = stat.inactive_anon;
663663
model.active_anon = stat.active_anon;
664664
model.inactive_file = stat.inactive_file;

below/model/src/common_field_ids.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ pub const COMMON_MODEL_FIELD_IDS: &[&str] = &[
206206
"cgroup.[path:/<cgroup_path>/.]mem.file_writeback",
207207
"cgroup.[path:/<cgroup_path>/.]mem.file_thp",
208208
"cgroup.[path:/<cgroup_path>/.]mem.anon_thp",
209+
"cgroup.[path:/<cgroup_path>/.]mem.shmem_thp",
209210
"cgroup.[path:/<cgroup_path>/.]mem.inactive_anon",
210211
"cgroup.[path:/<cgroup_path>/.]mem.active_anon",
211212
"cgroup.[path:/<cgroup_path>/.]mem.inactive_file",

below/render/src/default_configs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl HasRenderConfigForDump for model::SingleCgroupModel {
244244
FileWriteback => Some(gauge.unit("bytes")),
245245
FileThp => Some(gauge.unit("bytes")),
246246
AnonThp => Some(gauge.unit("bytes")),
247+
ShmemThp => Some(gauge.unit("bytes")),
247248
InactiveAnon => Some(gauge.unit("bytes")),
248249
ActiveAnon => Some(gauge.unit("bytes")),
249250
InactiveFile => Some(gauge.unit("bytes")),
@@ -370,6 +371,7 @@ impl HasRenderConfig for model::CgroupMemoryModel {
370371
FileWriteback => rc.title("File WB").format(ReadableSize),
371372
FileThp => rc.title("File THP").format(ReadableSize),
372373
AnonThp => rc.title("Anon THP").format(ReadableSize),
374+
ShmemThp => rc.title("Shmem THP").format(ReadableSize),
373375
InactiveAnon => rc.title("Inactive Anon").format(ReadableSize),
374376
ActiveAnon => rc.title("Active Anon").format(ReadableSize),
375377
InactiveFile => rc.title("Inactive File").format(ReadableSize),

below/view/src/cgroup_tabs.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ impl CgroupTab {
108108
) {
109109
let mut cgroup_stack = vec![cgroup];
110110
while let Some(cgroup) = cgroup_stack.pop() {
111-
if let Some(set) = &filtered_set {
112-
if !set.contains(&cgroup.data.full_path) {
113-
continue;
114-
}
111+
if let Some(set) = &filtered_set
112+
&& !set.contains(&cgroup.data.full_path)
113+
{
114+
continue;
115115
}
116116

117117
let collapsed = state
@@ -282,6 +282,7 @@ pub mod default_tabs {
282282
use model::CgroupMemoryModelFieldId::Pgscan;
283283
use model::CgroupMemoryModelFieldId::Pgsteal;
284284
use model::CgroupMemoryModelFieldId::Shmem;
285+
use model::CgroupMemoryModelFieldId::ShmemThp;
285286
use model::CgroupMemoryModelFieldId::Slab;
286287
use model::CgroupMemoryModelFieldId::SlabReclaimable;
287288
use model::CgroupMemoryModelFieldId::SlabUnreclaimable;
@@ -379,6 +380,7 @@ pub mod default_tabs {
379380
ViewItem::from_default(Mem(FileWriteback)),
380381
ViewItem::from_default(Mem(FileThp)),
381382
ViewItem::from_default(Mem(AnonThp)),
383+
ViewItem::from_default(Mem(ShmemThp)),
382384
ViewItem::from_default(Mem(InactiveAnon)),
383385
ViewItem::from_default(Mem(ActiveAnon)),
384386
ViewItem::from_default(Mem(InactiveFile)),

0 commit comments

Comments
 (0)