[Gloucs] OProfile and SystemTap

John Patrick nhoj.patrick at gmail.com
Wed Aug 22 10:15:25 BST 2007


Matt,

I think you forgot to attach the slides and only attached the scripts.

John

ps just about to use OProfile in real life testing

On 21/08/07, Anthony Edward Cooper <aecooper at coosoft.plus.com> wrote:
>
> 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
>
>
> _______________________________________________
> gloucs mailing list
> gloucs at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gloucs
>


More information about the gloucs mailing list