diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rwxr-xr-x | examples/small_demos/sched_snoop.stp | 35 | ||||
-rw-r--r-- | tapset/ChangeLog | 1 | ||||
-rw-r--r-- | tapset/scheduler.stp | 105 | ||||
-rwxr-xr-x | testsuite/buildok/sched_test.stp | 34 |
5 files changed, 180 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2006-05-17 Josh Stone <joshua.i.stone@intel.com> + + * testsuite/buildok/sched_test.stp: test scheduler tapset + * examples/small_demos/sched_snoop.stp: demo scheduler tapset + 2006-05-18 Li Guanglei <guanglei@cn.ibm.com> * testsuite/buildok/ioscheduler.stp: testcase for ioscheduler.stp diff --git a/examples/small_demos/sched_snoop.stp b/examples/small_demos/sched_snoop.stp new file mode 100755 index 00000000..9c6ebe65 --- /dev/null +++ b/examples/small_demos/sched_snoop.stp @@ -0,0 +1,35 @@ +#!/usr/bin/env stap + +global start_ts + +probe begin { + start_ts = gettimeofday_us() + printf("%12s %3s %5s %5s %-16s ACTION\n", + "TIMESTAMP", "CPU", "PID", "TID", "EXECNAME") +} + +function report(action:string) { + printf("%3d %12d %5d %5d %-16s %s\n", + gettimeofday_us() - start_ts, cpu(), + pid(), tid(), execname(), action) +} + +probe scheduler.cpu_off { + report(sprintf("cpu_off%s", idle? " [idle]" : "")) +} + +probe scheduler.cpu_on { + report(sprintf("cpu_on%s", idle? " [idle]" : "")) +} + +probe scheduler.tick { + report(sprintf("tick%s", idle? " [idle]" : "")) +} + +probe scheduler.migrate { + report("migrate") +} + +probe scheduler.balance { + report("balance") +} diff --git a/tapset/ChangeLog b/tapset/ChangeLog index aa6843c1..7c534c81 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -12,6 +12,7 @@ to process_complete, to allow process.* to work properly. * process.stp (_IS_ERR): declare parameter type * process.stp (process.create): correct new_pid assignment + * scheduler.stp: New scheduler tapset 2006-05-18 Li Guanglei <guanglei@cn.ibm.com> diff --git a/tapset/scheduler.stp b/tapset/scheduler.stp new file mode 100644 index 00000000..e1fac79d --- /dev/null +++ b/tapset/scheduler.stp @@ -0,0 +1,105 @@ +// scheduler tapset +// Copyright (C) 2006 Intel Corporation. +// +// This file is part of systemtap, and is free software. You can +// redistribute it and/or modify it under the terms of the GNU General +// Public License (GPL); either version 2, or (at your option) any +// later version. + + +function __is_idle:long() +%{ + /* Ways to detect idle-ness: + * - pid() or tid() == 0 + * - current == current->parent + * - current == this_rq()->idle + * - others? + */ + THIS->__retvalue = (current->pid == 0); +%} + + +/* probe scheduler.cpu_off + * + * Fires when a process is about to stop running on a cpu. + * + * Context: + * The process leaving the cpu. + * + * Arguments: + * task_prev - the process leaving the cpu (same as current) + * task_next - the process replacing current + * idle - boolean indicating whether current is the idle process + */ +probe scheduler.cpu_off + = kernel.inline("context_switch") +{ + task_prev = $prev + task_next = $next + idle = __is_idle() +} + + +/* probe scheduler.cpu_on + * + * Fires when a process is beginning execution on a cpu. + * + * Context: + * The resuming process. + * + * Arguments: + * task_prev - the process that was previously running on this cpu. + * idle - boolean indicating whether current is the idle process + */ +probe scheduler.cpu_on + = kernel.inline("finish_task_switch") +{ + task_prev = $prev + idle = __is_idle() +} + + +/* probe scheduler.tick + * + * Fires on the schedulers internal tick, when a processes timeslice + * accounting is updated. + * + * Context: + * The process whose accounting will be updated. + * + * Arguments: + * idle - boolean indicating whether current is the idle process + */ +probe scheduler.tick = kernel.function("scheduler_tick") +{ + idle = __is_idle() +} + + +/* probe scheduler.migrate + * + * Fires whenever a task is moved to a different cpu's runqueue. + * + * Context: + * Unknown (sometimes migration thread, sometimes cpu_to) + * + * Arguments: + * task - the process that is being migrated + * cpu_from - the cpu that is losing the task + * cpu_to - the cpu that is claiming the task + */ +probe scheduler.migrate = kernel.inline("pull_task") { + task = $p + cpu_from = $p->thread_info->cpu + cpu_to = $this_cpu +} + + +/* probe scheduler.balance + * + * Fires when a cpu attempts to find more work. + * + * Context: + * The cpu looking for more work. + */ +probe scheduler.balance = kernel.inline("idle_balance") {} diff --git a/testsuite/buildok/sched_test.stp b/testsuite/buildok/sched_test.stp new file mode 100755 index 00000000..547b0682 --- /dev/null +++ b/testsuite/buildok/sched_test.stp @@ -0,0 +1,34 @@ +#! stap -p4 + +// there are problems accessing parameters of inline functions, +// so for now the tapset parameters are commented out. + +probe scheduler.cpu_off { + log(pp()) + //log(sprint(task_prev)) + //log(sprint(task_next)) + log(sprint(idle)) +} + +probe scheduler.cpu_on { + log(pp()) + //log(sprint(task_prev)) + log(sprint(idle)) +} + +probe scheduler.tick { + log(pp()) + log(sprint(idle)) +} + +probe scheduler.migrate { + log(pp()) + //log(sprint(task)) + //log(sprint(cpu_from)) + //log(sprint(cpu_to)) +} + +probe scheduler.balance { + log(pp()) +} + |