parse_sched_file

Function parse_sched_file 

Source
pub fn parse_sched_file(content: &str) -> Option<(u64, u64)>
Expand description

Parse /proc/<pid>/sched content into a SchedSample.

The kernel format (per kernel/sched/debug.c::proc_sched_show_task) is:

<comm> (<pid>, #threads: N)
---------------------------
se.exec_start                  :       12345.6789
...
nr_switches                    :              42
nr_voluntary_switches          :              30
...
se.sum_exec_runtime            :        1234.567890
...

Each “key : value” line uses arbitrary whitespace around the :. The parser extracts the two named keys and ignores everything else; missing keys yield None.

se.sum_exec_runtime is emitted as fractional milliseconds by kernel/sched/debug.c::proc_sched_show_task via the PN macro (SPLIT_NS divides the ns value by 1_000_000 and formats with 6 decimal places). This parser reads it as an f64 in ms and multiplies by 1_000_000 to recover nanoseconds.