public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Srinivasa Ds <srinivasa@in.ibm.com>
To: SystemTAP <systemtap@sources.redhat.com>
Subject: [RFC] [PATCH] tapsets to provide memory related information
Date: Wed, 19 Sep 2007 15:25:00 -0000	[thread overview]
Message-ID: <46F12A4F.8090202@in.ibm.com> (raw)


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

                 reply	other threads:[~2007-09-19 13:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46F12A4F.8090202@in.ibm.com \
    --to=srinivasa@in.ibm.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).