perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

diskstats misses disk

Open sifangli-labs opened this issue 1 year ago • 6 comments

I am getting diskstats with the following cfg - however, I can only see 1 of the two disks (sda) reported in the pftrace.

name: "linux.sys_stats"
    target_buffer: 0
    sys_stats_config {
      diskstat_period_ms : 1000

Here is the summary of the diskstats content - I note the nvme0n1 is missing in the pftrace's diskstats - sda is showing though.

$ cat /proc/diskstats 
   7       0 loop0 ...
   7       1 loop1 ...
...
 259       0 nvme0n1 ... 
 259       1 nvme0n1p1 ... 
   8       0 sda ...

sifangli-labs avatar Aug 05 '25 18:08 sifangli-labs

Please link the trace file. it's very difficult to debug these sort of issues without the trace.

LalitMaganti avatar Aug 05 '25 18:08 LalitMaganti

Actually I figured it out, the data is being dropped in trace processor: https://source.chromium.org/chromium/chromium/src/+/main:third_party/perfetto/src/trace_processor/importers/proto/system_probes_parser.cc;l=133;bpv=1;bpt=0

This restriction comes all the way from the initial contribution: https://r.android.com/2249376

I'm not sure what the motivation for this was. Potentially that on Android, we only care about the primary disk? We can probably drop it as long as the semantics of the fields of disk stats are the same between nvme* and sd* disks

LalitMaganti avatar Aug 05 '25 18:08 LalitMaganti

Actually the nvme was the primary disk, this is on Linux and we do care about both disk's stats

sifangli-labs avatar Aug 05 '25 18:08 sifangli-labs

I'm happy to drop the restriction but the main problem we have right now is that we have a hardcoded value of 2048 sectors per MB (implying sector size of 512). But afaik, nvme devices often use 4K sectors.

Can I ask you to do /sys/block/<device_name>/queue/logical_block_size for both disks and see what the values are?

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/perfetto/src/trace_processor/importers/proto/system_probes_parser.cc;l=243;bpv=0;bpt=0

LalitMaganti avatar Aug 05 '25 18:08 LalitMaganti

both says 512 on in our env

sifangli-labs avatar Aug 05 '25 18:08 sifangli-labs

Sent https://github.com/google/perfetto/pull/2425 to fix this. Filed https://github.com/google/perfetto/issues/2427 as a follow-up to track 4k logical sector sizes.

LalitMaganti avatar Aug 05 '25 19:08 LalitMaganti