Re: [PATCH] Export mlock information via smaps

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nikanth Karthikesan
Date: Tuesday, August 17, 2010 - 9:53 pm

On Tuesday 17 August 2010 21:55:36 Matt Mackall wrote:

So how to proceed? Create another "ssmaps" file or something? :) Or is the
following patch any better? Even the "Yes"/"No" could be changed to "0 kB" or
"x kB", if it would make it better.

Thanks
Nikanth

Currently there is no way to find whether a process has locked its pages in
memory or not. And which of the memory regions are locked in memory.

Add a new field "Locked" to export this information via smaps file.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index a6aca87..6eafd26 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -373,6 +373,7 @@ Referenced:          892 kB
 Swap:                  0 kB
 KernelPageSize:        4 kB
 MMUPageSize:           4 kB
+Locked:         No
 
 The first  of these lines shows  the same information  as is displayed for the
 mapping in /proc/PID/maps.  The remaining lines show  the size of the mapping,
@@ -397,6 +398,8 @@ To clear the bits for the file mapped pages associated with the process
     > echo 3 > /proc/PID/clear_refs
 Any other value written to /proc/PID/clear_refs will have no effect.
 
+The "Locked" indicates whether the mapping is locked in memory or not.
+
 
 1.2 Kernel data
 ---------------
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index aea1d3f..7bafbcf 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -405,7 +405,8 @@ static int show_smap(struct seq_file *m, void *v)
 		   "Referenced:     %8lu kB\n"
 		   "Swap:           %8lu kB\n"
 		   "KernelPageSize: %8lu kB\n"
-		   "MMUPageSize:    %8lu kB\n",
+		   "MMUPageSize:    %8lu kB\n"
+		   "Locked:         %s\n",
 		   (vma->vm_end - vma->vm_start) >> 10,
 		   mss.resident >> 10,
 		   (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
@@ -416,7 +417,8 @@ static int show_smap(struct seq_file *m, void *v)
 		   mss.referenced >> 10,
 		   mss.swap >> 10,
 		   vma_kernel_pagesize(vma) >> 10,
-		   vma_mmu_pagesize(vma) >> 10);
+		   vma_mmu_pagesize(vma) >> 10,
+		   (vma->vm_flags & VM_LOCKED) ? "Yes" : "No");
 
 	if (m->count < m->size)  /* vma is copied successfully */
 		m->version = (vma != get_gate_vma(task)) ? vma->vm_start : 0;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Export mlock information via smaps, Nikanth Karthikesan, (Mon Aug 16, 10:09 pm)
Re: [PATCH] Export mlock information via smaps, Minchan Kim, (Tue Aug 17, 7:42 am)
Re: [PATCH] Export mlock information via smaps, Matt Mackall, (Tue Aug 17, 9:25 am)
Re: [PATCH] Export mlock information via smaps, Nikanth Karthikesan, (Tue Aug 17, 9:53 pm)
Re: [PATCH] Export mlock information via smaps, Balbir Singh, (Tue Aug 17, 10:52 pm)
Re: [PATCH] Export mlock information via smaps, Nikanth Karthikesan, (Tue Aug 17, 11:49 pm)
Re: [PATCH] Export mlock information via smaps, Balbir Singh, (Tue Aug 17, 11:56 pm)
Re: [PATCH] Export mlock information via smaps, Wu Fengguang, (Wed Aug 18, 8:07 am)
Re: [PATCH] Export mlock information via smaps, Wu Fengguang, (Wed Aug 18, 8:12 am)
Re: [PATCH] Export mlock information via smaps, Andrew Morton, (Thu Aug 19, 5:25 pm)
Re: [PATCH] Export mlock information via smaps, Matt Mackall, (Fri Aug 20, 2:57 pm)