diff options
author | Mark Wielaard <mjw@redhat.com> | 2010-03-03 15:05:36 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2010-03-03 15:05:36 +0100 |
commit | 9b06e18aef324786a88a0fbb61dcfdb369586e7f (patch) | |
tree | 0fe7fc267e2879ac43673d06f7c00cd9bff32905 | |
parent | 8822ed7f38927e45168f2ee5375ee844de3d1900 (diff) | |
download | systemtap-steved-9b06e18aef324786a88a0fbb61dcfdb369586e7f.tar.gz systemtap-steved-9b06e18aef324786a88a0fbb61dcfdb369586e7f.tar.xz systemtap-steved-9b06e18aef324786a88a0fbb61dcfdb369586e7f.zip |
Add task_stime_tid(), task_utime_tid() and task_time_string_tid() support.
* tapset/task_time.stp: New functions task_stime_tid(), task_utime_tid()
and task_time_string_tid().
* testsuite/buildok/task_test.stp: Add tests.
-rw-r--r-- | tapset/task_time.stp | 50 | ||||
-rwxr-xr-x | testsuite/buildok/task_test.stp | 5 |
2 files changed, 54 insertions, 1 deletions
diff --git a/tapset/task_time.stp b/tapset/task_time.stp index 55b7934c..c6af10d0 100644 --- a/tapset/task_time.stp +++ b/tapset/task_time.stp @@ -1,5 +1,5 @@ // Task time query and utility functions. -// Copyright (C) 2009 Red Hat Inc. +// Copyright (C) 2009, 2010 Red Hat Inc. // // 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 @@ -36,6 +36,23 @@ function task_utime:long () %} /** + * sfunction task_utime - User time of the given task. + * + * Description: Returns the user time of the given task in cputime, + * or zero if the task doesn't exist. + * Does not include any time used by other tasks in this process, nor + * does it include any time of the children of this task. + */ +function task_utime_tid:long(tid:long) +{ + task = pid2task(tid); + if (task != 0) + return @cast(task, "task_struct", "kernel<linux/sched.h>")->utime; + else + return 0; +} + +/** * sfunction task_stime - System time of the current task. * * Description: Returns the system time of the current task in cputime. @@ -48,6 +65,23 @@ function task_stime:long () %} /** + * sfunction task_stime_tid - System time of the given task. + * + * Description: Returns the system time of the given task in cputime, + * or zero if the task doesn't exist. + * Does not include any time used by other tasks in this process, nor + * does it include any time of the children of this task. + */ +function task_stime_tid:long(tid:long) +{ + task = pid2task(tid); + if (task != 0) + return @cast(task, "task_struct", "kernel<linux/sched.h>")->stime; + else + return 0; +} + +/** * sfunction cputime_to_msecs - Translates the given cputime into milliseconds. * @cputime: Time to convert to milliseconds. */ @@ -99,3 +133,17 @@ function task_time_string:string () cputime_to_string (task_utime()), cputime_to_string (task_stime())); } + +/** + * sfunction task_time_string_tid - Human readable string of task time usage. + * + * Description: Returns a human readable string showing the user and + * system time the given task has used up to now. For example + * "usr: 0m12.908s, sys: 1m6.851s". + */ +function task_time_string_tid:string (tid:long) +{ + return sprintf ("usr: %s, sys: %s", + cputime_to_string (task_utime_tid(tid)), + cputime_to_string (task_stime_tid(tid))); +} diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp index e391377f..b21e4fca 100755 --- a/testsuite/buildok/task_test.stp +++ b/testsuite/buildok/task_test.stp @@ -26,5 +26,10 @@ probe begin { log(sprint(cputime_to_msecs(0))) log(sprint(task_stime())) log(sprint(task_utime())) + + log(task_time_string_tid(0)) + log(sprint(task_stime_tid(0))) + log(sprint(task_utime_tid(0))) + exit() } |