kata-containers / cgroups-rs

Native Rust library for managing control groups under Linux
https://crates.io/crates/cgroups-rs
Other
116 stars 47 forks source link

Parsing of v2 blkio stat broken #57

Open flxo opened 3 years ago

flxo commented 3 years ago

Describe the bug

Parsing the stats of the blkio controller is broken. According to [1], section IO Interface Files the io.stat file has the format:

8:16 rbytes=1459200 wbytes=314773504 rios=192 wios=35
8:0 rbytes=90430464 wbytes=299008000 rios=8950 wios=1252

but the parsing code expects a : instead of a = in blk.rs

Expected behavior

Parse the correct values.

Additional context

The implementation could be easily optimised to avoid the String and Vec allocations by modifying get_value:

    fn get_value(s: &str) -> u64 {
        s.split('=')
            .skip(1)
            .next()
            .and_then(|s| s.parse::<u64>().ok())
            .unwrap_or_default()
    }

which is only used for the v2 parsing. Same applies for more places of the parsing code in (at least) blkio.

[1] https://www.kernel.org/doc/Documentation/cgroup-v2.txt

Tim-Zhang commented 3 years ago

@liubin PTAL

flxo commented 2 years ago

Hello,

This issues is open for quite a long time. Anything I can support here in order to make progress?

Thanks,

@flxo

liubin commented 2 years ago

Hi @c3d, you assigned to yourself, do you plan to fix this issue?