[procps] Re: diskstat library

  • From: Craig Small <csmall-procps@xxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Tue, 7 Jul 2015 22:57:43 +1000

On Sat, Jul 04, 2015 at 08:28:23AM -0500, Jim Warner wrote:

I can’t help with diskstat.
It's ok, I got it completed anyhow. The more I looked into it, the more
it didn't make sense to try to separate out the disks and partitions so
I have used a flag. The reasons for doing so in the past were
historical as the data would be different or come from different files.

To get around the whole /sys/block is not available, I have changed the
way the library handles partitions versus disks.

1) assume everything in /proc/diskstat is a partition
2) attempt to readdir() /sys/block, if this fails, make all devs a disk
3) if readdir() works, every entry in /sys/block is marked as a disk.

This way things like vmstat -d work even if /sys is not mounted. Sure
you get the entire lot of partitions and disks but its better than no
lines as before.

I also got rid of vmstat -p only working for partitions, it doesn't
make sense and means if /sys is unmounted you get no partition found.

I hope it doesn't mess up your meminfo work. I'm working in different
files, so should be ok. I'd also like to fold in the slabinfo stuff
too.

But I’m refactoring meminfo to make sorting much more generalized. This
iteration holds much promise for the PID stuff, when (if) we get around to it.
I'm curious to see what you come up with. I think doing the PID stuff
is worth doing in this release. I need some time to write some test
code; I'm not entirely convinced the perfect hashing is worth the
horrible complexity in gains in processing time. Your trick of the one
char switch and a strcmp would be close (ok not as fast) but a lot
easier to maintain.

Of course if your current work means its even better than the
switch-then-strcmp then we're even less needing perfect hashing.

- Craig
--
Craig Small (@smallsees) http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5

Other related posts: