[Gloucs] OProfile and SystemTap
Anthony Edward Cooper
aecooper at coosoft.plus.com
Tue Aug 21 23:39:46 BST 2007
Excellent presentation, many thanks once again....
Tony :-).
Matthew Booth wrote:
> As requested, here are my slides. I've also attached the 2 SystemTap
> scripts I used.
>
> The salient points:
>
> What's my CPU doing?
> man opcontrol
> man opreport
>
> What my kernel doing?
> man stap
>
> Matt
>
> ------------------------------------------------------------------------
>
> # Executed for every read() system call
> probe syscall.read {
> # It would be boring if it always said the same thing
> if(execname() == "staprun") next;
>
> # Say hello from whatever our context is
> printf("Hello world from %s\n", execname());
>
> # Quit the script
> exit();
> }
>
> ------------------------------------------------------------------------
>
> # timers stores system call entry time indexed by thread id
> global timers
>
> # syscalls stores total time spent in system call indexed by <app>.<syscall>
> global syscalls
>
> # Called on entry to every system call
> probe syscall.* {
> exe = execname();
>
> # Only monitor target processes
> if(exe != "logger" &&
> exe != "syslogd" &&
> exe != "seq") next;
>
> timers[tid()] = gettimeofday_ms();
> }
>
> # Called on return of every system call
> probe syscall.*.return {
> tid = tid();
>
> # If we didn't catch the entry, ignore the exit
> if(!([tid] in timers)) next;
>
> # Record the total amount of time spent in this system call
> duration = gettimeofday_ms() - timers[tid];
>
> if(duration > 0) {
> syscalls[execname().".".probefunc()] <<< duration;
> }
>
> # Delete the system call entry time
> delete timers[tid];
> }
>
> # Called when the script exits
> probe end {
> # Display the totals from syscalls
> foreach (call in syscalls) {
> printf("%s %i\n", call, @sum(syscalls[call]));
> }
> }
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gloucs mailing list
> gloucs at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gloucs
More information about the gloucs
mailing list