linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joonsoo Kim <js1304@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kexec@lists.infradead.org, Joonsoo Kim <js1304@gmail.com>
Subject: [RFC PATCH 5/8] mm, vmalloc: iterate vmap_area_list in get_vmalloc_info()
Date: Fri,  7 Dec 2012 01:09:32 +0900	[thread overview]
Message-ID: <1354810175-4338-6-git-send-email-js1304@gmail.com> (raw)
In-Reply-To: <1354810175-4338-1-git-send-email-js1304@gmail.com>

This patch is preparing step for removing vmlist entirely.
For above purpose, we change iterating a vmap_list codes to iterating a
vmap_area_list. It is somewhat trivial change, but just one thing
should be noticed.

vmlist is lack of information about some areas in vmalloc address space.
For example, vm_map_ram() allocate area in vmalloc address space,
but it doesn't make a link with vmlist. To provide full information about
vmalloc address space is better idea, so we don't use va->vm and use
vmap_area directly.
This makes get_vmalloc_info() more precise.

Signed-off-by: Joonsoo Kim <js1304@gmail.com>

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index d21167f..f7f4a35 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2668,46 +2668,47 @@ module_init(proc_vmalloc_init);
 
 void get_vmalloc_info(struct vmalloc_info *vmi)
 {
-	struct vm_struct *vma;
+	struct vmap_area *va;
 	unsigned long free_area_size;
 	unsigned long prev_end;
 
 	vmi->used = 0;
+	vmi->largest_chunk = 0;
 
-	if (!vmlist) {
-		vmi->largest_chunk = VMALLOC_TOTAL;
-	} else {
-		vmi->largest_chunk = 0;
+	prev_end = VMALLOC_START;
 
-		prev_end = VMALLOC_START;
+	spin_lock(&vmap_area_lock);
 
-		read_lock(&vmlist_lock);
+	if (list_empty(&vmap_area_list)) {
+		vmi->largest_chunk = VMALLOC_TOTAL;
+		goto out;
+	}
 
-		for (vma = vmlist; vma; vma = vma->next) {
-			unsigned long addr = (unsigned long) vma->addr;
+	list_for_each_entry(va, &vmap_area_list, list) {
+		unsigned long addr = va->va_start;
 
-			/*
-			 * Some archs keep another range for modules in vmlist
-			 */
-			if (addr < VMALLOC_START)
-				continue;
-			if (addr >= VMALLOC_END)
-				break;
+		/*
+		 * Some archs keep another range for modules in vmalloc space
+		 */
+		if (addr < VMALLOC_START)
+			continue;
+		if (addr >= VMALLOC_END)
+			break;
 
-			vmi->used += vma->size;
+		vmi->used += (va->va_end - va->va_start);
 
-			free_area_size = addr - prev_end;
-			if (vmi->largest_chunk < free_area_size)
-				vmi->largest_chunk = free_area_size;
+		free_area_size = addr - prev_end;
+		if (vmi->largest_chunk < free_area_size)
+			vmi->largest_chunk = free_area_size;
 
-			prev_end = vma->size + addr;
-		}
+		prev_end = va->va_end;
+	}
 
-		if (VMALLOC_END - prev_end > vmi->largest_chunk)
-			vmi->largest_chunk = VMALLOC_END - prev_end;
+	if (VMALLOC_END - prev_end > vmi->largest_chunk)
+		vmi->largest_chunk = VMALLOC_END - prev_end;
 
-		read_unlock(&vmlist_lock);
-	}
+out:
+	spin_unlock(&vmap_area_lock);
 }
 #endif
 
-- 
1.7.9.5

--
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:[~2012-12-06 16:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-06 16:09 [RFC PATCH 0/8] remove vm_struct list management Joonsoo Kim
2012-12-06 16:09 ` [RFC PATCH 1/8] mm, vmalloc: change iterating a vmlist to find_vm_area() Joonsoo Kim
2012-12-07  7:44   ` Pekka Enberg
2012-12-07  8:15     ` Bob Liu
2012-12-07 13:40     ` JoonSoo Kim
2012-12-10  5:20   ` guanxuetao
2012-12-10 15:13   ` Chris Metcalf
2013-01-24 15:50   ` Ingo Molnar
2012-12-06 16:09 ` [RFC PATCH 2/8] mm, vmalloc: move get_vmalloc_info() to vmalloc.c Joonsoo Kim
2012-12-06 16:09 ` [RFC PATCH 3/8] mm, vmalloc: protect va->vm by vmap_area_lock Joonsoo Kim
2012-12-06 16:09 ` [RFC PATCH 4/8] mm, vmalloc: iterate vmap_area_list, instead of vmlist in vread/vwrite() Joonsoo Kim
2012-12-06 16:09 ` Joonsoo Kim [this message]
2012-12-06 16:09 ` [RFC PATCH 6/8] mm, vmalloc: iterate vmap_area_list, instead of vmlist, in vmallocinfo() Joonsoo Kim
2012-12-06 16:09 ` [RFC PATCH 7/8] mm, vmalloc: makes vmlist only for kexec Joonsoo Kim
2012-12-06 16:09 ` [RFC PATCH 8/8] mm, vmalloc: remove list management operation after initializing vmalloc Joonsoo Kim
2012-12-06 22:45 ` [RFC PATCH 0/8] remove vm_struct list management Andrew Morton
2012-12-07 13:05   ` JoonSoo Kim
2012-12-06 22:50 ` Andrew Morton
2012-12-07 13:16   ` JoonSoo Kim
2012-12-07 14:59     ` Vivek Goyal
2012-12-10 14:40       ` JoonSoo Kim
2012-12-11 14:41         ` Dave Anderson
2012-12-11 21:48         ` Vivek Goyal
2012-12-11 22:17           ` Dave Anderson
2012-12-12  5:56             ` Atsushi Kumagai
2012-12-12 14:10               ` JoonSoo Kim
2012-12-07  3:37 ` Bob Liu
2012-12-07 13:35   ` JoonSoo Kim

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=1354810175-4338-6-git-send-email-js1304@gmail.com \
    --to=js1304@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    /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 NNTP newsgroup(s).