public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [RFC] [PATCH] tapsets to provide memory related information
@ 2007-09-19 15:25 Srinivasa Ds
  0 siblings, 0 replies; only message in thread
From: Srinivasa Ds @ 2007-09-19 15:25 UTC (permalink / raw)
  To: SystemTAP


Hi 
  I have developed some memory related tapsets. These tapsets
   display tasks maximum virtual size, current virtual size,
   hiwater_rss,hiwater_vm,anon_rss.

I have encountered some challenges here. Could someone please
comment on these.

 	1) I have not incremented mm_users count while reading
 data from struct_mm. This is because we may sleep while decrementing
 it(mmput() sleeps). Does rcu_read_lock() helps here?
	
	2) I have to use atomic_long_read() to read atomic variables 
 like _anon_rss,_file_rss. Is there any kread() equivalent to read atomic
 variables.
 
 Iam attaching the patch here. Iam planning to format the data cleanly. Please
 let me know your comments.


Signed-off-by: Srinivasa DS <srinivasa@in.ibm.com>


---
 tapset/task.stp |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

Index: src/tapset/task.stp
===================================================================
--- src.orig/tapset/task.stp
+++ src/tapset/task.stp
@@ -189,3 +189,54 @@ function task_max_file_handles:long (tas
     CATCH_DEREF_FAULT();
 %}
 %)
+
+function task_vsize:long (task:long) %{
+   struct task_struct *t = (struct task_struct *)(long)THIS->task;
+   struct mm_struct * mm = kread(&(t->mm));
+   if (mm)
+    THIS->__retvalue = kread(&(mm->total_vm));
+   else
+    THIS->__retvalue = 0;
+  CATCH_DEREF_FAULT();
+%}
+
+function task_size:long (task:long) %{
+   struct task_struct *t = (struct task_struct *)(long)THIS->task;
+   struct mm_struct * mm = kread(&(t->mm));
+   if (mm)
+    THIS->__retvalue = kread(&(mm->task_size));
+   else
+    THIS->__retvalue = 0;
+  CATCH_DEREF_FAULT();
+%}
+
+function task_hiwater_rss:long (task:long) %{
+   struct task_struct *t = (struct task_struct *)(long)THIS->task;
+   struct mm_struct * mm = kread(&(t->mm));
+   if (mm)
+    THIS->__retvalue = kread(&(mm->hiwater_rss));
+   else
+    THIS->__retvalue = 0;
+  CATCH_DEREF_FAULT();
+%}
+
+function task_hiwater_vm:long (task:long) %{
+   struct task_struct *t = (struct task_struct *)(long)THIS->task;
+   struct mm_struct * mm = kread(&(t->mm));
+   if (mm)
+    THIS->__retvalue = kread(&(mm->hiwater_vm));
+   else
+    THIS->__retvalue = 0;
+  CATCH_DEREF_FAULT();
+%}
+
+function task_anon_rss:long (task:long) %{
+   struct task_struct *t = (struct task_struct *)(long)THIS->task;
+   struct mm_struct * mm = kread(&(t->mm));
+   if (mm)
+    THIS->__retvalue = atomic_long_read(&(mm->_anon_rss));
+   else
+    THIS->__retvalue = 0;
+  CATCH_DEREF_FAULT();
+%}
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-19 13:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 15:25 [RFC] [PATCH] tapsets to provide memory related information Srinivasa Ds

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).