Debian Codegraph @

testsuite/systemtap.examples/process/chng_cpu.stp

raw
1 #! /usr/bin/env stap
2 /* Filename: chng_cpu.stp
3 * Author: Ankita Garg <[email protected]>
4 * Description: Captures information on the number of times an executable
5 * switches cpu
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * Copyright (C) IBM Corp. 2009. All Rights Reserved.
18 *
19 */
20
21 global threads
22
23 probe scheduler.cpu_on
24 {
25 if ((threads[tid()] != cpu() && (execname() == @1))) {
26 printf("\nthread %d (%s) context switched on cpu%d state: %d\n",
27 tid(), execname(), cpu(), task_state(task_current()));
28 print_syms(backtrace());
29 threads[tid()] = cpu();
30 }
31 }