Hi
I have a Dtrace script ( attached ) which examines memory usage, using
fbt:genunix:anon_resvmem:entry & return
On my T2000 it totals the 65k pages being reserved by my application, printing out the total in bytes.

Seems to work well, tested with a small app that malloced < 65 K, malloced 200M and mmapeed a 16M file and it appeared to get things correct.

Could I just get a second pair of eyes to eyeball it.

Basically I am looking at an app that seems to wander off the reservation in terms of memory usage, so wanted to rule out any bugs in the script.

I have the app compiled in debug ( -g ) so non-stripped, is there a way to get the stack of the calling app at the point in time of the anon_resvmem:entry & return.

Any help appreciated
Enda
#!/usr/sbin/dtrace -ws
#pragma D option dynvarsize=20m
#pragma D option quiet
/*			1 - Default output
**			2 - Timestamp output (includes TIME)
**			3 - Everything, space delimited (for spreadsheets)
*/


/*
**  Print header
*/
dtrace:::BEGIN{ 
	total[pid]=(long long)0;
	printf("%5s %5s %9s %s\n","UID","PID","TOTAL","ARGS");
}

/*
**  Main
*/
fbt:genunix:anon_resvmem:entry
/arg1 != 0/
{
	/* Store values for a reservation of anon mem */
	self->size = (long long)arg0;
	self->uid = curpsinfo->pr_euid;
	self->pid = pid;
	self->args = (char *)curpsinfo->pr_psargs;
	self->on=1;
}
fbt:genunix:anon_resvmem:return
/self->args != NULL && arg1 != 0 && self->on/
{
        /* Increment total anon mem if successful */
        total[self->pid] += (long long )self->size;
        printf("%5d %5d %9d %s\n",
        self->uid,self->pid,total[self->pid],stringof(self->args));
        self->size = 0;
        self->pid = 0;
        self->uid = 0;
        self->args = NULL;
	self->on=0;

}


fbt:genunix:anon_unresvmem:entry
/self->size > 0/
{
	printf("in free\n");
	/* Decrement anon mem for unreservations */
	self->size=(long long)self->size;
	self->uid = curpsinfo->pr_euid;
	self->pid = pid;
	self->args = (char *)curpsinfo->pr_psargs;
	self->on=1;
	
}
fbt:genunix:anon_unresvmem:return
/self->on/
{
	total[pid] -= (long long)self->size;
	self->on=0;
        printf("%5d %5d %9d %s\n",
        self->uid,self->pid,total[self->pid],stringof(self->args));
        self->size = 0;
        self->pid = 0;
        self->uid = 0;
        self->args = NULL;

	
}

syscall::rexit:entry
{
	total[pid] = 0;
}
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to