This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] [PATCH] tapsets to provide memory related information


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();
+%}
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]