This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Stap scripts to track task cpu changes


> 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   


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]