Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / proc / mmu.c
bloba7041038ad56108ef45f195bedf109dbbb7ddb24
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>
19 #include <linux/mm.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>
30 #include <asm/tlb.h>
31 #include <asm/div64.h>
32 #include "internal.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;
40 vmi->used = 0;
42 if (!vmlist) {
43 vmi->largest_chunk = VMALLOC_TOTAL;
45 else {
46 vmi->largest_chunk = 0;
48 prev_end = VMALLOC_START;
50 read_lock(&vmlist_lock);
52 for (vma = vmlist; vma; vma = vma->next) {
53 vmi->used += vma->size;
55 free_area_size = (unsigned long) vma->addr - prev_end;
56 if (vmi->largest_chunk < free_area_size)
57 vmi->largest_chunk = free_area_size;
59 prev_end = vma->size + (unsigned long) vma->addr;
62 if (VMALLOC_END - prev_end > vmi->largest_chunk)
63 vmi->largest_chunk = VMALLOC_END - prev_end;
65 read_unlock(&vmlist_lock);