Commit f98782dd authored by Joonsoo Kim's avatar Joonsoo Kim Committed by Linus Torvalds

mm, vmalloc: iterate vmap_area_list in get_vmalloc_info()

This patch is a preparatory 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: default avatarJoonsoo Kim <js1304@gmail.com>
Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e81ce85f
...@@ -2671,46 +2671,50 @@ module_init(proc_vmalloc_init); ...@@ -2671,46 +2671,50 @@ module_init(proc_vmalloc_init);
void get_vmalloc_info(struct vmalloc_info *vmi) void get_vmalloc_info(struct vmalloc_info *vmi)
{ {
struct vm_struct *vma; struct vmap_area *va;
unsigned long free_area_size; unsigned long free_area_size;
unsigned long prev_end; unsigned long prev_end;
vmi->used = 0; vmi->used = 0;
vmi->largest_chunk = 0;
if (!vmlist) { prev_end = VMALLOC_START;
vmi->largest_chunk = VMALLOC_TOTAL;
} else {
vmi->largest_chunk = 0;
prev_end = VMALLOC_START; spin_lock(&vmap_area_lock);
read_lock(&vmlist_lock);
for (vma = vmlist; vma; vma = vma->next) { if (list_empty(&vmap_area_list)) {
unsigned long addr = (unsigned long) vma->addr; vmi->largest_chunk = VMALLOC_TOTAL;
goto out;
}
/* list_for_each_entry(va, &vmap_area_list, list) {
* Some archs keep another range for modules in vmlist unsigned long addr = va->va_start;
*/
if (addr < VMALLOC_START)
continue;
if (addr >= VMALLOC_END)
break;
vmi->used += vma->size; /*
* Some archs keep another range for modules in vmalloc space
*/
if (addr < VMALLOC_START)
continue;
if (addr >= VMALLOC_END)
break;
free_area_size = addr - prev_end; if (va->flags & (VM_LAZY_FREE | VM_LAZY_FREEING))
if (vmi->largest_chunk < free_area_size) continue;
vmi->largest_chunk = free_area_size;
prev_end = vma->size + addr; vmi->used += (va->va_end - va->va_start);
}
if (VMALLOC_END - prev_end > vmi->largest_chunk) free_area_size = addr - prev_end;
vmi->largest_chunk = VMALLOC_END - prev_end; if (vmi->largest_chunk < free_area_size)
vmi->largest_chunk = free_area_size;
read_unlock(&vmlist_lock); prev_end = va->va_end;
} }
if (VMALLOC_END - prev_end > vmi->largest_chunk)
vmi->largest_chunk = VMALLOC_END - prev_end;
out:
spin_unlock(&vmap_area_lock);
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment