Date: Wed, 17 Jun 2015 19:49:46 +0000 From: Mark Johnston <markj@FreeBSD.org> To: abhishek kulkarni <abhya007@gmail.com> Cc: freebsd-dtrace@freebsd.org Subject: Re: Regarding a Sched Dtrace Script for FreeBSD Message-ID: <20150617194946.GA34351@muskytusk> In-Reply-To: <CAJUVset6fHUGkbgLmd-iGRmaRzD9ZBt5wjMkeec9vW2bmnph0g@mail.gmail.com> References: <CAJUVset6fHUGkbgLmd-iGRmaRzD9ZBt5wjMkeec9vW2bmnph0g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jun 16, 2015 at 11:01:27AM -0700, abhishek kulkarni wrote: > Hello all, > > > > I am working on Dtrace and trying to implement a sched script for FreeBSD > 10.0 > > The script uses the probes on-cpu and off-cpu. > > The purpose is to measure the time that a CPU spends on the current thread. > > I am trying to use the aggregation function “SUM” to capture the CPU time > for the ping utility. I am doing it by opening a new putty terminal and > running the ping utility in it, and then running the Dtrace script in > another instance of the terminal. > > I am also using the time utility in order to verify the Kernel Time for a > ping. The time given by the “Time” utility and the Dtrace script do not > match. Could you please help with this . The following is the Dtrace script > we are trying out : Hello, There are a couple of problems in the script, which I've pointed out below. > > > > sched:::on-cpu > > /curthread->td_name == "ping"/ Generally, only kernel threads will have names, so this condition will never be true. You can use the execname variable to match processes named "ping", but note that this will give incorrect results if there are multiple ping processes running at the same time as the script. You can match a specific process using its PID and dtrace(1)'s -c option. For example: dtrace -n 'syscall:::entry /pid == $target/{}' -c "ping -c 3 google.com" > > { > > self->ts = timestamp; > > } > > > > sched:::off-cpu > > /self->ts != 0/ > > { > > @delta[curthread->td_name] = sum(timestamp - self->ts)/1000000; This will result in an error since the sum function doesn't return an integer. I suspect you meant "sum((timestamp - self->ts) / 1000000);"? > > self->ts =0; > > }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150617194946.GA34351>