1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use heim_common::units::Information;

/// Linux-specific extension to process [IoCounters] information.
///
/// [IoCounters]: ../../struct.IoCounters.html
pub trait IoCountersExt {
    /// The number of bytes which this task has caused to be read from storage.
    fn chars_read(&self) -> Information;
    /// The number of bytes which this task has caused, or shall cause to be written to disk.
    fn chars_written(&self) -> Information;
    /// Attempt to count the number of read I/O operations,
    /// i.e. syscalls like `read()` and `pread()`.
    fn read_syscalls(&self) -> u64;
    /// Attempt to count the number of write I/O operations,
    /// i.e. syscalls like `write()` and `pwrite()`.
    fn write_syscalls(&self) -> u64;
    // Attempt to count the number of bytes which this process really did cause to
    /// be fetched from the storage layer.
    fn bytes_read(&self) -> Information;
    /// Attempt to count the number of bytes which this process caused to be sent to
    /// the storage layer.
    fn bytes_written(&self) -> Information;
    /// The number of bytes which this process caused to not happen,
    /// by truncating pagecache.
    fn cancelled_write_bytes(&self) -> Information;
}

impl IoCountersExt for crate::process::IoCounters {
    /// The number of bytes which this task has caused to be read from storage.
    fn chars_read(&self) -> Information {
        self.as_ref().chars_read()
    }

    /// The number of bytes which this task has caused, or shall cause to be written to disk.
    fn chars_written(&self) -> Information {
        self.as_ref().chars_written()
    }

    /// Attempt to count the number of read I/O operations,
    /// i.e. syscalls like `read()` and `pread()`.
    fn read_syscalls(&self) -> u64 {
        self.as_ref().read_syscalls()
    }

    /// Attempt to count the number of write I/O operations,
    /// i.e. syscalls like `write()` and `pwrite()`.
    fn write_syscalls(&self) -> u64 {
        self.as_ref().write_syscalls()
    }

    /// Attempt to count the number of bytes which this process really did cause to
    /// be fetched from the storage layer.
    fn bytes_read(&self) -> Information {
        self.as_ref().bytes_read()
    }

    /// Attempt to count the number of bytes which this process caused to be sent to
    /// the storage layer.
    fn bytes_written(&self) -> Information {
        self.as_ref().bytes_written()
    }

    /// The number of bytes which this process caused to not happen,
    /// by truncating pagecache.
    fn cancelled_write_bytes(&self) -> Information {
        self.as_ref().cancelled_write_bytes()
    }
}