1 /* mmu.c: mmu memory info files
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/types.h>
13 #include <linux/errno.h>
14 #include <linux/time.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/mman.h>
18 #include <linux/proc_fs.h>
20 #include <linux/mmzone.h>
21 #include <linux/pagemap.h>
22 #include <linux/swap.h>
23 #include <linux/slab.h>
24 #include <linux/smp.h>
25 #include <linux/seq_file.h>
26 #include <linux/hugetlb.h>
27 #include <linux/vmalloc.h>
28 #include <asm/uaccess.h>
29 #include <asm/pgtable.h>
31 #include <asm/div64.h>
34 void get_vmalloc_info(struct vmalloc_info *vmi)
36 struct vm_struct *vma;
37 unsigned long free_area_size;
38 unsigned long prev_end;
43 vmi->largest_chunk = VMALLOC_TOTAL;
46 vmi->largest_chunk = 0;
48 prev_end = VMALLOC_START;
50 read_lock(&vmlist_lock);
52 for (vma = vmlist; vma; vma = vma->next) {
53 unsigned long addr = (unsigned long) vma->addr;
56 * Some archs keep another range for modules in vmlist
58 if (addr < VMALLOC_START)
60 if (addr >= VMALLOC_END)
63 vmi->used += vma->size;
65 free_area_size = addr - prev_end;
66 if (vmi->largest_chunk < free_area_size)
67 vmi->largest_chunk = free_area_size;
69 prev_end = vma->size + addr;
72 if (VMALLOC_END - prev_end > vmi->largest_chunk)
73 vmi->largest_chunk = VMALLOC_END - prev_end;
75 read_unlock(&vmlist_lock);