Is it possible to combine more than one provider. Say I want to trace the page outs while a process is holding adaptive locks. Is it possible to combine the two providers? Thanks Neelam This message posted from opensolaris.org
Hi Neelam, Are you asking if you can have one D script that enables lockstat probes and vminfo probes at the same time? Absolutely. I would think you would have one set of probe clauses to trace paging activity and another set to trace lock activity. However, since you''ll likely be dealing with multiple threads causing enabled probes to fire simultaneously, make sure you use thread local variables appropriately. Chip Neelam wrote:> Is it possible to combine more than one provider. > > Say I want to trace the page outs while a process is holding adaptive locks. Is it possible to combine the two providers? > > Thanks > Neelam > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Neelam wrote:> Is it possible to combine more than one provider. > > Say I want to trace the page outs while a process is holding adaptive locks. Is it possible to combine the two providers?you need to be a bit more specific ... as Chip said, it''s definitely possible to "combine" providers, but depending on what you actually want to do, this may look like: provider1 { self->watchit=1; } provder2 /self->watchit==1/ { /* record data */ self->watchit=0; } or provider1, provider2 { /* record data */ } ... HTH Michael -- Michael Schuster Sun Microsystems, Inc.
well what i am looking for is the second option... e.g. i want to trace the pageouts while the process is holding locks.. if i use the lockstat and vminfo providers, it would tell me separately about the paging activity and the lacks while the process was running. But i want to trace the paging while a process is holding a particular lock. Thanks, Neelam This message posted from opensolaris.org
Neelam, Since DTrace is event driven, this is where you use variables to maintain the current state between events. When the lock is acquired, you set a variable to indicate this has occurred. Then when paging activity happens, you check the variable with a predicate to see if the lock is being held right now. If not, you ignore the paging event. When the lock is released, you turn off the variable. Something like: ~~~~~~~~~~~~~~ lockstat:::adaptive-acquire / some check for the right lock: i.e. pid, tid, etc. / { self->lockset = 1; } vminfo:::pgin / self->lockset / { /* counter, aggregation, whatever */ } lockstat:::adaptive-release / self->lockset / { self->lockset = 0; } ~~~~~~~~~~~~~~~ Regards, Chip Neelam wrote:> well what i am looking for is the second option... > > e.g. i want to trace the pageouts while the process is holding locks.. > > if i use the lockstat and vminfo providers, it would tell me separately about the paging activity and the lacks while the process was running. But i want to trace the paging while a process is holding a particular lock. > > Thanks, > Neelam > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Thanks Chip.. Actually i tried exactly the same thing yesterday. But i think there are a few potential problems here... e.g the lock might be (and it usually is) acquired many times and released many times. So the paging activity would correspond to the total locks being acquired. I was wondering if I could do something that would give me the paging traces corresponding to each time the lock is held. And another thing, to my surprise i could see any paging activity happening at all while the locks were held. I tried using simple StarOffice benchmark in solaris. Thanks and Regards, Neelam This message posted from opensolaris.org
Neelam wrote:> Thanks Chip.. > > Actually i tried exactly the same thing yesterday. But i think there are a few potential problems here... > e.g the lock might be (and it usually is) acquired many times and released many times. So the paging activity would correspond to the total locks being acquired. I was wondering if I could do something that would give me the paging traces corresponding to each time the lock is held. >I don''t completely understand what you are saying, so I''ll just list some choices: If you''re displaying some kind of trace every time there''s is paging activity, the predicate based on self-lockset will make sure you are only tracing when the lock is acquired If you want some statistical data to start over each time the lock is released, then zero it out in the lock-release probe clause. If you want some data to be totals for the times the lock was acquired, then simply don''t zero out these variables out. If the stats need to be based on the amount of time the locks are held, then you need to save deltas based on the timestamp variable and use this in aggregations with paging data. Am I getting anywhere close to what you''re talking about? ;-)> And another thing, to my surprise i could see any paging activity happening at all while the locks were held. I tried using simple StarOffice benchmark in solaris. >I assume you meant you couldn''t see paging data. You might run "vmstat -p 5" to get a look at what it think your paging activity looks like. Chip
Thanks chip.. now i have fair idea what i need to do....actually i have just started working with DTrace, so was kind of confused... By the way is there a way to print the aggregated value or anything per say in a file rather than on the console? or storing the values in an array and printing the array..... also i was wondering, if it''s possible to trace for each thread in a multi-threaded program rather than one particular instance (which we do by using self)? Thanks, Neelam This message posted from opensolaris.org
Hi Neelam, Neelam wrote:> By the way is there a way to print the aggregated value or anything per say in a file rather than on the console? or storing the values in an array and printing the array..... >Use the -o option on the DTrace command line to redirect the trace output to a file. I don''t know of any way to save aggregation results into an array. Of course, in a way, the aggregation result is an array, and you can trace its contents any time using printa.> also i was wondering, if it''s possible to trace for each thread in a multi-threaded program rather than one particular instance (which we do by using self)? >That''s actually the point of thread-local variables ("self"). The variable "x" is global, has only one instance, and is seen by all threads. However, the variable "self->x" has an instance for each thread, that is only seen by one thread. For example, in the following: #pragma D option quiet syscall::exec*:entry { self->exn = execname; } syscall::exec*:return / self->exn != NULL / { printf ("%-20s %s\n", self->exn, execname); self->exn = 0; } every time there is an exec system call, the name of the calling program gets saved in self->exn. When the exec system call returns, the name of the calling program, along with the new program, gets traced (printf). There could be many threads that have called "exec" that haven''t returned from the exec yet. The thread-local variable self->exn serves two purposes: 1. Each thread gets its own copy of self->exn, so all of the calling execnames can all be saved at the same time. 2. When return happens, since the thread that invokes the probe clause can only see its own thread-local variables, we automatically get the "right" calling execname that goes with the new execname. (If the exec fails, the execname on return is going to be the same as when exec was called, but we''re not concerned about error conditions here.) Or, maybe a time-line would help: --- entry -------------------------- return self->exn(t1)="abc" trace(self->exn(t1)) self->exn(t1)=0 ------------entry ----------------------------return self->exn(t2)="def" trace(self->exn(t2)) self->exn(t2)=0 ----------------------entry ---------------------------return self->exn(t3)="ghi" trace(self->exn(t3)) self->exn(t3)=0 ^ | 3 instances of self-exn.--------+ If you''re using a fixed width font, hopefully this time-line will line up. At one point in time, three execs are in progress, and three different self->exn variables exist to represent the three calling execnames. Hopefully I haven''t made this too complicated. :-) Chip
I think I understand what you are saying Chip..you haven''t confused me.. it''s fine that every process/thread has it''s own copy of local variables..but how do i distinguish between those threads/processes? Say I want to know for how long each process holds an adaptive lock? i want to recognize individual time the process/thread holds the lock for. Can i distinguish with pid/tid or something like that/ Thanks Neelam This message posted from opensolaris.org
Neelam wrote:> I think I understand what you are saying Chip..you haven''t confused me.. > > it''s fine that every process/thread has it''s own copy of local variables..but how do i distinguish between those threads/processes? >That depends on what you''re doing. Let''s take some examples: If you''re just saving a timestamp to be referenced later (so that you can calculate the delta), you just put the timestamp in a thread-local variable. When that thread does the time calculation later, in a different probe clause, it will pick up the right one by virtue of the fact that it''s the only instance of the variable that the thread can see. If you''re doing aggregations (which are global), use the "pid" and "tid" built-in variables as aggregation keys. If you''re creating you''re own associative arrays for collecting data, again you can use the pid and tid variables as keys. Chip
Hi Chip, Thanks for all your inputs and i am back with more queries :) About the paging activity, we can trace the page ins and page outs to and from swap device/backing store. Is there a way i can trace how long a page stay in free-list before being swapped put to disk. Thanks Neelam This message posted from opensolaris.org
Can someone tell me about the overhead associated with the proves. Say I want to time something (e.g. duration a lock is held for) and I am using timestamp within the corresponding providers and take the difference. So this would include the time the probe takes to invoke. Is there anyway I could time the attributes more accurately? Thanks, Neelam This message posted from opensolaris.org