linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Mel Gorman <mel@csn.ul.ie>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Adam Litke <agl@us.ibm.com>
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: [RFC PATCH] Report the shmid backing a VMA in maps
Date: Sat,  4 Oct 2008 21:04:03 +0900 (JST)	[thread overview]
Message-ID: <20081004205650.CE47.KOSAKI.MOTOHIRO@jp.fujitsu.com> (raw)
In-Reply-To: <1223052415-18956-3-git-send-email-mel@csn.ul.ie>

Hi

I made another hugepage administrating helping patch.
So, I'd like to hear hugepage folks.

I tested this patch on mmotm 02/Oct + Mel's "Report the size of pages backing VMAs in /proc V3" series.


Thanks!


======================================================
Recently, Mel Gorman introduce attribute showing mechanism to /proc/{pid}/maps.
It is very powerful and useful feature.

In the other hand, huge page is often used via ipc shm, not mmap.
So, administrator often want to know relationship of memory region and shmid.

Then, To add shmid attribute in /proc/{pid}/maps is useful.


In addition, shmid information is not only useful for huge page, but also for normal shm.
Then, this patch works well on normal shm.

this patch depend on Mel's "Report the pagesize backing a VMA in /proc/pid/maps" patch.


example output of /proc/{pid}/maps
---------------------------------------------------------
00000000-00010000 r--p 00000000 00:00 0                                  
2000000000000000-2000000000040000 r-xp 00000000 fd:00 7372806            /lib/ld-2.5.so
2000000000040000-2000000000050000 rw-p 00030000 fd:00 7372806            /lib/ld-2.5.so
2000000000050000-2000000000060000 rw-p 2000000000050000 00:00 0          
2000000000060000-20000000000d0000 r-xp 00000000 fd:00 2334823            /usr/lib/libreadline.so.5.1
20000000000d0000-20000000000e0000 rw-p 00060000 fd:00 2334823            /usr/lib/libreadline.so.5.1
20000000000e0000-2000000000170000 r-xp 00000000 fd:00 2334751            /usr/lib/libncurses.so.5.5
2000000000170000-2000000000190000 rw-p 00080000 fd:00 2334751            /usr/lib/libncurses.so.5.5
2000000000190000-20000000001a0000 r-xp 00000000 fd:00 2337176            /usr/lib/libnuma.so.1
20000000001a0000-20000000001b0000 rw-p 00000000 fd:00 2337176            /usr/lib/libnuma.so.1
20000000001b0000-2000000000420000 r-xp 00000000 fd:00 7372813            /lib/libc-2.5.so
2000000000420000-2000000000430000 rw-p 00260000 fd:00 7372813            /lib/libc-2.5.so
2000000000430000-2000000000440000 rw-p 2000000000430000 00:00 0          
2000000000440000-2000000000450000 r-xp 00000000 fd:00 7372819            /lib/libdl-2.5.so
2000000000450000-2000000000460000 rw-p 00000000 fd:00 7372819            /lib/libdl-2.5.so
2000000000460000-20000000004d0000 rw-p 2000000000460000 00:00 0          
2000000000500000-2000000000900000 rw-s 00000000 00:09 0                  /SYSV00000000 (deleted) (shmid=0)
2000000000900000-2000000000d00000 rw-s 00000000 00:09 32769              /SYSV00000000 (deleted) (shmid=32769)
4000000000000000-4000000000030000 r-xp 00000000 fd:00 7536864            /home/kosaki/download/Memtoy-0.16/memtoy
6000000000000000-6000000000010000 rw-p 00020000 fd:00 7536864            /home/kosaki/download/Memtoy-0.16/memtoy
6000000000010000-6000000000040000 rw-p 6000000000010000 00:00 0          [heap]
6007ffffffc70000-6007ffffffc80000 rw-p 6007ffffffc70000 00:00 0          
600fffffffb10000-600fffffffc60000 rw-p 600fffffffea0000 00:00 0          [stack]
8000000000000000-8000000010000000 rw-s 00000000 00:0c 65538              /SYSV00000000 (deleted) (hpagesize=262144kB) (shmid=65538)
a000000000000000-a000000000020000 r-xp 00000000 00:00 0                  [vdso]
------------------------------------------------------------

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Mel Gorman <mel@csn.ul.ie>
---
 fs/proc/task_mmu.c  |   12 +++++++++---
 include/linux/shm.h |   10 ++++++++++
 ipc/shm.c           |   17 +++++++++++++++++
 3 files changed, 36 insertions(+), 3 deletions(-)

Index: b/fs/proc/task_mmu.c
===================================================================
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -254,9 +254,15 @@ static void show_map_vma(struct seq_file
 	 * Print additional attributes of the VMA of interest
 	 * - hugepage size if hugepage-backed
 	 */
-	if (showattributes && vma->vm_flags & VM_HUGETLB)
-		seq_printf(m, " (hpagesize=%lukB)",
-			vma_kernel_pagesize(vma) >> 10);
+	if (showattributes) {
+		if (vma->vm_flags & VM_HUGETLB)
+			seq_printf(m, " (hpagesize=%lukB)",
+				   vma_kernel_pagesize(vma) >> 10);
+		if (is_shm_vma(vma))
+			seq_printf(m, " (shmid=%d)",
+				   vma_shmid(vma));
+	}
+
 	seq_putc(m, '\n');
 }
 
Index: b/include/linux/shm.h
===================================================================
--- a/include/linux/shm.h
+++ b/include/linux/shm.h
@@ -106,6 +106,8 @@ struct shmid_kernel /* private to the ke
 #ifdef CONFIG_SYSVIPC
 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr);
 extern int is_file_shm_hugepages(struct file *file);
+int is_shm_vma(struct vm_area_struct *vma);
+int vma_shmid(struct vm_area_struct *vma);
 #else
 static inline long do_shmat(int shmid, char __user *shmaddr,
 				int shmflg, unsigned long *addr)
@@ -116,6 +118,14 @@ static inline int is_file_shm_hugepages(
 {
 	return 0;
 }
+static inline int is_shm_vma(struct vm_area_struct *vma)
+{
+	return 0;
+}
+int vma_shmid(struct vm_area_struct *vma)
+{
+	return -ENOENT;
+}
 #endif
 
 #endif /* __KERNEL__ */
Index: b/ipc/shm.c
===================================================================
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1074,3 +1074,20 @@ static int sysvipc_shm_proc_show(struct 
 			  shp->shm_ctim);
 }
 #endif
+
+int is_shm_vma(struct vm_area_struct *vma)
+{
+	return !!(vma->vm_ops == &shm_vm_ops);
+}
+
+int vma_shmid(struct vm_area_struct *vma)
+{
+	struct shm_file_data *sfd;
+
+	if (!is_shm_vma(vma))
+		return -ENOENT;
+
+	sfd = (struct shm_file_data *)vma->vm_file->private_data;
+	return sfd->id;
+}
+


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2008-10-04 12:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-03 16:46 [PATCH 0/2] Report the size of pages backing VMAs in /proc V3 Mel Gorman
2008-10-03 16:46 ` [PATCH 1/2] Report the pagesize backing a VMA in /proc/pid/smaps Mel Gorman
2008-10-08 21:38   ` Alexey Dobriyan
2008-10-09  2:16     ` KOSAKI Motohiro
2008-10-09 10:24     ` Mel Gorman
2008-10-03 16:46 ` [PATCH 2/2] Report the pagesize backing a VMA in /proc/pid/maps Mel Gorman
2008-10-04  8:14   ` KOSAKI Motohiro
2008-10-04 12:04   ` KOSAKI Motohiro [this message]
2008-10-04 12:07     ` [RFC PATCH] Report the shmid backing a VMA in maps KOSAKI Motohiro
2008-10-04 21:52     ` Alexey Dobriyan
2008-10-05  5:48       ` KOSAKI Motohiro
2008-10-04 22:13   ` [PATCH 2/2] Report the pagesize backing a VMA in /proc/pid/maps Alexey Dobriyan
2008-10-05  6:00     ` KOSAKI Motohiro
2008-10-06 10:09     ` Mel Gorman

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=20081004205650.CE47.KOSAKI.MOTOHIRO@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=agl@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    /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