public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Re: Re: Stap scripts to track task cpu changes
       [not found] <200907141106.18667.varunc@linux.vnet.ibm.com>
@ 2009-07-14  5:53 ` Ankita Garg
  0 siblings, 0 replies; only message in thread
From: Ankita Garg @ 2009-07-14  5:53 UTC (permalink / raw)
  To: William Cohen; +Cc: systemtap, prerna

> Ankita Garg wrote:
> > Hello William,
> > 
> >> Subject: Re: Stap scripts to track task cpu changes
> >> Date: Thursday 09 Jul 2009
> >> From: William Cohen <wcohen@redhat.com>
> >> To: Ankita Garg <ankita@in.ibm.com>, systemtap@sources.redhat.com, 
> >> prerna@linux.vnet.ibm.com
> >>
> 
> Hi Ankita,
> 
> A bit more tweaking on the examples. For the chng_cpu2.stp I moved the
> assignment to threads associative array inside the if statement to avoid
> overflowing the array. For migrate3.stp I made it take the executable name, so
> that it works in a manner similar to chng_cpu2.stp. Was there multiple 
> instances
> of the same execname running one the machine or would using the execname be
> sufficent for migrate.stp?

The change in chng_cpu2.stp seems fine. There is indeed no point
tracking cpu information for tids we are not interested in. 

As for migrate.stp, it is possible for multiple instances of same
execname running on the machine, for example, most of the java threads
are simply called 'java'. However, the particular usage scenario of the
stap could vary. I might have been interested in a particular tid,
whereas someone else could just be interested in tracking all java threads.
So, I'd be ok with either here (specifying execname is more user-friendly
though). Not sure if its worth supporting both. 

Thanks Will for making these changes !


> /*    Filename: chng_cpu.stp
>  *      Author: Ankita Garg <ankita@in.ibm.com>
>  * Description: Captures information on the number of times an executable
>  * switches cpu
>  *
>  * This program is free software; you can redistribute it and/or modify
>  * it under the terms of the GNU General Public License as published by
>  * the Free Software Foundation; either version 2 of the License, or
>  * (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * Copyright (C) IBM Corp. 2009.  All Rights Reserved.
>  *
>  */
> 
> global threads
> 
> probe scheduler.cpu_on
> {
>   if ((threads[tid()] != cpu() && (execname() == @1))) {
>     printf("\nthread %d (%s) context switched on cpu%d state: %d\n",
>            tid(), execname(), cpu(), task_state(task_current()));
>     print_stack(backtrace());
>     threads[tid()] = cpu();
>   }
> }

> /*    Filename: migrate.stp
>  *      Author: Ankita Garg <ankita@in.ibm.com>
>  * Description: Captures information on the migration of a thread
>  *
>  * This program is free software; you can redistribute it and/or modify
>  * it under the terms of the GNU General Public License as published by
>  * the Free Software Foundation; either version 2 of the License, or
>  * (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * Copyright (C) IBM Corp. 2009.  All Rights Reserved.
>  *
> */
> 
> probe kernel.function("__migrate_task")
> {
>   comm = kernel_string($p->comm);
>   if (comm == @1) {
>     printf ("thread %d (%s) is migrating from %d to %d \n",
>             $p->pid, comm, $src_cpu, $dest_cpu);
>   }
> }


-- 
Regards,
Ankita Garg (ankita@in.ibm.com)
Linux Technology Center
IBM India Systems & Technology Labs, 
Bangalore, India   

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-14  5:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200907141106.18667.varunc@linux.vnet.ibm.com>
2009-07-14  5:53 ` Re: Stap scripts to track task cpu changes Ankita Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).