io provider, b_bcount

Eugene M. Zheganin emz at norma.perm.ru
Wed Feb 18 06:38:36 UTC 2015


Hi.

I'm trying to port the Solaris iotop script (not the complicated
ksh-iottop, but rather simple iotop) to FreeBSD.

Here's the script:

#!/usr/sbin/dtrace -s

#pragma D option quiet

BEGIN {
    printf("%-6s  %-20s  %s\n", "PID", "COMMAND", "BYTES/SEC");
    printf("------  --------------------  ---------");
    last = timestamp;
}

io:::start {
    @io[pid, execname] = sum(args[0]->b_bcount);
}

tick-5sec {
    trunc(@io, 10);
    printf("\n");
    normalize(@io, (timestamp - last) / 1000000000);
    printa("%-6d  %-20s  %@d\n", @io);
    trunc(@io, 0);
    last = timestamp;
}

It works fine on Solaris, but on FreeBSD I got the error

dtrace: failed to compile script ./iotop.old: line 12: b_bcount is not a
member of struct bio

I figured out that since the bio struct is mentioned, I have to use the
bio_bcount instead. Is this correct ?

Second issue - when running this modified with bio_bcount script, I get
the actual data, that seems to reflect reality, but I'm also getting
tonnes of errors like:

dtrace: error on enabled probe ID 2 (ID 56400: io:kernel::start):
invalid address (0x20) in action #4 at DIF offset 16
dtrace: error on enabled probe ID 2 (ID 56400: io:kernel::start):
invalid address (0x20) in action #4 at DIF offset 16
dtrace: error on enabled probe ID 2 (ID 56400: io:kernel::start):
invalid address (0x20) in action #4 at DIF offset 16
dtrace: error on enabled probe ID 2 (ID 56400: io:kernel::start):
invalid address (0x20) in action #4 at DIF offset 16
dtrace: error on enabled probe ID 2 (ID 56400: io:kernel::start):
invalid address (0x20) in action #4 at DIF offset 16

- and I want to ask - why. I get no errors on Solaris (and yes - the
modification may be the reason). Is it safe to ignore the errors, or
should the script be modified in some manner ?

Thanks.
Eugene.


More information about the freebsd-dtrace mailing list