Skip to content

Commit 65dbd61

Browse files
committed
[CONTINT-4562] Add comments
1 parent 8292f87 commit 65dbd61

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lading/src/observer/linux/wss.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
55
use tracing::debug;
66

77
mod process_descendents;
8-
use process_descendents::ProcessDescendentsIterator;
8+
use process_descendents::ProcessDescendantsIterator;
99

1010
mod pfnset;
1111
use pfnset::PfnSet;
@@ -51,7 +51,7 @@ impl Sampler {
5151
let page_size = page_size::get();
5252
let mut pfn_set = PfnSet::new();
5353

54-
for process in ProcessDescendentsIterator::new(self.parent_pid) {
54+
for process in ProcessDescendantsIterator::new(self.parent_pid) {
5555
debug!("Process PID: {}", process.pid());
5656
let mut pagemap = process.pagemap()?;
5757
for MemoryMap {

lading/src/observer/linux/wss/pfnset.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use procfs::process::Pfn;
22
use std::collections::HashMap;
33

4+
/// Structure used to represent a set of page frame numbers (PFNs)
5+
/// in a format suitable for use with the Idle Page Tracking API.
6+
/// https://www.kernel.org/doc/html/latest/admin-guide/mm/idle_page_tracking.html
47
#[derive(Debug)]
58
pub(super) struct PfnSet(HashMap<u64, u64>);
69

lading/src/observer/linux/wss/process_descendents.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use procfs::process::Process;
22

3-
pub(super) struct ProcessDescendentsIterator {
3+
// Iterator which, given a process ID, returns the process and all its descendants
4+
pub(super) struct ProcessDescendantsIterator {
45
stack: Vec<Process>,
56
}
67

7-
impl ProcessDescendentsIterator {
8+
impl ProcessDescendantsIterator {
89
pub(super) fn new(parent_pid: i32) -> Self {
910
Self {
1011
stack: vec![
@@ -15,7 +16,7 @@ impl ProcessDescendentsIterator {
1516
}
1617
}
1718

18-
impl Iterator for ProcessDescendentsIterator {
19+
impl Iterator for ProcessDescendantsIterator {
1920
type Item = Process;
2021

2122
fn next(&mut self) -> Option<Self::Item> {
@@ -44,6 +45,9 @@ mod tests {
4445
use std::io::BufReader;
4546
use std::process::{Command, Stdio};
4647

48+
/// Test the ProcessDescendentsIterator by creating a process tree.
49+
/// Each process will print its PID to stdout.
50+
/// The test will read the PIDs from stdout and check that the iterator returns all of them.
4751
#[test]
4852
fn process_descendants_iterator() {
4953
const NB_PROCESSES_PER_LEVEL: usize = 3;
@@ -71,7 +75,7 @@ mod tests {
7175
assert!(children_pids.insert(pid));
7276
}
7377

74-
for process in ProcessDescendentsIterator::new(child.id() as i32) {
78+
for process in ProcessDescendantsIterator::new(child.id() as i32) {
7579
assert!(
7680
children_pids.remove(&process.pid()),
7781
"ProcessDescendentsIterator returned unexpected PID {pid}",

0 commit comments

Comments
 (0)