io provider, b_bcount

Mark Johnston markj at FreeBSD.org
Wed Feb 18 22:30:45 UTC 2015


On Wed, Feb 18, 2015 at 11:38:28AM +0500, Eugene M. Zheganin wrote:
> Hi.
> 

Hi Eugene,

> 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 ?

Yes, that's the right thing to do. The io provider in FreeBSD doesn't
have Solaris-compatible argument types.

> 
> 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 ?

It looks like this probe can fire with a NULL bio argument when
devstat_start_transaction() is called. In particular,
devstat_start_transaction_bio() always calls
devstat_start_transaction(), and there's a probe in both functions.

I'm not sure why this is the case. I think it's sufficient to have a
io:::start probe in devstat_start_transaction_bio(). I've cc'ed gnn, who
implemented the provider originally and might have some insight here.

The errors should be safe to ignore. You can hide them by adding a
predicate of /args[0] != NULL/ to the io:::start probe in your script.

Thanks,
-Mark


More information about the freebsd-dtrace mailing list