* [PATCH] Small code cleanup in task.stp.
@ 2014-03-03 12:15 Robin Hack
0 siblings, 0 replies; only message in thread
From: Robin Hack @ 2014-03-03 12:15 UTC (permalink / raw)
To: systemtap
[-- Attachment #1: Type: text/plain, Size: 182 bytes --]
Hi.
I did very small code cleanup in task.stp. Only 2 functions are affected.
Interesting site effect for me is that gvim syntax highlighting now works.
Have nice day.
Robin Hack
[-- Attachment #2: task-cleanup.patch --]
[-- Type: text/plain, Size: 3235 bytes --]
commit 40d4f10bc0676d77252c53889babfd773f6c91e4
Author: Robin Hack <rhack@redhat.com>
Date: Sat Mar 1 21:05:34 2014 +0100
Code cleanup in tapset/linux/task.stp.
task_max_file_handles and task_open_file_handles:
* use incode C macros instead of systemtap macros
diff --git a/tapset/linux/task.stp b/tapset/linux/task.stp
index e65d9f515c49521ad748771c26121992b24d50c4..be859871879974c73bffe024c2189e25bb2796f2 100644
--- a/tapset/linux/task.stp
+++ b/tapset/linux/task.stp
@@ -287,16 +287,25 @@ function task_cpu:long (task:long)
* Description: This function returns the number of open file handlers for the given task.
*/
function task_open_file_handles:long (task:long)
-%( kernel_v >= "2.6.15" %?
%{ /* pure */
int locked = 0;
unsigned int count=0, fd, max;
struct task_struct *t;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ /* Older kernels */
+ struct files_struct *f;
+#else
struct files_struct *fs;
struct fdtable *f;
+#endif
t = (struct task_struct *)(long)STAP_ARG_task;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ /* Older kernels */
+ f = kread(&(t->files));
+#else
fs = kread(&(t->files));
f = kread(&(fs->fdt));
+#endif
rcu_read_lock();
locked = 1;
max = kread(&(f->max_fds));
@@ -309,27 +318,6 @@ function task_open_file_handles:long (task:long)
if (locked)
rcu_read_unlock();
%}
-%:
-%{ /* pure */
- int locked = 0;
- unsigned int count=0, fd, max;
- struct task_struct *t;
- struct files_struct *f;
- t = (struct task_struct *)(long)STAP_ARG_task;
- f = kread(&(t->files));
- rcu_read_lock();
- locked = 1;
- max = kread(&(f->max_fds));
- for (fd = 0; fd < max; fd++) {
- if ( kread(&(f->fd[fd])) != NULL)
- count ++;
- }
- STAP_RETVALUE = count;
- CATCH_DEREF_FAULT();
- if (locked)
- rcu_read_unlock();
-%}
-%)
/**
* sfunction task_max_file_handles - The max number of open files for the task
@@ -339,15 +327,22 @@ function task_open_file_handles:long (task:long)
* Description: This function returns the maximum number of file handlers for the given task.
*/
function task_max_file_handles:long (task:long)
-%( kernel_v >= "2.6.15" %?
%{ /* pure */
int locked = 0;
struct task_struct *t;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ struct files_struct *f;
+#else
struct files_struct *fs;
struct fdtable *f;
+#endif
t = (struct task_struct *)(long)STAP_ARG_task;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ f = kread(&(t->files));
+#else
fs = kread (&(t->files));
f = kread(&(fs->fdt));
+#endif
rcu_read_lock();
locked = 1;
STAP_RETVALUE = kread(&(f->max_fds));
@@ -355,18 +350,3 @@ function task_max_file_handles:long (task:long)
if (locked)
rcu_read_unlock();
%}
-%:
-%{ /* pure */
- int locked = 0;
- struct task_struct *t;
- struct files_struct *f;
- t = (struct task_struct *)(long)STAP_ARG_task;
- f = kread(&(t->files));
- rcu_read_lock();
- locked = 1;
- STAP_RETVALUE = kread(&(f->max_fds));
- CATCH_DEREF_FAULT();
- if (locked)
- rcu_read_unlock();
-%}
-%)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-03-03 12:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-03 12:15 [PATCH] Small code cleanup in task.stp Robin Hack
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).