From owner-freebsd-dtrace@FreeBSD.ORG Wed Feb 18 06:38:36 2015 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 171B85C6 for ; Wed, 18 Feb 2015 06:38:36 +0000 (UTC) Received: from elf.hq.norma.perm.ru (unknown [IPv6:2a00:7540:1::5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.norma.perm.ru", Issuer "Vivat-Trade UNIX Root CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 70E75692 for ; Wed, 18 Feb 2015 06:38:34 +0000 (UTC) Received: from bsdrookie.norma.com. (bsdrookie.norma.com [192.168.7.224]) by elf.hq.norma.perm.ru (8.14.9/8.14.9) with ESMTP id t1I6cSMT051332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Wed, 18 Feb 2015 11:38:29 +0500 (YEKT) (envelope-from emz@norma.perm.ru) Message-ID: <54E43364.7050000@norma.perm.ru> Date: Wed, 18 Feb 2015 11:38:28 +0500 From: "Eugene M. Zheganin" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: freebsd-dtrace@freebsd.org Subject: io provider, b_bcount Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (elf.hq.norma.perm.ru [192.168.3.10]); Wed, 18 Feb 2015 11:38:29 +0500 (YEKT) X-Spam-Status: No hits=-101.2 bayes=0.0000 testhits ALL_TRUSTED=-1, AWL=1.724, BAYES_00=-1.9, USER_IN_WHITELIST=-100 autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on elf.hq.norma.perm.ru X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 06:38:36 -0000 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. From owner-freebsd-dtrace@FreeBSD.ORG Wed Feb 18 22:30:45 2015 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 960E0928 for ; Wed, 18 Feb 2015 22:30:45 +0000 (UTC) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6856596C for ; Wed, 18 Feb 2015 22:30:45 +0000 (UTC) Received: by pablf10 with SMTP id lf10so4469651pab.12 for ; Wed, 18 Feb 2015 14:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=RFtDzKiFmo9Is0ZkdPQu/RLHQi5Zn1BD2Tzjd4M9u3I=; b=y45D0OSbyt9QL/oplQU55dlKrF8y8Ai6lY4ImGyy11ACDDeOEQsVGXY7PuGeenZSts B1Le5GxOICS1bzmLc4JdLGOqNanM+huupeOYRCaXdKTz56K/NXa3KeMHrnc485KObhCO bovR+uAJyQwLzVsgnWhPX1SD5e4E2AZDBEJdjTDUEvW9W/ZWl/L9aKNUt0EVEeozZjBX lUkRkjXuIS1WpGa7h04WaR6KCjnj/3fYOyiyyKjvazZq8yhhua1mLPrqKCqvw/MpMX5C GCgzJPF2Py9Wogld1if0umliEl3uOwdBk48QOH6c1vQVXm/4HnEU1hV3J12OZg9oNnMX XRLQ== X-Received: by 10.70.47.70 with SMTP id b6mr2456734pdn.136.1424298644359; Wed, 18 Feb 2015 14:30:44 -0800 (PST) Received: from charmander.picturesperfect.net (c-67-182-131-225.hsd1.wa.comcast.net. [67.182.131.225]) by mx.google.com with ESMTPSA id bs2sm5643551pbd.74.2015.02.18.14.30.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 14:30:43 -0800 (PST) Sender: Mark Johnston Date: Wed, 18 Feb 2015 14:30:37 -0800 From: Mark Johnston To: "Eugene M. Zheganin" Subject: Re: io provider, b_bcount Message-ID: <20150218223037.GA20537@charmander.picturesperfect.net> References: <54E43364.7050000@norma.perm.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54E43364.7050000@norma.perm.ru> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 22:30:45 -0000 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