Hi all,
I have a problem with a script I am running to determine how much
time is spent in the syscall mmap for one particular file which is
mapped in a large number of times. The problem is I can not think of
a way to identify the return of the particular mmap in question.
Here is the script.
#!/usr/sbin/dtrace -qs
BEGIN
{
dts = timestamp;
}
syscall::mmap:entry
/execname == "ttcs" && arg4==38/
{
self->ts=timestamp;
@cnt["Num of mmaps"] = count();
}
#here is the problem how do I work out if it is the return of the
mmap I am interested in?
syscall::mmap:return
/self->ts && execname == "ttcs"/
{
@["total time in mmap"] = sum((timestamp - self->ts));
}
END
{
printf("Total time spent in dtrace is %d \n", (timestamp -
dts));
}
Regards
Damien
Michael Schuster
2005-Oct-13 06:41 UTC
[dtrace-discuss] finding the correct return from mmap
Damien,
in the mmap:return case, you need to reset self->ts to 0 (after using it
:-). That way, you can be sure that you''ll only catch mmap:return
clauses where mmap:entry has first taken place.
thus:
syscall::mmap:return
/self->ts/
{
/* do your bit */
self->ts = 0;
}
HTH
Damien Cooke wrote:>
> Hi all,
> I have a problem with a script I am running to determine how much
> time is spent in the syscall mmap for one particular file which is
> mapped in a large number of times. The problem is I can not think of
> a way to identify the return of the particular mmap in question.
>
> Here is the script.
>
> #!/usr/sbin/dtrace -qs
>
> BEGIN
> {
> dts = timestamp;
> }
>
> syscall::mmap:entry
> /execname == "ttcs" && arg4==38/
> {
> self->ts=timestamp;
> @cnt["Num of mmaps"] = count();
> }
>
> #here is the problem how do I work out if it is the return of the
> mmap I am interested in?
> syscall::mmap:return
> /self->ts && execname == "ttcs"/
> {
> @["total time in mmap"] = sum((timestamp -
self->ts));
> }
>
> END
> {
> printf("Total time spent in dtrace is %d \n", (timestamp
-
> dts));
> }
>
> Regards
> Damien
>
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss at opensolaris.org
--
Michael Schuster
Sun Microsystems